Conversation
| @@ -0,0 +1,59 @@ | |||
| "use client"; | |||
|
|
|||
| import { useParams, useRouter } from "next/navigation"; | |||
There was a problem hiding this comment.
There are inconsistency here, few files using useRouter from @/lib/navigation, but this is using next/navigation.
Is this intended? Or auto impott problem?
There was a problem hiding this comment.
I think @/lib/navigation optimized for i18n
There was a problem hiding this comment.
Fixed in 8e05041 — useRouter is now imported from @/lib/navigation for i18n consistency. useParams is kept from next/navigation since @/lib/navigation doesn't export it.
| return ( | ||
| <div className="container mx-auto max-w-3xl px-4 py-8"> | ||
| <div className="text-center"> | ||
| <h1 className="mb-4 text-2xl font-bold">Transaction Not Found</h1> |
There was a problem hiding this comment.
There are hardcoded strings in english, better to use i18n
There was a problem hiding this comment.
Fixed in 8e05041 — all hardcoded strings have been replaced with useTranslations("MyEventDetailPage") keys added to both en.json and id.json.
| const { data: paymentData, isLoading } = useGetPaymentDetail(transactionId); | ||
|
|
||
| if (isLoading) { | ||
| return ( | ||
| <div className="flex min-h-screen items-center justify-center"> | ||
| <Loader /> | ||
| </div> | ||
| ); | ||
| } |
There was a problem hiding this comment.
There is no handled for isError or error
There was a problem hiding this comment.
Fixed in 8e05041 — isError is now destructured from useGetPaymentDetail and handled in the condition: if (isError || !paymentData?.data).
| id?: number; | ||
| order_no?: string; | ||
| event_id?: number; | ||
| user_id?: string; |
There was a problem hiding this comment.
Is there any reason why id or no like these marked as optional? I belive event should has these value
There was a problem hiding this comment.
Fixed in 8e05041 — id, order_no, event_id, and user_id are now required fields in UserEventResponse.
| const handleViewDetails = () => { | ||
| openDialog({ | ||
| title: "Event Details", | ||
| content: <EventDetailModal event={event} />, | ||
| size: "xl", | ||
| className: "h-[80%]", | ||
| }); | ||
| router.push(`/my-events/${event.order_no}`); | ||
| }; |
There was a problem hiding this comment.
order_no is optional, so it's probalby empty, better to put condition to protect this router's push if this commented code intentioanl #105 (comment)
| mutationFn: ({ event_id }: { event_id: number }) => eventsService.registerEvent(event_id), | ||
| onSuccess: (data) => { | ||
| toast.success(data?.message); | ||
| router.push(`/my-events/${data.data.order_no}`); |
There was a problem hiding this comment.
Same comment with this
There was a problem hiding this comment.
Can refactor be like:
onSuccess: (data) => {
toast.success(data?.message);
const orderNo = data?.data?.order_no;
if (orderNo) {
router.push(`/my-events/${orderNo}`);
} else {
router.push("/my-events");
}
},So will push user to main event page when error
There was a problem hiding this comment.
Fixed in 8e05041 — refactored to the suggested pattern: checks for orderNo and falls back to /my-events if it's missing.
| const params = useParams(); | ||
|
|
||
| const transactionId = params?.transactionId as string; | ||
| const { data: paymentData, isLoading } = useGetPaymentDetail(transactionId); |
There was a problem hiding this comment.
useGetPaymentDetail function parameter is order_no, its better to make it consistent between order_no or transactionId
There was a problem hiding this comment.
Including the nested routing also using transactionId
params?.transactionId
There was a problem hiding this comment.
Fixed in 8e05041 — the local variable is now named order_no (extracted from params?.transactionId which reflects the route param name [transactionId]), making the intent clear when passed to useGetPaymentDetail(order_no).
| </Button> | ||
| </div> | ||
|
|
||
| <div className="rounded-lg border border-gray-200 bg-white p-6 dark:border-gray-800 dark:bg-gray-900"> |
There was a problem hiding this comment.
I believe the current css theme can adjust it's own opposite color when activating the dark mode, can remove classnames that started with dark:
There was a problem hiding this comment.
Fixed in 8e05041 — removed dark:border-gray-800 and dark:bg-gray-900 classnames from the container.
| router.push(`/my-events/${data.data.order_no}`); | ||
| }, | ||
| onError: (error) => { | ||
| toast.error(error?.message); |
There was a problem hiding this comment.
Depends solely on backend can be confusing if the error is not what is expected. Can put handle like this
onError: (error) => {
const message = error?.message || "Failed to xxxx";
toast.error(message);
},And use i18n to store that Failed to xxxx
There was a problem hiding this comment.
Fixed in 8e05041 — onError now uses error?.message || t("register-error") with the fallback message stored in i18n (en.json: "Failed to register event", id.json: "Gagal mendaftar event").
|
@copilot fix |
… safety Agent-Logs-Url: https://github.com/hammercode-dev/hammercode-web/sessions/3d9c5db3-7c5a-4dde-8b64-6d63b5002423 Co-authored-by: morizkay <26421928+morizkay@users.noreply.github.com>
Agent-Logs-Url: https://github.com/hammercode-dev/hammercode-web/sessions/3d9c5db3-7c5a-4dde-8b64-6d63b5002423 Co-authored-by: morizkay <26421928+morizkay@users.noreply.github.com>
All review comments addressed in commits 8e05041 and 88c107a:
|

Adds a detail page for registered events (
/my-events/[transactionId]) showing payment status, event info, and registration details. Addresses review feedback on i18n consistency, error handling, type safety, and routing.Changes
UserEventDetailPage.tsxuseRouter→@/lib/navigation(i18n-aware router, consistent with rest of codebase)useTranslations("MyEventDetailPage")isErrorhandling alongside the existing!paymentData?.dataguarddark:classnames — theme handles contrast automaticallytransactionId→order_nofor consistency withuseGetPaymentDetailparameteruseRegistEvent.tsxonSuccess: guardsorder_nobefore navigating; falls back to/my-eventsif missingonError: useserror?.message || t("register-error")instead of relying solely on backend messageuserEvent.tsid,order_no,event_id,user_idchanged from optional to required inUserEventResponse— backend always returns theseen.json/id.jsonMyEventDetailPagenamespace andEventsPage.Hook.register-errorkeyRelated Issue(s) / Tickets
Checklist
Please review and check all applicable items:
Screenshots (if applicable)
Additional Notes
Route param is
[transactionId](from the Next.js folder name) — locally aliased asorder_noin the component to match the API parameter. Route rename not done to minimize scope.