diff --git a/infra/staff/src/App.tsx b/infra/staff/src/App.tsx index 0586b69dff..c610ac9aa4 100644 --- a/infra/staff/src/App.tsx +++ b/infra/staff/src/App.tsx @@ -190,7 +190,10 @@ const App: React.FC = () => { 0) > 0 ? "Enabled" : "Disabled", - "Can Disable EmailMFA": userDataResponse.details?.profileData.canDisableEmailMFA ? "Yes":"No", + "Can Disable EmailMFA": userDataResponse.details + ?.profileData.canDisableEmailMFA + ? "Yes" + : "No", AuthCodes: `${userDataResponse.authCodes ?? 0}`, }, }; diff --git a/infra/staff/src/components/ToggleEmailMFA.tsx b/infra/staff/src/components/ToggleEmailMFA.tsx index 919c6002ec..0e0a469a73 100644 --- a/infra/staff/src/components/ToggleEmailMFA.tsx +++ b/infra/staff/src/components/ToggleEmailMFA.tsx @@ -86,7 +86,9 @@ const ToggleEmailMFA: React.FC = ({ handleToggleEmailMFA(enable); // Notify parent component of successful action with status handleClose(); // Close dialog on successful action - console.log(`Email MFA ${enable ? "enabled" : "disabled"} successfully`); + console.log( + `Email MFA ${enable ? "enabled" : "disabled"} successfully`, + ); } catch (error) { if (error instanceof Error) { alert(error.message); @@ -130,7 +132,8 @@ const ToggleEmailMFA: React.FC = ({ - Do you want to enable or disable Email MFA for this account? + Do you want to enable or disable Email MFA for this + account? @@ -180,4 +183,4 @@ const ToggleEmailMFA: React.FC = ({ ); }; -export default ToggleEmailMFA; \ No newline at end of file +export default ToggleEmailMFA; diff --git a/infra/staff/src/components/UserComponent.tsx b/infra/staff/src/components/UserComponent.tsx index f0c78b831f..bc93101960 100644 --- a/infra/staff/src/components/UserComponent.tsx +++ b/infra/staff/src/components/UserComponent.tsx @@ -17,8 +17,8 @@ import ChangeEmail from "./ChangeEmail"; import DeleteAccount from "./DeleteAccont"; import Disable2FA from "./Disable2FA"; import DisablePasskeys from "./DisablePasskeys"; -import UpdateSubscription from "./UpdateSubscription"; import ToggleEmailMFA from "./ToggleEmailMFA"; +import UpdateSubscription from "./UpdateSubscription"; export interface UserData { User: Record; @@ -46,7 +46,9 @@ const UserComponent: React.FC = ({ userData }) => { React.useEffect(() => { setTwoFactorEnabled(userData?.Security["Two factor 2FA"] === "Enabled"); setEmail2FAEnabled(userData?.Security["Email MFA"] === "Enabled"); - setCanDisableEmailMFA(userData?.Security["Can Disable EmailMFA"] === "Yes"); + setCanDisableEmailMFA( + userData?.Security["Can Disable EmailMFA"] === "Yes", + ); }, [userData]); const handleEditEmail = () => setChangeEmailOpen(true); @@ -91,7 +93,7 @@ const UserComponent: React.FC = ({ userData }) => { open={email2FAOpen} handleClose={() => setEmail2FAToggleOpen(false)} handleToggleEmailMFA={(status) => setEmail2FAToggleOpen(status)} - /> + /> setUpdateSubscriptionOpen(false)} @@ -209,46 +211,46 @@ const DataTable: React.FC = ({ {Object.entries(data) .filter(([label]) => label !== "Can Disable EmailMFA") .map(([label, value], index) => ( - - - {label} - - - {/* eslint-disable-next-line @typescript-eslint/no-unsafe-assignment */} - {renderTableCellContent( - label, - value, - onEditEmail, - onDisablePasskeys, - canDisableEmailMFA, - twoFactorEnabled, - setTwoFactorEnabled, - setDisable2FAOpen, - email2FAEnabled, - setEmail2FAToggleOpen, - )} - - - ))} + + + {label} + + + {/* eslint-disable-next-line @typescript-eslint/no-unsafe-assignment */} + {renderTableCellContent( + label, + value, + onEditEmail, + onDisablePasskeys, + canDisableEmailMFA, + twoFactorEnabled, + setTwoFactorEnabled, + setDisable2FAOpen, + email2FAEnabled, + setEmail2FAToggleOpen, + )} + + + ))} @@ -335,41 +337,63 @@ const renderTableCellContent = ( )} ); - case "Email MFA": - return ( - - {value} - {canToggleEmailMFA && ( - { - setEmail2FAToggleOpen(true); - }} - sx={{ - "& .MuiSwitch-switchBase.Mui-checked": { - color: "#00B33C", - "&:hover": { - backgroundColor: - "rgba(0, 179, 60, 0.08)", - }, + // If Expirty time (in format 30/1/2026, 11:12:53 am) is greatheer than current date, show it in bold green + case "Expiry time": { + const expiryTime = new Date( + Date.parse( + value.replace( + /(\d+)\/(\d+)\/(\d+), (\d+:\d+:\d+ \w+)/, + "$2/$1/$3 $4", + ), + ), + ); + const currentTime = new Date(); + return ( + currentTime ? "#00B33C" : "red", + }} + > + {value} + + ); + } + case "Email MFA": + return ( + + {value} + {canToggleEmailMFA && ( + { + setEmail2FAToggleOpen(true); + }} + sx={{ + "& .MuiSwitch-switchBase.Mui-checked": { + color: "#00B33C", + "&:hover": { + backgroundColor: + "rgba(0, 179, 60, 0.08)", }, - "& .MuiSwitch-switchBase.Mui-checked + .MuiSwitch-track": - { - backgroundColor: "#00B33C", - }, - }} - /> - )} - - ); + }, + "& .MuiSwitch-switchBase.Mui-checked + .MuiSwitch-track": + { + backgroundColor: "#00B33C", + }, + }} + /> + )} + + ); default: return {value}; }