unrestricted checkout#32
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces a new configuration flag (unrestricted_checkout_location) (read from QR + persisted in AsyncStorage) to allow check-out (“OUT”) without enforcing location restrictions, while keeping location restriction behavior unchanged for check-in (“IN”).
Changes:
- Parse and persist a new QR field: “Unrestricted Checkout Location” →
unrestricted_checkout_location. - Skip office location fetch / radius enforcement when
type === "OUT"andunrestricted_checkout_location === "1"(service + camera flow). - Update AttendanceAction button disable/opacity logic to allow checkout while “out of bound” when the new flag is enabled.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| services/api/attendance.service.js | Skips location restriction checks for checkout when unrestricted_checkout_location is enabled. |
| screens/QrScan.jsx | Adds QR parsing + AsyncStorage persistence for the new unrestricted checkout flag. |
| screens/AttendanceCamera.jsx | Avoids location validation calls for checkout when unrestricted checkout is enabled. |
| screens/AttendanceAction.jsx | Allows the checkout action button even when out-of-bound if unrestricted checkout is enabled. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+113
to
+116
| console.log( | ||
| "QR UNRESTRICTED VALUE:", | ||
| cleanedData.unrestricted_checkout_location, | ||
| ); |
Comment on lines
47
to
66
| const KEYS = [ | ||
| "Company", | ||
| "Employee_Code", | ||
| "Full_Name", | ||
| "Photo", | ||
| "Restrict Location", // :point_left: NEW FIELD | ||
| "Restrict Location", | ||
| "Unrestricted Checkout Location", | ||
| "User_id", | ||
| "API", | ||
| "App_key", | ||
| ]; | ||
| // :one: Decode Base64 | ||
| let value = utf8.decode(base64.decode(data)); | ||
| // :two: Clean up weird characters | ||
| value = value | ||
| .replace(/[\u0000-\u001F\u00A0]+/g, " ") | ||
| .replace( | ||
| /[%#;]+(?:\s+)?(Company|Employee_Code|Full_Name|Photo|Restrict Location|User_id|API|App_key)(?:\s*[:=])/g, | ||
| (_, key) => `${key}:` | ||
| /[%#;]+(?:\s+)?(Company|Employee_Code|Full_Name|Photo|Restrict Location|Unrestricted Checkout Location|User_id|API|App_key)(?:\s*[:=])/g, | ||
| (_, key) => `${key}:`, | ||
| ) |
Comment on lines
+751
to
+753
| const allowCheckoutAnywhere = | ||
| checkin === true && unrestrictedCheckout === "1"; | ||
|
|
Comment on lines
+949
to
+960
| } ${ | ||
| restrictLocation === "1" && | ||
| !inTarget && | ||
| !allowCheckoutAnywhere | ||
| ? "opacity-50" | ||
| : "" | ||
| }`} | ||
| disabled={ | ||
| actionLoading || (restrictLocation === "1" && !inTarget) | ||
| actionLoading || | ||
| (restrictLocation === "1" && | ||
| !inTarget && | ||
| !allowCheckoutAnywhere) |
Comment on lines
+202
to
+217
| const unrestrictedCheckout = ( | ||
| await AsyncStorage.getItem("unrestricted_checkout_location") | ||
| )?.trim(); | ||
|
|
||
| let nearest = null; | ||
| let radius = null; | ||
|
|
||
| // 📍 Location restriction is enabled | ||
| if (restrictLocation && restrictLocation.toString() === "1") { | ||
| const shouldSkipLocationRestriction = | ||
| type === "OUT" && unrestrictedCheckout === "1"; | ||
|
|
||
| if ( | ||
| !shouldSkipLocationRestriction && | ||
| restrictLocation && | ||
| restrictLocation.toString() === "1" | ||
| ) { |
Comment on lines
+113
to
+116
| console.log( | ||
| "QR UNRESTRICTED VALUE:", | ||
| cleanedData.unrestricted_checkout_location, | ||
| ); |
Comment on lines
+751
to
+753
| const allowCheckoutAnywhere = | ||
| checkin === true && unrestrictedCheckout === "1"; | ||
|
|
Comment on lines
+949
to
+960
| } ${ | ||
| restrictLocation === "1" && | ||
| !inTarget && | ||
| !allowCheckoutAnywhere | ||
| ? "opacity-50" | ||
| : "" | ||
| }`} | ||
| disabled={ | ||
| actionLoading || (restrictLocation === "1" && !inTarget) | ||
| actionLoading || | ||
| (restrictLocation === "1" && | ||
| !inTarget && | ||
| !allowCheckoutAnywhere) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.