From 214782d9c9a7764f7292503645cb95eaf2df2b55 Mon Sep 17 00:00:00 2001 From: balzack Date: Sun, 8 Sep 2024 08:25:04 -0700 Subject: [PATCH] adding profile detail modal --- .../web/src/settings/Settings.module.css | 9 +- app/client/web/src/settings/Settings.tsx | 215 +++++++++++++----- .../web/src/settings/useSettings.hook.ts | 29 ++- 3 files changed, 181 insertions(+), 72 deletions(-) diff --git a/app/client/web/src/settings/Settings.module.css b/app/client/web/src/settings/Settings.module.css index a68b8062..fdc74163 100644 --- a/app/client/web/src/settings/Settings.module.css +++ b/app/client/web/src/settings/Settings.module.css @@ -16,7 +16,7 @@ flex-direction: column; align-items: center; padding: 8px; - gap: 8px; + gap: 2px; .header { font-size: 22px; @@ -115,20 +115,19 @@ width: 100%; padding-left: 8px; display: flex; - align-items: center; .radio { position: relative; - top: -4px; + top: -8px; } .entryIcon { width: 32px; - display: flex; } .entrySet { font-size: 14px; + white-space: preserve; } .entryUnset { @@ -166,6 +165,8 @@ align-items: center; max-width: 40%; padding: 0; + position: relative; + top: -4px; } } } diff --git a/app/client/web/src/settings/Settings.tsx b/app/client/web/src/settings/Settings.tsx index 6e0db941..ba9b1552 100644 --- a/app/client/web/src/settings/Settings.tsx +++ b/app/client/web/src/settings/Settings.tsx @@ -1,14 +1,18 @@ import { useSettings } from './useSettings.hook'; -import { Modal, TextInput, PasswordInput, Radio, Group, Select, Switch, Text, Image, Button, UnstyledButton } from '@mantine/core'; +import { Modal, Textarea, TextInput, PasswordInput, Radio, Group, Select, Switch, Text, Image, Button, UnstyledButton } from '@mantine/core'; import classes from './Settings.module.css'; -import { IconLock, IconUser, IconClock, IconCalendar, IconUsers, IconVideo, IconMicrophone, IconWorld, IconBrightness, IconTicket, IconCloudLock, IconBell, IconEye, IconBook, IconMapPin, IconLogout, IconLogin } from '@tabler/icons-react' +import { IconLock, IconUser, IconClock, IconIdBadge, IconCalendar, IconUsers, IconVideo, IconMicrophone, IconWorld, IconBrightness, IconTicket, IconCloudLock, IconBell, IconEye, IconBook, IconMapPin, IconLogout, IconLogin } from '@tabler/icons-react' import avatar from '../images/avatar.png' import { modals } from '@mantine/modals'; import { useDisclosure } from '@mantine/hooks' +import { useState } from 'react' export function Settings({ showLogout }) { const { state, actions } = useSettings(); const [changeOpened, { open: changeOpen, close: changeClose }] = useDisclosure(false) + const [detailsOpened, { open: detailsOpen, close: detailsClose }] = useDisclosure(false) + const [savingLogin, setSavingLogin] = useState(false); + const [savingDetails, setSavingDetails] = useState(false); const logout = () => modals.openConfirmModal({ title: state.strings.confirmLogout, @@ -24,28 +28,57 @@ export function Settings({ showLogout }) { onConfirm: actions.logout, }); - const setLogin = async () => { - try { -throw new Error("NO"); - await actions.setLogin(); - changeClose(); + const setDetails = async () => { + if (!savingDetails) { + setSavingDetails(true); + try { + await actions.setDetails(); + detailsClose(); + } + catch (err) { + console.log(err); + modals.openConfirmModal({ + title: state.strings.operationFailed, + withCloseButton: true, + overlayProps: { + backgroundOpacity: 0.55, + blur: 3, + }, + children: ( + {state.strings.tryAgain} + ), + cancelProps: { display: 'none' }, + confirmProps: { display: 'none' }, + }); + } + setSavingDetails(false); } - catch (err) { - console.log(err); - modals.openConfirmModal({ - title: state.strings.operationFailed, - withCloseButton: true, - overlayProps: { - backgroundOpacity: 0.55, - blur: 3, - }, - children: ( - {state.strings.tryAgain} - ), - cancelProps: { display: 'none' }, - confirmProps: { display: 'none' }, - }); + } + const setLogin = async () => { + if (!savingLogin) { + setSavingLogin(true); + try { + await actions.setLogin(); + changeClose(); + } + catch (err) { + console.log(err); + modals.openConfirmModal({ + title: state.strings.operationFailed, + withCloseButton: true, + overlayProps: { + backgroundOpacity: 0.55, + blur: 3, + }, + children: ( + {state.strings.tryAgain} + ), + cancelProps: { display: 'none' }, + confirmProps: { display: 'none' }, + }); + } + setSavingLogin(false); } } @@ -72,7 +105,7 @@ throw new Error("NO");
- { state.strings.edit } + { state.strings.edit }
{ !state.profile.name && ( {state.strings.name} @@ -146,43 +179,41 @@ throw new Error("NO"); { state.strings.changeLogin }
- -
-
- -
- { state.strings.timeFormat } - - - - - - -
-
-
- -
- { state.strings.dateFormat } - - - - - - -
-
+
+
+ +
+ { state.strings.timeFormat } + + + + + + +
+
+
+ +
+ { state.strings.dateFormat } + + + + + + +
@@ -249,13 +280,13 @@ throw new Error("NO"); } rightSection={state.taken ? : null} placeholder={state.strings.username} onChange={(event) => - actions.setUsername(event.currentTarget.value) + actions.setHandle(event.currentTarget.value) } error={state.taken} /> @@ -286,8 +317,66 @@ throw new Error("NO"); +
+
+ + +
+ } + placeholder={state.strings.name} + onChange={(event) => + actions.setName(event.currentTarget.value) + } + /> + } + placeholder={state.strings.location} + onChange={(event) => + actions.setLocation(event.currentTarget.value) + } + /> +