Files
maternal-app/maternal-web/components/family/JoinFamilyDialog.tsx
Andrei c22fa82521
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
feat: Implement comprehensive error handling and production deployment pipeline
## 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>
2025-10-09 21:27:39 +00:00

106 lines
2.6 KiB
TypeScript

'use client';
import { useState, useEffect } from 'react';
import {
Dialog,
DialogTitle,
DialogContent,
DialogActions,
Button,
TextField,
Box,
Alert,
Typography,
} from '@mui/material';
import { JoinFamilyData } from '@/lib/api/families';
interface JoinFamilyDialogProps {
open: boolean;
onClose: () => void;
onSubmit: (data: JoinFamilyData) => Promise<void>;
isLoading?: boolean;
}
export function JoinFamilyDialog({
open,
onClose,
onSubmit,
isLoading = false,
}: JoinFamilyDialogProps) {
const [shareCode, setShareCode] = useState<string>('');
const [error, setError] = useState<string>('');
useEffect(() => {
if (open) {
setShareCode('');
setError('');
}
}, [open]);
const handleSubmit = async () => {
setError('');
// Validation
if (!shareCode.trim()) {
setError('Please enter a share code');
return;
}
try {
await onSubmit({ shareCode: shareCode.trim() });
onClose();
} catch (err: any) {
setError(err.message || 'Failed to join family');
}
};
return (
<Dialog
open={open}
onClose={onClose}
maxWidth="sm"
fullWidth
aria-labelledby="join-family-dialog-title"
aria-describedby="join-family-dialog-description"
>
<DialogTitle id="join-family-dialog-title">Join a Family</DialogTitle>
<DialogContent>
<Box sx={{ pt: 2, display: 'flex', flexDirection: 'column', gap: 2 }}>
{error && (
<Alert severity="error" onClose={() => setError('')} role="alert">
{error}
</Alert>
)}
<Typography variant="body2" color="text.secondary" id="join-family-dialog-description">
Enter the share code provided by the family administrator to join their family.
</Typography>
<TextField
label="Share Code"
value={shareCode}
onChange={(e) => setShareCode(e.target.value.toUpperCase())}
fullWidth
required
autoFocus
disabled={isLoading}
placeholder="XXXX-XXXX"
helperText="Share codes are automatically converted to uppercase"
inputProps={{
style: { textTransform: 'uppercase' },
}}
/>
</Box>
</DialogContent>
<DialogActions>
<Button onClick={onClose} disabled={isLoading}>
Cancel
</Button>
<Button onClick={handleSubmit} variant="contained" disabled={isLoading}>
{isLoading ? 'Joining...' : 'Join Family'}
</Button>
</DialogActions>
</Dialog>
);
}