diff --git a/src/App.tsx b/src/App.tsx index 13e42c8..ffae9ea 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -5,9 +5,11 @@ import CafeDetail from './pages/CafeDetail' import PaymentSuccess from './pages/PaymentSuccess' import CafeOwnerRegister from './pages/CafeOwnerRegister' import CafeRegisterSuccess from './pages/CafeRegisterSuccess' +import CafeRegisterFail from './pages/CafeRegisterFail' import CafeOwnerPanel from './pages/CafeOwnerPanel' import AddEvent from './pages/AddEvent' import AddEventSuccess from './pages/AddEventSuccess' +import AddEventFail from './pages/AddEventFail' import EventReservations from './pages/EventReservations' import MyReservations from './pages/MyReservations' import Login from './pages/Login' @@ -36,9 +38,11 @@ export default function App() { } /> } /> } /> + } /> } /> } /> } /> + } /> } /> } /> } /> diff --git a/src/components/FailIcon.tsx b/src/components/FailIcon.tsx new file mode 100644 index 0000000..7305924 --- /dev/null +++ b/src/components/FailIcon.tsx @@ -0,0 +1,18 @@ +export default function FailIcon({ className = 'mx-auto h-28 w-28' }: { className?: string }) { + return ( + + + + + + ) +} diff --git a/src/pages/AddEvent.tsx b/src/pages/AddEvent.tsx index 37158f1..43e9c9e 100644 --- a/src/pages/AddEvent.tsx +++ b/src/pages/AddEvent.tsx @@ -204,10 +204,8 @@ export default function AddEvent() { const [entryFee, setEntryFee] = useState(100000) const [description, setDescription] = useState('') const [isSubmitting, setIsSubmitting] = useState(false) - const [error, setError] = useState('') const handleSubmit = async () => { - setError('') setIsSubmitting(true) try { await createCafeSchedule(getCafeUuid() ?? '', { @@ -218,7 +216,7 @@ export default function AddEvent() { }) navigate('/owner/events/success') } catch { - setError('ثبت رویداد با خطا مواجه شد. لطفاً دوباره تلاش کنید.') + navigate('/owner/events/fail') } finally { setIsSubmitting(false) } @@ -247,8 +245,6 @@ export default function AddEvent() { - - {error &&

{error}

}
diff --git a/src/pages/AddEventFail.tsx b/src/pages/AddEventFail.tsx new file mode 100644 index 0000000..f5a46c2 --- /dev/null +++ b/src/pages/AddEventFail.tsx @@ -0,0 +1,34 @@ +import { useNavigate } from 'react-router-dom' +import FailIcon from '../components/FailIcon' + +export default function AddEventFail() { + const navigate = useNavigate() + + return ( +
+
+ +
+ +

ثبت ایونت با خطا مواجه شد. لطفا دوباره تلاش کنید.

+
+ +
+ + +
+
+ ) +} diff --git a/src/pages/CafeOwnerRegister.tsx b/src/pages/CafeOwnerRegister.tsx index 9bb250d..f5bc445 100644 --- a/src/pages/CafeOwnerRegister.tsx +++ b/src/pages/CafeOwnerRegister.tsx @@ -401,7 +401,14 @@ export default function CafeOwnerRegister() { navigate("/owner/register/success"); } } catch { - setError("ثبت اطلاعات با خطا مواجه شد. لطفاً دوباره تلاش کنید."); + // only the final cafe-registration step has a dedicated success page to mirror — + // owner registration (step 1) and editing an existing cafe just advance/redirect + // inline on success, so their failures stay inline too + if (step === 2 && !isEditMode) { + navigate("/owner/register/fail"); + } else { + setError("ثبت اطلاعات با خطا مواجه شد. لطفاً دوباره تلاش کنید."); + } } finally { setIsSubmitting(false); } diff --git a/src/pages/CafeRegisterFail.tsx b/src/pages/CafeRegisterFail.tsx new file mode 100644 index 0000000..57b8914 --- /dev/null +++ b/src/pages/CafeRegisterFail.tsx @@ -0,0 +1,29 @@ +import { useNavigate } from 'react-router-dom' +import FailIcon from '../components/FailIcon' + +export default function CafeRegisterFail() { + const navigate = useNavigate() + + return ( +
+
+ +
+ +

ثبت کافه با خطا مواجه شد. لطفا دوباره تلاش کنید.

+
+ +
+ {/* no "مشاهده پنل" option here, unlike the other fail pages — registration never + completed, so there's no cafe yet for the panel or "add event" flow to operate on */} + +
+
+ ) +} diff --git a/src/pages/PaymentSuccess.tsx b/src/pages/PaymentSuccess.tsx index 26fdb78..dd415c9 100644 --- a/src/pages/PaymentSuccess.tsx +++ b/src/pages/PaymentSuccess.tsx @@ -1,5 +1,6 @@ import { useEffect, useState } from 'react' import { useNavigate, useSearchParams } from 'react-router-dom' +import FailIcon from '../components/FailIcon' import InfoIcon from '../components/InfoIcon' import SuccessIcon from '../components/SuccessIcon' import { createReservation, ReservationResult } from '../services/campaignApi' @@ -26,6 +27,8 @@ export default function PaymentSuccess() { const isSuccess = searchParams.get('state') === SUCCESS_STATE const [reservation, setReservation] = useState(null) const [error, setError] = useState('') + // gateway-reported failure, or a successful payment whose reservation couldn't be created + const isFail = !isSuccess || !!error useEffect(() => { if (!isSuccess) return @@ -42,7 +45,7 @@ export default function PaymentSuccess() { return (
- + {isFail ? : } {isSuccess ? ( reservation ? (