Add address management features and improve validation

- Implement saveMyAddress mutation for updating user addresses.
- Enhance address validation schema with additional fields.
- Add error handling for location loading in LocationPicker.
- Update translations for loading errors in English and Amharic.
- Introduce phone number validation for Ethiopian formats.
- Refactor AddressFormContent to accommodate new address structure.
This commit is contained in:
estifanos
2026-08-08 07:32:33 +00:00
parent 0f7c1dba4b
commit 85c9930363
9 changed files with 160 additions and 62 deletions

View File

@@ -0,0 +1,13 @@
import { z } from 'zod';
/** Accepts `09xxxxxxxx` or `+2519xxxxxxxx`; always yields `+2519xxxxxxxx`. */
export const ethiopianPhone = z
.string()
.trim()
.transform((v) => (/^09\d{8}$/.test(v) ? `+251${v.slice(1)}` : v))
.refine((v) => /^\+2519\d{8}$/.test(v), {
message: 'Enter a valid phone number (+2519xxxxxxxx)',
});
/** Same rules, but blank is allowed. */
export const optionalEthiopianPhone = z.union([z.literal(''), ethiopianPhone]).optional();