+
+
diff --git a/src/pages/Login.tsx b/src/pages/Login.tsx
index 9f27e87..7101b1c 100644
--- a/src/pages/Login.tsx
+++ b/src/pages/Login.tsx
@@ -1,8 +1,9 @@
-import { useState } from "react";
+import { useEffect, useState } from "react";
import { useLocation, useNavigate } from "react-router-dom";
import { requestOtp } from "../services/authApi";
import { toPersianDigits } from "../utils/formatNumber";
import { toE164 } from "../utils/phone";
+import { setUserRole } from "../utils/role";
function CheckIcon() {
return (
@@ -24,6 +25,11 @@ export default function Login() {
const navigate = useNavigate();
const location = useLocation();
const initialPhone = (location.state as { phone?: string } | null)?.phone ?? "";
+ const isOwnerFlow = location.pathname.startsWith("/cafe/login");
+
+ useEffect(() => {
+ setUserRole(isOwnerFlow ? "cafe_owner" : "customer");
+ }, [isOwnerFlow]);
const [phone, setPhone] = useState(initialPhone);
const [acceptedTerms, setAcceptedTerms] = useState(false);
@@ -89,7 +95,7 @@ export default function Login() {
{acceptedTerms &&
}
-
+
قوانین و شرایط
{" "}
را میپذیرم.
diff --git a/src/pages/LoginOtp.tsx b/src/pages/LoginOtp.tsx
index c828a8b..4b8384e 100644
--- a/src/pages/LoginOtp.tsx
+++ b/src/pages/LoginOtp.tsx
@@ -33,6 +33,7 @@ export default function LoginOtp() {
const location = useLocation()
const state = location.state as { phone?: string; ttl?: number } | null
const phone = state?.phone ?? ''
+ const loginPath = getUserRole() === 'cafe_owner' ? '/cafe/login' : '/login'
const [otp, setOtp] = useState(Array(OTP_LENGTH).fill(''))
const [secondsLeft, setSecondsLeft] = useState(Math.round(state?.ttl ?? DEFAULT_RESEND_SECONDS))
@@ -44,9 +45,9 @@ export default function LoginOtp() {
useEffect(() => {
if (!phone) {
- navigate('/login', { replace: true })
+ navigate(loginPath, { replace: true })
}
- }, [phone, navigate])
+ }, [phone, loginPath, navigate])
useEffect(() => {
const timer = setInterval(() => {
@@ -118,7 +119,7 @@ export default function LoginOtp() {
کد ارسال شده را وارد کنید:
{phone}
-
diff --git a/src/pages/MyReservations.tsx b/src/pages/MyReservations.tsx
new file mode 100644
index 0000000..75ae8ab
--- /dev/null
+++ b/src/pages/MyReservations.tsx
@@ -0,0 +1,115 @@
+import { useEffect, useState } from 'react'
+import { createPortal } from 'react-dom'
+import { useNavigate } from 'react-router-dom'
+import InfoIcon from '../components/InfoIcon'
+import SuccessIcon from '../components/SuccessIcon'
+import { mockMyReservations, MyReservation } from '../data/mockMyReservations'
+import { formatPersianNumber } from '../utils/formatNumber'
+
+function ChevronIcon({ className = '' }: { className?: string }) {
+ return (
+
+ )
+}
+
+function MyReservationCard({ reservation, onClick }: { reservation: MyReservation; onClick: () => void }) {
+ return (
+
+ {reservation.matchLabel}
+ {reservation.dateTimeLabel}
+
+
+ {formatPersianNumber(reservation.count)} نفر
+
+
+ {reservation.code}
+
+
+
+ )
+}
+
+function DetailRow({ label, value }: { label: string; value: string }) {
+ return (
+
+ {label}
+ {value}
+
+ )
+}
+
+function ReservationDetailModal({ reservation, onClose }: { reservation: MyReservation; onClose: () => void }) {
+ useEffect(() => {
+ const previousOverflow = document.body.style.overflow
+ document.body.style.overflow = 'hidden'
+ return () => {
+ document.body.style.overflow = previousOverflow
+ }
+ }, [])
+
+ return createPortal(
+
+
e.stopPropagation()}
+ >
+
+
جزئیات رزرو
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ کد رزرو را برای ورود نزد خود نگه دارید. اطلاعات ورود و کد دیگری برای دقایقی شما پیامک میشود.
+
+
+
+
+ بازگشت
+
+
+
,
+ document.body,
+ )
+}
+
+export default function MyReservations() {
+ const navigate = useNavigate()
+ const [selectedReservation, setSelectedReservation] = useState(null)
+
+ return (
+
+
+
+
navigate(-1)} className="mt-4 flex w-full items-center justify-start gap-2 px-4">
+
+ رزروهای شما
+
+
+
+ {mockMyReservations.map((reservation) => (
+ setSelectedReservation(reservation)} />
+ ))}
+
+
+ {selectedReservation && (
+
setSelectedReservation(null)} />
+ )}
+
+ )
+}
diff --git a/src/utils/role.ts b/src/utils/role.ts
index 4080b40..4db59dd 100644
--- a/src/utils/role.ts
+++ b/src/utils/role.ts
@@ -2,8 +2,11 @@ export type UserRole = 'customer' | 'cafe_owner'
const ROLE_STORAGE_KEY = 'role'
-// dev-only helper until real auth/role assignment exists — set via
-// localStorage.setItem('role', 'cafe_owner') in devtools to test that flow
+// set by Login.tsx based on whether the user entered via /login or /cafe/login
+export function setUserRole(role: UserRole) {
+ localStorage.setItem(ROLE_STORAGE_KEY, role)
+}
+
export function getUserRole(): UserRole {
return localStorage.getItem(ROLE_STORAGE_KEY) === 'cafe_owner' ? 'cafe_owner' : 'customer'
}