From 2a25727ef1406cc8821b1f52dc85574271b34a0f Mon Sep 17 00:00:00 2001 From: Mahdi Date: Mon, 25 May 2026 20:05:41 +0330 Subject: [PATCH] edit time rezerv --- .../owner/BusinessAvailabilityEditor.vue | 474 ++++++++++++++---- src/components/owner/HmTimePickers.vue | 35 ++ src/components/owner/TimeRangeList.vue | 92 ++++ src/components/ui/AppIcon.vue | 6 + src/types/icons.ts | 5 +- src/utils/format.ts | 32 ++ 6 files changed, 534 insertions(+), 110 deletions(-) create mode 100644 src/components/owner/HmTimePickers.vue create mode 100644 src/components/owner/TimeRangeList.vue diff --git a/src/components/owner/BusinessAvailabilityEditor.vue b/src/components/owner/BusinessAvailabilityEditor.vue index 8549ff9..8e33437 100644 --- a/src/components/owner/BusinessAvailabilityEditor.vue +++ b/src/components/owner/BusinessAvailabilityEditor.vue @@ -1,73 +1,161 @@ diff --git a/src/components/owner/HmTimePickers.vue b/src/components/owner/HmTimePickers.vue new file mode 100644 index 0000000..7007c33 --- /dev/null +++ b/src/components/owner/HmTimePickers.vue @@ -0,0 +1,35 @@ + + + diff --git a/src/components/owner/TimeRangeList.vue b/src/components/owner/TimeRangeList.vue new file mode 100644 index 0000000..d59edee --- /dev/null +++ b/src/components/owner/TimeRangeList.vue @@ -0,0 +1,92 @@ + + + diff --git a/src/components/ui/AppIcon.vue b/src/components/ui/AppIcon.vue index 5247f73..d18251d 100644 --- a/src/components/ui/AppIcon.vue +++ b/src/components/ui/AppIcon.vue @@ -14,7 +14,10 @@ import { ArrowRight, Calendar, Camera, + ChevronDown, + ChevronUp, CircleCheck, + Clock, ClipboardList, FolderOpen, Home, @@ -49,6 +52,9 @@ const iconMap: Record = { camera: Camera, 'circle-check': CircleCheck, search: Search, + 'chevron-down': ChevronDown, + 'chevron-up': ChevronUp, + clock: Clock, }; const props = withDefaults( diff --git a/src/types/icons.ts b/src/types/icons.ts index b8ac506..b61a361 100644 --- a/src/types/icons.ts +++ b/src/types/icons.ts @@ -15,7 +15,10 @@ export type AppIconName = | 'x' | 'camera' | 'circle-check' - | 'search'; + | 'search' + | 'chevron-down' + | 'chevron-up' + | 'clock'; export type NavItem = { to: string; diff --git a/src/utils/format.ts b/src/utils/format.ts index 3b622c8..3008f92 100644 --- a/src/utils/format.ts +++ b/src/utils/format.ts @@ -69,6 +69,38 @@ export function bookingStatusLabel(status: string): string { return map[status] ?? status; } +const PERSIAN_DIGITS = '۰۱۲۳۴۵۶۷۸۹'; +const ARABIC_DIGITS = '٠١٢٣٤٥٦٧٨٩'; + +function toAsciiDigits(value: string): string { + return value.replace(/./g, (ch) => { + const pi = PERSIAN_DIGITS.indexOf(ch); + if (pi >= 0) return String(pi); + const ai = ARABIC_DIGITS.indexOf(ch); + if (ai >= 0) return String(ai); + return ch; + }); +} + +/** Normalizes browser/API time to HH:mm (24h) for availability API. */ +export function normalizeHmTime(value: string): string | null { + const raw = toAsciiDigits(String(value ?? '').trim()).normalize('NFKC'); + if (!raw) return null; + const match = /^(\d{1,2}):(\d{1,2})(?::\d{1,2})?$/.exec(raw); + if (!match) return null; + let h = Number.parseInt(match[1], 10); + const m = Number.parseInt(match[2], 10); + if (h === 24 && m === 0) return '23:59'; + if (h < 0 || h > 23 || m < 0 || m > 59) return null; + return `${String(h).padStart(2, '0')}:${String(m).padStart(2, '0')}`; +} + +export function isHmRangeValid(start: string, end: string): boolean { + const s = normalizeHmTime(start); + const e = normalizeHmTime(end); + return Boolean(s && e && s < e); +} + export function formatDuration(minutes: number | null, fallback?: number): string { const m = minutes ?? fallback; if (!m) {