index.tsx 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. import { useAuthStore } from '@/stores/auth-store'
  2. import { useStatus } from '@/hooks/use-status'
  3. import { AppHeader, Main } from '@/components/layout'
  4. import {
  5. CardStaggerContainer,
  6. CardStaggerItem,
  7. } from '@/components/page-transition'
  8. import { CheckinCalendarCard } from './components/checkin-calendar-card'
  9. import { PasskeyCard } from './components/passkey-card'
  10. import { ProfileHeader } from './components/profile-header'
  11. import { ProfileSecurityCard } from './components/profile-security-card'
  12. import { ProfileSettingsCard } from './components/profile-settings-card'
  13. import { SidebarModulesCard } from './components/sidebar-modules-card'
  14. import { TwoFACard } from './components/two-fa-card'
  15. import { useProfile } from './hooks'
  16. export function Profile() {
  17. const { profile, loading, refreshProfile } = useProfile()
  18. const { status } = useStatus()
  19. const permissions = useAuthStore((s) => s.auth.user?.permissions)
  20. const checkinEnabled = status?.checkin_enabled === true
  21. const turnstileEnabled = !!(
  22. status?.turnstile_check && status?.turnstile_site_key
  23. )
  24. const turnstileSiteKey = status?.turnstile_site_key || ''
  25. const canConfigureSidebar = permissions?.sidebar_settings !== false
  26. return (
  27. <>
  28. <AppHeader />
  29. <Main>
  30. <div className='min-h-0 flex-1 overflow-auto px-4 py-6'>
  31. <CardStaggerContainer className='space-y-8'>
  32. <CardStaggerItem>
  33. <ProfileHeader profile={profile} loading={loading} />
  34. </CardStaggerItem>
  35. <CardStaggerItem>
  36. <div className='grid gap-6 lg:grid-cols-2 lg:items-start'>
  37. <div className='space-y-6'>
  38. <ProfileSecurityCard profile={profile} loading={loading} />
  39. <PasskeyCard loading={loading} />
  40. <TwoFACard loading={loading} />
  41. </div>
  42. <div className='space-y-6'>
  43. {checkinEnabled && (
  44. <CheckinCalendarCard
  45. checkinEnabled={checkinEnabled}
  46. turnstileEnabled={turnstileEnabled}
  47. turnstileSiteKey={turnstileSiteKey}
  48. />
  49. )}
  50. <ProfileSettingsCard
  51. profile={profile}
  52. loading={loading}
  53. onProfileUpdate={refreshProfile}
  54. />
  55. {canConfigureSidebar && <SidebarModulesCard />}
  56. </div>
  57. </div>
  58. </CardStaggerItem>
  59. </CardStaggerContainer>
  60. </div>
  61. </Main>
  62. </>
  63. )
  64. }