mirror of
https://gitea.tendokyu.moe/ppc/amnet.git
synced 2026-09-25 07:38:17 +03:00
improve ux when scanning already imported physical card
This commit is contained in:
@@ -26,25 +26,19 @@ export default function PhysicalCardScan() {
|
||||
return;
|
||||
}
|
||||
|
||||
const accessCode = cardInfo.type === ICType.Amusement ? cardInfo.accessCode : icCard0008Number(cardInfo.idm);
|
||||
|
||||
realm.write(() => {
|
||||
let existingCard = realm.objects<AMCard>(AMCard.schema.name).find(x => x.code === accessCode);
|
||||
const physicalCardInfo = realm.create<AMPhysicalCardData>(AMPhysicalCardData.schema.name, {
|
||||
// check if the card has already been registered (convert a manually entered card to a physically scanned card)
|
||||
const accessCode = cardInfo.type === ICType.Amusement ? cardInfo.accessCode : icCard0008Number(cardInfo.idm);
|
||||
const cardEntity = realm.objects<AMCard>(AMCard.schema.name).find(x => x.code === accessCode) ?? realm.create<AMCard>(AMCard.schema.name, AMCard.generate(accessCode, cardName));
|
||||
|
||||
// set physical card props
|
||||
cardEntity.name = cardName;
|
||||
cardEntity.added = new Date();
|
||||
cardEntity.physicalCardData ??= realm.objectForPrimaryKey<AMPhysicalCardData>(AMPhysicalCardData.schema.name, cardInfo.idm) ?? realm.create<AMPhysicalCardData>(AMPhysicalCardData.schema.name, {
|
||||
cardIDm: cardInfo.idm,
|
||||
cardType: cardInfo.type,
|
||||
cardVendor: cardInfo.type === ICType.Amusement ? cardInfo.vendor : null
|
||||
});
|
||||
|
||||
if (!existingCard) {
|
||||
existingCard = realm.create<AMCard>(AMCard.schema.name, AMCard.generate(accessCode, cardName));
|
||||
} else {
|
||||
existingCard.name = cardName;
|
||||
}
|
||||
|
||||
// set physical card props
|
||||
existingCard.added = new Date();
|
||||
existingCard.physicalCardData = physicalCardInfo;
|
||||
});
|
||||
|
||||
// dismiss the parent screen (this screen can only be accessed from modal -> stack)
|
||||
@@ -81,7 +75,7 @@ export default function PhysicalCardScan() {
|
||||
</Card.Content>
|
||||
</Card>
|
||||
|
||||
<Paragraph>
|
||||
<Paragraph style={modalStyles.formFootnote}>
|
||||
Ensure you have either an Amusement IC or Transport card ready to scan.
|
||||
After the scan has completed, the card will be saved to your device.
|
||||
</Paragraph>
|
||||
|
||||
Reference in New Issue
Block a user