Files
Alaister YoungandKevin Grüneberg 70da0f1d1d chore: cleanup packages (#27770)
* chore: cleanup packages

- Avoid circular imports
- Export API-types as types
- pg-format without depending on Node internal Buffer (not browser-compatible)
- Avoid importing from barrel files in ui dir

* chore: avoid barrel file imports in studio (#27771)

* chore: avoid barrel file imports

- Removes some unused imports
- Avoids barrel file import for faster builds + less memory

* add eslint rule

* type fixes

* delete layouts barrel

* delete components/grid barrel file

* delete components/grid/utils barrel file

* delete components/grid/components/common barrel file

* delete components/grid/components/editor barrel file

* delete components/grid/components/formatter barrel file

* delete components/grid/components/grid barrel file

* delete components/grid/components/header/filter barrel file

* remote components/grid/store barrel file

* remove components/interfaces/Auth/Policies barrel file

* delete components/interfaces/Settings/Logs barrel file

* delete components/ui/CodeEditor barrel file

* delete components/ui/Forms barrel file

* delete components/ui/Shimmers barrel file

* delete data/analytics barrel file

* delete hooks barrel file

* cleanup lib/common/fetch barrel file

* final * barral files cleanup

* global react-data-grid styles

* remove console.log

---------

Co-authored-by: Kevin Grüneberg <k.grueneberg1994@gmail.com>

* fix build

---------

Co-authored-by: Kevin Grüneberg <k.grueneberg1994@gmail.com>
2024-07-04 14:48:10 +08:00

86 lines
2.2 KiB
TypeScript

import {
AccountInformation,
AnalyticsSettings,
ThemeSettings,
ThemeSettingsOld,
} from 'components/interfaces/Account/Preferences'
import { AccountDeletion } from 'components/interfaces/Account/Preferences/AccountDeletion'
import { ProfileInformation } from 'components/interfaces/Account/Preferences/ProfileInformation'
import AccountLayout from 'components/layouts/AccountLayout/AccountLayout'
import AlertError from 'components/ui/AlertError'
import Panel from 'components/ui/Panel'
import { GenericSkeletonLoader } from 'components/ui/ShimmeringLoader'
import { useIsFeatureEnabled } from 'hooks/misc/useIsFeatureEnabled'
import { useFlag } from 'hooks/ui/useFlag'
import { useProfile } from 'lib/profile'
import type { NextPageWithLayout } from 'types'
const User: NextPageWithLayout = () => {
return (
<div className="my-2">
<ProfileCard />
</div>
)
}
User.getLayout = (page) => (
<AccountLayout
title="Preferences"
breadcrumbs={[
{
key: `supabase-settings`,
label: 'Preferences',
},
]}
>
{page}
</AccountLayout>
)
export default User
const ProfileCard = () => {
const profileUpdateEnabled = useIsFeatureEnabled('profile:update')
const { profile, error, isLoading, isError, isSuccess } = useProfile()
const experimentalThemeEnabled = useFlag('enableExperimentalTheme')
return (
<article className="max-w-4xl p-4">
{isLoading && (
<Panel>
<div className="p-4">
<GenericSkeletonLoader />
</div>
</Panel>
)}
{isError && (
<Panel>
<div className="p-4">
<AlertError error={error} subject="Failed to retrieve account information" />
</div>
</Panel>
)}
{isSuccess && (
<>
<section>
<AccountInformation profile={profile} />
</section>
{profileUpdateEnabled && isSuccess ? <ProfileInformation profile={profile!} /> : null}
</>
)}
<section>{experimentalThemeEnabled ? <ThemeSettings /> : <ThemeSettingsOld />}</section>
<section>
<AnalyticsSettings />
</section>
<section>
<AccountDeletion />
</section>
</article>
)
}