-
Notifications
You must be signed in to change notification settings - Fork 4
fix: add badge data to show on swal popup on badge check in #671
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -224,3 +224,5 @@ export const ROOM_OCCUPANCY_OPTIONS = [ | |
| "FULL", | ||
| "OVERFLOW" | ||
| ]; | ||
|
|
||
| export const BADGE_QR_MINIMUM_EXPECTED_FIELDS = 3; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: # First, find and examine the constant definition
cat -n src/utils/constants.js | grep -A 2 -B 2 "BADGE_QR_MINIMUM_EXPECTED_FIELDS"Repository: fntechgit/summit-admin Length of output: 141 🏁 Script executed: # Search for all usages of BADGE_QR_MINIMUM_EXPECTED_FIELDS
rg "BADGE_QR_MINIMUM_EXPECTED_FIELDS" -n -B 3 -A 3Repository: fntechgit/summit-admin Length of output: 969 🏁 Script executed: # Find and examine the formatBadgeQR function
rg "formatBadgeQR" -n -A 20 src/utils/methods.jsRepository: fntechgit/summit-admin Length of output: 560 Constant value doesn't align with array access pattern in The constant is set to 3, but Change the constant to -export const BADGE_QR_MINIMUM_EXPECTED_FIELDS = 3;
+export const BADGE_QR_MINIMUM_EXPECTED_FIELDS = 4;🤖 Prompt for AI Agents |
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -30,7 +30,8 @@ import { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ONE_MINUTE, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| INT_BASE, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| OR_FILTER, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| MARKETING_SETTING_TYPE_HEX_COLOR | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| MARKETING_SETTING_TYPE_HEX_COLOR, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| BADGE_QR_MINIMUM_EXPECTED_FIELDS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } from "./constants"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const DAY_IN_SECONDS = 86400; // 86400 seconds per day | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -504,3 +505,21 @@ export const arrayToString = (array, join = ",") => { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export const capitalizeFirstLetter = (val) => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| String(val).charAt(0).toUpperCase() + String(val).slice(1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export const formatBadgeQR = (code, summit) => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const qrCodeArray = code.split(summit.qr_registry_field_delimiter); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| qrCodeArray.length >= BADGE_QR_MINIMUM_EXPECTED_FIELDS && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| qrCodeArray[0] === summit.badge_qr_prefix | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| badgePrefix: qrCodeArray[0], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ticketNumber: qrCodeArray[1], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| email: qrCodeArray[2] || "", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fullName: qrCodeArray[3] || "" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return null; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+509
to
+525
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add input validation and ensure array bounds are properly checked. Several concerns with this function:
Based on past review comments from smarcet. 🔎 Proposed improvements export const formatBadgeQR = (code, summit) => {
+ if (!code || !summit?.qr_registry_field_delimiter || !summit?.badge_qr_prefix) {
+ return null;
+ }
+
const qrCodeArray = code.split(summit.qr_registry_field_delimiter);
if (
qrCodeArray.length >= BADGE_QR_MINIMUM_EXPECTED_FIELDS &&
qrCodeArray[0] === summit.badge_qr_prefix
) {
+ const ticketNumber = qrCodeArray[1]?.trim();
+ const email = qrCodeArray[2]?.trim() || "";
+ const fullName = qrCodeArray[3]?.trim() || "";
+
+ // Validate that required fields are not empty
+ if (!ticketNumber) {
+ return null;
+ }
+
return {
badgePrefix: qrCodeArray[0],
- ticketNumber: qrCodeArray[1],
- email: qrCodeArray[2] || "",
- fullName: qrCodeArray[3] || ""
+ ticketNumber,
+ email,
+ fullName
};
}
return null;
};Note: Also ensure 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
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.
current summit is never used removed it if not used