Skip to content

Commit

Permalink
fix(qr): types and null check
Browse files Browse the repository at this point in the history
  • Loading branch information
Vexcited committed Nov 7, 2024
1 parent ae2a59c commit b45ada2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions src/widgets/Components/RestaurantQRCode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const RestaurantQRCodeWidget = forwardRef(({

const account = useCurrentAccount((store) => store.account);
const linkedAccounts = useCurrentAccount(store => store.linkedAccounts);
const [qrcode, setQRCodes] = useState<number[] | null>(null);
const [qrcode, setQRCodes] = useState<string[] | null>(null);
const navigation = useNavigation<NavigationProps>();

useImperativeHandle(ref, () => ({
Expand All @@ -41,14 +41,15 @@ const RestaurantQRCodeWidget = forwardRef(({
void async function () {
setHidden(true);
setLoading(true);
const qrcodes: number[] = [];
const qrcodes: string[] = [];
const currentHour = new Date().getHours();
for (const account of linkedAccounts) {
if (account.service === AccountService.Turboself || account.service === AccountService.ARD) {
const cardnumber = await qrcodeFromExternal(account);
cardnumber !== 0 && qrcodes.push(cardnumber);
const cardNumber = await qrcodeFromExternal(account);
if (cardNumber) qrcodes.push(cardNumber);
}
}

setQRCodes(qrcodes);
setHidden(qrcodes.length === 0 || currentHour < 11 || currentHour > 14);
setLoading(false);
Expand Down

0 comments on commit b45ada2

Please sign in to comment.