-
Couldn't load subscription status.
- Fork 0
Dev : Middleware & ETC. #81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
-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
…/fdrpkm68-frontend into feat/firstdate/staff-qr
- 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
…/fdrpkm68-frontend into feat/firstdate/staff-qr
* 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]>
(cherry picked from commit 77bf8bf)
Fix/qr code not scan
There was a problem hiding this 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.astrowith<Tabs>,<QRScanner>, manual form, check-in modals, and associated client script. - Extend
src/lib/eventAPI.tsto handle cufest timing and addstaffQRScanRegister; updatesrc/lib/api.tsto include auth headers. - Update
src/middleware.tsfor 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: truestatus 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> |
Copilot
AI
Jul 17, 2025
There was a problem hiding this comment.
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.
| <StaffWithNavbar> | |
| <StaffWithNavbar title="Event QR Scanner" description="Scan QR codes to register for events"> |
| <p class="mt-4 font-bold text-red-500"> | ||
| สถานะ: ยังไม่ได้ลงทะเบียน | ||
| </p> | ||
| {eventType != "cufest" && ( |
Copilot
AI
Jul 17, 2025
There was a problem hiding this comment.
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.
| {eventType != "cufest" && ( | |
| {eventType !== "cufest" && ( |
| 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); |
Copilot
AI
Jul 17, 2025
There was a problem hiding this comment.
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.
| qrData.includes("id=7137ec7e-0f4b-4d65-88c4-982d36f7692f") && | ||
| qrData.includes("userId=a8e7e644-ed12-4748-89fc-4599f868ab5d") | ||
| ) { | ||
| // Keep the old test QR support |
Copilot
AI
Jul 17, 2025
There was a problem hiding this comment.
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.
| 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 |
| @@ -0,0 +1,145 @@ | |||
| <div> | |||
| <div class="relative my-8 flex w-full px-4"> | |||
Copilot
AI
Jul 17, 2025
There was a problem hiding this comment.
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.
| <div class="relative my-8 flex w-full px-4"> | |
| <div class="relative my-8 flex w-full px-4" role="tablist"> |
| createdAt: "", | ||
| updatedAt: "", | ||
| }; | ||
| let currentActiveEvent: any = null; |
Copilot
AI
Jul 17, 2025
There was a problem hiding this comment.
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.
| let currentActiveEvent: any = null; | |
| interface ActiveEvent { | |
| id: string; | |
| name: string; | |
| status: string; | |
| startTime: string; | |
| endTime: string; | |
| } | |
| let currentActiveEvent: ActiveEvent | null = null; |
No description provided.