Skip to content

Commit

Permalink
fix(ui): toast visibility should be triggered on toast msg change
Browse files Browse the repository at this point in the history
  • Loading branch information
iFergal committed Nov 22, 2023
1 parent cfef02c commit 6315762
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 60 deletions.
2 changes: 1 addition & 1 deletion src/ui/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const App = () => {
useEffect(() => {
setShowScan(currentOperation === OperationType.SCAN_CONNECTION);
setShowToast(toastMsg !== undefined);
}, [currentOperation]);
}, [currentOperation, toastMsg]);

return (
<IonApp>
Expand Down
47 changes: 0 additions & 47 deletions src/ui/__fixtures__/credsFix.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,51 +42,4 @@ const credsFix: CredentialDetails[] = [
},
];

const universityCredentials = {
id: "metadata:e140217a-9ead-41f2-be3e-41841f531039",
colors: ["#efa18f", "#f5c7bc"],
issuanceDate: "2023-10-24T09:07:14.901Z",
credentialType: "UniversityDegreeCredential",
status: "confirmed",
type: ["VerifiableCredential", "UniversityDegreeCredential"],
connectionId: "1eb57b02-8cc9-4509-a34a-d1342280e589",
credentialSubject: {
id: "did:key:z6Mkvdhigk2EwyFy1ZYNvVrwRZYGujePLha9zLkB9JNGshRg",
name: "John Smith",
degree: {
type: "BachelorDegree",
name: "Bachelor of Science and Arts",
},
},
proofType: "Ed25519Signature2018",
proofValue:
"eyJhbGciOiJFZERTQSIsImI2NCI6ZmFsc2UsImNyaXQiOlsiYjY0Il19..m1c7d46h-f0CqxF5NVmb8_ODt03uaIj24LxX5-9d5NuPug7Z4nQa_dOIrAkER0vN9f08-HmskIm3Wu3uMKhLAg",
};

const residenceCredentials = {
id: "metadata:e7363c7d-1d23-46ad-aea3-b4d224bf35fd",
colors: ["#9fef8f", "#c6f5bc"],
issuanceDate: "2023-10-25T13:12:16.773Z",
credentialType: "PermanentResidentCard",
status: "confirmed",
type: ["VerifiableCredential", "PermanentResidentCard"],
connectionId: "d8dc33ba-7234-4989-87e2-e96d674d74ef",
expirationDate: "2025-12-12T12:12:12Z",
credentialSubject: {
id: "did:key:z6MktNjjqFdTksu46nngQ1xhisB1J426DcjLSA1rKwYHzM4B",
type: ["PermanentResident", "Person"],
birthCountry: "The Bahamas",
givenName: "John",
familyName: "Smith",
gender: "Male",
image: "static/johnsmith_photo.jpg",
residentSince: "2022-10-10T10:12:12Z",
lprCategory: "C09",
lprNumber: "999-999-999",
},
proofType: "Ed25519Signature2018",
proofValue:
"eyJhbGciOiJFZERTQSIsImI2NCI6ZmFsc2UsImNyaXQiOlsiYjY0Il19..gYBknKig0P88Z-CGhu8his1G9dRsZd1UqhVJOT51To3iKZ9m24MC152-u0QgNXOe4Z_QaWDByA20-1ilg3a4Dw",
};

export { credsFix };
10 changes: 6 additions & 4 deletions src/ui/__fixtures__/filteredCredsFix.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
const filteredCredsFix = [
import { CredentialShortDetails } from "../../core/agent/agent.types";
import { CredentialMetadataRecordStatus } from "../../core/agent/modules/generalStorage/repositories/credentialMetadataRecord.types";

const filteredCredsFix: CredentialShortDetails[] = [
{
id: "did:example:ebfeb1ebc6f1c276ef71212ec21",
issuanceDate: "2010-01-01T19:23:24Z",
credentialType: "University Credential",
issuerLogo: "https://www.w3.org/Icons/WWW/w3c_home_nb-v.svg",
colors: ["#FFBC60", "#FFA21F"],
status: "confirmed",
status: CredentialMetadataRecordStatus.CONFIRMED,
},
{
id: "did:example:ebfeb1f712ebc6f1c276e12ec21",
issuanceDate: "2010-01-01T19:23:24Z",
credentialType: "University Credential",
nameOnCredential: "Thomas A. Mayfield",
issuerLogo: "https://www.w3.org/Icons/WWW/w3c_home_nb-v.svg",
colors: ["#D9EDDF", "#ACD8B9"],
status: "confirmed",
status: CredentialMetadataRecordStatus.CONFIRMED,
},
];

Expand Down
4 changes: 3 additions & 1 deletion src/ui/components/Alert/Alert.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ const Alert = ({
header={headerText}
subHeader={subheaderText}
buttons={buttons}
onDidDismiss={handleDismiss}
onDidDismiss={({ detail }) =>
detail.role === "backdrop" && handleDismiss
}
/>
</div>
);
Expand Down
14 changes: 7 additions & 7 deletions src/ui/components/VerifyPasscode/VerifyPasscode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const VerifyPasscode = ({
const dispatch = useAppDispatch();
const currentOperation = useAppSelector(getCurrentOperation);
const currentRoute = useAppSelector(getCurrentRoute);
const [currentAction, setCurrentAction] = useState<ToastMsgType>();
const [toastMsgToDispatch, setToastMsgToDispatch] = useState<ToastMsgType>();
const authentication = useAppSelector(getAuthentication);
const [passcode, setPasscode] = useState("");
const seedPhrase = localStorage.getItem("seedPhrase");
Expand All @@ -48,24 +48,24 @@ const VerifyPasscode = ({
const cancelButtonText = i18n.t("verifypasscode.alert.button.cancel");

useEffect(() => {
let operation;
let toastMsg;
if (
currentRoute?.path?.includes(TabsRoutePath.DIDS) &&
currentOperation === OperationType.DELETE_IDENTIFIER
) {
operation = ToastMsgType.IDENTIFIER_DELETED;
toastMsg = ToastMsgType.IDENTIFIER_DELETED;
} else if (
currentRoute?.path?.includes(TabsRoutePath.CREDS) &&
currentOperation === OperationType.DELETE_CREDENTIAL
) {
operation = ToastMsgType.CREDENTIAL_DELETED;
toastMsg = ToastMsgType.CREDENTIAL_DELETED;
} else if (
currentRoute?.path?.includes(RoutePath.CONNECTION_DETAILS) &&
currentOperation === OperationType.DELETE_CONNECTION
) {
operation = ToastMsgType.CONNECTION_DELETED;
toastMsg = ToastMsgType.CONNECTION_DELETED;
}
setCurrentAction(operation);
setToastMsgToDispatch(toastMsg);
}, [currentRoute?.path, currentOperation]);

const handleClearState = () => {
Expand All @@ -82,7 +82,7 @@ const VerifyPasscode = ({
verifyPasscode(passcode + digit)
.then((verified) => {
if (verified) {
dispatch(setToastMsg(currentAction));
dispatch(setToastMsg(toastMsgToDispatch));
onVerify();
handleClearState();
} else {
Expand Down

0 comments on commit 6315762

Please sign in to comment.