mirror of
https://github.com/selfxyz/self.git
synced 2026-04-05 03:00:53 -04:00
update error sheet on register
This commit is contained in:
@@ -661,21 +661,25 @@ const MainScreen: React.FC = () => {
|
||||
dismissOnSnapToBottom modal animation="medium" snapPoints={[80]}
|
||||
>
|
||||
<Sheet.Overlay />
|
||||
<Sheet.Frame bg={bgColor} borderRadius="$9" pt="$2">
|
||||
<YStack p="$4" f={1} gap="$3">
|
||||
<H2 textAlign='center' mb="$6" color={textColor1}>Passport unsupported</H2>
|
||||
<Text fontSize="$6" mb="$4" color={textColor1}>Unfortunately, your passport is currently not supported. Details:</Text>
|
||||
<Text fontSize="$6" mb="$4" textAlign="center" color="#a0a0a0">{registrationErrorMessage} </Text>
|
||||
<Sheet.Frame bg={bgWhite} borderRadius="$9" pt="$2">
|
||||
<YStack p="$4" f={1} gap="$3" pb="$6">
|
||||
<YStack jc="flex-start" >
|
||||
<Text fontSize="$9" textAlign='left' mb="$2" color={textBlack}>Sorry, an error has occurred</Text>
|
||||
</YStack>
|
||||
|
||||
<Text fontSize="$6" mb="$4" color={textColor1}>To help us add support for it, please consider contributing its data!</Text>
|
||||
<Fieldset gap="$4" mt="$1" horizontal>
|
||||
<Label color={textColor1} width={200} justifyContent="flex-end" htmlFor="restart">
|
||||
Contribute
|
||||
</Label>
|
||||
<Button bg={componentBgColor} jc="center" borderColor={borderColor} borderWidth={1.2} size="$3.5" ml="$2" onPress={() => setDialogContributeIsOpen(true)}>
|
||||
<Share color={textColor1} />
|
||||
</Button>
|
||||
</Fieldset>
|
||||
<Text fontSize="$7">Error details:</Text>
|
||||
<Text fontSize="$6" mb="$2" textAlign="center" color="#a0a0a0">{registrationErrorMessage} </Text>
|
||||
|
||||
<Separator borderColor={separatorColor} />
|
||||
<Text mt="$4" fontSize="$6" mb="$4" color={textBlack}>Unfortunately, your passport is currently not supported.</Text>
|
||||
|
||||
<Text fontSize="$6" mb="$4" color={textBlack}>To help us add support for it, please consider contributing its data!</Text>
|
||||
<XStack f={1} />
|
||||
<CustomButton
|
||||
text="Contribute"
|
||||
onPress={() => setDialogContributeIsOpen(true)}
|
||||
Icon={<Share />}
|
||||
/>
|
||||
</YStack>
|
||||
</Sheet.Frame>
|
||||
</Sheet>
|
||||
|
||||
@@ -17,6 +17,7 @@ const RegisterScreen: React.FC = () => {
|
||||
const handleRegister = async () => {
|
||||
setRegistering(true);
|
||||
useUserStore.getState().registerCommitment();
|
||||
|
||||
setRegisterStep("Generating witness...");
|
||||
setTimeout(() => {
|
||||
setRegisterStep("Generating proof...");
|
||||
|
||||
@@ -32,6 +32,11 @@ const StartScreen: React.FC = () => {
|
||||
<CustomButton Icon={<ArrowRight />} text="Let's start" onPress={() => {
|
||||
setSelectedTab("scan");
|
||||
}} />
|
||||
{/* <Button onPress={() => {
|
||||
setSelectedTab("register");
|
||||
}}>
|
||||
Register
|
||||
</Button> */}
|
||||
</YStack >
|
||||
);
|
||||
};
|
||||
|
||||
@@ -117,6 +117,7 @@ const useUserStore = create<UserState>((set, get) => ({
|
||||
},
|
||||
|
||||
registerCommitment: async (mockPassportData?: PassportData) => {
|
||||
console.log("registerCommitment")
|
||||
const {
|
||||
toast,
|
||||
setStep,
|
||||
@@ -129,6 +130,7 @@ const useUserStore = create<UserState>((set, get) => ({
|
||||
}
|
||||
|
||||
const isAlreadyRegistered = await isCommitmentRegistered(secret, passportData);
|
||||
console.log("isAlreadyRegistered", isAlreadyRegistered)
|
||||
if (isAlreadyRegistered) {
|
||||
console.log("commitment is already registered")
|
||||
toast.show('Identity already registered, skipping', {
|
||||
|
||||
@@ -8,7 +8,16 @@ import { formatMrz, packBytes } from "../../../common/src/utils/utils";
|
||||
import { findIndexInTree } from "../../../common/src/utils/generateInputs";
|
||||
|
||||
export async function isCommitmentRegistered(secret: string, passportData: PassportData) {
|
||||
const response = await axios.get(COMMITMENT_TREE_TRACKER_URL)
|
||||
|
||||
|
||||
let response;
|
||||
console.log(COMMITMENT_TREE_TRACKER_URL)
|
||||
try {
|
||||
response = await axios.get(COMMITMENT_TREE_TRACKER_URL);
|
||||
} catch (error) {
|
||||
console.error('Error fetching commitment tree:', error);
|
||||
throw error; // rethrow the error after logging
|
||||
}
|
||||
console.log('response.data:', response.data);
|
||||
|
||||
const imt = new LeanIMT(
|
||||
@@ -40,7 +49,7 @@ export async function isCommitmentRegistered(secret: string, passportData: Passp
|
||||
try {
|
||||
findIndexInTree(imt as any, commitment); // this will throw if not found
|
||||
return true
|
||||
} catch(err) {
|
||||
} catch (err) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user