Skip to content

Conversation

@neennera
Copy link
Contributor

No description provided.

dhanavadh and others added 30 commits July 13, 2025 22:27
-added staff scan qr page
added staff-qr page
- Fixed Staff-qr handling error
- Fix error type assertions in staff/event/index.astro
- Remove unused imports and variables
- Added auth functions getAuthToken() and getAuthHeaders() in api.ts
- Fixed body stream error when scan qr code
- Added handle error when user is not exist and when user scan wrong qr
- fix ButtonFd not send data
- Fixed no events active layout
* feat: added staff scan qr page

-added staff scan qr page

* fix: firstdate staff bg

* feat: add @yudiel/react-qr-scanner

* Feat: added staff-qr page

added staff-qr page

* chore: fix middleware doesn't work

* feat: Implement qr scan with api

* fix: staff-qr code

- Fixed Staff-qr handling error
- Fix error type assertions in staff/event/index.astro
- Remove unused imports and variables

* fix: qr scan error, body stream err, cannot send cookie to backend err

- Added auth functions getAuthToken() and getAuthHeaders() in api.ts
- Fixed body stream error when scan qr code
- Added handle error when user is not exist and when user scan wrong qr

* Fix: alternative form handle error

- fix ButtonFd not send data

* fix: no event active layout

- Fixed no events active layout

* fix: qrcode

---------

Co-authored-by: neennera <[email protected]>
Co-authored-by: Thukdanai Thaothawin <[email protected]>
Co-authored-by: Borworntat Dendumrongkul <[email protected]>
@neennera neennera requested review from RawSalmon69 and Copilot July 17, 2025 19:45
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds a full-featured staff event check-in page with QR scanning and manual entry, updates event API/middleware logic (including time-based route whitelisting and cufest support), and includes various UI tweaks and link fixes.

  • Introduce src/pages/staff/event/index.astro with <Tabs>, <QRScanner>, manual form, check-in modals, and associated client script.
  • Extend src/lib/eventAPI.ts to handle cufest timing and add staffQRScanRegister; update src/lib/api.ts to include auth headers.
  • Update src/middleware.ts for time‐based access to non‐started routes and make minor UI/link adjustments across several pages.

Reviewed Changes

Copilot reviewed 16 out of 20 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
src/pages/staff/event/index.astro New staff event check-in UI and logic
src/lib/eventAPI.ts cufest timing logic, staffQRScanRegister, updated event configs
src/lib/api.ts Added auth headers, improved error handling
src/middleware.ts Time-based whitelist for pre-start routes
src/components/staff/QRScanner.tsx New React QR scanner component
src/components/common/Tabs.astro Tab UI component for QR vs manual entry
Various src/pages/firstdate/... and src/pages/fest Minor link, text, and map refresh hints
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported
Comments suppressed due to low confidence (1)

src/lib/eventAPI.ts:133

  • The cufest branch returns only after the target date, but for dates before the target it falls through to backend calls rather than marking as coming soon. Consider returning an isComingSoon: true status for pre-target dates.
  if (eventType === "cufest") {

<div class="min-h-screen px-4 py-16">
<div class="mx-auto max-w-4xl">
<h1 class="mb-12 text-center text-2xl font-bold">
<StaffWithNavbar>
Copy link

Copilot AI Jul 17, 2025

Choose a reason for hiding this comment

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

The StaffWithNavbar layout is rendered without title and description props, resulting in an undefined <title> and meta description. Pass title and description or set defaults in the layout.

Suggested change
<StaffWithNavbar>
<StaffWithNavbar title="Event QR Scanner" description="Scan QR codes to register for events">

Copilot uses AI. Check for mistakes.
<p class="mt-4 font-bold text-red-500">
สถานะ: ยังไม่ได้ลงทะเบียน
</p>
{eventType != "cufest" && (
Copy link

Copilot AI Jul 17, 2025

Choose a reason for hiding this comment

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

Use strict comparison (!==) instead of loose (!=) to avoid unintended type coercion.

Suggested change
{eventType != "cufest" && (
{eventType !== "cufest" && (

Copilot uses AI. Check for mistakes.
Comment on lines 73 to 82
if (response.body) {
try {
const raw: ApiResponseRaw = JSON.parse(await response.text());
const responseText = await response.text();
const raw: ApiResponseRaw = JSON.parse(responseText);
errorMsg = raw.error || raw.message || errorMsg;
} catch {
errorMsg = await response.text();
errorMsg = "Request failed";
}
}
throw new ApiError(errorMsg, response.status, response);
Copy link

Copilot AI Jul 17, 2025

Choose a reason for hiding this comment

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

[nitpick] On JSON parse failure the code falls back to a generic "Request failed" message, losing server-side error details. Consider logging the raw response or including it for easier debugging.

Copilot uses AI. Check for mistakes.
Comment on lines +92 to +95
qrData.includes("id=7137ec7e-0f4b-4d65-88c4-982d36f7692f") &&
qrData.includes("userId=a8e7e644-ed12-4748-89fc-4599f868ab5d")
) {
// Keep the old test QR support
Copy link

Copilot AI Jul 17, 2025

Choose a reason for hiding this comment

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

Hardcoded test QR code values are embedded in production logic. Remove or guard this test data behind a debug flag or configuration.

Suggested change
qrData.includes("id=7137ec7e-0f4b-4d65-88c4-982d36f7692f") &&
qrData.includes("userId=a8e7e644-ed12-4748-89fc-4599f868ab5d")
) {
// Keep the old test QR support
process.env.DEBUG_MODE === "true" &&
qrData.includes("id=7137ec7e-0f4b-4d65-88c4-982d36f7692f") &&
qrData.includes("userId=a8e7e644-ed12-4748-89fc-4599f868ab5d")
) {
// Keep the old test QR support in debug mode

Copilot uses AI. Check for mistakes.
@@ -0,0 +1,145 @@
<div>
<div class="relative my-8 flex w-full px-4">
Copy link

Copilot AI Jul 17, 2025

Choose a reason for hiding this comment

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

The tab component is missing ARIA roles and properties (e.g., role="tablist", role="tab", aria-selected). Add appropriate accessibility attributes for screen reader support.

Suggested change
<div class="relative my-8 flex w-full px-4">
<div class="relative my-8 flex w-full px-4" role="tablist">

Copilot uses AI. Check for mistakes.
createdAt: "",
updatedAt: "",
};
let currentActiveEvent: any = null;
Copy link

Copilot AI Jul 17, 2025

Choose a reason for hiding this comment

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

Using any for currentActiveEvent loses type safety. Define and use a proper interface/type for this variable.

Suggested change
let currentActiveEvent: any = null;
interface ActiveEvent {
id: string;
name: string;
status: string;
startTime: string;
endTime: string;
}
let currentActiveEvent: ActiveEvent | null = null;

Copilot uses AI. Check for mistakes.
@Taihenc Taihenc merged commit 0874b69 into main Jul 17, 2025
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants