2025-02-17 19:33:00 +00:00
|
|
|
import { Container, Heading, Tabs } from "@chakra-ui/react"
|
2024-04-08 15:49:22 -05:00
|
|
|
import { createFileRoute } from "@tanstack/react-router"
|
2024-03-07 19:16:23 +01:00
|
|
|
|
2024-03-17 17:28:45 +01:00
|
|
|
import Appearance from "../../components/UserSettings/Appearance"
|
|
|
|
import ChangePassword from "../../components/UserSettings/ChangePassword"
|
|
|
|
import DeleteAccount from "../../components/UserSettings/DeleteAccount"
|
|
|
|
import UserInformation from "../../components/UserSettings/UserInformation"
|
2025-02-17 19:33:00 +00:00
|
|
|
import useAuth from "../../hooks/useAuth"
|
2024-02-26 09:39:09 -05:00
|
|
|
|
|
|
|
const tabsConfig = [
|
2025-02-17 19:33:00 +00:00
|
|
|
{ value: "my-profile", title: "My profile", component: UserInformation },
|
|
|
|
{ value: "password", title: "Password", component: ChangePassword },
|
|
|
|
{ value: "appearance", title: "Appearance", component: Appearance },
|
|
|
|
{ value: "danger-zone", title: "Danger zone", component: DeleteAccount },
|
2024-03-08 14:58:36 +01:00
|
|
|
]
|
2024-02-12 16:46:51 -05:00
|
|
|
|
2024-03-17 17:28:45 +01:00
|
|
|
export const Route = createFileRoute("/_layout/settings")({
|
2024-03-08 14:58:36 +01:00
|
|
|
component: UserSettings,
|
2024-03-07 19:16:23 +01:00
|
|
|
})
|
2024-02-12 16:46:51 -05:00
|
|
|
|
2024-03-07 19:16:23 +01:00
|
|
|
function UserSettings() {
|
2025-02-17 19:33:00 +00:00
|
|
|
const { user: currentUser } = useAuth()
|
2024-03-08 14:58:36 +01:00
|
|
|
const finalTabs = currentUser?.is_superuser
|
|
|
|
? tabsConfig.slice(0, 3)
|
|
|
|
: tabsConfig
|
2024-02-12 16:46:51 -05:00
|
|
|
|
2025-02-17 19:33:00 +00:00
|
|
|
if (!currentUser) {
|
|
|
|
return null
|
|
|
|
}
|
|
|
|
|
2024-03-08 14:58:36 +01:00
|
|
|
return (
|
|
|
|
<Container maxW="full">
|
2024-03-17 17:28:45 +01:00
|
|
|
<Heading size="lg" textAlign={{ base: "center", md: "left" }} py={12}>
|
2024-03-08 14:58:36 +01:00
|
|
|
User Settings
|
|
|
|
</Heading>
|
2025-02-17 19:33:00 +00:00
|
|
|
|
|
|
|
<Tabs.Root defaultValue="my-profile" variant="subtle">
|
|
|
|
<Tabs.List>
|
|
|
|
{finalTabs.map((tab) => (
|
|
|
|
<Tabs.Trigger key={tab.value} value={tab.value}>
|
|
|
|
{tab.title}
|
|
|
|
</Tabs.Trigger>
|
2024-03-08 14:58:36 +01:00
|
|
|
))}
|
2025-02-17 19:33:00 +00:00
|
|
|
</Tabs.List>
|
|
|
|
{finalTabs.map((tab) => (
|
|
|
|
<Tabs.Content key={tab.value} value={tab.value}>
|
|
|
|
<tab.component />
|
|
|
|
</Tabs.Content>
|
|
|
|
))}
|
|
|
|
</Tabs.Root>
|
2024-03-08 14:58:36 +01:00
|
|
|
</Container>
|
|
|
|
)
|
2024-03-07 19:16:23 +01:00
|
|
|
}
|