format all files
This commit is contained in:
1 parent
bfa6197ee4
commit
1b81251c93
81 files changed
+2628
-2330
No files matched your search
@@ -94,7 +94,10 @@ const PasswordPanel = () => {
|
||||
const action = await dispatch(update({ localData }));
|
||||
if (action.payload.success) {
|
||||
createToast({
|
||||
body: t("passwordPanel.passwordChangedSuccess", "Your password was changed successfully."),
|
||||
body: t(
|
||||
"passwordPanel.passwordChangedSuccess",
|
||||
"Your password was changed successfully."
|
||||
),
|
||||
});
|
||||
setLocalData({
|
||||
password: "",
|
||||
@@ -104,7 +107,10 @@ const PasswordPanel = () => {
|
||||
} else {
|
||||
// TODO: Check for other errors?
|
||||
createToast({
|
||||
body: t("passwordPanel.passwordInputIncorrect", "Your password input was incorrect."),
|
||||
body: t(
|
||||
"passwordPanel.passwordInputIncorrect",
|
||||
"Your password input was incorrect."
|
||||
),
|
||||
});
|
||||
setErrors({ password: "*" + action.payload.msg + "." });
|
||||
}
|
||||
@@ -153,7 +159,10 @@ const PasswordPanel = () => {
|
||||
<TextInput
|
||||
type="password"
|
||||
id="edit-current-password"
|
||||
placeholder={t("passwordPanel.enterCurrentPassword", "Enter your current password")}
|
||||
placeholder={t(
|
||||
"passwordPanel.enterCurrentPassword",
|
||||
"Enter your current password"
|
||||
)}
|
||||
autoComplete="current-password"
|
||||
value={localData.password}
|
||||
onChange={handleChange}
|
||||
@@ -219,7 +228,10 @@ const PasswordPanel = () => {
|
||||
<Box sx={{ maxWidth: "70ch" }}>
|
||||
<Alert
|
||||
variant="warning"
|
||||
body={t("passwordPanel.passwordRequirements", "New password must contain at least 8 characters and must have at least one uppercase letter, one lowercase letter, one number and one special character.")}
|
||||
body={t(
|
||||
"passwordPanel.passwordRequirements",
|
||||
"New password must contain at least 8 characters and must have at least one uppercase letter, one lowercase letter, one number and one special character."
|
||||
)}
|
||||
/>
|
||||
</Box>
|
||||
)}
|
||||
|
||||
@@ -85,13 +85,13 @@ const ProfilePanel = () => {
|
||||
// Resets picture-related states and clears interval
|
||||
const removePicture = () => {
|
||||
errors["picture"] && clearError("picture");
|
||||
setFile(undefined);
|
||||
setFile(undefined);
|
||||
setLocalData((prev) => ({
|
||||
...prev,
|
||||
file: undefined,
|
||||
deleteProfileImage: true,
|
||||
deleteProfileImage: true,
|
||||
}));
|
||||
};
|
||||
};
|
||||
|
||||
// Opens the picture update modal
|
||||
const openPictureModal = () => {
|
||||
@@ -102,9 +102,9 @@ const ProfilePanel = () => {
|
||||
// Closes the picture update modal and resets related states
|
||||
const closePictureModal = () => {
|
||||
if (errors["picture"]) clearError("picture");
|
||||
setFile(undefined);
|
||||
setIsOpen("");
|
||||
};
|
||||
setFile(undefined);
|
||||
setIsOpen("");
|
||||
};
|
||||
|
||||
// Updates profile image displayed on UI
|
||||
const handleUpdatePicture = () => {
|
||||
@@ -116,24 +116,23 @@ const ProfilePanel = () => {
|
||||
setIsOpen("");
|
||||
if (errors["unchanged"]) clearError("unchanged");
|
||||
};
|
||||
|
||||
|
||||
// Handles form submission to update user profile
|
||||
const handleSaveProfile = async (event) => {
|
||||
event.preventDefault();
|
||||
const nameChanged =
|
||||
localData.firstName !== user.firstName ||
|
||||
localData.lastName !== user.lastName;
|
||||
localData.firstName !== user.firstName || localData.lastName !== user.lastName;
|
||||
|
||||
const avatarChanged =
|
||||
localData.deleteProfileImage === true ||
|
||||
(localData.file && localData.file !== `data:image/png;base64,${user.avatarImage}`);
|
||||
localData.deleteProfileImage === true ||
|
||||
(localData.file && localData.file !== `data:image/png;base64,${user.avatarImage}`);
|
||||
|
||||
if (!nameChanged && !avatarChanged) {
|
||||
createToast({
|
||||
body: "Unable to update profile — no changes detected.",
|
||||
});
|
||||
setErrors({ unchanged: "unable to update profile" });
|
||||
return;
|
||||
createToast({
|
||||
body: "Unable to update profile — no changes detected.",
|
||||
});
|
||||
setErrors({ unchanged: "unable to update profile" });
|
||||
return;
|
||||
}
|
||||
|
||||
const action = await dispatch(update({ localData }));
|
||||
@@ -205,7 +204,7 @@ const ProfilePanel = () => {
|
||||
>
|
||||
{/* This 0.9 is a bit magic numbering, refactor */}
|
||||
<Box flex={0.9}>
|
||||
<Typography component="h1">{t('FirstName')}</Typography>
|
||||
<Typography component="h1">{t("FirstName")}</Typography>
|
||||
</Box>
|
||||
<TextInput
|
||||
id="edit-first-name"
|
||||
@@ -223,7 +222,7 @@ const ProfilePanel = () => {
|
||||
gap={SPACING_GAP}
|
||||
>
|
||||
<Box flex={0.9}>
|
||||
<Typography component="h1">{t('LastName')}</Typography>
|
||||
<Typography component="h1">{t("LastName")}</Typography>
|
||||
</Box>
|
||||
<TextInput
|
||||
id="edit-last-name"
|
||||
@@ -241,12 +240,12 @@ const ProfilePanel = () => {
|
||||
gap={SPACING_GAP}
|
||||
>
|
||||
<Stack flex={0.9}>
|
||||
<Typography component="h1">{t('email')}</Typography>
|
||||
<Typography component="h1">{t("email")}</Typography>
|
||||
<Typography
|
||||
component="p"
|
||||
sx={{ opacity: 0.6 }}
|
||||
>
|
||||
{t('EmailDescriptionText')}
|
||||
{t("EmailDescriptionText")}
|
||||
</Typography>
|
||||
</Stack>
|
||||
<TextInput
|
||||
@@ -264,12 +263,12 @@ const ProfilePanel = () => {
|
||||
gap={SPACING_GAP}
|
||||
>
|
||||
<Stack flex={0.9}>
|
||||
<Typography component="h1">{t('YourPhoto')}</Typography>
|
||||
<Typography component="h1">{t("YourPhoto")}</Typography>
|
||||
<Typography
|
||||
component="p"
|
||||
sx={{ opacity: 0.6 }}
|
||||
>
|
||||
{t('PhotoDescriptionText')}
|
||||
{t("PhotoDescriptionText")}
|
||||
</Typography>
|
||||
</Stack>
|
||||
<Stack
|
||||
@@ -293,14 +292,14 @@ const ProfilePanel = () => {
|
||||
color="error"
|
||||
onClick={handleDeletePicture}
|
||||
>
|
||||
{t('delete')}
|
||||
{t("delete")}
|
||||
</Button>
|
||||
<Button
|
||||
variant="contained" // CAIO_REVIEW
|
||||
color="accent"
|
||||
onClick={openPictureModal}
|
||||
>
|
||||
{t('update')}
|
||||
{t("update")}
|
||||
</Button>
|
||||
</Stack>
|
||||
</Stack>
|
||||
@@ -325,7 +324,7 @@ const ProfilePanel = () => {
|
||||
disabled={Object.keys(errors).length !== 0 && !errors?.picture && true}
|
||||
sx={{ px: theme.spacing(12) }}
|
||||
>
|
||||
{t('save')}
|
||||
{t("save")}
|
||||
</Button>
|
||||
</Box>
|
||||
</Stack>
|
||||
@@ -344,12 +343,12 @@ const ProfilePanel = () => {
|
||||
spellCheck="false"
|
||||
>
|
||||
<Box mb={theme.spacing(6)}>
|
||||
<Typography component="h1">{t('DeleteAccountTitle')}</Typography>
|
||||
<Typography component="h1">{t("DeleteAccountTitle")}</Typography>
|
||||
<Typography
|
||||
component="p"
|
||||
sx={{ opacity: 0.6 }}
|
||||
>
|
||||
{t('DeleteDescriptionText')}
|
||||
{t("DeleteDescriptionText")}
|
||||
</Typography>
|
||||
</Box>
|
||||
<Button
|
||||
@@ -357,17 +356,17 @@ const ProfilePanel = () => {
|
||||
color="error"
|
||||
onClick={() => setIsOpen("delete")}
|
||||
>
|
||||
{t('DeleteAccountButton')}
|
||||
{t("DeleteAccountButton")}
|
||||
</Button>
|
||||
</Box>
|
||||
)}
|
||||
<Dialog
|
||||
open={isModalOpen("delete")}
|
||||
theme={theme}
|
||||
title={t('DeleteWarningTitle')}
|
||||
description={t('DeleteAccountWarning')}
|
||||
title={t("DeleteWarningTitle")}
|
||||
description={t("DeleteAccountWarning")}
|
||||
onCancel={() => setIsOpen("")}
|
||||
confirmationButtonLabel={t('DeleteAccountButton')}
|
||||
confirmationButtonLabel={t("DeleteAccountButton")}
|
||||
onConfirm={handleDeleteAccount}
|
||||
isLoading={isLoading}
|
||||
/>
|
||||
@@ -389,13 +388,13 @@ const ProfilePanel = () => {
|
||||
: user?.avatarImage
|
||||
? `data:image/png;base64,${user.avatarImage}`
|
||||
: ""
|
||||
}
|
||||
}
|
||||
onChange={(newFile) => {
|
||||
if (newFile) {
|
||||
setFile(newFile);
|
||||
clearError("unchanged");
|
||||
}
|
||||
}}
|
||||
}}
|
||||
previewIsRound
|
||||
maxSize={3 * 1024 * 1024}
|
||||
/>
|
||||
@@ -410,7 +409,7 @@ const ProfilePanel = () => {
|
||||
color="info"
|
||||
onClick={removePicture}
|
||||
>
|
||||
{t('remove')}
|
||||
{t("remove")}
|
||||
</Button>
|
||||
<Button
|
||||
variant="contained"
|
||||
@@ -418,7 +417,7 @@ const ProfilePanel = () => {
|
||||
onClick={handleUpdatePicture}
|
||||
disabled={!!errors.picture || !file?.src}
|
||||
>
|
||||
{t('update')}
|
||||
{t("update")}
|
||||
</Button>
|
||||
</Stack>
|
||||
</GenericDialog>
|
||||
|
||||
@@ -48,7 +48,8 @@ const TeamPanel = () => {
|
||||
{row.firstName + " " + row.lastName}
|
||||
</Typography>
|
||||
<Typography>
|
||||
{t("teamPanel.table.created")} {new Date(row.createdAt).toLocaleDateString()}
|
||||
{t("teamPanel.table.created")}{" "}
|
||||
{new Date(row.createdAt).toLocaleDateString()}
|
||||
</Typography>
|
||||
</Stack>
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user