-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(web): workspace setting page (#1174)
Co-authored-by: tcsola <[email protected]> Co-authored-by: tcsola <[email protected]> Co-authored-by: airslice <[email protected]>
- Loading branch information
1 parent
b96d9f3
commit 967eb7c
Showing
28 changed files
with
1,216 additions
and
226 deletions.
There are no files selected for viewing
99 changes: 0 additions & 99 deletions
99
web/src/beta/features/AccountAndWorkSpaceSetting/innerPages/AccountSetting/index.tsx
This file was deleted.
Oops, something went wrong.
54 changes: 0 additions & 54 deletions
54
web/src/beta/features/AccountAndWorkSpaceSetting/innerPages/common.tsx
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,158 @@ | ||
import useAccountSettingsTabs from "@reearth/beta/hooks/useAccountSettingsTabs"; | ||
import { | ||
Collapse, | ||
TextInput, | ||
Typography, | ||
IconButton | ||
} from "@reearth/beta/lib/reearth-ui"; | ||
import SettingBase from "@reearth/beta/ui/components/SettingBase"; | ||
import { InputField, SelectField } from "@reearth/beta/ui/fields"; | ||
import { useT } from "@reearth/services/i18n"; | ||
import { useWorkspace } from "@reearth/services/state"; | ||
import { styled } from "@reearth/services/theme"; | ||
import { FC, useState } from "react"; | ||
|
||
import useHook from "./hooks"; | ||
import PasswordModal from "./PasswordModal"; | ||
|
||
const AccountSetting: FC = () => { | ||
const t = useT(); | ||
const [changePasswordModal, setChangePasswordModal] = | ||
useState<boolean>(false); | ||
|
||
const { | ||
meData, | ||
passwordPolicy, | ||
handleUpdateUserPassword, | ||
handleUpdateUserLanguage | ||
} = useHook(); | ||
const { name, email } = meData; | ||
|
||
const [currentWorkspace] = useWorkspace(); | ||
|
||
const { tabs } = useAccountSettingsTabs({ | ||
workspaceId: currentWorkspace?.id ?? "" | ||
}); | ||
|
||
const options = [ | ||
{ | ||
label: t("Auto"), | ||
value: "und" | ||
}, | ||
{ | ||
label: "English", | ||
value: "en" | ||
}, | ||
{ | ||
label: "日本語", | ||
value: "ja" | ||
} | ||
]; | ||
type LanguageOption = (typeof options)[number]["value"]; | ||
const [languageLabel, setLanguageLabel] = useState<LanguageOption>("und"); | ||
|
||
return ( | ||
<SettingBase tabs={tabs} tab={"account"}> | ||
<InnerPage> | ||
<SettingsWrapper> | ||
<Collapse size="large" title={t("Account")}> | ||
<SettingsFields> | ||
<InputField | ||
title={t("Name")} | ||
value={name ? t(name) : ""} | ||
appearance="readonly" | ||
disabled | ||
/> | ||
<InputField | ||
title={t("Email address")} | ||
value={email ? t(email) : ""} | ||
appearance="readonly" | ||
disabled | ||
/> | ||
|
||
<PasswordWrapper> | ||
<Typography size="body">{t("Password")}</Typography> | ||
<PasswordInputWrapper> | ||
<TextInput | ||
value={"**********"} | ||
appearance="readonly" | ||
disabled | ||
extendWidth | ||
/> | ||
<IconButton | ||
appearance="secondary" | ||
icon="pencilSimple" | ||
onClick={() => { | ||
setChangePasswordModal(true); | ||
}} | ||
size="medium" | ||
hasBorder={true} | ||
/> | ||
</PasswordInputWrapper> | ||
</PasswordWrapper> | ||
<SelectField | ||
title={t("Language")} | ||
value={languageLabel} | ||
options={options} | ||
onChange={(value) => { | ||
if (typeof value === "string") { | ||
setLanguageLabel(value); | ||
handleUpdateUserLanguage({ lang: value }); | ||
} | ||
}} | ||
/> | ||
</SettingsFields> | ||
</Collapse> | ||
</SettingsWrapper> | ||
|
||
<PasswordModal | ||
isVisible={changePasswordModal} | ||
passwordPolicy={passwordPolicy} | ||
onClose={() => setChangePasswordModal(false)} | ||
handleUpdateUserPassword={handleUpdateUserPassword} | ||
/> | ||
</InnerPage> | ||
</SettingBase> | ||
); | ||
}; | ||
export default AccountSetting; | ||
|
||
const PasswordWrapper = styled("div")(() => ({ | ||
display: "flex", | ||
flexDirection: "column", | ||
width: "100%" | ||
})); | ||
|
||
const PasswordInputWrapper = styled("div")(({ theme }) => ({ | ||
display: "flex", | ||
gap: theme.spacing.smallest, | ||
alignItems: "center" | ||
})); | ||
|
||
const InnerPage = styled("div")<{ | ||
wide?: boolean; | ||
transparent?: boolean; | ||
}>(({ wide, transparent, theme }) => ({ | ||
boxSizing: "border-box", | ||
display: "flex", | ||
width: "100%", | ||
maxWidth: wide ? 950 : 750, | ||
backgroundColor: transparent ? "none" : theme.bg[1], | ||
borderRadius: theme.radius.normal | ||
})); | ||
|
||
const SettingsWrapper = styled("div")(({ theme }) => ({ | ||
display: "flex", | ||
flexDirection: "column", | ||
width: "100%", | ||
flex: 1, | ||
["> div:not(:last-child)"]: { | ||
borderBottom: `1px solid ${theme.outline.weaker}` | ||
} | ||
})); | ||
|
||
const SettingsFields = styled("div")(({ theme }) => ({ | ||
display: "flex", | ||
flexDirection: "column", | ||
gap: theme.spacing.largest | ||
})); |
Oops, something went wrong.