From 9a03e6c7aa65798881b779f39f9396713c2fb5ef Mon Sep 17 00:00:00 2001 From: "Muhammad A. Ghorbani" Date: Sun, 15 Nov 2026 17:24:45 +0330 Subject: [PATCH] feat: add authentication page and custom trip order detail management with API services --- src/features/auth/LoginPage.tsx | 22 ------------ .../custom-trip/CustomTripOrderDetailPage.tsx | 34 ++++++++++++++++++- .../CustomTripOrderReviewDialog.tsx | 16 +++++++-- .../components/CustomTripOrdersTab.tsx | 9 +++++ .../custom-trip/services/custom-trip-api.ts | 15 +++++++- src/features/custom-trip/types.ts | 2 ++ src/locales/ar.json | 11 ++++-- src/locales/en.json | 11 ++++-- src/locales/fa.json | 11 ++++-- vite.config.ts | 2 ++ 10 files changed, 98 insertions(+), 35 deletions(-) diff --git a/src/features/auth/LoginPage.tsx b/src/features/auth/LoginPage.tsx index b836cc9..01d7a15 100644 --- a/src/features/auth/LoginPage.tsx +++ b/src/features/auth/LoginPage.tsx @@ -43,11 +43,6 @@ export default function LoginPage() { loginMutation.mutate({ email: email.trim(), password }) } - const fillDemo = () => { - setEmail('admin@gmail.com') - setPassword('admin') - } - const errorMessage = loginMutation.error instanceof ApiError ? loginMutation.error.message @@ -78,23 +73,6 @@ export default function LoginPage() { onSubmit={submit} className="space-y-4 rounded-2xl border border-border-soft bg-card/60 p-6 shadow-2xl backdrop-blur" > - {/* راهنمای لاگین دمو */} -
-
- {t('auth.demoBoxTitle')} - admin@gmail.com / admin -
- -
- +
+ {t('customTrip.tripStartDate')}: +
+ + {(editLegs[0]?.departureDate || order.startDate) + ? formatDualDate((editLegs[0]?.departureDate || order.startDate) as string, language) + : '—'} + + {order.travelDateText && !/^\d{4}-\d{2}-\d{2}/.test(order.travelDateText) && ( + + ({order.travelDateText === 'This Month' + ? t('customTrip.quickDateThisMonth') + : order.travelDateText === 'Next Month' + ? t('customTrip.quickDateNextMonth') + : order.travelDateText === 'Arbaeen Pilgrimage Season' + ? t('customTrip.quickDateArbaeen') + : order.travelDateText === 'Arafah & Eid al-Adha' + ? t('customTrip.quickDateArafah') + : order.travelDateText === 'Nisfu Shaban Season' + ? t('customTrip.quickDateShaban') + : order.travelDateText === 'Date Not Decided Yet' + ? t('customTrip.quickDateUndecided') + : order.travelDateText}) + + )} +
+
+
{t('customTrip.createdDate')}: diff --git a/src/features/custom-trip/components/CustomTripOrderReviewDialog.tsx b/src/features/custom-trip/components/CustomTripOrderReviewDialog.tsx index c07a4c6..5fe2b49 100644 --- a/src/features/custom-trip/components/CustomTripOrderReviewDialog.tsx +++ b/src/features/custom-trip/components/CustomTripOrderReviewDialog.tsx @@ -248,7 +248,7 @@ export function CustomTripOrderReviewDialog({ useEffect(() => { if (order) { const orig = order.originCity || '' - const defaultStart = getDefaultBaseDate(order.created) + const defaultStart = order.startDate || order.legs?.[0]?.departureDate || getDefaultBaseDate(order.created) setEditOriginCity(orig) const initialLegs: CustomTripLeg[] = order.legs && order.legs.length > 0 @@ -594,6 +594,8 @@ export function CustomTripOrderReviewDialog({ priceEstimate: Number(editPrice), adminNotes: editNotes, originCity: editOriginCity, + startDate: editLegs[0]?.departureDate || order.startDate || null, + travelDateText: order.travelDateText || editLegs[0]?.departureDate || '', legs: editLegs, transferToBilling: false, }) @@ -625,6 +627,8 @@ export function CustomTripOrderReviewDialog({ priceEstimate: finalAmount, adminNotes: editNotes, originCity: editOriginCity, + startDate: editLegs[0]?.departureDate || order.startDate || null, + travelDateText: order.travelDateText || editLegs[0]?.departureDate || '', legs: editLegs, transferToBilling: true, }) @@ -751,7 +755,7 @@ export function CustomTripOrderReviewDialog({
{/* Customer Info Card */} -
+
{t('customTrip.passengerName')}: @@ -772,6 +776,14 @@ export function CustomTripOrderReviewDialog({ {order.infantsCount > 0 && `، ${toFa(order.infantsCount)} ${t('customTrip.infants')}`}
+
+ {t('customTrip.tripStartDate')}: + + {(editLegs[0]?.departureDate || order.startDate) + ? formatDualDate((editLegs[0]?.departureDate || order.startDate) as string, language) + : '—'} + +
{/* Origin City Selector */} diff --git a/src/features/custom-trip/components/CustomTripOrdersTab.tsx b/src/features/custom-trip/components/CustomTripOrdersTab.tsx index 75ec3f9..abccbc2 100644 --- a/src/features/custom-trip/components/CustomTripOrdersTab.tsx +++ b/src/features/custom-trip/components/CustomTripOrdersTab.tsx @@ -392,6 +392,15 @@ export function CustomTripOrdersTab({ .join(' | ')}
)} + {(order.startDate || order.legs?.[0]?.departureDate) && ( +
+ + + {t('customTrip.tripStartDate')}:{' '} + {formatDateByLanguage((order.startDate || order.legs?.[0]?.departureDate) as string, language)} + +
+ )} diff --git a/src/features/custom-trip/services/custom-trip-api.ts b/src/features/custom-trip/services/custom-trip-api.ts index 358bf9d..a712e8b 100644 --- a/src/features/custom-trip/services/custom-trip-api.ts +++ b/src/features/custom-trip/services/custom-trip-api.ts @@ -64,6 +64,8 @@ function mapBackendOrderToPanel(raw: any): CustomTripOrderItem { const rawServices = Array.isArray(raw.services) ? raw.services : [] const originCity = raw.origin_city || raw.originCity || '' const destinations: string[] = Array.isArray(raw.destinations) ? raw.destinations : [] + const rawStartDate: string | null = raw.start_date || raw.startDate || null + const rawTravelDateText: string = raw.travel_date_text || raw.travelDateText || '' let legs = rawLegs.map((leg: any, idx: number) => { const isReturn = Boolean( @@ -145,7 +147,7 @@ function mapBackendOrderToPanel(raw: any): CustomTripOrderItem { }) } - let curDate = legs[0].departureDate || getDefaultStartDateIso(raw.created) + let curDate = legs[0].departureDate || rawStartDate || getDefaultStartDateIso(raw.created) legs = legs.map((l, idx) => { const fromCity = idx === 0 ? originCity || l.fromCity : legs[idx - 1].toCity || l.fromCity if (l.isReturn) { @@ -224,6 +226,8 @@ function mapBackendOrderToPanel(raw: any): CustomTripOrderItem { factorId: raw.factor_id ?? null, factorNumber: raw.factor_number ?? null, status: (raw.status || 'PENDING') as CustomTripOrderStatus, + startDate: rawStartDate || legs[0]?.departureDate || stays[0]?.check_in || null, + travelDateText: rawTravelDateText || '', created: raw.created || new Date().toISOString(), detail: cleanLegacyDetail(raw.detail), adminNotes: raw.admin_notes || raw.adminNotes || '', @@ -267,6 +271,8 @@ export async function updateCustomTripOrder( priceEstimate?: number adminNotes?: string originCity?: string + startDate?: string | null + travelDateText?: string legs?: { fromCity: string toCity: string @@ -289,6 +295,13 @@ export async function updateCustomTripOrder( if (data.originCity) { itineraryPayload.origin_city = data.originCity } + const effectiveStartDate = data.startDate || data.legs?.[0]?.departureDate || null + if (effectiveStartDate) { + itineraryPayload.start_date = String(effectiveStartDate).slice(0, 10) + } + if (data.travelDateText !== undefined) { + itineraryPayload.travel_date_text = data.travelDateText + } if (Array.isArray(data.legs) && data.legs.length > 0) { itineraryPayload.legs = data.legs.map((leg, idx) => ({ sequence: idx + 1, diff --git a/src/features/custom-trip/types.ts b/src/features/custom-trip/types.ts index b488702..282463d 100644 --- a/src/features/custom-trip/types.ts +++ b/src/features/custom-trip/types.ts @@ -64,6 +64,8 @@ export interface CustomTripOrderItem { factorId?: number | null factorNumber?: number | null status: CustomTripOrderStatus + startDate?: string | null + travelDateText?: string created: string detail?: string adminNotes?: string diff --git a/src/locales/ar.json b/src/locales/ar.json index 043b88c..a497896 100644 --- a/src/locales/ar.json +++ b/src/locales/ar.json @@ -60,8 +60,6 @@ "auth": { "loginTitle": "تسجيل الدخول إلى لوحة الإدارة", "loginDescription": "أدخل بيانات الاعتماد الخاصة بك للوصول إلى بوابة الإدارة", - "demoBoxTitle": "حساب تجريبي جاهز:", - "autoFill": "تعبئة تلقائية", "emailLabel": "البريد الإلكتروني للحساب", "emailPlaceholder": "you@example.com", "passwordLabel": "كلمة المرور", @@ -965,7 +963,14 @@ "originStartAndEnd": "(نقطة انطلاق ونهاية الرحلة)", "selectReturnDestinationPlaceholder": "يرجى اختيار مدينة الوجهة في مسار العودة.", "viewInBilling": "عرض في القسم المالي", - "nightsCountLabel": "عدد ليالي الإقامة" + "nightsCountLabel": "عدد ليالي الإقامة", + "tripStartDate": "تاريخ بدء الرحلة", + "quickDateThisMonth": "هذا الشهر", + "quickDateNextMonth": "الشهر القادم", + "quickDateArbaeen": "موسم زيارة الأربعين", + "quickDateArafah": "موسم عرفة وعيد الأضحى", + "quickDateShaban": "موسم النصف من شعبان", + "quickDateUndecided": "لم أحدد التاريخ بعد (مرن)" }, "languages": { "fa": "فارسی", diff --git a/src/locales/en.json b/src/locales/en.json index 2361d79..b1f9dec 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -60,8 +60,6 @@ "auth": { "loginTitle": "Login to Admin Dashboard", "loginDescription": "Enter your credentials to access the management portal", - "demoBoxTitle": "Demo Ready Account:", - "autoFill": "Auto Fill", "emailLabel": "Account Email", "emailPlaceholder": "you@example.com", "passwordLabel": "Password", @@ -965,7 +963,14 @@ "originStartAndEnd": "(Origin & final endpoint of journey)", "selectReturnDestinationPlaceholder": "Please select the destination city for the return leg.", "viewInBilling": "View in Billing", - "nightsCountLabel": "Stay Nights" + "nightsCountLabel": "Stay Nights", + "tripStartDate": "Trip Start Date", + "quickDateThisMonth": "This Month", + "quickDateNextMonth": "Next Month", + "quickDateArbaeen": "Arbaeen Pilgrimage Season", + "quickDateArafah": "Arafah & Eid al-Adha", + "quickDateShaban": "Nisfu Shaban Season", + "quickDateUndecided": "Date Not Decided Yet (Flexible)" }, "languages": { "fa": "فارسی", diff --git a/src/locales/fa.json b/src/locales/fa.json index 750611f..206995a 100644 --- a/src/locales/fa.json +++ b/src/locales/fa.json @@ -60,8 +60,6 @@ "auth": { "loginTitle": "ورود به پنل مدیریت و داشبورد", "loginDescription": "برای دسترسی به پرتال مدیریت، اطلاعات ورود خود را وارد نمایید", - "demoBoxTitle": "حساب آزمایشی آماده:", - "autoFill": "پر کردن خودکار", "emailLabel": "ایمیل حساب کاربری", "emailPlaceholder": "you@example.com", "passwordLabel": "رمز عبور", @@ -965,7 +963,14 @@ "originStartAndEnd": "(مبدأ آغاز و پایان سفر)", "selectReturnDestinationPlaceholder": "لطفاً شهر مقصد در مسیر بازگشت را انتخاب نمایید.", "viewInBilling": "مشاهده در بخش مالی", - "nightsCountLabel": "تعداد شب اقامت" + "nightsCountLabel": "تعداد شب اقامت", + "tripStartDate": "تاریخ شروع سفر", + "quickDateThisMonth": "همین ماه", + "quickDateNextMonth": "ماه آینده", + "quickDateArbaeen": "ایام اربعین حسینی", + "quickDateArafah": "ایام عرفه و عید قربان", + "quickDateShaban": "ایام نیمه شعبان", + "quickDateUndecided": "هنوز مشخص نکرده‌ام (انعطاف‌پذیر)" }, "languages": { "fa": "فارسی", diff --git a/vite.config.ts b/vite.config.ts index 7f14f89..092ee06 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -316,6 +316,8 @@ export default defineConfig(({ mode }) => { alias: { '@': path.resolve(__dirname, './src') }, }, server: { + /* پورت پیش‌فرض خارج از بازهٔ ephemeral و پورت رزرو ۵۳۵۷ ویندوز تا با تداخل پورت کرش نکند. */ + port: Number(env.VITE_DEV_PORT) || 15173, proxy: { '/api': { target: apiTarget,