You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
72 lines
1.8 KiB
72 lines
1.8 KiB
import {
|
|
Dialog,
|
|
DialogClose,
|
|
DialogContent,
|
|
DialogDescription,
|
|
DialogHeader,
|
|
DialogTitle,
|
|
} from "@components/UI/Dialog.tsx";
|
|
import { useDevice } from "@core/stores/deviceStore.ts";
|
|
import { useTranslation } from "react-i18next";
|
|
|
|
export interface ClientNotificationDialogProps {
|
|
open: boolean;
|
|
onOpenChange: (open: boolean) => void;
|
|
}
|
|
|
|
export const ClientNotificationDialog = ({
|
|
open,
|
|
onOpenChange,
|
|
}: ClientNotificationDialogProps) => {
|
|
const { t } = useTranslation("dialog");
|
|
const { getClientNotification, removeClientNotification } = useDevice();
|
|
|
|
const localOnOpenChange = (open: boolean) => {
|
|
removeClientNotification(0);
|
|
if (!getClientNotification(0)) {
|
|
onOpenChange(open);
|
|
}
|
|
};
|
|
|
|
const dialogContent = (() => {
|
|
if (!getClientNotification(0)) {
|
|
return;
|
|
}
|
|
|
|
switch (getClientNotification(0)?.payloadVariant.case) {
|
|
// TODO: Add KeyVerification logic
|
|
/*case "keyVerificationNumberInform":
|
|
return <></>;
|
|
case "keyVerificationNumberRequest":
|
|
return <></>;
|
|
case "keyVerificationFinal":
|
|
return <></>;
|
|
case "duplicatedPublicKey":
|
|
return <></>;
|
|
case "lowEntropyKey":
|
|
return <></>;*/
|
|
|
|
default:
|
|
return (
|
|
<DialogHeader>
|
|
<DialogTitle>{t("clientNotification.title")}</DialogTitle>
|
|
<DialogDescription>
|
|
{t([
|
|
`clientNotification.${getClientNotification(0)?.message}`,
|
|
getClientNotification(0)?.message ?? "",
|
|
])}
|
|
</DialogDescription>
|
|
</DialogHeader>
|
|
);
|
|
}
|
|
})();
|
|
|
|
return (
|
|
<Dialog open={open} onOpenChange={localOnOpenChange}>
|
|
<DialogContent>
|
|
<DialogClose />
|
|
{dialogContent}
|
|
</DialogContent>
|
|
</Dialog>
|
|
);
|
|
};
|
|
|