From 4259902da6e79bc97eb97843fea165b477db745f Mon Sep 17 00:00:00 2001 From: kim Date: Thu, 9 Nov 2023 14:16:51 +0100 Subject: [PATCH] feat: replace profile path, add translations --- .github/workflows/deploy-dev.yml | 5 +- .github/workflows/deploy-prod.yml | 5 +- .github/workflows/deploy-stage.yml | 5 +- package.json | 2 +- src/components/App.tsx | 10 - src/components/common/UserSwitchWrapper.tsx | 4 +- .../context/FlagItemModalContext.tsx | 16 +- src/components/member/AvatarSetting.tsx | 162 --------------- src/components/member/DeleteMemberDialog.tsx | 105 ---------- .../member/EmailPreferenceSwitch.tsx | 51 ----- src/components/member/LanguageSwitch.tsx | 43 ---- src/components/member/MemberProfileScreen.tsx | 192 ------------------ src/components/member/PasswordSetting.tsx | 170 ---------------- src/config/env.ts | 2 + src/config/i18n.ts | 1 - src/env.d.ts | 1 + src/langs/constants.ts | 4 + src/langs/en.json | 5 +- yarn.lock | 20 +- 19 files changed, 33 insertions(+), 770 deletions(-) delete mode 100644 src/components/member/AvatarSetting.tsx delete mode 100644 src/components/member/DeleteMemberDialog.tsx delete mode 100644 src/components/member/EmailPreferenceSwitch.tsx delete mode 100644 src/components/member/LanguageSwitch.tsx delete mode 100644 src/components/member/MemberProfileScreen.tsx delete mode 100644 src/components/member/PasswordSetting.tsx diff --git a/.github/workflows/deploy-dev.yml b/.github/workflows/deploy-dev.yml index b63e79a3f..8ad5e7c6f 100644 --- a/.github/workflows/deploy-dev.yml +++ b/.github/workflows/deploy-dev.yml @@ -28,10 +28,11 @@ jobs: VITE_VERSION: ${{ github.sha }} VITE_GRAASP_DOMAIN: ${{ vars.VITE_GRAASP_DOMAIN }} VITE_GRAASP_API_HOST: ${{ vars.VITE_GRAASP_API_HOST }} + VITE_GRAASP_ACCOUNT_HOST: ${{ vars.VITE_GRAASP_ACCOUNT_HOST }} + VITE_GRAASP_ANALYZER_HOST: ${{ vars.VITE_GRAASP_ANALYZER_HOST }} VITE_GRAASP_AUTH_HOST: ${{ vars.VITE_GRAASP_AUTH_HOST }} - VITE_GRAASP_PLAYER_HOST: ${{ vars.VITE_GRAASP_PLAYER_HOST }} VITE_GRAASP_LIBRARY_HOST: ${{ vars.VITE_GRAASP_LIBRARY_HOST }} - VITE_GRAASP_ANALYZER_HOST: ${{ vars.VITE_GRAASP_ANALYZER_HOST }} + VITE_GRAASP_PLAYER_HOST: ${{ vars.VITE_GRAASP_PLAYER_HOST }} VITE_H5P_INTEGRATION_URL: ${{ secrets.VITE_H5P_INTEGRATION_URL }} VITE_GRAASP_ASSETS_URL: ${{ secrets.VITE_GRAASP_ASSETS_URL }} VITE_SENTRY_ENV: ${{ vars.VITE_SENTRY_ENV }} diff --git a/.github/workflows/deploy-prod.yml b/.github/workflows/deploy-prod.yml index cdd580689..5cfc4bf6e 100644 --- a/.github/workflows/deploy-prod.yml +++ b/.github/workflows/deploy-prod.yml @@ -31,10 +31,11 @@ jobs: VITE_VERSION: ${{ github.event.client_payload.tag }} VITE_GRAASP_DOMAIN: ${{ vars.VITE_GRAASP_DOMAIN }} VITE_GRAASP_API_HOST: ${{ vars.VITE_GRAASP_API_HOST }} + VITE_GRAASP_ACCOUNT_HOST: ${{ vars.VITE_GRAASP_ACCOUNT_HOST }} + VITE_GRAASP_ANALYZER_HOST: ${{ vars.VITE_GRAASP_ANALYZER_HOST }} VITE_GRAASP_AUTH_HOST: ${{ vars.VITE_GRAASP_AUTH_HOST }} - VITE_GRAASP_PLAYER_HOST: ${{ vars.VITE_GRAASP_PLAYER_HOST }} VITE_GRAASP_LIBRARY_HOST: ${{ vars.VITE_GRAASP_LIBRARY_HOST }} - VITE_GRAASP_ANALYZER_HOST: ${{ vars.VITE_GRAASP_ANALYZER_HOST }} + VITE_GRAASP_PLAYER_HOST: ${{ vars.VITE_GRAASP_PLAYER_HOST }} VITE_H5P_INTEGRATION_URL: ${{ secrets.VITE_H5P_INTEGRATION_URL }} VITE_GRAASP_ASSETS_URL: ${{ secrets.VITE_GRAASP_ASSETS_URL }} VITE_SENTRY_ENV: ${{ vars.VITE_SENTRY_ENV }} diff --git a/.github/workflows/deploy-stage.yml b/.github/workflows/deploy-stage.yml index b7e53ed96..d760a38a5 100644 --- a/.github/workflows/deploy-stage.yml +++ b/.github/workflows/deploy-stage.yml @@ -31,10 +31,11 @@ jobs: VITE_VERSION: ${{ github.event.client_payload.tag }} VITE_GRAASP_DOMAIN: ${{ vars.VITE_GRAASP_DOMAIN }} VITE_GRAASP_API_HOST: ${{ vars.VITE_GRAASP_API_HOST }} + VITE_GRAASP_ACCOUNT_HOST: ${{ vars.VITE_GRAASP_ACCOUNT_HOST }} + VITE_GRAASP_ANALYZER_HOST: ${{ vars.VITE_GRAASP_ANALYZER_HOST }} VITE_GRAASP_AUTH_HOST: ${{ vars.VITE_GRAASP_AUTH_HOST }} - VITE_GRAASP_PLAYER_HOST: ${{ vars.VITE_GRAASP_PLAYER_HOST }} VITE_GRAASP_LIBRARY_HOST: ${{ vars.VITE_GRAASP_LIBRARY_HOST }} - VITE_GRAASP_ANALYZER_HOST: ${{ vars.VITE_GRAASP_ANALYZER_HOST }} + VITE_GRAASP_PLAYER_HOST: ${{ vars.VITE_GRAASP_PLAYER_HOST }} VITE_H5P_INTEGRATION_URL: ${{ secrets.VITE_H5P_INTEGRATION_URL }} VITE_GRAASP_ASSETS_URL: ${{ secrets.VITE_GRAASP_ASSETS_URL }} VITE_SENTRY_ENV: ${{ vars.VITE_SENTRY_ENV }} diff --git a/package.json b/package.json index aae5f92cd..9e319b1d8 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "@graasp/chatbox": "3.0.0", "@graasp/query-client": "2.0.0", "@graasp/sdk": "2.0.1", - "@graasp/translations": "1.19.2", + "@graasp/translations": "1.19.4", "@graasp/ui": "4.0.0", "@mui/icons-material": "5.14.16", "@mui/lab": "5.0.0-alpha.151", diff --git a/src/components/App.tsx b/src/components/App.tsx index 215de0b13..61d422788 100644 --- a/src/components/App.tsx +++ b/src/components/App.tsx @@ -13,7 +13,6 @@ import { FAVORITE_ITEMS_PATH, HOME_PATH, ITEMS_PATH, - MEMBER_PROFILE_PATH, PUBLISHED_ITEMS_PATH, RECYCLE_BIN_PATH, REDIRECT_PATH, @@ -30,7 +29,6 @@ import Home from './main/Home'; import ItemScreen from './main/ItemScreen'; import PublishedItems from './main/PublishedItems'; import Redirect from './main/Redirect'; -import MemberProfileScreen from './member/MemberProfileScreen'; const { useItemFeedbackUpdates } = hooks; @@ -62,10 +60,6 @@ const App = (): JSX.Element => { FavoriteItems, withAuthorizationProps, ); - const MemberWithAuthorization = withAuthorization( - MemberProfileScreen, - withAuthorizationProps, - ); const RecycleWithAuthorization = withAuthorization( RecycleBinScreen, withAuthorizationProps, @@ -89,10 +83,6 @@ const App = (): JSX.Element => { element={} /> } /> - } - /> } /> } /> } /> diff --git a/src/components/common/UserSwitchWrapper.tsx b/src/components/common/UserSwitchWrapper.tsx index d32c0a1f7..9edfb4865 100644 --- a/src/components/common/UserSwitchWrapper.tsx +++ b/src/components/common/UserSwitchWrapper.tsx @@ -1,9 +1,9 @@ import { CompleteMember } from '@graasp/sdk'; import { UserSwitchWrapper as GraaspUserSwitch } from '@graasp/ui'; +import { GRAASP_ACCOUNT_HOST } from '@/config/env'; import { SIGN_IN_PATH } from '@/config/externalPaths'; import { useBuilderTranslation } from '@/config/i18n'; -import { MEMBER_PROFILE_PATH } from '@/config/paths'; import { mutations } from '@/config/queryClient'; import { HEADER_MEMBER_MENU_BUTTON_ID, @@ -47,7 +47,7 @@ const UserSwitchWrapper = ({ ButtonContent }: Props): JSX.Element => { )} signOutText={translateBuilder(BUILDER.USER_SWITCH_SIGN_OUT_BUTTON)} // switchMemberText={translateBuilder(BUILDER.USER_SWITCH_SWITCH_USER_TEXT)} - profilePath={MEMBER_PROFILE_PATH} + profilePath={GRAASP_ACCOUNT_HOST} redirectPath={SIGN_IN_PATH} buttonId={HEADER_MEMBER_MENU_BUTTON_ID} signInMenuItemId={HEADER_MEMBER_MENU_SIGN_IN_BUTTON_ID} diff --git a/src/components/context/FlagItemModalContext.tsx b/src/components/context/FlagItemModalContext.tsx index 9de592849..5f34d760b 100644 --- a/src/components/context/FlagItemModalContext.tsx +++ b/src/components/context/FlagItemModalContext.tsx @@ -2,9 +2,12 @@ import { createContext, useMemo, useState } from 'react'; import { routines } from '@graasp/query-client'; import { FlagType } from '@graasp/sdk'; +import { COMMON } from '@graasp/translations'; import { ItemFlagDialog } from '@graasp/ui'; -import { useBuilderTranslation } from '../../config/i18n'; +import { BUILDER } from '@/langs/constants'; + +import { useBuilderTranslation, useCommonTranslation } from '../../config/i18n'; import notifier from '../../config/notifier'; import { mutations } from '../../config/queryClient'; @@ -20,6 +23,7 @@ const FlagItemModalProvider = ({ children: JSX.Element | JSX.Element[]; }): JSX.Element => { const { t: translateBuilder } = useBuilderTranslation(); + const { t: translateCommon } = useCommonTranslation(); const { mutate: postItemFlag } = mutations.usePostItemFlag(); const [open, setOpen] = useState(false); const [itemId, setItemId] = useState(null); @@ -58,12 +62,10 @@ const FlagItemModalProvider = ({ onFlag={onFlag} open={open} onClose={onClose} - descriptionText={translateBuilder( - 'Select reason for flagging this item', - )} - title={translateBuilder('Flag Item')} - cancelButtonText={translateBuilder('Cancel')} - confirmButtonText={translateBuilder('Flag')} + descriptionText={translateBuilder(BUILDER.FLAG_REASON_DESCRIPTION)} + title={translateBuilder(BUILDER.FLAG_MODAL_TITLE)} + cancelButtonText={translateCommon(COMMON.CANCEL_BUTTON)} + confirmButtonText={translateBuilder(BUILDER.FLAG_MODAL_CONFIRM)} /> {children} diff --git a/src/components/member/AvatarSetting.tsx b/src/components/member/AvatarSetting.tsx deleted file mode 100644 index 7ef3a2a23..000000000 --- a/src/components/member/AvatarSetting.tsx +++ /dev/null @@ -1,162 +0,0 @@ -import { FormEventHandler, useEffect, useRef, useState } from 'react'; - -import Grid from '@mui/material/Grid'; -import Typography from '@mui/material/Typography'; - -import { Member } from '@graasp/sdk'; -import { ACCOUNT } from '@graasp/translations'; - -import Uppy from '@uppy/core'; - -import { - THUMBNAIL_SETTING_MAX_HEIGHT, - THUMBNAIL_SETTING_MAX_WIDTH, -} from '../../config/constants'; -import { useAccountTranslation } from '../../config/i18n'; -import { mutations } from '../../config/queryClient'; -import { MEMBER_PROFILE_AVATAR_UPLOAD_BUTTON_CLASSNAME } from '../../config/selectors'; -import { configureAvatarUppy } from '../../utils/uppy'; -import CropModal, { CropProps } from '../common/CropModal'; -import MemberAvatar from '../common/MemberAvatar'; -import StatusBar from '../file/StatusBar'; - -type Props = { - user: Member; -}; - -const AvatarSetting = ({ user }: Props): JSX.Element | null => { - const inputRef = useRef(null); - const [uppy, setUppy] = useState(); - const [showCropModal, setShowCropModal] = useState(false); - const [fileSource, setFileSource] = useState(); - const [openStatusBar, setOpenStatusBar] = useState(false); - const { t } = useAccountTranslation(); - const { mutate: onUploadAvatar } = mutations.useUploadAvatar(); - - const userId = user?.id; - - useEffect(() => { - setUppy( - configureAvatarUppy({ - itemId: userId, - onUpload: () => { - setOpenStatusBar(true); - }, - onError: (error: Error) => { - onUploadAvatar({ id: userId, error }); - }, - onComplete: (result: { - successful: { response: { body: unknown } }[]; - }) => { - // update app on complete - // todo: improve with websockets or by receiving corresponding items - if (result?.successful?.length) { - const data = result.successful[0].response.body; - onUploadAvatar({ id: userId, data }); - } - - return false; - }, - }), - ); - // eslint-disable-next-line react-hooks/exhaustive-deps - }, [userId]); - - if (!uppy) { - return null; - } - - const handleClose = () => { - setOpenStatusBar(false); - }; - - const onSelectFile: FormEventHandler = (e) => { - const target = e.target as HTMLInputElement; - if (target.files && target.files.length > 0) { - const reader = new FileReader(); - reader.addEventListener('load', () => - setFileSource(reader.result as string), - ); - reader.readAsDataURL(target.files[0]); - setShowCropModal(true); - } - }; - - const onClose = () => { - setShowCropModal(false); - if (inputRef.current) { - inputRef.current.value = ''; - } - }; - - const onConfirmCrop: CropProps['onConfirm'] = (croppedImage) => { - onClose(); - - // submit cropped image - try { - if (!croppedImage) { - throw new Error('cropped image is not defined'); - } - // remove waiting files - uppy.cancelAll(); - - uppy.addFile({ - type: croppedImage.type, - data: croppedImage, - }); - } catch (error) { - console.error(error); - } - }; - - return ( - <> - {uppy && ( - - )} - - - - {t(ACCOUNT.PROFILE_AVATAR_TITLE)} - - - {t(ACCOUNT.PROFILE_AVATAR_INFORMATION)} - - - - - - - - {fileSource && ( - - )} - - ); -}; - -export default AvatarSetting; diff --git a/src/components/member/DeleteMemberDialog.tsx b/src/components/member/DeleteMemberDialog.tsx deleted file mode 100644 index 49b634557..000000000 --- a/src/components/member/DeleteMemberDialog.tsx +++ /dev/null @@ -1,105 +0,0 @@ -import { useState } from 'react'; - -import { Grid, Typography } from '@mui/material'; -import Dialog from '@mui/material/Dialog'; -import DialogActions from '@mui/material/DialogActions'; -import DialogContent from '@mui/material/DialogContent'; -import DialogContentText from '@mui/material/DialogContentText'; -import DialogTitle from '@mui/material/DialogTitle'; - -import { ACCOUNT } from '@graasp/translations'; -import { Button } from '@graasp/ui'; - -import { useAccountTranslation } from '../../config/i18n'; -import { mutations } from '../../config/queryClient'; -import { - CONFIRM_DELETE_BUTTON_ID, - DELETE_MEMBER_BUTTON_ID, -} from '../../config/selectors'; -import CancelButton from '../common/CancelButton'; - -type Props = { - id: string; -}; - -const DeleteMemberDialog = ({ id }: Props): JSX.Element => { - const { t: translateAccount } = useAccountTranslation(); - const [open, setOpen] = useState(false); - const { mutate: deleteMember } = mutations.useDeleteMember(); - - const alertDialogTitle = 'alert-dialog-title'; - const alertDialogDescription = 'alert-dialog-description'; - - return ( - <> - setOpen(false)} - aria-labelledby={alertDialogTitle} - aria-describedby={alertDialogDescription} - > - - {translateAccount(ACCOUNT.PROFILE_DELETE_ACCOUNT_MODAL_TITLE)} - - - - {translateAccount(ACCOUNT.PROFILE_DELETE_ACCOUNT_MODAL_INFORMATION)} - - - - setOpen(false)} color="primary" /> - - - - - - - - {translateAccount(ACCOUNT.PROFILE_DELETE_ACCOUNT_TITLE)} - - - - - - {translateAccount(ACCOUNT.PROFILE_DELETE_ACCOUNT_INFORMATION)} - - - - - - ); -}; - -export default DeleteMemberDialog; diff --git a/src/components/member/EmailPreferenceSwitch.tsx b/src/components/member/EmailPreferenceSwitch.tsx deleted file mode 100644 index 6bc00c440..000000000 --- a/src/components/member/EmailPreferenceSwitch.tsx +++ /dev/null @@ -1,51 +0,0 @@ -import { SelectChangeEvent } from '@mui/material'; - -import { MemberExtra } from '@graasp/sdk'; -import { Select } from '@graasp/ui'; - -import { emailFrequency } from '../../config/constants'; -import { mutations } from '../../config/queryClient'; -import { buildEmailFrequencyOptionId } from '../../config/selectors'; - -type EmailPreferenceSwitchProps = { - id?: string; - memberId: string; - emailFreq: MemberExtra['emailFreq']; -}; - -const EmailPreferenceSwitch = ({ - id, - memberId, - emailFreq, -}: EmailPreferenceSwitchProps): JSX.Element => { - const { mutate: editMember } = mutations.useEditMember(); - - const handleChange = (event: SelectChangeEvent) => { - if (event.target.value) { - editMember({ - id: memberId, - extra: { - emailFreq: event.target.value as MemberExtra['emailFreq'], - }, - }); - } else { - console.error(`The frequency ${event.target.value} is not valid`); - } - }; - - return ( - ({ value, text }))} - /> - ); -}; - -export default LanguageSwitch; diff --git a/src/components/member/MemberProfileScreen.tsx b/src/components/member/MemberProfileScreen.tsx deleted file mode 100644 index 82c54970b..000000000 --- a/src/components/member/MemberProfileScreen.tsx +++ /dev/null @@ -1,192 +0,0 @@ -import FileCopyIcon from '@mui/icons-material/FileCopy'; -import { - Alert, - Box, - Grid, - IconButton, - Switch, - Tooltip, - Typography, -} from '@mui/material'; - -import { formatDate } from '@graasp/sdk'; -import { ACCOUNT, COMMON } from '@graasp/translations'; -import { Loader } from '@graasp/ui'; - -import { - DEFAULT_EMAIL_FREQUENCY, - DEFAULT_LANG, - DEFAULT_MEMBER_PROFILE_SAVE_ACTIONS_SETTING, -} from '../../config/constants'; -import i18n, { - useAccountTranslation, - useBuilderTranslation, - useCommonTranslation, -} from '../../config/i18n'; -import notifier from '../../config/notifier'; -import { mutations } from '../../config/queryClient'; -import { - MEMBER_PROFILE_EMAIL_FREQ_SWITCH_ID, - MEMBER_PROFILE_EMAIL_ID, - MEMBER_PROFILE_INSCRIPTION_DATE_ID, - MEMBER_PROFILE_LANGUAGE_SWITCH_ID, - MEMBER_PROFILE_MEMBER_ID_COPY_BUTTON_ID, - MEMBER_PROFILE_MEMBER_ID_ID, - MEMBER_PROFILE_MEMBER_NAME_ID, - MEMBER_PROFILE_SAVE_ACTIONS_TOGGLE_ID, -} from '../../config/selectors'; -import { BUILDER } from '../../langs/constants'; -import { COPY_MEMBER_ID_TO_CLIPBOARD } from '../../types/clipboard'; -import { copyToClipboard } from '../../utils/clipboard'; -import { useCurrentUserContext } from '../context/CurrentUserContext'; -import Main from '../main/Main'; -import AvatarSetting from './AvatarSetting'; -import DeleteMemberDialog from './DeleteMemberDialog'; -import EmailPreferenceSwitch from './EmailPreferenceSwitch'; -import LanguageSwitch from './LanguageSwitch'; -import PasswordSetting from './PasswordSetting'; - -const MemberProfileScreen = (): JSX.Element => { - const { t } = useAccountTranslation(); - const { t: translateCommon } = useCommonTranslation(); - const { t: translateBuilder } = useBuilderTranslation(); - const { data: member, isLoading } = useCurrentUserContext(); - const { mutate: editMember } = mutations.useEditMember(); - - if (isLoading) { - return ; - } - - if (!member) { - return {t('User is not unauthenticated')}; - } - - const copyIdToClipboard = () => { - copyToClipboard(member.id, { - onSuccess: () => { - notifier({ type: COPY_MEMBER_ID_TO_CLIPBOARD.SUCCESS, payload: {} }); - }, - onError: () => { - notifier({ type: COPY_MEMBER_ID_TO_CLIPBOARD.FAILURE, payload: {} }); - }, - }); - }; - - const handleOnToggle = (event: { target: { checked: boolean } }): void => { - editMember({ - id: member.id, - extra: { - enableSaveActions: event.target.checked, - }, - }); - }; - - return ( -
- - - - - {member.name} - - {/* todo: display only as light user */} - - - {t(ACCOUNT.PROFILE_MEMBER_ID_TITLE)} - - - - {member.id} - - - - - - - - - {t(ACCOUNT.PROFILE_EMAIL_TITLE)} - - - - {member.email} - - - - - - {t(ACCOUNT.PROFILE_CREATED_AT_TITLE)} - - - - {formatDate(member.createdAt, { - locale: i18n.language, - defaultValue: translateCommon(COMMON.UNKNOWN_DATE), - })} - - - - - - {t(ACCOUNT.PROFILE_LANGUAGE_TITLE)} - - - - - - - - - {t(ACCOUNT.PROFILE_EMAIL_FREQUENCY_TITLE)} - - - - - - - - - {t(ACCOUNT.PROFILE_SAVE_ACTIONS_TITLE)} - - - - - - - - - - - - - - - - -
- ); -}; - -export default MemberProfileScreen; diff --git a/src/components/member/PasswordSetting.tsx b/src/components/member/PasswordSetting.tsx deleted file mode 100644 index a409dc836..000000000 --- a/src/components/member/PasswordSetting.tsx +++ /dev/null @@ -1,170 +0,0 @@ -import { ChangeEvent, useState } from 'react'; - -import { Button, TextField } from '@mui/material'; -import Grid from '@mui/material/Grid'; -import Typography from '@mui/material/Typography'; - -import { isPasswordStrong } from '@graasp/sdk'; -import { ACCOUNT, FAILURE_MESSAGES } from '@graasp/translations'; - -import { useAccountTranslation } from '../../config/i18n'; -import { mutations } from '../../config/queryClient'; -import { - CONFIRM_CHANGE_PASSWORD_BUTTON_ID, - CONFIRM_RESET_PASSWORD_BUTTON_ID, - USER_CONFIRM_PASSWORD_INPUT_ID, - USER_CURRENT_PASSWORD_INPUT_ID, - USER_NEW_PASSWORD_INPUT_ID, -} from '../../config/selectors'; - -const PasswordSetting = (): JSX.Element => { - const { t: translateAccount } = useAccountTranslation(); - - const [currentPassword, setCurrentPassword] = useState(''); - const [newPassword, setNewPassword] = useState(''); - const [confirmPassword, setConfirmPassword] = useState(''); - const [newPasswordError, setNewPasswordError] = useState(); - const [confirmPasswordError, setConfirmPasswordError] = useState< - string | null - >(); - const { mutate: updatePassword } = mutations.useUpdatePassword(); - - const verifyEmptyPassword = () => { - const newPasswordIsNotEmpty = Boolean(newPassword); - const confirmPasswordIsNotEmpty = Boolean(confirmPassword); - setNewPasswordError( - newPasswordIsNotEmpty ? null : FAILURE_MESSAGES.PASSWORD_EMPTY_ERROR, - ); - setConfirmPasswordError( - confirmPasswordIsNotEmpty ? null : FAILURE_MESSAGES.PASSWORD_EMPTY_ERROR, - ); - - return newPasswordIsNotEmpty || confirmPasswordIsNotEmpty; - }; - - const onClose = () => { - setCurrentPassword(''); - setNewPassword(''); - setConfirmPassword(''); - }; - - const handleChangePassword = () => { - // verify there are no empty inputs - const isValid = verifyEmptyPassword(); - - if (isValid) { - // perform validation when all fields are filled in - if (currentPassword === newPassword) { - return setNewPasswordError(FAILURE_MESSAGES.PASSWORD_EQUAL_ERROR); - } - if (newPassword !== confirmPassword) { - return setConfirmPasswordError(FAILURE_MESSAGES.PASSWORD_CONFIRM_ERROR); - } - - // check password strength for new password - if (!isPasswordStrong(newPassword)) { - return setNewPasswordError(FAILURE_MESSAGES.PASSWORD_WEAK_ERROR); - } - - // perform password update - updatePassword({ - password: newPassword, - currentPassword, - }); - } - - return onClose(); - }; - - const handleCurrentPasswordInput = (event: ChangeEvent) => { - setCurrentPassword(event.target.value); - }; - const handleNewPasswordInput = (event: ChangeEvent) => { - setNewPassword(event.target.value); - setNewPasswordError(event.target.value ? null : 'Password is empty'); - }; - const handleConfirmPasswordInput = (event: ChangeEvent) => { - setConfirmPassword(event.target.value); - setConfirmPasswordError(event.target.value ? null : 'Password is empty'); - }; - - return ( - - - - {translateAccount(ACCOUNT.PASSWORD_SETTINGS_TITLE)} - - - {translateAccount(ACCOUNT.PASSWORD_SETTINGS_CONFIRM_INFORMATION)} - - - - - - - {translateAccount(ACCOUNT.PASSWORD_SETTINGS_CURRENT_INFORMATION)} - - - - - - - - - - - - - - ); -}; - -export default PasswordSetting; diff --git a/src/config/env.ts b/src/config/env.ts index 8c7938e01..24c00948c 100644 --- a/src/config/env.ts +++ b/src/config/env.ts @@ -12,6 +12,8 @@ export const GRAASP_LIBRARY_HOST = import.meta.env.VITE_GRAASP_LIBRARY_HOST || 'http://localhost:3005'; export const GRAASP_ANALYZER_HOST = import.meta.env.VITE_GRAASP_ANALYZER_HOST || 'http://localhost:3113'; +export const GRAASP_ACCOUNT_HOST = + import.meta.env.VITE_GRAASP_ACCOUNT_HOST || 'http://localhost:3115'; export const H5P_INTEGRATION_URL = import.meta.env.VITE_H5P_INTEGRATION_URL || `${API_HOST}/p/h5p-integration`; diff --git a/src/config/i18n.ts b/src/config/i18n.ts index a315bb06d..b567152ad 100644 --- a/src/config/i18n.ts +++ b/src/config/i18n.ts @@ -20,7 +20,6 @@ i18n.addResourceBundle('it', BUILDER_NAMESPACE, it); export const useBuilderTranslation = () => useTranslation(BUILDER_NAMESPACE); export const useCommonTranslation = () => useTranslation(namespaces.common); -export const useAccountTranslation = () => useTranslation(namespaces.account); export const useMessagesTranslation = () => useTranslation(namespaces.messages); export const useEnumsTranslation = () => useTranslation(namespaces.enums); export const useCategoriesTranslation = () => diff --git a/src/env.d.ts b/src/env.d.ts index eca360ba9..c5e341c4b 100644 --- a/src/env.d.ts +++ b/src/env.d.ts @@ -9,6 +9,7 @@ interface ImportMetaEnv { readonly VITE_GRAASP_PLAYER_HOST?: string; readonly VITE_GRAASP_LIBRARY_HOST?: string; readonly VITE_GRAASP_ANALYZER_HOST?: string; + readonly VITE_GRAASP_ACCOUNT_HOST?: string; readonly VITE_H5P_INTEGRATION_URL?: string; readonly VITE_GRAASP_ASSETS_URL?: string; readonly VITE_SENTRY_ENV: string; diff --git a/src/langs/constants.ts b/src/langs/constants.ts index e77875b86..bd73ef473 100644 --- a/src/langs/constants.ts +++ b/src/langs/constants.ts @@ -328,4 +328,8 @@ export const BUILDER = { CREATE_NEW_APP_BACK_TO_APP_LIST_BUTTON: 'CREATE_NEW_APP_BACK_TO_APP_LIST_BUTTON', APP_LIST_LOADING_FAILED: 'APP_LIST_LOADING_FAILED', + + FLAG_REASON_DESCRIPTION: 'FLAG_REASON_DESCRIPTION', + FLAG_MODAL_TITLE: 'FLAG_MODAL_TITLE', + FLAG_MODAL_CONFIRM: 'FLAG_MODAL_CONFIRM', }; diff --git a/src/langs/en.json b/src/langs/en.json index 5883a10f8..f8fa792ce 100644 --- a/src/langs/en.json +++ b/src/langs/en.json @@ -267,5 +267,8 @@ "DOWNGRADE_PERMISSION_DESCRIPTION": "Are you sure you want to downgrade your own permission? Once it's done you can't undo.", "CREATE_CUSTOM_APP_HELPER_TEXT": "If you know the URL of an interactive app that can leverage Graasp's API you can input it here.", "CREATE_NEW_APP_BACK_TO_APP_LIST_BUTTON": "Back To App's List", - "APP_LIST_LOADING_FAILED": "There was an error getting the app list. Please try again later." + "APP_LIST_LOADING_FAILED": "There was an error getting the app list. Please try again later.", + "FLAG_REASON_DESCRIPTION": "Select reason for flagging this item", + "FLAG_MODAL_TITLE": "Flag Item", + "FLAG_MODAL_CONFIRM": "Flag" } diff --git a/yarn.lock b/yarn.lock index cf52a4f05..220dd3c46 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1779,15 +1779,6 @@ __metadata: languageName: node linkType: hard -"@graasp/translations@npm:1.19.2": - version: 1.19.2 - resolution: "@graasp/translations@npm:1.19.2" - dependencies: - i18next: 23.4.6 - checksum: e4ae1daf83e4e9e2b9bc23f3aa6480d53cbe03b53a2ad847f9933351f7b1aea31c3866fb5296aadc2872d5fdf0db22ba0b576bfff712bd6916a971094c823266 - languageName: node - linkType: hard - "@graasp/translations@npm:1.19.4": version: 1.19.4 resolution: "@graasp/translations@npm:1.19.4" @@ -7092,7 +7083,7 @@ __metadata: "@graasp/chatbox": 3.0.0 "@graasp/query-client": 2.0.0 "@graasp/sdk": 2.0.1 - "@graasp/translations": 1.19.2 + "@graasp/translations": 1.19.4 "@graasp/ui": 4.0.0 "@mui/icons-material": 5.14.16 "@mui/lab": 5.0.0-alpha.151 @@ -7446,15 +7437,6 @@ __metadata: languageName: node linkType: hard -"i18next@npm:23.4.6": - version: 23.4.6 - resolution: "i18next@npm:23.4.6" - dependencies: - "@babel/runtime": ^7.22.5 - checksum: ffc63889e28b2bfce2c6e635bd686087290fe2e2f58e0a235525011bb74d541ff681895abe994b12546be6c92b66a7cc3002a13c26e587b4da8c89b15ef648db - languageName: node - linkType: hard - "i18next@npm:23.6.0": version: 23.6.0 resolution: "i18next@npm:23.6.0"