Skip to content

[FEAT] - my events page detail#105

Open
mpsalunggg wants to merge 4 commits intodevelopmentfrom
feat/my-events-page-detail
Open

[FEAT] - my events page detail#105
mpsalunggg wants to merge 4 commits intodevelopmentfrom
feat/my-events-page-detail

Conversation

@mpsalunggg
Copy link
Copy Markdown
Member

@mpsalunggg mpsalunggg commented Jan 8, 2026

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.tsx

  • useRouter@/lib/navigation (i18n-aware router, consistent with rest of codebase)
  • All hardcoded EN strings replaced with useTranslations("MyEventDetailPage")
  • Added isError handling alongside the existing !paymentData?.data guard
  • Removed manual dark: classnames — theme handles contrast automatically
  • Renamed local var transactionIdorder_no for consistency with useGetPaymentDetail parameter

useRegistEvent.tsx

  • onSuccess: guards order_no before navigating; falls back to /my-events if missing
  • onError: uses error?.message || t("register-error") instead of relying solely on backend message
onSuccess: (data) => {
  toast.success(data?.message);
  const orderNo = data?.data?.order_no;
  if (orderNo) {
    router.push(`/my-events/${orderNo}`);
  } else {
    router.push("/my-events");
  }
},
onError: (error) => {
  const message = error?.message || t("register-error");
  toast.error(message);
},

userEvent.ts

  • id, order_no, event_id, user_id changed from optional to required in UserEventResponse — backend always returns these

en.json / id.json

  • Added MyEventDetailPage namespace and EventsPage.Hook.register-error key

Related Issue(s) / Tickets

  • Related Issue: #...
  • Notion/Jira Ticket: JIRA-XXXX

Checklist

Please review and check all applicable items:

  • I have tested the changes locally and they work as expected
  • I have added/updated relevant documentation (if applicable)
  • My code follows the project's coding style guidelines
  • All tests pass successfully
  • I have updated the necessary dependencies (if applicable)
  • I have squashed any insignificant commits into meaningful ones

Screenshots (if applicable)

My Events Detail Page

Additional Notes

Route param is [transactionId] (from the Next.js folder name) — locally aliased as order_no in the component to match the API parameter. Route rename not done to minimize scope.

@mpsalunggg mpsalunggg self-assigned this Jan 8, 2026
@mpsalunggg mpsalunggg added the enhancement New feature or request label Jan 8, 2026
@mpsalunggg mpsalunggg requested a review from vickyadrii January 11, 2026 12:49
@@ -0,0 +1,59 @@
"use client";

import { useParams, useRouter } from "next/navigation";
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are inconsistency here, few files using useRouter from @/lib/navigation, but this is using next/navigation.

Is this intended? Or auto impott problem?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think @/lib/navigation optimized for i18n

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 8e05041useRouter 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>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are hardcoded strings in english, better to use i18n

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 8e05041 — all hardcoded strings have been replaced with useTranslations("MyEventDetailPage") keys added to both en.json and id.json.

Comment on lines +15 to +23
const { data: paymentData, isLoading } = useGetPaymentDetail(transactionId);

if (isLoading) {
return (
<div className="flex min-h-screen items-center justify-center">
<Loader />
</div>
);
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no handled for isError or error

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 8e05041isError is now destructured from useGetPaymentDetail and handled in the condition: if (isError || !paymentData?.data).

Comment on lines +63 to +66
id?: number;
order_no?: string;
event_id?: number;
user_id?: string;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any reason why id or no like these marked as optional? I belive event should has these value

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 8e05041id, order_no, event_id, and user_id are now required fields in UserEventResponse.

Comment on lines 54 to 56
const handleViewDetails = () => {
openDialog({
title: "Event Details",
content: <EventDetailModal event={event} />,
size: "xl",
className: "h-[80%]",
});
router.push(`/my-events/${event.order_no}`);
};
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since order_no is now a required field in UserEventResponse (fixed in 8e05041), the navigation is guaranteed safe by the type. The null-check was cleaned up in 88c107a.

mutationFn: ({ event_id }: { event_id: number }) => eventsService.registerEvent(event_id),
onSuccess: (data) => {
toast.success(data?.message);
router.push(`/my-events/${data.data.order_no}`);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment with this

#105 (comment)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

useGetPaymentDetail function parameter is order_no, its better to make it consistent between order_no or transactionId

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Including the nested routing also using transactionId

params?.transactionId

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[transactionId]

CleanShot 2026-02-06 at 22 57 06@2x

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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">
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 8e05041onError 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").

@morizkay
Copy link
Copy Markdown
Member

morizkay commented Apr 8, 2026

@copilot fix

Copy link
Copy Markdown

Copilot AI commented Apr 8, 2026

@copilot fix

All review comments addressed in commits 8e05041 and 88c107a:

  • useRouter changed to @/lib/navigation
  • All hardcoded strings replaced with i18n translations
  • isError handling added
  • dark: classnames removed
  • order_no, id, event_id, user_id made required in UserEventResponse
  • onSuccess refactored with order_no guard, onError uses i18n fallback message

Copilot AI requested a review from morizkay April 8, 2026 12:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants