feature: phase0 - Global patients + mobile normalization

This commit is contained in:
2026-06-28 14:49:37 +03:30
parent 653d67e15b
commit 64c7e5a257
23 changed files with 535 additions and 260 deletions

View File

@@ -5,6 +5,7 @@ import { Button } from '@/components/ui/shared/Button';
import { DialogCloseButton } from '@/components/ui/shared/DialogCloseButton';
import { Input } from '@/components/ui/shared/Input';
import { CreatePatientInput } from '@/types/patient';
import { isValidMobile, normalizeMobile } from '@/lib/phone';
interface CreatePatientModalProps {
isOpen: boolean;
@@ -49,9 +50,10 @@ function CreatePatientFormFields({
onChange={(e) => onChange({ lastName: e.target.value })}
/>
<Input
label={t('phone')}
value={formData.phone || ''}
onChange={(e) => onChange({ phone: e.target.value })}
label={t('mobile')}
value={formData.mobile || ''}
onChange={(e) => onChange({ mobile: e.target.value })}
placeholder={t('mobilePlaceholder')}
/>
<Input
label={tCommon('email')}
@@ -66,7 +68,7 @@ function CreatePatientFormFields({
variant="primary"
onClick={onSubmit}
isLoading={loading}
disabled={!formData.firstName || !formData.lastName}
disabled={!formData.firstName || !formData.lastName || !isValidMobile(normalizeMobile(formData.mobile || '') ?? '')}
>
{t('savePatient')}
</Button>

View File

@@ -3,6 +3,7 @@
import { useTranslations } from 'next-intl';
import { Search } from 'lucide-react';
import { Input } from '@/components/ui/shared/Input';
import { formatMobileForDisplay } from '@/lib/phone';
import { Patient } from '@/types/patient';
interface PatientSearchSelectProps {
@@ -56,7 +57,9 @@ export function PatientSearchSelect({
<p className="text-sm font-medium text-text-primary">
{patient.firstName} {patient.lastName}
</p>
<p className="text-xs text-text-muted">{patient.phone || patient.email || t('noContact')}</p>
<p className="text-xs text-text-muted">
{formatMobileForDisplay(patient.mobile) || patient.email || t('noContact')}
</p>
</button>
);
})}

View File

@@ -1,6 +1,7 @@
'use client';
import { useTranslations } from 'next-intl';
import { formatMobileForDisplay } from '@/lib/phone';
import { Patient } from '@/types/patient';
interface PatientSummaryCardProps {
@@ -24,7 +25,7 @@ export function PatientSummaryCard({ patient }: PatientSummaryCardProps) {
{patient.firstName} {patient.lastName}
</h2>
<p className="text-sm text-text-secondary">
{t('phoneLabel')} {patient.phone || t('emptyValue')}
{t('mobileLabel')} {formatMobileForDisplay(patient.mobile)}
</p>
<p className="text-sm text-text-secondary">
{t('emailLabel')} {patient.email || t('emptyValue')}