mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-03 22:16:54 +00:00
feat(bank/nui): bank alert component
This commit is contained in:
1 parent
bf2a991ebc
commit
b8ef73b95f
2 files changed
+51
No files matched your search
@@ -0,0 +1,8 @@
|
||||
import React from "react";
|
||||
import MuiAlert from "@material-ui/lab/Alert";
|
||||
|
||||
export function Alert(props) {
|
||||
return <MuiAlert elevation={6} variant="filled" {...props} />;
|
||||
}
|
||||
|
||||
export default Alert;
|
||||
@@ -0,0 +1,43 @@
|
||||
import React, { useState, useEffect } from "react";
|
||||
import { useBankAlert } from "../../hooks/useBankAlert";
|
||||
import Snackbar from "@material-ui/core/Snackbar";
|
||||
import Alert from "./Alert";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
export const BankAlert = () => {
|
||||
const { t } = useTranslation();
|
||||
const [open, setOpen] = useState(false);
|
||||
const { bankAlert, setBankAlert } = useBankAlert();
|
||||
const [ message, setMessage ] = useState(null);
|
||||
const [severity, setSeverity] = useState("");
|
||||
|
||||
const _handleClose = () => {
|
||||
setOpen(false);
|
||||
setBankAlert(null);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (bankAlert === true ) {
|
||||
setOpen(true);
|
||||
setMessage(t("APPS_BANK_ALERT_TRANSFER_SUCCESS"));
|
||||
setSeverity("success")
|
||||
} else if (bankAlert === false) {
|
||||
setOpen(true);
|
||||
setMessage(t("APPS_BANK_ALERT_TRANSFER_FAILURE"));
|
||||
setSeverity("error")
|
||||
}
|
||||
}, [bankAlert])
|
||||
|
||||
return (
|
||||
<Snackbar
|
||||
style={{ width: "80%" }}
|
||||
open={open}
|
||||
autoHideDuration={6000}
|
||||
onClose={_handleClose}
|
||||
>
|
||||
<Alert onClose={_handleClose} severity={severity}>
|
||||
{message}
|
||||
</Alert>
|
||||
</Snackbar>
|
||||
);
|
||||
};
|
||||
Reference in new issue
Block a user