feat: complete release preparation, 10+ ad mediation, CI/CD, and docker deployment
Some checks failed
CI Pipeline / Code Quality & Typecheck (push) Waiting to run
CI Pipeline / Test Suite (macos-latest) (push) Blocked by required conditions
CI Pipeline / Test Suite (ubuntu-latest) (push) Blocked by required conditions
CI Pipeline / Test Suite (windows-latest) (push) Blocked by required conditions
CI Pipeline / Build Validation (admin) (push) Blocked by required conditions
CI Pipeline / Build Validation (desktop) (push) Blocked by required conditions
Deploy Landing Page / deploy (push) Blocked by required conditions
Deploy Landing Page / build (push) Waiting to run
Release & Packaging Pipeline / Build & Publish Admin Docker Image (push) Failing after 8s
Release & Code Signing CA Pipeline / build-and-sign-windows (push) Failing after 1m51s
Build macOS / Build & Package (macOS) (push) Failing after 4s
Build macOS / Build & Package (macOS)-1 (push) Failing after 5s
Release & Code Signing CA Pipeline / build-and-sign-macos (push) Failing after 3s
Release & Packaging Pipeline / Package macOS Desktop App (push) Failing after 4s
Release & Packaging Pipeline / Package Windows Desktop App (push) Failing after 2m28s
Release & Packaging Pipeline / Publish Official GitHub Release (push) Has been skipped

This commit is contained in:
Yun Chan 2026-08-20 11:12:05 +09:00
parent 5cd1de6859
commit 708e20f747
406 changed files with 42464 additions and 6199 deletions

View file

@ -1,201 +1,255 @@
// apps/admin/src/app/(admin)/users/page.tsx
// D3RO Console — Users list
// D3RO Voice — User Directory & CRM Console (Midnight Glass v2)
import { Box } from '@mui/material'
import { C, FONT, panelSx, tableSx, filterBtnSx, statusBadgeSx } from '@/lib/console-theme'
import { getSupabaseServerClient } from '@/lib/supabase-server'
import React from 'react'
import { Box, Typography, Button } from '@mui/material'
import { fetchUsers } from '@/lib/api-server'
import { C, FONT_SANS, FONT_MONO, panelSx, tableSx, filterBtnSx, statusBadgeSx } from '@/lib/console-theme'
import { DoubleBezelCard, TactileBadge } from '@d3ro/ui/components/ds'
import Link from 'next/link'
const PAGE_SIZE = 20
interface UserRow {
id: string
name: string | null
tier: string
role: string
created_at: string
subscription_status: string | null
payment_provider: string | null
}
async function loadUsers(page: number, search: string, tierFilter: string): Promise<{ users: UserRow[]; total: number }> {
const supabase = await getSupabaseServerClient()
const from = page * PAGE_SIZE
const to = from + PAGE_SIZE - 1
const profileQuery = supabase
.from('profiles')
.select('id, name, tier, created_at', { count: 'exact' })
.order('created_at', { ascending: false })
.range(from, to)
if (search) profileQuery.ilike('name', `%${search}%`)
if (tierFilter && tierFilter !== 'all') profileQuery.eq('tier', tierFilter as 'free' | 'pro' | 'pro_plus')
const { data: rawProfiles, count } = await profileQuery
const profiles = (rawProfiles ?? []) as Array<Record<string, unknown>>
const userIds = profiles.map((p) => p.id as string)
const { data: rawSubs } = userIds.length > 0
? await supabase.from('subscriptions').select('user_id, status, payment_provider').in('user_id', userIds)
: { data: [] }
const subMap = new Map(
((rawSubs ?? []) as Array<Record<string, unknown>>).map((s) => [s.user_id as string, s])
)
const { data: rawRoles } = userIds.length > 0
? await supabase.from('profiles').select('id, role').in('id', userIds)
: { data: [] }
const roleMap = new Map(
((rawRoles ?? []) as Array<Record<string, unknown>>).map((r) => [r.id as string, (r.role as string) ?? 'user'])
)
const users: UserRow[] = profiles.map((row) => {
const sub = subMap.get(row.id as string)
return {
id: row.id as string,
name: row.name as string | null,
tier: (row.tier as string) ?? 'free',
role: roleMap.get(row.id as string) ?? 'user',
created_at: row.created_at as string,
subscription_status: (sub?.status as string) ?? null,
payment_provider: (sub?.payment_provider as string) ?? null,
}
})
return { users, total: count ?? 0 }
}
interface PageProps {
searchParams: Promise<{ page?: string; search?: string; tier?: string }>
searchParams: Promise<{ tier?: string; role?: string; q?: string }>
}
export default async function AdminUsersPage({ searchParams }: PageProps): Promise<React.ReactElement> {
const params = await searchParams
const page = parseInt(params.page ?? '0', 10)
const search = params.search ?? ''
const tierFilter = params.tier ?? 'all'
const { users, total } = await loadUsers(page, search, tierFilter)
const totalPages = Math.ceil(total / PAGE_SIZE)
const roleFilter = params.role ?? 'all'
const searchQuery = (params.q ?? '').toLowerCase()
const roleColor = (r: string): string =>
r === 'super_admin' ? C.purple400 : r === 'admin' ? C.green400 : r === 'manager' ? C.orange400 : C.dim
const allUsers = await fetchUsers()
const filteredUsers = allUsers.filter((u) => {
if (tierFilter !== 'all' && u.tier !== tierFilter) return false
if (roleFilter !== 'all' && u.role !== roleFilter) return false
if (searchQuery) {
const matchEmail = u.email.toLowerCase().includes(searchQuery)
const matchName = u.name.toLowerCase().includes(searchQuery)
const matchUid = u.uid.toLowerCase().includes(searchQuery)
if (!matchEmail && !matchName && !matchUid) return false
}
return true
})
return (
<>
{/* Header */}
<Box sx={{
...panelSx,
height: 72, flexShrink: 0,
display: 'flex', alignItems: 'center', px: 4, justifyContent: 'space-between',
}}>
<Box
sx={{
...panelSx,
minHeight: 84,
px: { xs: 2.5, md: 4 },
py: 2,
display: 'flex',
flexWrap: 'wrap',
alignItems: 'center',
justifyContent: 'space-between',
gap: 2,
}}
>
<Box sx={{ display: 'flex', alignItems: 'center', gap: 2 }}>
<Box sx={{ width: 4, height: 24, bgcolor: C.accent, borderRadius: 4 }} />
<Box component="h2" sx={{
fontFamily: FONT, fontSize: '18px', fontWeight: 300,
letterSpacing: '0.15em', textTransform: 'uppercase', color: C.bright, m: 0,
}}>
Users
</Box>
<Box component="span" sx={{
fontFamily: FONT, fontSize: '10px', letterSpacing: '0.1em',
color: C.dim, bgcolor: C.border, px: 1, py: 0.5, borderRadius: '4px',
}}>
{total} TOTAL
<Box
sx={{
width: 4,
height: 32,
borderRadius: '999px',
background: 'linear-gradient(180deg, #3b82f6 0%, #8b5cf6 100%)',
}}
/>
<Box>
<Box sx={{ display: 'flex', alignItems: 'center', gap: 1.5 }}>
<Typography
component="h1"
sx={{
fontFamily: FONT_SANS,
fontSize: '20px',
fontWeight: 700,
color: C.bright,
letterSpacing: '-0.02em',
m: 0,
}}
>
Registered Users & CRM Directory
</Typography>
<TactileBadge tone="mono" mono>
{allUsers.length} REGISTERED
</TactileBadge>
</Box>
<Typography
sx={{
fontFamily: FONT_MONO,
fontSize: '11px',
color: C.dim,
letterSpacing: '0.04em',
mt: 0.25,
}}
>
MULTI-TIER QUOTAS • HARDWARE SESSIONS • ROLES & ACCESS CONTROL
</Typography>
</Box>
</Box>
<Box sx={{ display: 'flex', gap: 1 }}>
{['all', 'free', 'pro', 'pro_plus'].map((t) => (
<Link key={t} href={`/users?tier=${t}&search=${search}`} style={{ textDecoration: 'none' }}>
{/* Tier Filter Pills */}
<Box sx={{ display: 'flex', gap: 1, alignItems: 'center', flexWrap: 'wrap' }}>
{['all', 'pro_plus', 'pro', 'free'].map((t) => (
<Link key={t} href={`/users?tier=${t}&role=${roleFilter}`} style={{ textDecoration: 'none' }}>
<Box sx={filterBtnSx(tierFilter === t)}>
{t === 'all' ? 'ALL' : t === 'pro_plus' ? 'PRO+' : t.toUpperCase()}
{t === 'pro_plus' ? 'PRO+ VIP' : t.toUpperCase()}
</Box>
</Link>
))}
</Box>
</Box>
{/* Table */}
<Box sx={{ ...panelSx, flex: 1, display: 'flex', flexDirection: 'column', overflow: 'hidden' }}>
<Box className="bg-grid" sx={{ position: 'absolute', inset: 0, opacity: 0.02, pointerEvents: 'none' }} />
<Box sx={{ flex: 1, overflow: 'auto', p: 3, position: 'relative', zIndex: 1 }}>
<Box component="table" sx={tableSx}>
<thead>
<tr>
<th>Name</th>
<th style={{ width: 80 }}>Tier</th>
<th style={{ width: 100 }}>Role</th>
<th style={{ width: 100 }}>Status</th>
<th style={{ width: 100 }}>Provider</th>
<th style={{ width: 110 }}>Joined</th>
</tr>
</thead>
<tbody>
{users.map((u) => (
<tr key={u.id}>
<td>
<Link href={`/users/${u.id}`} style={{ color: C.accent, textDecoration: 'none' }}>
{u.name ?? u.id.substring(0, 8)}
</Link>
</td>
<td>
<Box component="span" sx={statusBadgeSx(
u.tier === 'pro_plus' ? 'purple' : u.tier === 'pro' ? 'green' : 'blue'
)}>
{u.tier === 'pro_plus' ? 'PRO+' : u.tier.toUpperCase()}
</Box>
</td>
<td style={{ color: roleColor(u.role) }}>{u.role.toUpperCase()}</td>
<td>
{u.subscription_status ? (
<Box component="span" sx={statusBadgeSx(
u.subscription_status === 'active' ? 'green' : u.subscription_status === 'expired' ? 'red' : 'orange'
)}>
{u.subscription_status.toUpperCase()}
</Box>
) : (
<span style={{ color: C.dim }}>-</span>
)}
</td>
<td style={{ color: C.dim }}>{u.payment_provider ?? '-'}</td>
<td style={{ color: C.dim, whiteSpace: 'nowrap' }}>{new Date(u.created_at).toLocaleDateString()}</td>
</tr>
))}
{users.length === 0 && (
<tr><td colSpan={6} style={{ textAlign: 'center', color: C.dim, padding: '32px 0' }}>No users found</td></tr>
)}
</tbody>
</Box>
{/* Main Table Card */}
<DoubleBezelCard bezelPadding="6px" innerPadding="24px">
<Box sx={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', mb: 2.5 }}>
<Typography sx={{ fontFamily: FONT_SANS, fontSize: '16px', fontWeight: 700, color: C.bright }}>
User Account Profiles & Quota Consumption
</Typography>
<Typography sx={{ fontFamily: FONT_MONO, fontSize: '11px', color: C.dim }}>
SHOWING {filteredUsers.length} OF {allUsers.length} USERS
</Typography>
</Box>
{/* Pagination */}
{totalPages > 1 && (
<Box sx={{
display: 'flex', justifyContent: 'center', gap: 0.5,
py: 2, borderTop: `1px solid ${C.border}`,
position: 'relative', zIndex: 1,
}}>
{Array.from({ length: Math.min(totalPages, 10) }, (_, i) => (
<Link key={i} href={`/users?page=${i}&tier=${tierFilter}&search=${search}`} style={{ textDecoration: 'none' }}>
<Box sx={{
fontFamily: FONT, fontSize: '11px', fontWeight: 500,
width: 28, height: 28,
display: 'flex', alignItems: 'center', justifyContent: 'center',
borderRadius: '4px',
bgcolor: page === i ? C.accent : 'transparent',
color: page === i ? C.bright : C.dim,
border: `1px solid ${page === i ? C.accent : C.border}`,
cursor: 'pointer',
'&:hover': { borderColor: C.dim },
transition: 'all 0.15s',
}}>
{i + 1}
<Box sx={{ overflowX: 'auto' }}>
<Box component="table" sx={tableSx}>
<Box component="thead">
<Box component="tr">
<Box component="th">USER PROFILE</Box>
<Box component="th">TIER</Box>
<Box component="th">ROLE</Box>
<Box component="th">DAILY QUOTA STATUS</Box>
<Box component="th">LAST ACTIVE PLATFORM</Box>
<Box component="th">STATUS</Box>
<Box component="th" sx={{ textAlign: 'right' }}>ACTION</Box>
</Box>
</Box>
<Box component="tbody">
{filteredUsers.length === 0 ? (
<Box component="tr">
<Box component="td" colSpan={7} sx={{ textAlign: 'center', color: C.dim, py: 4 }}>
NO USERS MATCHING THE SELECTED FILTERS
</Box>
</Box>
</Link>
))}
) : (
filteredUsers.map((u) => {
const isProPlus = u.tier === 'pro_plus'
const isPro = u.tier === 'pro'
return (
<Box component="tr" key={u.id}>
{/* User Profile */}
<Box component="td">
<Link href={`/users/${u.id}`} style={{ textDecoration: 'none' }}>
<Box sx={{ display: 'flex', alignItems: 'center', gap: 1.5 }}>
<Box
sx={{
width: 34,
height: 34,
borderRadius: '10px',
background: isProPlus
? 'linear-gradient(135deg, #a855f7 0%, #3b82f6 100%)'
: isPro
? 'linear-gradient(135deg, #10b981 0%, #3b82f6 100%)'
: 'linear-gradient(135deg, #64748b 0%, #475569 100%)',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
color: '#ffffff',
fontWeight: 700,
fontSize: '13px',
boxShadow: isProPlus ? '0 0 12px rgba(168, 85, 247, 0.4)' : 'none',
}}
>
{u.name.charAt(0)}
</Box>
<Box>
<Typography sx={{ fontFamily: FONT_SANS, fontSize: '13px', fontWeight: 600, color: C.bright }}>
{u.name}
</Typography>
<Typography sx={{ fontFamily: FONT_MONO, fontSize: '11px', color: C.dim }}>
{u.email}
</Typography>
</Box>
</Box>
</Link>
</Box>
{/* Tier Badge */}
<Box component="td">
<Box component="span" sx={statusBadgeSx(isProPlus ? 'purple' : isPro ? 'green' : 'blue')}>
{isProPlus ? 'PRO+ VIP' : u.tier.toUpperCase()}
</Box>
</Box>
{/* Role Badge */}
<Box component="td">
<Typography sx={{ fontFamily: FONT_MONO, fontSize: '11px', color: u.role === 'super_admin' ? C.purple400 : u.role === 'admin' ? C.cyanLight : C.dim }}>
{u.role.toUpperCase()}
</Typography>
</Box>
{/* Daily Quota Status */}
<Box component="td">
<Box sx={{ display: 'flex', flexDirection: 'column', gap: 0.5 }}>
<Box sx={{ display: 'flex', justifyContent: 'space-between', fontSize: '10px', fontFamily: FONT_MONO }}>
<span style={{ color: C.dim }}>Dictations:</span>
<strong style={{ color: isProPlus || isPro ? C.green400 : C.bright }}>
{u.dailyUsage.dictations} / {u.dailyUsage.dictationsMax === 9999 ? '∞' : u.dailyUsage.dictationsMax}
</strong>
</Box>
<Box sx={{ display: 'flex', justifyContent: 'space-between', fontSize: '10px', fontFamily: FONT_MONO }}>
<span style={{ color: C.dim }}>LLM Calls:</span>
<strong style={{ color: C.bright }}>
{u.dailyUsage.llmCalls} / {u.dailyUsage.llmCallsMax === 9999 ? '∞' : u.dailyUsage.llmCallsMax}
</strong>
</Box>
</Box>
</Box>
{/* Last Active Platform */}
<Box component="td" sx={{ fontFamily: FONT_MONO, fontSize: '11px', color: C.text }}>
{u.lastActiveDevice}
</Box>
{/* Status */}
<Box component="td">
<Box component="span" sx={statusBadgeSx(u.isActive ? 'green' : 'red')}>
{u.isActive ? 'ACTIVE' : 'DISABLED'}
</Box>
</Box>
{/* Action */}
<Box component="td" sx={{ textAlign: 'right' }}>
<Link href={`/users/${u.id}`} style={{ textDecoration: 'none' }}>
<Button
size="small"
variant="outlined"
sx={{
fontFamily: FONT_SANS,
fontSize: '11px',
fontWeight: 600,
color: C.accentLight,
borderColor: C.borderHl,
borderRadius: '8px',
textTransform: 'none',
px: 1.5,
'&:hover': { bgcolor: 'rgba(59, 130, 246, 0.15)', borderColor: C.accentLight },
}}
>
Manage →
</Button>
</Link>
</Box>
</Box>
)
})
)}
</Box>
</Box>
)}
</Box>
</Box>
</DoubleBezelCard>
</>
)
}