feat: Implement comprehensive error handling and production deployment pipeline
Some checks failed
ParentFlow CI/CD Pipeline / Backend Tests (push) Has been cancelled
ParentFlow CI/CD Pipeline / Frontend Tests (push) Has been cancelled
ParentFlow CI/CD Pipeline / Security Scanning (push) Has been cancelled
ParentFlow CI/CD Pipeline / Build Docker Images (map[context:maternal-app/maternal-app-backend dockerfile:Dockerfile.production name:backend]) (push) Has been cancelled
ParentFlow CI/CD Pipeline / Build Docker Images (map[context:maternal-web dockerfile:Dockerfile.production name:frontend]) (push) Has been cancelled
ParentFlow CI/CD Pipeline / Deploy to Development (push) Has been cancelled
ParentFlow CI/CD Pipeline / Deploy to Production (push) Has been cancelled
CI/CD Pipeline / Lint and Test (push) Has been cancelled
CI/CD Pipeline / E2E Tests (push) Has been cancelled
CI/CD Pipeline / Build Application (push) Has been cancelled
Some checks failed
ParentFlow CI/CD Pipeline / Backend Tests (push) Has been cancelled
ParentFlow CI/CD Pipeline / Frontend Tests (push) Has been cancelled
ParentFlow CI/CD Pipeline / Security Scanning (push) Has been cancelled
ParentFlow CI/CD Pipeline / Build Docker Images (map[context:maternal-app/maternal-app-backend dockerfile:Dockerfile.production name:backend]) (push) Has been cancelled
ParentFlow CI/CD Pipeline / Build Docker Images (map[context:maternal-web dockerfile:Dockerfile.production name:frontend]) (push) Has been cancelled
ParentFlow CI/CD Pipeline / Deploy to Development (push) Has been cancelled
ParentFlow CI/CD Pipeline / Deploy to Production (push) Has been cancelled
CI/CD Pipeline / Lint and Test (push) Has been cancelled
CI/CD Pipeline / E2E Tests (push) Has been cancelled
CI/CD Pipeline / Build Application (push) Has been cancelled
## Error Handling System - Add centralized error handling utilities (errorHandler.ts) - Create reusable error components (ErrorMessage, ErrorToast) - Implement multilingual error support (preserves backend error messages in 5 languages) - Update 15+ forms and components with consistent error handling - Auth forms: login, register, forgot-password - Family management: family page, join family dialog - Child management: child dialog - All tracking forms: feeding, sleep, diaper, medicine, growth, activity ## Production Build Fixes - Fix backend TypeScript errors: InviteCode.uses → InviteCode.useCount (5 instances) - Remove non-existent savedFamily variable from registration response - Fix admin panel TypeScript errors: SimpleMDE toolbar type, PieChart label type ## User Experience Improvements - Auto-uppercase invite code and share code inputs - Visual feedback for case conversion with helper text - Improved form validation with error codes ## CI/CD Pipeline - Create comprehensive production deployment checklist (PRODUCTION_DEPLOYMENT_CHECKLIST.md) - Add automated pre-deployment check script (pre-deploy-check.sh) - Validates frontend, backend, and admin panel builds - Checks git status, branch, and sync state - Verifies environment files and migrations - Add quick start deployment guide (DEPLOYMENT_QUICK_START.md) - Add production deployment automation template (deploy-production.sh) ## Cleanup - Remove outdated push notifications documentation files - Remove outdated PWA implementation plan 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -15,30 +15,31 @@ import { Email, ArrowBack } from '@mui/icons-material';
|
||||
import { motion } from 'framer-motion';
|
||||
import Link from 'next/link';
|
||||
import apiClient from '@/lib/api/client';
|
||||
import { useErrorMessage } from '@/components/common/ErrorMessage';
|
||||
import { formatErrorMessage } from '@/lib/utils/errorHandler';
|
||||
|
||||
export default function ForgotPasswordPage() {
|
||||
const [email, setEmail] = useState('');
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [error, setError] = useState('');
|
||||
const { error, showError, clearError, hasError } = useErrorMessage();
|
||||
const [success, setSuccess] = useState(false);
|
||||
|
||||
const handleSubmit = async (e: React.FormEvent) => {
|
||||
e.preventDefault();
|
||||
|
||||
if (!email.trim()) {
|
||||
setError('Please enter your email address');
|
||||
showError({ message: 'Please enter your email address', code: 'VALIDATION_EMAIL_REQUIRED' });
|
||||
return;
|
||||
}
|
||||
|
||||
setLoading(true);
|
||||
setError('');
|
||||
clearError();
|
||||
|
||||
try {
|
||||
await apiClient.post('/api/v1/auth/password/forgot', { email });
|
||||
setSuccess(true);
|
||||
} catch (err: any) {
|
||||
console.error('Forgot password error:', err);
|
||||
setError(err.response?.data?.message || 'Failed to send reset email. Please try again.');
|
||||
showError(err);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
@@ -97,9 +98,9 @@ export default function ForgotPasswordPage() {
|
||||
</Typography>
|
||||
</Box>
|
||||
|
||||
{error && (
|
||||
<Alert severity="error" sx={{ mb: 3, borderRadius: 2 }}>
|
||||
{error}
|
||||
{hasError && (
|
||||
<Alert severity="error" sx={{ mb: 3, borderRadius: 2 }} onClose={clearError}>
|
||||
{formatErrorMessage(error)}
|
||||
</Alert>
|
||||
)}
|
||||
|
||||
|
||||
@@ -28,6 +28,8 @@ import { startAuthentication } from '@simplewebauthn/browser';
|
||||
import Link from 'next/link';
|
||||
import { useTranslation } from '@/hooks/useTranslation';
|
||||
import { useTheme } from '@mui/material/styles';
|
||||
import { useErrorMessage } from '@/components/common/ErrorMessage';
|
||||
import { formatErrorMessage } from '@/lib/utils/errorHandler';
|
||||
|
||||
const loginSchema = z.object({
|
||||
email: z.string().email('Invalid email address'),
|
||||
@@ -40,7 +42,7 @@ export default function LoginPage() {
|
||||
const { t } = useTranslation('auth');
|
||||
const theme = useTheme();
|
||||
const [showPassword, setShowPassword] = useState(false);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const { error, showError, clearError, hasError } = useErrorMessage();
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
const [isBiometricLoading, setIsBiometricLoading] = useState(false);
|
||||
const [isBiometricSupported, setIsBiometricSupported] = useState(false);
|
||||
@@ -74,7 +76,7 @@ export default function LoginPage() {
|
||||
};
|
||||
|
||||
const handleBiometricLogin = async () => {
|
||||
setError(null);
|
||||
clearError();
|
||||
setIsBiometricLoading(true);
|
||||
|
||||
try {
|
||||
@@ -100,11 +102,11 @@ export default function LoginPage() {
|
||||
} catch (err: any) {
|
||||
console.error('Biometric login failed:', err);
|
||||
if (err.name === 'NotAllowedError') {
|
||||
setError('Biometric authentication was cancelled');
|
||||
showError({ message: 'Biometric authentication was cancelled', code: 'BIOMETRIC_CANCELLED' });
|
||||
} else if (err.name === 'NotSupportedError') {
|
||||
setError('Biometric authentication is not supported on this device');
|
||||
showError({ message: 'Biometric authentication is not supported on this device', code: 'BIOMETRIC_NOT_SUPPORTED' });
|
||||
} else {
|
||||
setError(err.response?.data?.message || err.message || 'Biometric login failed. Please try again.');
|
||||
showError(err);
|
||||
}
|
||||
} finally {
|
||||
setIsBiometricLoading(false);
|
||||
@@ -112,7 +114,7 @@ export default function LoginPage() {
|
||||
};
|
||||
|
||||
const onSubmit = async (data: LoginFormData) => {
|
||||
setError(null);
|
||||
clearError();
|
||||
setIsLoading(true);
|
||||
|
||||
try {
|
||||
@@ -127,7 +129,7 @@ export default function LoginPage() {
|
||||
mfaMethod: err.response.data.mfaMethod,
|
||||
});
|
||||
} else {
|
||||
setError(err.message || 'Failed to login. Please check your credentials.');
|
||||
showError(err);
|
||||
}
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
@@ -193,9 +195,9 @@ export default function LoginPage() {
|
||||
{t('login.subtitle')}
|
||||
</Typography>
|
||||
|
||||
{error && (
|
||||
<Alert severity="error" sx={{ mb: 3, borderRadius: 2 }}>
|
||||
{error}
|
||||
{hasError && (
|
||||
<Alert severity="error" sx={{ mb: 3, borderRadius: 2 }} onClose={clearError}>
|
||||
{formatErrorMessage(error)}
|
||||
</Alert>
|
||||
)}
|
||||
|
||||
|
||||
@@ -24,6 +24,8 @@ import { useAuth } from '@/lib/auth/AuthContext';
|
||||
import Link from 'next/link';
|
||||
import { useTheme } from '@mui/material/styles';
|
||||
import apiClient from '@/lib/api/client';
|
||||
import { useErrorMessage } from '@/components/common/ErrorMessage';
|
||||
import { formatErrorMessage } from '@/lib/utils/errorHandler';
|
||||
|
||||
// Create a function to generate schema dynamically based on requireInviteCode
|
||||
const createRegisterSchema = (requireInviteCode: boolean) => z.object({
|
||||
@@ -79,7 +81,7 @@ export default function RegisterPage() {
|
||||
const theme = useTheme();
|
||||
const [showPassword, setShowPassword] = useState(false);
|
||||
const [showConfirmPassword, setShowConfirmPassword] = useState(false);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const { error, showError, clearError, hasError } = useErrorMessage();
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
const [userAge, setUserAge] = useState<number | null>(null);
|
||||
const [requiresParentalConsent, setRequiresParentalConsent] = useState(false);
|
||||
@@ -150,11 +152,11 @@ export default function RegisterPage() {
|
||||
}, [dateOfBirth]);
|
||||
|
||||
const onSubmit = async (data: RegisterFormData) => {
|
||||
setError(null);
|
||||
clearError();
|
||||
|
||||
// Validate invite code if required
|
||||
if (requireInviteCode && (!data.inviteCode || data.inviteCode.trim() === '')) {
|
||||
setError('Invite code is required to register');
|
||||
showError({ message: 'Invite code is required to register', code: 'VALIDATION_INVITE_CODE_REQUIRED' });
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -172,7 +174,7 @@ export default function RegisterPage() {
|
||||
});
|
||||
// Navigation to onboarding is handled in the register function
|
||||
} catch (err: any) {
|
||||
setError(err.message || 'Failed to register. Please try again.');
|
||||
showError(err);
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
}
|
||||
@@ -224,9 +226,9 @@ export default function RegisterPage() {
|
||||
Start your journey to organized parenting
|
||||
</Typography>
|
||||
|
||||
{error && (
|
||||
<Alert severity="error" sx={{ mb: 3, borderRadius: 2 }}>
|
||||
{error}
|
||||
{hasError && (
|
||||
<Alert severity="error" sx={{ mb: 3, borderRadius: 2 }} onClose={clearError}>
|
||||
{formatErrorMessage(error)}
|
||||
</Alert>
|
||||
)}
|
||||
|
||||
@@ -285,14 +287,21 @@ export default function RegisterPage() {
|
||||
label="Invite Code"
|
||||
margin="normal"
|
||||
error={!!errors.inviteCode}
|
||||
helperText={errors.inviteCode?.message || 'Enter your invite code to register'}
|
||||
{...register('inviteCode')}
|
||||
helperText={errors.inviteCode?.message || 'Invite codes are automatically converted to uppercase'}
|
||||
{...register('inviteCode', {
|
||||
setValueAs: (value) => value?.toUpperCase() || '',
|
||||
})}
|
||||
onChange={(e) => {
|
||||
const uppercased = e.target.value.toUpperCase();
|
||||
setValue('inviteCode', uppercased);
|
||||
}}
|
||||
disabled={isLoading}
|
||||
required
|
||||
inputProps={{
|
||||
'aria-required': 'true',
|
||||
'aria-invalid': !!errors.inviteCode,
|
||||
'aria-describedby': errors.inviteCode ? 'invite-code-error' : 'invite-code-helper',
|
||||
style: { textTransform: 'uppercase' },
|
||||
}}
|
||||
InputProps={{
|
||||
sx: { borderRadius: 3 },
|
||||
|
||||
Reference in New Issue
Block a user