feat: ship Wave 5-6 multi-surface hygiene, optimization, and bug fixes
This commit is contained in:
parent
01ef3293cf
commit
66b6b45ba9
399 changed files with 17828 additions and 11330 deletions
|
|
@ -1,7 +1,7 @@
|
|||
'use client'
|
||||
|
||||
import Link from 'next/link'
|
||||
import { useCallback, useEffect, useState } from 'react'
|
||||
import { useCallback, useEffect, useRef, useState } from 'react'
|
||||
import { Alert, Box, Button, CircularProgress, Typography } from '@mui/material'
|
||||
import {
|
||||
ArrowUpRight,
|
||||
|
|
@ -73,12 +73,25 @@ function formatDuration(seconds: number): string {
|
|||
|
||||
export default function DashboardPage(): React.ReactElement {
|
||||
const { user, loading: authLoading } = useAuth()
|
||||
const userId = user?.id
|
||||
const [snapshot, setSnapshot] = useState<DashboardSnapshot | null>(null)
|
||||
const [loading, setLoading] = useState(true)
|
||||
const [error, setError] = useState<string | null>(null)
|
||||
const mountedRef = useRef(true)
|
||||
const requestSeqRef = useRef(0)
|
||||
|
||||
useEffect(() => {
|
||||
mountedRef.current = true
|
||||
return () => {
|
||||
mountedRef.current = false
|
||||
}
|
||||
}, [])
|
||||
|
||||
const load = useCallback(async (): Promise<void> => {
|
||||
if (!user) {
|
||||
const seq = ++requestSeqRef.current
|
||||
const isStale = (): boolean => !mountedRef.current || requestSeqRef.current !== seq
|
||||
|
||||
if (!userId) {
|
||||
if (!authLoading) {
|
||||
setSnapshot(null)
|
||||
setError('세션이 만료되었습니다. 다시 로그인해 주세요.')
|
||||
|
|
@ -90,14 +103,19 @@ export default function DashboardPage(): React.ReactElement {
|
|||
setError(null)
|
||||
try {
|
||||
const client = getSupabaseBrowserClient() as unknown as D3roSupabaseClient
|
||||
setSnapshot(await loadDashboardSnapshot(client, user.id))
|
||||
const nextSnapshot = await loadDashboardSnapshot(client, userId)
|
||||
if (isStale()) return
|
||||
setSnapshot(nextSnapshot)
|
||||
} catch (requestError) {
|
||||
if (isStale()) return
|
||||
setSnapshot(null)
|
||||
setError(dashboardMessage(requestError))
|
||||
} finally {
|
||||
setLoading(false)
|
||||
if (!isStale()) {
|
||||
setLoading(false)
|
||||
}
|
||||
}
|
||||
}, [authLoading, user])
|
||||
}, [authLoading, userId])
|
||||
|
||||
useEffect(() => {
|
||||
void load()
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ import {
|
|||
} from '@mui/material'
|
||||
import { ArrowLeft, Check, Copy, RefreshCw, Save, Star, Trash2 } from 'lucide-react'
|
||||
import type { D3roSupabaseClient, HistoryEntry } from '@d3ro/api-client'
|
||||
import { formatDurationClockFromSeconds } from '@d3ro/core/format'
|
||||
import { MetalCard, PhosphorText } from '@d3ro/ui/components/ds'
|
||||
import { d3roFontMono, d3roPalette } from '@d3ro/ui/theme'
|
||||
import { getSupabaseBrowserClient } from '@/lib/supabase-browser'
|
||||
|
|
@ -330,11 +331,5 @@ function Metadata({ label, value }: { label: string; value: string }): React.Rea
|
|||
)
|
||||
}
|
||||
|
||||
function formatDuration(durationSeconds: number): string {
|
||||
const totalSeconds = Number.isFinite(durationSeconds) ? Math.max(0, Math.floor(durationSeconds)) : 0
|
||||
const hours = Math.floor(totalSeconds / 3600)
|
||||
const minutes = Math.floor((totalSeconds % 3600) / 60)
|
||||
const seconds = totalSeconds % 60
|
||||
if (hours > 0) return `${hours}:${String(minutes).padStart(2, '0')}:${String(seconds).padStart(2, '0')}`
|
||||
return `${minutes}:${String(seconds).padStart(2, '0')}`
|
||||
}
|
||||
const formatDuration = (durationSeconds: number): string =>
|
||||
formatDurationClockFromSeconds(durationSeconds, { showHours: true })
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
import Link from 'next/link'
|
||||
import React, { useCallback, useEffect, useRef, useState } from 'react'
|
||||
import { formatDurationClockFromSeconds } from '@d3ro/core/format'
|
||||
import {
|
||||
Alert,
|
||||
Box,
|
||||
|
|
@ -387,11 +388,5 @@ export default function HistoryPage(): React.ReactElement {
|
|||
)
|
||||
}
|
||||
|
||||
function formatDuration(durationSeconds: number): string {
|
||||
const totalSeconds = Number.isFinite(durationSeconds) ? Math.max(0, Math.floor(durationSeconds)) : 0
|
||||
const hours = Math.floor(totalSeconds / 3600)
|
||||
const minutes = Math.floor((totalSeconds % 3600) / 60)
|
||||
const seconds = totalSeconds % 60
|
||||
if (hours > 0) return `${hours}:${String(minutes).padStart(2, '0')}:${String(seconds).padStart(2, '0')}`
|
||||
return `${minutes}:${String(seconds).padStart(2, '0')}`
|
||||
}
|
||||
const formatDuration = (durationSeconds: number): string =>
|
||||
formatDurationClockFromSeconds(durationSeconds, { showHours: true })
|
||||
|
|
|
|||
|
|
@ -1,43 +1,17 @@
|
|||
// apps/web/src/app/(app)/teams/page.tsx
|
||||
// 팀 리스트 + 새 팀 생성 — auth/Sidebar는 (app)/layout.tsx가 제공
|
||||
|
||||
import Link from 'next/link'
|
||||
import { Box, Grid } from '@mui/material'
|
||||
import { MetalCard, PhosphorText } from '@d3ro/ui/components/ds'
|
||||
import { d3roPalette, typoSx } from '@d3ro/ui/theme'
|
||||
import { Box } from '@mui/material'
|
||||
import { PhosphorText } from '@d3ro/ui/components/ds'
|
||||
import { CreateTeamForm } from '@/components/teams/create-team-form'
|
||||
import { TeamCardGrid } from '@/components/teams/team-card-grid'
|
||||
import { getSupabaseServerClient } from '@/lib/supabase-server'
|
||||
import { loadUserTeamsWithCounts, type SupabaseTeamReader, type WebTeamRow } from '@/lib/team-client'
|
||||
|
||||
interface TeamRow {
|
||||
id: string
|
||||
name: string
|
||||
avatar_url: string | null
|
||||
member_count: number
|
||||
role: 'owner' | 'admin' | 'member'
|
||||
}
|
||||
|
||||
async function loadTeams(): Promise<TeamRow[]> {
|
||||
async function loadTeams(): Promise<WebTeamRow[]> {
|
||||
try {
|
||||
const supabase = await getSupabaseServerClient()
|
||||
// 본인이 속한 팀만 RLS로 자동 필터링
|
||||
const { data: members } = await supabase
|
||||
.from('team_members')
|
||||
.select('team_id, role, teams(id, name, avatar_url)')
|
||||
|
||||
if (!members) return []
|
||||
|
||||
return members
|
||||
.filter((m: { teams: unknown }) => m.teams !== null)
|
||||
.map((m: { team_id: string; role: string; teams: unknown }) => {
|
||||
const team = m.teams as { id: string; name: string; avatar_url: string | null }
|
||||
return {
|
||||
id: team.id,
|
||||
name: team.name,
|
||||
avatar_url: team.avatar_url,
|
||||
member_count: 0, // count는 별도 query 필요. MVP에서는 생략
|
||||
role: m.role as 'owner' | 'admin' | 'member'
|
||||
}
|
||||
})
|
||||
return await loadUserTeamsWithCounts(supabase as unknown as SupabaseTeamReader)
|
||||
} catch {
|
||||
return []
|
||||
}
|
||||
|
|
@ -56,50 +30,7 @@ export default async function TeamsPage(): Promise<React.ReactElement> {
|
|||
<CreateTeamForm />
|
||||
</Box>
|
||||
|
||||
{teams.length === 0 ? (
|
||||
<MetalCard sx={{ p: 6, textAlign: 'center', color: d3roPalette.text.muted }}>
|
||||
아직 가입한 팀이 없습니다. 위에서 새 팀을 만들거나, 다른 팀에서 초대를 받아보세요.
|
||||
</MetalCard>
|
||||
) : (
|
||||
<Grid container spacing={3}>
|
||||
{teams.map((team) => (
|
||||
<Grid size={{ xs: 12, sm: 6, md: 4 }} key={team.id}>
|
||||
<Link href={`/teams/${team.id}`} style={{ textDecoration: 'none' }}>
|
||||
<MetalCard sx={{ p: 3, cursor: 'pointer', minHeight: 140 }}>
|
||||
<Box sx={{ ...typoSx('value'), color: d3roPalette.text.primary, mb: 1 }}>
|
||||
{team.name}
|
||||
</Box>
|
||||
<Box
|
||||
sx={{
|
||||
display: 'inline-block',
|
||||
px: 1.5,
|
||||
py: 0.5,
|
||||
borderRadius: 1,
|
||||
fontSize: 11,
|
||||
fontWeight: 500,
|
||||
bgcolor:
|
||||
team.role === 'owner'
|
||||
? d3roPalette.tag.purpleBg
|
||||
: team.role === 'admin'
|
||||
? d3roPalette.tag.orangeBg
|
||||
: d3roPalette.tag.greenBg,
|
||||
color:
|
||||
team.role === 'owner'
|
||||
? d3roPalette.tag.purple
|
||||
: team.role === 'admin'
|
||||
? d3roPalette.tag.orange
|
||||
: d3roPalette.tag.green,
|
||||
letterSpacing: 0
|
||||
}}
|
||||
>
|
||||
{team.role.toUpperCase()}
|
||||
</Box>
|
||||
</MetalCard>
|
||||
</Link>
|
||||
</Grid>
|
||||
))}
|
||||
</Grid>
|
||||
)}
|
||||
<TeamCardGrid teams={teams} />
|
||||
</Box>
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import { Box, Stack, Alert } from '@mui/material'
|
|||
import { useI18n } from '@d3ro/i18n'
|
||||
import { getSupabaseBrowserClient, isSupabaseConfigured } from '@/lib/supabase-browser'
|
||||
import { useAuth } from '@/components/providers/auth-provider'
|
||||
import { LocaleSwitcher } from '@/components/layout/locale-switcher'
|
||||
import { appUrlFor, safeReturnPath } from '@/lib/web-app-url'
|
||||
|
||||
/** (app) 레이아웃이 붙여 보낸 `?next=` — 로그인 뒤 돌아갈 웹앱 내부 경로. */
|
||||
|
|
@ -111,6 +112,9 @@ export default function LoginPage(): React.ReactElement {
|
|||
}}
|
||||
>
|
||||
{/* Header & LED Indicators */}
|
||||
<Box sx={{ display: 'flex', justifyContent: 'flex-end', mb: 1.5 }}>
|
||||
<LocaleSwitcher compact />
|
||||
</Box>
|
||||
<Box sx={{ display: 'flex', flexDirection: 'column', alignItems: 'center', mb: 4 }}>
|
||||
<Box sx={{ display: 'flex', alignItems: 'center', gap: 1.25, mb: 2 }}>
|
||||
<Box
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue