π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Clean up staff source code
Manav Rathi110db7832dbe
diff --git a/infra/staff/src/App.tsx b/infra/staff/src/App.tsxindex d042f45c96..0ade251e29 100644--- a/infra/staff/src/App.tsx+++ b/infra/staff/src/App.tsx@@ -199,57 +199,49 @@ export const App: React.FC = () => {const handleTabChange = (_event: React.SyntheticEvent,-newValue: number,) => {setTabValue(newValue);};+return (<div className="container">- <div>- <form className="input-form" onKeyDown={handleKeyDown}>- <div className="horizontal-group">- <a- href="https://staff.ente.sh"- target="_blank"- rel="noopener"- className="link-text"+ <form className="input-form" onKeyDown={handleKeyDown}>+ <div className="horizontal-group">+ <a+ href="https://staff.ente.sh"+ target="_blank"+ rel="noopener"+ className="link-text"+ >+ staff.ente.io+ </a>+ <div className="text-fields">+ <TextField+ label="Email"+ value={localEmail}+ onChange={(e) => {+ setLocalEmail(e.target.value);+ setEmail(e.target.value);+ }}+ size="medium"+ />+ </div>+ <div className="fetch-button-container">+ <Button+ variant="contained"+ onClick={() => {+ fetchData().catch((error: unknown) =>+ console.error("Fetch data error:", error),+ );+ }}+ style={{ padding: "0 16px" }}>- staff.ente.io- </a>- <div className="text-fields">- <TextField- label="Email"- value={localEmail}- onChange={(e) => {- setLocalEmail(e.target.value);- setEmail(e.target.value);- }}- size="medium"- className="text-field-email"- style={{ width: "parent" }}- />- </div>- <div className="fetch-button-container">- <Button- variant="contained"- onClick={() => {- fetchData().catch((error: unknown) =>- console.error(- "Fetch data error:",- error,- ),- );- }}- className="fetch-button"- style={{ padding: "0 16px" }}- >- FETCH- </Button>- </div>+ FETCH+ </Button></div>- </form>- </div>+ </div>+ </form><div className="content-container">{loading ? (<CircularProgress@@ -304,19 +296,13 @@ export const App: React.FC = () => {<UserComponent userData={userData} />)}{tabValue === 1 && userData && (- <div>- <FamilyTableComponent />- </div>+ <FamilyTableComponent />)}{tabValue === 2 && userData && (- <div>- <StorageBonusTableComponent />- </div>+ <StorageBonusTableComponent />)}{tabValue === 3 && userData && (- <div>- <TokensTableComponent />- </div>+ <TokensTableComponent />)}</Box></>diff --git a/infra/staff/src/components/AddOtt.tsx b/infra/staff/src/components/AddOTT.tsxsimilarity index 98%rename from infra/staff/src/components/AddOtt.tsxrename to infra/staff/src/components/AddOTT.tsxindex 32f9389622..f2f1bf39fb 100644--- a/infra/staff/src/components/AddOtt.tsx+++ b/infra/staff/src/components/AddOTT.tsx@@ -25,13 +25,13 @@ const APP_OPTIONS = [type AppOption = (typeof APP_OPTIONS)[number]["value"];-interface AddOttProps {+interface AddOTTProps {open: boolean;onClose: () => void;userEmail: string;}-export const AddOtt: React.FC<AddOttProps> = ({ open, onClose, userEmail }) => {+export const AddOTT: React.FC<AddOTTProps> = ({ open, onClose, userEmail }) => {const [selectedApp, setSelectedApp] = useState<AppOption>("photos");const [submitting, setSubmitting] = useState(false);const [error, setError] = useState<string | null>(null);diff --git a/infra/staff/src/components/ChangeEmail.tsx b/infra/staff/src/components/ChangeEmail.tsxindex b39c4cc1ba..65529688f9 100644--- a/infra/staff/src/components/ChangeEmail.tsx+++ b/infra/staff/src/components/ChangeEmail.tsx@@ -56,12 +56,10 @@ export const ChangeEmail: React.FC<ChangeEmailProps> = ({ open, onClose }) => {) => {event.preventDefault();- const token = requireToken();- const url = `${apiOrigin}/admin/user/change-email`;-- const body = { userID, email: newEmail };-try {+ const token = requireToken();+ const url = `${apiOrigin}/admin/user/change-email`;+ const body = { userID, email: newEmail };const response = await fetch(url, {method: "PUT",headers: {@@ -72,15 +70,14 @@ export const ChangeEmail: React.FC<ChangeEmailProps> = ({ open, onClose }) => {});if (!response.ok) {- let errorData;+ let errorMessage = "Network response was not ok";try {- errorData = (await response.json()) as ErrorResponse;+ const errorData = (await response.json()) as ErrorResponse;+ errorMessage = errorData.message;} catch (error) {console.error("Error parsing error response:", error);}- throw new Error(- errorData?.message ?? "Network response was not ok",- );+ throw new Error(errorMessage);}onClose();@@ -88,11 +85,6 @@ export const ChangeEmail: React.FC<ChangeEmailProps> = ({ open, onClose }) => {console.error("Error updating email:", error);}};- const handleSubmitSync = (event: React.SyntheticEvent<HTMLFormElement>) => {- handleSubmit(event).catch((error: unknown) => {- console.error("Error in handleSubmit:", error);- });- };return (<Dialog@@ -118,7 +110,7 @@ export const ChangeEmail: React.FC<ChangeEmailProps> = ({ open, onClose }) => {</Button></DialogTitle><DialogContent>- <form onSubmit={handleSubmitSync}>+ <form onSubmit={handleSubmit}><div style={{ marginBottom: "16px" }}><labelhtmlFor="newEmail"diff --git a/infra/staff/src/components/CloseFamily.tsx b/infra/staff/src/components/CloseFamily.tsxindex 0f4db70cfb..fde2c97f28 100644--- a/infra/staff/src/components/CloseFamily.tsx+++ b/infra/staff/src/components/CloseFamily.tsx@@ -62,67 +62,61 @@ export const CloseFamily: React.FC<CloseFamilyProps> = ({};return (- <div>- <Dialog- open={open}- onClose={handleClose}- aria-labelledby="alert-dialog-title"- aria-describedby="alert-dialog-description"- PaperComponent={Paper}- sx={{- width: "499px",- height: "286px",- margin: "auto",- display: "flex",- flexDirection: "column",- alignItems: "center",- justifyContent: "center",- }}- slotProps={{- backdrop: {- style: {- backgroundColor: "rgba(255, 255, 255, 0.9)", // Semi-transparent backdrop- },- },- }}- >- <DialogTitle id="alert-dialog-title">- {"Close Family?"}- </DialogTitle>- <DialogContent>- <DialogContentText id="alert-dialog-description">- Are you sure you want to close family relations for this- account?- </DialogContentText>- </DialogContent>- <DialogActions sx={{ justifyContent: "center" }}>- <Button- onClick={handleClose}- sx={{- bgcolor: "white",- color: "black",- "&:hover": { bgcolor: "#FAFAFA" },- }}- >- Cancel- </Button>- <Button- onClick={() => {- handleClosure().catch((error: unknown) =>- console.error(error),- );- }}- sx={{- bgcolor: "#F4473D",- color: "white",- "&:hover": { bgcolor: "#E53935" },- }}- disabled={loading}- >- {loading ? "Closing..." : "Close"}- </Button>- </DialogActions>- </Dialog>- </div>+ <Dialog+ open={open}+ onClose={handleClose}+ aria-labelledby="alert-dialog-title"+ aria-describedby="alert-dialog-description"+ PaperComponent={Paper}+ sx={{+ width: "499px",+ height: "286px",+ margin: "auto",+ display: "flex",+ flexDirection: "column",+ alignItems: "center",+ justifyContent: "center",+ }}+ slotProps={{+ backdrop: {+ style: { backgroundColor: "rgba(255, 255, 255, 0.9)" },+ },+ }}+ >+ <DialogTitle id="alert-dialog-title">Close Family?</DialogTitle>+ <DialogContent>+ <DialogContentText id="alert-dialog-description">+ Are you sure you want to close family relations for this+ account?+ </DialogContentText>+ </DialogContent>+ <DialogActions sx={{ justifyContent: "center" }}>+ <Button+ onClick={handleClose}+ sx={{+ bgcolor: "white",+ color: "black",+ "&:hover": { bgcolor: "#FAFAFA" },+ }}+ >+ Cancel+ </Button>+ <Button+ onClick={() => {+ handleClosure().catch((error: unknown) =>+ console.error(error),+ );+ }}+ sx={{+ bgcolor: "#F4473D",+ color: "white",+ "&:hover": { bgcolor: "#E53935" },+ }}+ disabled={loading}+ >+ {loading ? "Closing..." : "Close"}+ </Button>+ </DialogActions>+ </Dialog>);};diff --git a/infra/staff/src/components/DeleteAccount.tsx b/infra/staff/src/components/DeleteAccount.tsxindex 210029c50e..d439302d5f 100644--- a/infra/staff/src/components/DeleteAccount.tsx+++ b/infra/staff/src/components/DeleteAccount.tsx@@ -45,65 +45,59 @@ export const DeleteAccount: React.FC<DeleteAccountProps> = ({};return (- <div>- <Dialog- open={open}- onClose={handleClose}- aria-labelledby="alert-dialog-title"- aria-describedby="alert-dialog-description"- PaperComponent={Paper}- sx={{- width: "499px",- height: "286px",- margin: "auto",- display: "flex",- flexDirection: "column",- alignItems: "center",- justifyContent: "center",- }}- slotProps={{- backdrop: {- style: {- backgroundColor: "rgba(255, 255, 255, 0.9)", // Semi-transparent backdrop- },- },- }}- >- <DialogTitle id="alert-dialog-title">- {"Delete Account?"}- </DialogTitle>- <DialogContent>- <DialogContentText id="alert-dialog-description">- Are you sure you want to delete the account?- </DialogContentText>- </DialogContent>- <DialogActions sx={{ justifyContent: "center" }}>- <Button- onClick={handleClose}- sx={{- bgcolor: "white",- color: "black",- "&:hover": { bgcolor: "#FAFAFA" },- }}- >- Cancel- </Button>- <Button- onClick={() => {- handleDelete().catch((error: unknown) =>- console.error("Fetch data error:", error),- );- }}- sx={{- bgcolor: "#F4473D",- color: "white",- "&:hover": { bgcolor: "#E53935" },- }}- >- Delete- </Button>- </DialogActions>- </Dialog>- </div>+ <Dialog+ open={open}+ onClose={handleClose}+ aria-labelledby="alert-dialog-title"+ aria-describedby="alert-dialog-description"+ PaperComponent={Paper}+ sx={{+ width: "499px",+ height: "286px",+ margin: "auto",+ display: "flex",+ flexDirection: "column",+ alignItems: "center",+ justifyContent: "center",+ }}+ slotProps={{+ backdrop: {+ style: { backgroundColor: "rgba(255, 255, 255, 0.9)" },+ },+ }}+ >+ <DialogTitle id="alert-dialog-title">Delete Account?</DialogTitle>+ <DialogContent>+ <DialogContentText id="alert-dialog-description">+ Are you sure you want to delete the account?+ </DialogContentText>+ </DialogContent>+ <DialogActions sx={{ justifyContent: "center" }}>+ <Button+ onClick={handleClose}+ sx={{+ bgcolor: "white",+ color: "black",+ "&:hover": { bgcolor: "#FAFAFA" },+ }}+ >+ Cancel+ </Button>+ <Button+ onClick={() => {+ handleDelete().catch((error: unknown) =>+ console.error("Fetch data error:", error),+ );+ }}+ sx={{+ bgcolor: "#F4473D",+ color: "white",+ "&:hover": { bgcolor: "#E53935" },+ }}+ >+ Delete+ </Button>+ </DialogActions>+ </Dialog>);};diff --git a/infra/staff/src/components/Disable2FA.tsx b/infra/staff/src/components/Disable2FA.tsxindex bbe9b9b1e1..bc6c168af5 100644--- a/infra/staff/src/components/Disable2FA.tsx+++ b/infra/staff/src/components/Disable2FA.tsx@@ -61,66 +61,60 @@ export const Disable2FA: React.FC<Disable2FAProps> = ({};return (- <div>- <Dialog- open={open}- onClose={handleClose}- aria-labelledby="alert-dialog-title"- aria-describedby="alert-dialog-description"- PaperComponent={Paper}- sx={{- width: "499px",- height: "286px",- margin: "auto",- display: "flex",- flexDirection: "column",- alignItems: "center",- justifyContent: "center",- }}- slotProps={{- backdrop: {- style: {- backgroundColor: "rgba(255, 255, 255, 0.9)", // Semi-transparent backdrop- },- },- }}- >- <DialogTitle id="alert-dialog-title">- {"Disable 2FA?"}- </DialogTitle>- <DialogContent>- <DialogContentText id="alert-dialog-description">- Are you sure you want to disable 2FA for this account?- </DialogContentText>- </DialogContent>- <DialogActions sx={{ justifyContent: "center" }}>- <Button- onClick={handleClose}- sx={{- bgcolor: "white",- color: "black",- "&:hover": { bgcolor: "#FAFAFA" },- }}- >- Cancel- </Button>- <Button- onClick={() => {- handleDisable().catch((error: unknown) =>- console.error(error),- );- }}- sx={{- bgcolor: "#F4473D",- color: "white",- "&:hover": { bgcolor: "#E53935" },- }}- disabled={loading}- >- {loading ? "Disabling..." : "Disable"}- </Button>- </DialogActions>- </Dialog>- </div>+ <Dialog+ open={open}+ onClose={handleClose}+ aria-labelledby="alert-dialog-title"+ aria-describedby="alert-dialog-description"+ PaperComponent={Paper}+ sx={{+ width: "499px",+ height: "286px",+ margin: "auto",+ display: "flex",+ flexDirection: "column",+ alignItems: "center",+ justifyContent: "center",+ }}+ slotProps={{+ backdrop: {+ style: { backgroundColor: "rgba(255, 255, 255, 0.9)" },+ },+ }}+ >+ <DialogTitle id="alert-dialog-title">Disable 2FA?</DialogTitle>+ <DialogContent>+ <DialogContentText id="alert-dialog-description">+ Are you sure you want to disable 2FA for this account?+ </DialogContentText>+ </DialogContent>+ <DialogActions sx={{ justifyContent: "center" }}>+ <Button+ onClick={handleClose}+ sx={{+ bgcolor: "white",+ color: "black",+ "&:hover": { bgcolor: "#FAFAFA" },+ }}+ >+ Cancel+ </Button>+ <Button+ onClick={() => {+ handleDisable().catch((error: unknown) =>+ console.error(error),+ );+ }}+ sx={{+ bgcolor: "#F4473D",+ color: "white",+ "&:hover": { bgcolor: "#E53935" },+ }}+ disabled={loading}+ >+ {loading ? "Disabling..." : "Disable"}+ </Button>+ </DialogActions>+ </Dialog>);};diff --git a/infra/staff/src/components/DisablePasskeys.tsx b/infra/staff/src/components/DisablePasskeys.tsxindex 65f5be3261..027a98f2f7 100644--- a/infra/staff/src/components/DisablePasskeys.tsx+++ b/infra/staff/src/components/DisablePasskeys.tsx@@ -62,67 +62,60 @@ export const DisablePasskeys: React.FC<DisablePasskeysProps> = ({};return (- <div>- <Dialog- open={open}- onClose={handleClose}- aria-labelledby="alert-dialog-title"- aria-describedby="alert-dialog-description"- PaperComponent={Paper}- sx={{- width: "499px",- height: "286px",- margin: "auto",- display: "flex",- flexDirection: "column",- alignItems: "center",- justifyContent: "center",- }}- slotProps={{- backdrop: {- style: {- backgroundColor: "rgba(255, 255, 255, 0.9)", // Semi-transparent backdrop- },- },- }}- >- <DialogTitle id="alert-dialog-title">- {"Disable Passkeys?"}- </DialogTitle>- <DialogContent>- <DialogContentText id="alert-dialog-description">- Are you sure you want to disable passkeys for this- account?- </DialogContentText>- </DialogContent>- <DialogActions sx={{ justifyContent: "center" }}>- <Button- onClick={handleClose}- sx={{- bgcolor: "white",- color: "black",- "&:hover": { bgcolor: "#FAFAFA" },- }}- >- Cancel- </Button>- <Button- onClick={() => {- handleDisabling().catch((error: unknown) =>- console.error(error),- );- }}- sx={{- bgcolor: "#F4473D",- color: "white",- "&:hover": { bgcolor: "#E53935" },- }}- disabled={loading}- >- {loading ? "Disabling..." : "Disable"}- </Button>- </DialogActions>- </Dialog>- </div>+ <Dialog+ open={open}+ onClose={handleClose}+ aria-labelledby="alert-dialog-title"+ aria-describedby="alert-dialog-description"+ PaperComponent={Paper}+ sx={{+ width: "499px",+ height: "286px",+ margin: "auto",+ display: "flex",+ flexDirection: "column",+ alignItems: "center",+ justifyContent: "center",+ }}+ slotProps={{+ backdrop: {+ style: { backgroundColor: "rgba(255, 255, 255, 0.9)" },+ },+ }}+ >+ <DialogTitle id="alert-dialog-title">Disable Passkeys?</DialogTitle>+ <DialogContent>+ <DialogContentText id="alert-dialog-description">+ Are you sure you want to disable passkeys for this account?+ </DialogContentText>+ </DialogContent>+ <DialogActions sx={{ justifyContent: "center" }}>+ <Button+ onClick={handleClose}+ sx={{+ bgcolor: "white",+ color: "black",+ "&:hover": { bgcolor: "#FAFAFA" },+ }}+ >+ Cancel+ </Button>+ <Button+ onClick={() => {+ handleDisabling().catch((error: unknown) =>+ console.error(error),+ );+ }}+ sx={{+ bgcolor: "#F4473D",+ color: "white",+ "&:hover": { bgcolor: "#E53935" },+ }}+ disabled={loading}+ >+ {loading ? "Disabling..." : "Disable"}+ </Button>+ </DialogActions>+ </Dialog>);};diff --git a/infra/staff/src/components/StorageBonusTableComponent.tsx b/infra/staff/src/components/StorageBonusTableComponent.tsxindex 586767397b..8cd5b70d13 100644--- a/infra/staff/src/components/StorageBonusTableComponent.tsx+++ b/infra/staff/src/components/StorageBonusTableComponent.tsx@@ -45,21 +45,6 @@ export const StorageBonusTableComponent: React.FC = () => {);}, []);- const formatCreatedAt = (createdAt: number): string =>- new Date(createdAt / 1000).toLocaleDateString();-- const formatValidTill = (validTill: number): string => {- if (validTill === 0) {- return "Forever";- }- return new Date(validTill / 1000).toLocaleDateString();- };-- const formatStorage = (storage: number): string => {- const inGB = storage / (1024 * 1024 * 1024);- return `${inGB.toFixed(2)} GB`;- };-if (loading) {return <p>Loading...</p>;}@@ -135,3 +120,16 @@ export const StorageBonusTableComponent: React.FC = () => {</div>);};++const formatCreatedAt = (createdAt: number): string =>+ new Date(createdAt / 1000).toLocaleDateString();++const formatValidTill = (validTill: number): string => {+ if (validTill === 0) {+ return "Forever";+ }+ return new Date(validTill / 1000).toLocaleDateString();+};++const formatStorage = (storage: number): string =>+ `${(storage / 1024 ** 3).toFixed(2)} GB`;diff --git a/infra/staff/src/components/ToggleEmailMFA.tsx b/infra/staff/src/components/ToggleEmailMFA.tsxindex 429e8ea22a..19536a8560 100644--- a/infra/staff/src/components/ToggleEmailMFA.tsx+++ b/infra/staff/src/components/ToggleEmailMFA.tsx@@ -62,82 +62,75 @@ export const ToggleEmailMFA: React.FC<ToggleEmailMFAProps> = ({};return (- <div>- <Dialog- open={open}- onClose={handleClose}- aria-labelledby="alert-dialog-title"- aria-describedby="alert-dialog-description"- PaperComponent={Paper}- sx={{- width: "499px",- height: "286px",- margin: "auto",- display: "flex",- flexDirection: "column",- alignItems: "center",- justifyContent: "center",- }}- slotProps={{- backdrop: {- style: {- backgroundColor: "rgba(255, 255, 255, 0.9)", // Semi-transparent backdrop- },- },- }}- >- <DialogTitle id="alert-dialog-title">- {"Toggle Email MFA"}- </DialogTitle>- <DialogContent>- <DialogContentText id="alert-dialog-description">- Do you want to enable or disable Email MFA for this- account?- </DialogContentText>- </DialogContent>- <DialogActions sx={{ justifyContent: "center" }}>- <Button- onClick={handleClose}- sx={{- bgcolor: "white",- color: "black",- "&:hover": { bgcolor: "#FAFAFA" },- }}- >- Cancel- </Button>- <Button- onClick={() => {- handleToggle(true).catch((error: unknown) =>- console.error(error),- );- }}- sx={{- bgcolor: "#4CAF50",- color: "white",- "&:hover": { bgcolor: "#45A049" },- }}- disabled={loading}- >- {loading ? "Processing..." : "Enable Email MFA"}- </Button>- <Button- onClick={() => {- handleToggle(false).catch((error: unknown) =>- console.error(error),- );- }}- sx={{- bgcolor: "#F4473D",- color: "white",- "&:hover": { bgcolor: "#E53935" },- }}- disabled={loading}- >- {loading ? "Processing..." : "Disable Email MFA"}- </Button>- </DialogActions>- </Dialog>- </div>+ <Dialog+ open={open}+ onClose={handleClose}+ aria-labelledby="alert-dialog-title"+ aria-describedby="alert-dialog-description"+ PaperComponent={Paper}+ sx={{+ width: "499px",+ height: "286px",+ margin: "auto",+ display: "flex",+ flexDirection: "column",+ alignItems: "center",+ justifyContent: "center",+ }}+ slotProps={{+ backdrop: {+ style: { backgroundColor: "rgba(255, 255, 255, 0.9)" },+ },+ }}+ >+ <DialogTitle id="alert-dialog-title">Toggle Email MFA</DialogTitle>+ <DialogContent>+ <DialogContentText id="alert-dialog-description">+ Do you want to enable or disable Email MFA for this account?+ </DialogContentText>+ </DialogContent>+ <DialogActions sx={{ justifyContent: "center" }}>+ <Button+ onClick={handleClose}+ sx={{+ bgcolor: "white",+ color: "black",+ "&:hover": { bgcolor: "#FAFAFA" },+ }}+ >+ Cancel+ </Button>+ <Button+ onClick={() => {+ handleToggle(true).catch((error: unknown) =>+ console.error(error),+ );+ }}+ sx={{+ bgcolor: "#4CAF50",+ color: "white",+ "&:hover": { bgcolor: "#45A049" },+ }}+ disabled={loading}+ >+ {loading ? "Processing..." : "Enable Email MFA"}+ </Button>+ <Button+ onClick={() => {+ handleToggle(false).catch((error: unknown) =>+ console.error(error),+ );+ }}+ sx={{+ bgcolor: "#F4473D",+ color: "white",+ "&:hover": { bgcolor: "#E53935" },+ }}+ disabled={loading}+ >+ {loading ? "Processing..." : "Disable Email MFA"}+ </Button>+ </DialogActions>+ </Dialog>);};diff --git a/infra/staff/src/components/TokenTableComponent.tsx b/infra/staff/src/components/TokenTableComponent.tsxindex eac273abed..28b1b00d87 100644--- a/infra/staff/src/components/TokenTableComponent.tsx+++ b/infra/staff/src/components/TokenTableComponent.tsx@@ -65,9 +65,6 @@ export const TokensTableComponent: React.FC = () => {return sortableTokens;}, [order, orderBy, tokens]);- const formatDate = (timestamp: number): string =>- new Date(timestamp / 1000).toLocaleDateString();-if (loading) {return <p>Loading...</p>;}@@ -173,3 +170,6 @@ export const TokensTableComponent: React.FC = () => {</div>);};++const formatDate = (timestamp: number): string =>+ new Date(timestamp / 1000).toLocaleDateString();diff --git a/infra/staff/src/components/UpdateSubscription.tsx b/infra/staff/src/components/UpdateSubscription.tsxindex 7fdad08c37..1311816469 100644--- a/infra/staff/src/components/UpdateSubscription.tsx+++ b/infra/staff/src/components/UpdateSubscription.tsx@@ -46,7 +46,7 @@ interface FormValues {provider: string;storage: number;transactionId: string;- expiryTime: string | Date | null;+ expiryTime: Date | null;userId: string;attributes: { customerID: string; stripeAccountCountry: string };}@@ -60,7 +60,7 @@ export const UpdateSubscription: React.FC<UpdateSubscriptionProps> = ({provider: "",storage: 0,transactionId: "",- expiryTime: "",+ expiryTime: null,userId: "",attributes: { customerID: "", stripeAccountCountry: "" },});@@ -118,41 +118,39 @@ export const UpdateSubscription: React.FC<UpdateSubscriptionProps> = ({const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {const { name, value } = event.target;- setValues({+ setValues((values) => ({...values,[name]: name === "storage" ? parseInt(value, 10) : value,- });+ }));};const handleChangeProvider = (event: SelectChangeEvent) => {- const { name, value } = event.target;-- if (name) {- setValues({ ...values, [name]: value });- }+ setValues((values) => ({ ...values, provider: event.target.value }));};const handleDatePickerChange = (date: Date | null) => {- setValues({ ...values, expiryTime: date });+ setValues((values) => ({ ...values, expiryTime: date }));setIsDatePickerOpen(false);};- const handleSubmit = (event: React.SyntheticEvent<HTMLFormElement>) => {+ const handleSubmit = async (+ event: React.SyntheticEvent<HTMLFormElement>,+ ) => {event.preventDefault();- (async () => {++ try {const token = requireToken();const url = `${apiOrigin}/admin/user/subscription`;let expiryTime = null;- if (values.expiryTime instanceof Date) {- const utcExpiryTime = new Date(values.expiryTime);- expiryTime = utcExpiryTime.getTime() * 1000;+ if (values.expiryTime) {+ expiryTime = values.expiryTime.getTime() * 1000;}const body = {userId: values.userId,- storage: values.storage * (1024 * 1024 * 1024),- expiryTime: expiryTime,+ storage: values.storage * 1024 ** 3,+ expiryTime,productId: values.productId,paymentProvider: values.provider,transactionId: values.transactionId,@@ -163,30 +161,26 @@ export const UpdateSubscription: React.FC<UpdateSubscriptionProps> = ({},};- try {- const response = await fetch(url, {- method: "PUT",- headers: {- "Content-Type": "application/json",- "X-AUTH-TOKEN": token,- },- body: JSON.stringify(body),- });+ const response = await fetch(url, {+ method: "PUT",+ headers: {+ "Content-Type": "application/json",+ "X-AUTH-TOKEN": token,+ },+ body: JSON.stringify(body),+ });- if (!response.ok) {- throw new Error("Network response was not ok");- }- onClose();- } catch (error) {- if (error instanceof Error) {- alert(`Failed to update subscription: ${error.message}`);- } else {- alert("Failed to update subscription");- }+ if (!response.ok) {+ throw new Error("Network response was not ok");}- })().catch((error: unknown) => {- console.error("Unhandled promise rejection:", error);- });+ onClose();+ } catch (error) {+ if (error instanceof Error) {+ alert(`Failed to update subscription: ${error.message}`);+ } else {+ alert("Failed to update subscription");+ }+ }};return (diff --git a/infra/staff/src/components/UserComponent.tsx b/infra/staff/src/components/UserComponent.tsxindex bddd358603..93bd0dbffc 100644--- a/infra/staff/src/components/UserComponent.tsx+++ b/infra/staff/src/components/UserComponent.tsx@@ -15,7 +15,7 @@ import {Typography,} from "@mui/material";import React, { useEffect, useState } from "react";-import { AddOtt } from "./AddOtt";+import { AddOTT } from "./AddOTT";import { ChangeEmail } from "./ChangeEmail";import { DeleteAccount } from "./DeleteAccount";import { Disable2FA } from "./Disable2FA";@@ -44,7 +44,7 @@ export const UserComponent: React.FC<UserComponentProps> = ({ userData }) => {const [updateSubscriptionOpen, setUpdateSubscriptionOpen] = useState(false);const [changeEmailOpen, setChangeEmailOpen] = useState(false);const [disablePasskeysOpen, setDisablePasskeysOpen] = useState(false);- const [addOttOpen, setAddOttOpen] = useState(false);+ const [addOTTOpen, setAddOTTOpen] = useState(false);useEffect(() => {setTwoFactorEnabled(userData?.security["Two factor 2FA"] === "Enabled");@@ -59,7 +59,9 @@ export const UserComponent: React.FC<UserComponentProps> = ({ userData }) => {const handleEditSubscription = () => setUpdateSubscriptionOpen(true);const handleDisablePasskeys = () => setDisablePasskeysOpen(true);- if (!userData) return null;+ if (!userData) {+ return null;+ }const sections = [{ title: "user", data: userData.user },@@ -79,13 +81,13 @@ export const UserComponent: React.FC<UserComponentProps> = ({ userData }) => {onDeleteAccount={handleDeleteAccountClick}onEditSubscription={handleEditSubscription}onDisablePasskeys={handleDisablePasskeys}- onAddOtt={() => setAddOttOpen(true)}+ onAddOTT={() => setAddOTTOpen(true)}canDisableEmailMFA={canDisableEmailMFA}twoFactorEnabled={twoFactorEnabled}setTwoFactorEnabled={setTwoFactorEnabled}setDisable2FAOpen={setDisable2FAOpen}email2FAEnabled={email2FAEnabled}- setEmail2FAToggleOpen={setEmail2FAToggleOpen}+ onToggleEmailMFA={() => setEmail2FAToggleOpen(true)}/></Grid>))}@@ -102,7 +104,7 @@ export const UserComponent: React.FC<UserComponentProps> = ({ userData }) => {<ToggleEmailMFAopen={email2FAOpen}handleClose={() => setEmail2FAToggleOpen(false)}- handleToggleEmailMFA={(status) => setEmail2FAToggleOpen(status)}+ handleToggleEmailMFA={setEmail2FAEnabled}/><UpdateSubscriptionopen={updateSubscriptionOpen}@@ -117,9 +119,9 @@ export const UserComponent: React.FC<UserComponentProps> = ({ userData }) => {handleClose={() => setDisablePasskeysOpen(false)}handleDisablePasskeys={() => setDisablePasskeysOpen(false)}/>- <AddOtt- open={addOttOpen}- onClose={() => setAddOttOpen(false)}+ <AddOTT+ open={addOTTOpen}+ onClose={() => setAddOTTOpen(false)}userEmail={userData.user.Email ?? ""}/></Grid>@@ -133,13 +135,13 @@ interface DataTableProps {onDeleteAccount: () => void;onEditSubscription: () => void;onDisablePasskeys: () => void;- onAddOtt: () => void;+ onAddOTT: () => void;canDisableEmailMFA: boolean;twoFactorEnabled: boolean;setTwoFactorEnabled: (enabled: boolean) => void;setDisable2FAOpen: (open: boolean) => void;email2FAEnabled: boolean;- setEmail2FAToggleOpen: (open: boolean) => void;+ onToggleEmailMFA: () => void;}const DataTable: React.FC<DataTableProps> = ({@@ -149,13 +151,13 @@ const DataTable: React.FC<DataTableProps> = ({onDeleteAccount,onEditSubscription,onDisablePasskeys,- onAddOtt,+ onAddOTT,canDisableEmailMFA,twoFactorEnabled,setTwoFactorEnabled,setDisable2FAOpen,email2FAEnabled,- setEmail2FAToggleOpen,+ onToggleEmailMFA,}) => (<TableContainercomponent={Paper}@@ -193,7 +195,7 @@ const DataTable: React.FC<DataTableProps> = ({aria-label="delete"onClick={onDeleteAccount}>- <DeleteIcon style={{ color: "" }} />+ <DeleteIcon /></IconButton>)}{title === "subscription" && (@@ -244,7 +246,6 @@ const DataTable: React.FC<DataTableProps> = ({: "none",}}>- {}{renderTableCellContent(label,value,@@ -255,7 +256,7 @@ const DataTable: React.FC<DataTableProps> = ({setTwoFactorEnabled,setDisable2FAOpen,email2FAEnabled,- setEmail2FAToggleOpen,+ onToggleEmailMFA,)}</TableCell></TableRow>@@ -275,7 +276,7 @@ const DataTable: React.FC<DataTableProps> = ({><Buttonvariant="contained"- onClick={onAddOtt}+ onClick={onAddOTT}sx={{ textTransform: "none" }}>Add OTT@@ -298,7 +299,7 @@ const renderTableCellContent = (setTwoFactorEnabled: (enabled: boolean) => void,setDisable2FAOpen: (open: boolean) => void,email2FAEnabled: boolean,- setEmail2FAToggleOpen: (open: boolean) => void,+ onToggleEmailMFA: () => void,) => {switch (label) {case "Email":@@ -336,7 +337,7 @@ const renderTableCellContent = (sx={{display: "flex",alignItems: "center",- justifyContent: "right",+ justifyContent: "flex-end",width: "100%",paddingRight: "50px",}}@@ -390,7 +391,7 @@ const renderTableCellContent = (sx={{display: "flex",alignItems: "center",- justifyContent: "right",+ justifyContent: "flex-end",width: "100%",paddingRight: "50px",}}@@ -399,9 +400,7 @@ const renderTableCellContent = ({canToggleEmailMFA && (<Switchchecked={email2FAEnabled}- onChange={() => {- setEmail2FAToggleOpen(true);- }}+ onChange={onToggleEmailMFA}sx={{"& .MuiSwitch-switchBase.Mui-checked": {color: "#00B33C",diff --git a/infra/staff/src/main.tsx b/infra/staff/src/main.tsxindex 528729a238..4ed8c32054 100644--- a/infra/staff/src/main.tsx+++ b/infra/staff/src/main.tsx@@ -4,7 +4,7 @@ import { App } from "./App";import "./styles/globals.css";const root = document.getElementById("root");-if (!root) throw new Error("Could not load root element to qrender onto");+if (!root) throw new Error("Could not load root element to render onto");ReactDOM.createRoot(root).render(<React.StrictMode>diff --git a/infra/staff/src/services/support.ts b/infra/staff/src/services/support.tsindex d53b2b5519..e16dd9774a 100644--- a/infra/staff/src/services/support.ts+++ b/infra/staff/src/services/support.ts@@ -4,9 +4,9 @@ import { getEmail, getToken } from "./session";export const apiOrigin =import.meta.env.VITE_ENTE_API_ORIGIN ?? "https://api.ente.io";-const UserDetails = z.looseObject({});+const UserDetailsSchema = z.looseObject({});-export type UserDetails = z.infer<typeof UserDetails>;+export type UserDetails = z.infer<typeof UserDetailsSchema>;/** Fetch details of the user associated with the given {@link authToken}. */export const getUserDetails = async (@@ -15,7 +15,7 @@ export const getUserDetails = async (const url = `${apiOrigin}/users/details/v2`;const res = await fetch(url, { headers: { "X-Auth-Token": authToken } });if (!res.ok) throw new Error(`Failed to fetch ${url}: HTTP ${res.status}`);- return UserDetails.parse(await res.json());+ return UserDetailsSchema.parse(await res.json());};const requireEmail = () => {