mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-12-02 05:54:44 +00:00
initial commit
This commit is contained in:
@@ -0,0 +1,95 @@
|
||||
import { DualSidebar, DualSidebarItem } from '@/ui/components/dual-sidebar'
|
||||
import { NotificationList } from '@/ui/components/notification-list'
|
||||
import { NotificationFillIcon } from '@/ui/components/ui/icons'
|
||||
import { Toaster } from '@/ui/components/ui/sonner'
|
||||
import { UploadCloudIcon } from '@/ui/components/ui/upload-cloud'
|
||||
import { UploadTasks } from '@/ui/components/upload-tasks'
|
||||
import { useAuthStore } from '@/ui/stores/auth'
|
||||
import { useTeamContextStore } from '@/ui/stores/team-context'
|
||||
import { useUploadStore } from '@/ui/stores/upload'
|
||||
import {
|
||||
createRootRouteWithContext,
|
||||
Outlet,
|
||||
useNavigate,
|
||||
useRouterState,
|
||||
} from '@tanstack/react-router'
|
||||
import { HomeIcon } from 'lucide-react'
|
||||
import { useEffect } from 'react'
|
||||
|
||||
function RootComponent() {
|
||||
const user = useAuthStore((state) => state.user)
|
||||
const { uploading } = useUploadStore()
|
||||
const pathname = useRouterState({ select: (s) => s.location.pathname })
|
||||
const navigate = useNavigate()
|
||||
|
||||
const showSidebar = user && (pathname.startsWith('/teams/') || pathname.startsWith('/projects/'))
|
||||
|
||||
if (!showSidebar) {
|
||||
return <Outlet />
|
||||
}
|
||||
|
||||
// Extract teamId from pathname if possible
|
||||
// Matches /teams/:teamId
|
||||
const teamIdMatch = pathname.match(/^\/teams\/([^/]+)/)
|
||||
const teamId = teamIdMatch ? teamIdMatch[1] : null
|
||||
|
||||
const projectIdMatch = pathname.match(/^\/projects\/([^/]+)/)
|
||||
const projectId = projectIdMatch ? projectIdMatch[1] : null
|
||||
|
||||
const { teamId: storedTeamId, setTeamId, ensureTeamIdForProject } = useTeamContextStore()
|
||||
|
||||
useEffect(() => {
|
||||
if (teamId) {
|
||||
setTeamId(teamId)
|
||||
} else if (projectId) {
|
||||
ensureTeamIdForProject(projectId)
|
||||
}
|
||||
}, [teamId, projectId, setTeamId, ensureTeamIdForProject])
|
||||
|
||||
return (
|
||||
<>
|
||||
<Toaster />
|
||||
<DualSidebar>
|
||||
<DualSidebarItem
|
||||
icon={<HomeIcon />}
|
||||
label="Dashboard"
|
||||
onItemClick={() => {
|
||||
if (storedTeamId) {
|
||||
navigate({
|
||||
to: '/teams/$teamId',
|
||||
params: { teamId: storedTeamId },
|
||||
})
|
||||
}
|
||||
}}
|
||||
/>
|
||||
<DualSidebarItem icon={<NotificationFillIcon />} label="Notifications">
|
||||
<NotificationList />
|
||||
</DualSidebarItem>
|
||||
<DualSidebarItem
|
||||
icon={
|
||||
<UploadCloudIcon
|
||||
uploading={uploading > 0}
|
||||
className={uploading > 0 ? 'text-blue-500' : ''}
|
||||
/>
|
||||
}
|
||||
label="Uploads"
|
||||
>
|
||||
<UploadTasks />
|
||||
</DualSidebarItem>
|
||||
</DualSidebar>
|
||||
<main className="md:pl-16">
|
||||
<Outlet />
|
||||
</main>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
import { QueryClient } from '@tanstack/react-query'
|
||||
|
||||
interface MyRouterContext {
|
||||
queryClient: QueryClient
|
||||
}
|
||||
|
||||
export const Route = createRootRouteWithContext<MyRouterContext>()({
|
||||
component: RootComponent,
|
||||
})
|
||||
@@ -0,0 +1,25 @@
|
||||
import { TeamSelector } from '@/ui/components/team-selector'
|
||||
import { useAuthStore } from '@/ui/stores/auth'
|
||||
import { createFileRoute, useNavigate } from '@tanstack/react-router'
|
||||
import { useEffect } from 'react'
|
||||
|
||||
function IndexPage() {
|
||||
const user = useAuthStore((state) => state.user)
|
||||
const navigate = useNavigate()
|
||||
|
||||
useEffect(() => {
|
||||
if (!user) {
|
||||
navigate({
|
||||
to: '/login',
|
||||
})
|
||||
}
|
||||
}, [user, navigate])
|
||||
|
||||
if (!user) return null
|
||||
|
||||
return <TeamSelector />
|
||||
}
|
||||
|
||||
export const Route = createFileRoute('/')({
|
||||
component: IndexPage,
|
||||
})
|
||||
@@ -0,0 +1,133 @@
|
||||
import { client } from '@/ui/api/client'
|
||||
import { useQuery } from '@tanstack/react-query'
|
||||
import { Button } from '@/ui/components/ui/button'
|
||||
import {
|
||||
Card,
|
||||
CardContent,
|
||||
CardDescription,
|
||||
CardFooter,
|
||||
CardHeader,
|
||||
CardTitle,
|
||||
} from '@/ui/components/ui/card'
|
||||
import { Input } from '@/ui/components/ui/input'
|
||||
import { Label } from '@/ui/components/ui/label'
|
||||
import { useAuthStore } from '@/ui/stores/auth'
|
||||
import { zodResolver } from '@hookform/resolvers/zod'
|
||||
import { createFileRoute, redirect, useNavigate } from '@tanstack/react-router'
|
||||
import { useEffect, useState } from 'react'
|
||||
import { useForm } from 'react-hook-form'
|
||||
import { z } from 'zod'
|
||||
import { signIn } from '@/ui/lib/auth-client'
|
||||
|
||||
const loginSchema = z.object({
|
||||
email: z.string().email('Invalid email address'),
|
||||
password: z.string().min(1, 'Password is required'),
|
||||
})
|
||||
|
||||
type LoginSchema = z.infer<typeof loginSchema>
|
||||
|
||||
function LoginPage() {
|
||||
const navigate = useNavigate()
|
||||
const setUser = useAuthStore((state) => state.setUser)
|
||||
const [error, setError] = useState<string | null>(null)
|
||||
const [loading, setLoading] = useState(false)
|
||||
|
||||
const { data: signupInfo } = useQuery({
|
||||
queryKey: ['/signup-info'],
|
||||
queryFn: async () => {
|
||||
const res = await client.api['signup-info'].$get()
|
||||
if (!res.ok) throw new Error('Failed to fetch signup info')
|
||||
return await res.json()
|
||||
},
|
||||
})
|
||||
|
||||
useEffect(() => {
|
||||
if (signupInfo?.userCount === 0) {
|
||||
navigate({ to: '/signup', search: { inviteCode: '' } })
|
||||
}
|
||||
}, [signupInfo, navigate])
|
||||
|
||||
const form = useForm<LoginSchema>({
|
||||
resolver: zodResolver(loginSchema),
|
||||
})
|
||||
|
||||
const onSubmit = async (data: LoginSchema) => {
|
||||
setLoading(true)
|
||||
setError(null)
|
||||
const { data: session, error: signInError } = await signIn.email({
|
||||
email: data.email,
|
||||
password: data.password,
|
||||
})
|
||||
|
||||
setLoading(false)
|
||||
if (signInError) {
|
||||
setError(signInError.message || 'Invalid credentials')
|
||||
return
|
||||
}
|
||||
|
||||
if (session) {
|
||||
setUser(session.user)
|
||||
navigate({ to: '/' })
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="flex items-center justify-center min-h-screen">
|
||||
<Card className="w-full max-w-sm">
|
||||
<CardHeader>
|
||||
<CardTitle>Login</CardTitle>
|
||||
<CardDescription>Enter your credentials to access your account.</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<form onSubmit={form.handleSubmit(onSubmit)} className="space-y-4">
|
||||
{error && <p className="text-red-500 text-sm text-center">{error}</p>}
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="email">Email</Label>
|
||||
<Input
|
||||
id="email"
|
||||
{...form.register('email')}
|
||||
placeholder="you@example.com"
|
||||
type="email"
|
||||
/>
|
||||
{form.formState.errors.email && (
|
||||
<p className="text-red-500 text-sm">{form.formState.errors.email.message}</p>
|
||||
)}
|
||||
</div>
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="password">Password</Label>
|
||||
<Input
|
||||
id="password"
|
||||
type="password"
|
||||
{...form.register('password')}
|
||||
placeholder="Your password"
|
||||
/>
|
||||
{form.formState.errors.password && (
|
||||
<p className="text-red-500 text-sm">{form.formState.errors.password.message}</p>
|
||||
)}
|
||||
</div>
|
||||
<Button type="submit" className="w-full" disabled={loading}>
|
||||
{loading ? 'Logging in...' : 'Login'}
|
||||
</Button>
|
||||
</form>
|
||||
</CardContent>
|
||||
<CardFooter className="text-center text-sm">
|
||||
Don't have an account?{' '}
|
||||
<a href="/signup" className="text-blue-500 hover:underline">
|
||||
Sign up
|
||||
</a>
|
||||
</CardFooter>
|
||||
</Card>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export const Route = createFileRoute('/login')({
|
||||
component: LoginPage,
|
||||
beforeLoad: () => {
|
||||
if (useAuthStore.getState().user) {
|
||||
throw redirect({
|
||||
to: '/',
|
||||
})
|
||||
}
|
||||
},
|
||||
})
|
||||
@@ -0,0 +1,211 @@
|
||||
import { InferRequestType, InferResponseType } from 'hono/client'
|
||||
import { useMutation } from '@tanstack/react-query'
|
||||
import { client } from '@/ui/api/client'
|
||||
import { BreadcrumbNav } from '@/ui/components/breadcrumb-nav'
|
||||
import { FileViewer } from '@/ui/components/file-viewer'
|
||||
import { FileViewerLeftSidebar } from '@/ui/components/file-viewer-left-sidebar'
|
||||
import { FileViewerRightSidebar } from '@/ui/components/file-viewer-right-sidebar'
|
||||
import { ResizeHandle } from '@/ui/components/resize-handle'
|
||||
import { useMemberStore } from '@/ui/stores/members'
|
||||
import { useTeamContextStore } from '@/ui/stores/team-context'
|
||||
import { useUiStore } from '@/ui/stores/ui'
|
||||
import { type Annotation } from '@/ui/types'
|
||||
|
||||
import { keepPreviousData, useQuery, useQueryClient } from '@tanstack/react-query'
|
||||
import { createFileRoute } from '@tanstack/react-router'
|
||||
import { Loader2 } from 'lucide-react'
|
||||
import { useEffect, useState, useRef } from 'react'
|
||||
import type { CommentInfo, AssetInfo } from '@/dtos/asset'
|
||||
import type Player from 'video.js/dist/types/player'
|
||||
|
||||
function FileViewPage() {
|
||||
const { projectId, fileId } = Route.useParams()
|
||||
const videoRef = useRef<Player | null>(null)
|
||||
const {
|
||||
fileViewRightSidebarCollapsed: isRightSidebarCollapsed,
|
||||
setFileViewRightSidebarCollapsed: setIsRightSidebarCollapsed,
|
||||
fileViewLeftSidebarCollapsed: isLeftSidebarCollapsed,
|
||||
setFileViewLeftSidebarCollapsed: setIsLeftSidebarCollapsed,
|
||||
} = useUiStore()
|
||||
const { teamId, ensureTeamIdForProject } = useTeamContextStore()
|
||||
const [leftSidebarWidth, setLeftSidebarWidth] = useState(280)
|
||||
const [rightSidebarWidth, setRightSidebarWidth] = useState(360)
|
||||
const [annotations, setAnnotations] = useState<Annotation[]>([])
|
||||
const $patchMetadata = client.api.teams[':teamId'].files[':fileId'].metadata.$patch
|
||||
const { mutate: patchMetadata } = useMutation<
|
||||
InferResponseType<typeof $patchMetadata>,
|
||||
Error,
|
||||
InferRequestType<typeof $patchMetadata>
|
||||
>({
|
||||
mutationFn: async (request) => {
|
||||
const res = await $patchMetadata(request)
|
||||
if (!res.ok) throw new Error('Failed to patch metadata')
|
||||
return (await res.json()) as unknown as InferResponseType<typeof $patchMetadata>
|
||||
},
|
||||
})
|
||||
const queryClient = useQueryClient()
|
||||
const { members, fetchMembers } = useMemberStore()
|
||||
|
||||
useEffect(() => {
|
||||
ensureTeamIdForProject(projectId)
|
||||
}, [projectId, ensureTeamIdForProject])
|
||||
|
||||
useEffect(() => {
|
||||
if (teamId) {
|
||||
fetchMembers(teamId, true)
|
||||
}
|
||||
}, [teamId, fetchMembers])
|
||||
|
||||
const {
|
||||
data: fileData,
|
||||
isLoading,
|
||||
isError,
|
||||
isFetching,
|
||||
} = useQuery({
|
||||
queryKey: ['teams', teamId, 'files', fileId],
|
||||
queryFn: async () => {
|
||||
const res = await client.api.teams[':teamId'].files[':fileId'].$get({
|
||||
param: { teamId: teamId!, fileId: fileId },
|
||||
})
|
||||
if (!res.ok) throw new Error('Failed to fetch file')
|
||||
return await res.json()
|
||||
},
|
||||
enabled: !!teamId,
|
||||
placeholderData: keepPreviousData,
|
||||
})
|
||||
|
||||
const { data: projectInfo } = useQuery({
|
||||
queryKey: ['projects', projectId],
|
||||
queryFn: async () => {
|
||||
const res = await client.api.projects[':projectId'].$get({
|
||||
param: { projectId: projectId },
|
||||
})
|
||||
if (!res.ok) throw new Error('Failed to fetch project')
|
||||
return await res.json()
|
||||
},
|
||||
})
|
||||
|
||||
if (isLoading && !fileData) {
|
||||
return <div>Loading...</div>
|
||||
}
|
||||
|
||||
if (isError || !fileData || !projectInfo || !teamId) {
|
||||
return <div>File not found.</div>
|
||||
}
|
||||
|
||||
const handleSaveField = (fieldId: string, value: unknown) => {
|
||||
if (!teamId) return
|
||||
patchMetadata(
|
||||
{
|
||||
param: { teamId: teamId, fileId: fileId },
|
||||
json: [{ key: fieldId, value }] as InferRequestType<typeof $patchMetadata>['json'],
|
||||
},
|
||||
{
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: ['teams', teamId, 'files', fileId],
|
||||
})
|
||||
},
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
const handleCommentSelect = (comment: CommentInfo) => {
|
||||
const newAnnotations = comment.annotations as Annotation[]
|
||||
if (newAnnotations && newAnnotations.length > 0) {
|
||||
setAnnotations(newAnnotations)
|
||||
if (videoRef.current) {
|
||||
videoRef.current.pause()
|
||||
}
|
||||
} else {
|
||||
setAnnotations([])
|
||||
}
|
||||
}
|
||||
|
||||
const handlePlay = () => {
|
||||
setAnnotations([])
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="flex h-screen flex-col bg-background">
|
||||
<BreadcrumbNav
|
||||
teamId={teamId}
|
||||
projectId={projectId}
|
||||
projectName={projectInfo.name ?? ''}
|
||||
ancestorFolders={fileData.ancestorFolders ?? []}
|
||||
currentAsset={{
|
||||
name: fileData.name,
|
||||
type: 'file',
|
||||
version: fileData.type === 'version_stack' ? fileData.fileCount : undefined,
|
||||
}}
|
||||
isRootFolder={false}
|
||||
isLeftSidebarCollapsed={isLeftSidebarCollapsed}
|
||||
onLeftSidebarToggle={() => setIsLeftSidebarCollapsed(!isLeftSidebarCollapsed)}
|
||||
isRightSidebarCollapsed={isRightSidebarCollapsed}
|
||||
onRightSidebarToggle={() => setIsRightSidebarCollapsed(!isRightSidebarCollapsed)}
|
||||
/>
|
||||
<div className="flex flex-1 overflow-hidden">
|
||||
{!isLeftSidebarCollapsed && (
|
||||
<>
|
||||
<div style={{ width: leftSidebarWidth }} className="flex-shrink-0">
|
||||
<FileViewerLeftSidebar
|
||||
teamId={teamId!}
|
||||
projectId={projectId}
|
||||
currentAssetId={fileId}
|
||||
parentFolderId={
|
||||
fileData.ancestorFolders?.[fileData.ancestorFolders.length - 1]?.id ??
|
||||
projectInfo.rootFolder ??
|
||||
''
|
||||
}
|
||||
onCollapse={() => setIsLeftSidebarCollapsed(true)}
|
||||
/>
|
||||
</div>
|
||||
<ResizeHandle
|
||||
onResize={(delta) => {
|
||||
setLeftSidebarWidth((prev) => Math.max(200, Math.min(500, prev + delta)))
|
||||
}}
|
||||
className="hidden md:block"
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
<div className="flex-1 relative">
|
||||
{isFetching && (
|
||||
<div className="absolute inset-0 z-10 flex items-center justify-center bg-background/50">
|
||||
<Loader2 className="h-8 w-8 animate-spin text-foreground" />
|
||||
</div>
|
||||
)}
|
||||
<FileViewer
|
||||
file={fileData as unknown as AssetInfo}
|
||||
videoRef={videoRef}
|
||||
onPlay={handlePlay}
|
||||
annotations={annotations}
|
||||
/>
|
||||
</div>
|
||||
{!isRightSidebarCollapsed && (
|
||||
<>
|
||||
<ResizeHandle
|
||||
onResize={(delta) => {
|
||||
setRightSidebarWidth((prev) => Math.max(240, Math.min(600, prev - delta)))
|
||||
}}
|
||||
className="hidden md:block"
|
||||
/>
|
||||
<div style={{ width: rightSidebarWidth }} className="flex-shrink-0">
|
||||
<FileViewerRightSidebar
|
||||
teamId={teamId!}
|
||||
projectId={projectId}
|
||||
file={fileData as unknown as AssetInfo}
|
||||
onSaveField={handleSaveField}
|
||||
members={members}
|
||||
onCommentSelect={handleCommentSelect}
|
||||
/>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export const Route = createFileRoute('/projects/$projectId/files/$fileId')({
|
||||
component: FileViewPage,
|
||||
})
|
||||
@@ -0,0 +1,63 @@
|
||||
import { client } from '@/ui/api/client'
|
||||
import FileSystemManager from '@/ui/components/file-system-manager'
|
||||
import { useTeamContextStore } from '@/ui/stores/team-context'
|
||||
import { useQuery, useSuspenseQuery } from '@tanstack/react-query'
|
||||
import { createFileRoute } from '@tanstack/react-router'
|
||||
import { useEffect } from 'react'
|
||||
|
||||
const projectInfoQueryOptions = (projectId: string) => ({
|
||||
queryKey: ['projects', projectId],
|
||||
queryFn: async () => {
|
||||
const res = await client.api.projects[':projectId'].$get({
|
||||
param: { projectId: projectId },
|
||||
})
|
||||
if (!res.ok) throw new Error('Failed to fetch project')
|
||||
return await res.json()
|
||||
},
|
||||
})
|
||||
|
||||
function FolderPage() {
|
||||
const { projectId, folderId } = Route.useParams()
|
||||
const { teamId, ensureTeamIdForProject } = useTeamContextStore()
|
||||
|
||||
useEffect(() => {
|
||||
ensureTeamIdForProject(projectId)
|
||||
}, [projectId, ensureTeamIdForProject])
|
||||
|
||||
const { data: projectInfo } = useSuspenseQuery(projectInfoQueryOptions(projectId))
|
||||
|
||||
const rootFolderId = projectInfo?.rootFolder
|
||||
|
||||
const { data: rootFolder } = useQuery({
|
||||
queryKey: ['folders', teamId!, rootFolderId!],
|
||||
queryFn: () =>
|
||||
(async () => {
|
||||
const res = await client.api.teams[':teamId'].folders[':folderId'].$get({
|
||||
param: { teamId: teamId!, folderId: rootFolderId! },
|
||||
})
|
||||
return await res.json()
|
||||
})(),
|
||||
enabled: !!teamId && !!rootFolderId,
|
||||
})
|
||||
|
||||
if (!teamId || !rootFolderId || !rootFolder) {
|
||||
return <div>Loading project...</div>
|
||||
}
|
||||
|
||||
return (
|
||||
<FileSystemManager
|
||||
teamId={teamId}
|
||||
projectId={projectId}
|
||||
projectName={projectInfo.name ?? ''}
|
||||
assetId={folderId}
|
||||
rootFolderId={rootFolderId}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
export const Route = createFileRoute('/projects/$projectId/folders/$folderId')({
|
||||
component: FolderPage,
|
||||
loader: ({ context: { queryClient }, params: { projectId } }) =>
|
||||
queryClient.ensureQueryData(projectInfoQueryOptions(projectId)),
|
||||
pendingComponent: () => <div>Loading project...</div>,
|
||||
})
|
||||
@@ -0,0 +1,63 @@
|
||||
import { client } from '@/ui/api/client'
|
||||
import FileSystemManager from '@/ui/components/file-system-manager'
|
||||
import { useTeamContextStore } from '@/ui/stores/team-context'
|
||||
import { useQuery, useSuspenseQuery } from '@tanstack/react-query'
|
||||
import { createFileRoute } from '@tanstack/react-router'
|
||||
import { useEffect } from 'react'
|
||||
|
||||
const projectInfoQueryOptions = (projectId: string) => ({
|
||||
queryKey: ['projects', projectId],
|
||||
queryFn: async () => {
|
||||
const res = await client.api.projects[':projectId'].$get({
|
||||
param: { projectId: projectId },
|
||||
})
|
||||
if (!res.ok) throw new Error('failed to fetch project')
|
||||
return await res.json()
|
||||
},
|
||||
})
|
||||
|
||||
function ProjectPage() {
|
||||
const { projectId } = Route.useParams()
|
||||
const { teamId, ensureTeamIdForProject } = useTeamContextStore()
|
||||
|
||||
useEffect(() => {
|
||||
ensureTeamIdForProject(projectId)
|
||||
}, [projectId, ensureTeamIdForProject])
|
||||
|
||||
const { data: projectInfo } = useSuspenseQuery(projectInfoQueryOptions(projectId))
|
||||
|
||||
const rootFolderId = projectInfo?.rootFolder
|
||||
|
||||
const { data: rootFolder } = useQuery({
|
||||
queryKey: ['folders', teamId!, rootFolderId!],
|
||||
queryFn: async () => {
|
||||
const res = await client.api.teams[':teamId'].folders[':folderId'].$get({
|
||||
param: { teamId: teamId!, folderId: rootFolderId! },
|
||||
})
|
||||
if (!res.ok) throw new Error('failed to fetch folder')
|
||||
return await res.json()
|
||||
},
|
||||
enabled: !!teamId && !!rootFolderId,
|
||||
})
|
||||
|
||||
if (!teamId || !rootFolderId || !rootFolder) {
|
||||
return <div>Loading project...</div>
|
||||
}
|
||||
|
||||
return (
|
||||
<FileSystemManager
|
||||
teamId={teamId}
|
||||
projectId={projectId}
|
||||
projectName={projectInfo.name ?? ''}
|
||||
assetId={rootFolderId}
|
||||
rootFolderId={rootFolderId}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
export const Route = createFileRoute('/projects/$projectId/')({
|
||||
component: ProjectPage,
|
||||
loader: ({ context: { queryClient }, params: { projectId } }) =>
|
||||
queryClient.ensureQueryData(projectInfoQueryOptions(projectId)),
|
||||
pendingComponent: () => <div>Loading project...</div>,
|
||||
})
|
||||
@@ -0,0 +1,63 @@
|
||||
import { client } from '@/ui/api/client'
|
||||
import FileSystemManager from '@/ui/components/file-system-manager'
|
||||
import { useTeamContextStore } from '@/ui/stores/team-context'
|
||||
import { useQuery, useSuspenseQuery } from '@tanstack/react-query'
|
||||
import { createFileRoute } from '@tanstack/react-router'
|
||||
import { useEffect } from 'react'
|
||||
|
||||
const projectInfoQueryOptions = (projectId: string) => ({
|
||||
queryKey: ['projects', projectId],
|
||||
queryFn: async () => {
|
||||
const res = await client.api.projects[':projectId'].$get({
|
||||
param: { projectId: projectId },
|
||||
})
|
||||
if (!res.ok) throw new Error('Failed to fetch project')
|
||||
return await res.json()
|
||||
},
|
||||
})
|
||||
|
||||
function RecentlyDeletedPage() {
|
||||
const { projectId } = Route.useParams()
|
||||
const { teamId, ensureTeamIdForProject } = useTeamContextStore()
|
||||
|
||||
useEffect(() => {
|
||||
ensureTeamIdForProject(projectId)
|
||||
}, [projectId, ensureTeamIdForProject])
|
||||
|
||||
const { data: projectInfo } = useSuspenseQuery(projectInfoQueryOptions(projectId))
|
||||
|
||||
const rootFolderId = projectInfo?.rootFolder
|
||||
|
||||
const { data: rootFolder } = useQuery({
|
||||
queryKey: ['folders', teamId!, rootFolderId!],
|
||||
queryFn: () =>
|
||||
(async () => {
|
||||
const res = await client.api.teams[':teamId'].folders[':folderId'].$get({
|
||||
param: { teamId: teamId!, folderId: rootFolderId! },
|
||||
})
|
||||
return await res.json()
|
||||
})(),
|
||||
enabled: !!teamId && !!rootFolderId,
|
||||
})
|
||||
|
||||
if (!teamId || !rootFolderId || !rootFolder) {
|
||||
return <div>Loading project...</div>
|
||||
}
|
||||
|
||||
return (
|
||||
<FileSystemManager
|
||||
teamId={teamId}
|
||||
projectId={projectId}
|
||||
projectName={projectInfo.name ?? ''}
|
||||
assetId="recently-deleted"
|
||||
rootFolderId={rootFolderId}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
export const Route = createFileRoute('/projects/$projectId/recently-deleted')({
|
||||
component: RecentlyDeletedPage,
|
||||
loader: ({ context: { queryClient }, params: { projectId } }) =>
|
||||
queryClient.ensureQueryData(projectInfoQueryOptions(projectId)),
|
||||
pendingComponent: () => <div>Loading project...</div>,
|
||||
})
|
||||
@@ -0,0 +1,63 @@
|
||||
import { client } from '@/ui/api/client'
|
||||
import ShareManager from '@/ui/components/share-manager'
|
||||
import { useTeamContextStore } from '@/ui/stores/team-context'
|
||||
import { useQuery, useSuspenseQuery } from '@tanstack/react-query'
|
||||
import { createFileRoute } from '@tanstack/react-router'
|
||||
import { useEffect } from 'react'
|
||||
|
||||
const projectInfoQueryOptions = (projectId: string) => ({
|
||||
queryKey: ['projects', projectId],
|
||||
queryFn: async () => {
|
||||
const res = await client.api.projects[':projectId'].$get({
|
||||
param: { projectId: projectId },
|
||||
})
|
||||
if (!res.ok) throw new Error('Failed to fetch project')
|
||||
return await res.json()
|
||||
},
|
||||
})
|
||||
|
||||
function SharePage() {
|
||||
const { projectId, shareId } = Route.useParams()
|
||||
const { teamId, ensureTeamIdForProject } = useTeamContextStore()
|
||||
|
||||
useEffect(() => {
|
||||
ensureTeamIdForProject(projectId)
|
||||
}, [projectId, ensureTeamIdForProject])
|
||||
|
||||
const { data: projectInfo } = useSuspenseQuery(projectInfoQueryOptions(projectId))
|
||||
|
||||
const rootFolderId = projectInfo?.rootFolder
|
||||
|
||||
const { data: rootFolder } = useQuery({
|
||||
queryKey: ['folders', teamId!, rootFolderId!],
|
||||
queryFn: async () => {
|
||||
const res = await client.api.teams[':teamId'].folders[':folderId'].$get({
|
||||
param: { teamId: teamId!, folderId: rootFolderId! },
|
||||
})
|
||||
if (!res.ok) throw new Error('Failed to fetch folder')
|
||||
return await res.json()
|
||||
},
|
||||
enabled: !!teamId && !!rootFolderId,
|
||||
})
|
||||
|
||||
if (!teamId || !rootFolderId || !rootFolder) {
|
||||
return <div>Loading project...</div>
|
||||
}
|
||||
|
||||
return (
|
||||
<ShareManager
|
||||
teamId={teamId}
|
||||
projectId={projectId}
|
||||
projectName={projectInfo.name ?? ''}
|
||||
shareId={shareId}
|
||||
rootFolderId={rootFolderId}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
export const Route = createFileRoute('/projects/$projectId/shares/$shareId')({
|
||||
component: SharePage,
|
||||
loader: ({ context: { queryClient }, params: { projectId } }) =>
|
||||
queryClient.ensureQueryData(projectInfoQueryOptions(projectId)),
|
||||
pendingComponent: () => <div>Loading share link...</div>,
|
||||
})
|
||||
@@ -0,0 +1,41 @@
|
||||
import { client } from '@/ui/api/client'
|
||||
import { useQuery } from '@tanstack/react-query'
|
||||
import { createFileRoute, Outlet } from '@tanstack/react-router'
|
||||
|
||||
function ShareLayout() {
|
||||
const { shareId } = Route.useParams()
|
||||
|
||||
const {
|
||||
data: shareInfo,
|
||||
isLoading,
|
||||
error,
|
||||
} = useQuery({
|
||||
queryKey: ['share-info', shareId],
|
||||
queryFn: async () => {
|
||||
const res = await client.api.shares[':shareId'].info.$get({
|
||||
param: { shareId },
|
||||
})
|
||||
if (!res.ok) throw new Error('Failed to fetch share info')
|
||||
return await res.json()
|
||||
},
|
||||
})
|
||||
|
||||
if (isLoading) return <div className="flex h-screen items-center justify-center">Loading...</div>
|
||||
if (error || !shareInfo)
|
||||
return (
|
||||
<div className="flex h-screen items-center justify-center text-destructive">
|
||||
Share not found or inaccessible.
|
||||
</div>
|
||||
)
|
||||
|
||||
return <Outlet />
|
||||
}
|
||||
|
||||
export const Route = createFileRoute('/share/$shareId')({
|
||||
component: ShareLayout,
|
||||
beforeLoad: ({ params: { shareId } }) => {
|
||||
return {
|
||||
password: localStorage.getItem(`share_pwd_${shareId}`) || '',
|
||||
}
|
||||
},
|
||||
})
|
||||
@@ -0,0 +1,36 @@
|
||||
import { client } from '@/ui/api/client'
|
||||
import { PublicShareManager } from '@/ui/components/public-share-manager'
|
||||
import { useQuery } from '@tanstack/react-query'
|
||||
import { createFileRoute } from '@tanstack/react-router'
|
||||
|
||||
function PublicShareFilePage() {
|
||||
const { shareId, fileId } = Route.useParams()
|
||||
|
||||
const { data: shareInfo } = useQuery({
|
||||
queryKey: ['share-info', shareId],
|
||||
queryFn: async () => {
|
||||
const res = await client.api.shares[':shareId'].info.$get({
|
||||
param: { shareId },
|
||||
})
|
||||
if (!res.ok) throw new Error('Failed to fetch share info')
|
||||
return await res.json()
|
||||
},
|
||||
})
|
||||
|
||||
if (!shareInfo) return null
|
||||
|
||||
return (
|
||||
<PublicShareManager
|
||||
shareInfo={{
|
||||
...shareInfo,
|
||||
expireAt: shareInfo.expireAt ?? null,
|
||||
isDisabled: shareInfo.isDisabled ?? false,
|
||||
}}
|
||||
initialFileId={fileId}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
export const Route = createFileRoute('/share/$shareId/files/$fileId')({
|
||||
component: PublicShareFilePage,
|
||||
})
|
||||
@@ -0,0 +1,36 @@
|
||||
import { client } from '@/ui/api/client'
|
||||
import { PublicShareManager } from '@/ui/components/public-share-manager'
|
||||
import { useQuery } from '@tanstack/react-query'
|
||||
import { createFileRoute } from '@tanstack/react-router'
|
||||
|
||||
function PublicShareFolderPage() {
|
||||
const { shareId, folderId } = Route.useParams()
|
||||
|
||||
const { data: shareInfo } = useQuery({
|
||||
queryKey: ['share-info', shareId],
|
||||
queryFn: async () => {
|
||||
const res = await client.api.shares[':shareId'].info.$get({
|
||||
param: { shareId },
|
||||
})
|
||||
if (!res.ok) throw new Error('Failed to fetch share info')
|
||||
return await res.json()
|
||||
},
|
||||
})
|
||||
|
||||
if (!shareInfo) return null
|
||||
|
||||
return (
|
||||
<PublicShareManager
|
||||
shareInfo={{
|
||||
...shareInfo,
|
||||
expireAt: shareInfo.expireAt ?? null,
|
||||
isDisabled: shareInfo.isDisabled ?? false,
|
||||
}}
|
||||
initialFolderId={folderId}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
export const Route = createFileRoute('/share/$shareId/folders/$folderId')({
|
||||
component: PublicShareFolderPage,
|
||||
})
|
||||
@@ -0,0 +1,36 @@
|
||||
import { client } from '@/ui/api/client'
|
||||
import { PublicShareManager } from '@/ui/components/public-share-manager'
|
||||
import { useQuery } from '@tanstack/react-query'
|
||||
import { createFileRoute } from '@tanstack/react-router'
|
||||
|
||||
function PublicShareIndexPage() {
|
||||
const { shareId } = Route.useParams()
|
||||
|
||||
const { data: shareInfo } = useQuery({
|
||||
queryKey: ['share-info', shareId],
|
||||
queryFn: async () => {
|
||||
const res = await client.api.shares[':shareId'].info.$get({
|
||||
param: { shareId },
|
||||
})
|
||||
if (!res.ok) throw new Error('Failed to fetch share info')
|
||||
return await res.json()
|
||||
},
|
||||
})
|
||||
|
||||
if (!shareInfo) return null
|
||||
|
||||
return (
|
||||
<PublicShareManager
|
||||
shareInfo={{
|
||||
...shareInfo,
|
||||
expireAt: shareInfo.expireAt ?? null,
|
||||
isDisabled: shareInfo.isDisabled ?? false,
|
||||
}}
|
||||
initialFolderId={shareInfo.rootFolderId}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
export const Route = createFileRoute('/share/$shareId/')({
|
||||
component: PublicShareIndexPage,
|
||||
})
|
||||
@@ -0,0 +1,210 @@
|
||||
import { client } from '@/ui/api/client'
|
||||
import { useQuery } from '@tanstack/react-query'
|
||||
import { Button } from '@/ui/components/ui/button'
|
||||
import {
|
||||
Card,
|
||||
CardContent,
|
||||
CardDescription,
|
||||
CardFooter,
|
||||
CardHeader,
|
||||
CardTitle,
|
||||
} from '@/ui/components/ui/card'
|
||||
import { Input } from '@/ui/components/ui/input'
|
||||
import { Label } from '@/ui/components/ui/label'
|
||||
import { Loader2 } from 'lucide-react'
|
||||
import { useAuthStore } from '@/ui/stores/auth'
|
||||
import { zodResolver } from '@hookform/resolvers/zod'
|
||||
import { createFileRoute, redirect, useNavigate } from '@tanstack/react-router'
|
||||
import { useForm } from 'react-hook-form'
|
||||
import { z } from 'zod'
|
||||
import { signUp } from '@/ui/lib/auth-client'
|
||||
import { useState } from 'react'
|
||||
|
||||
const signupSchema = z.object({
|
||||
name: z.string().min(1, 'Name is required'),
|
||||
email: z.string().email('Invalid email address'),
|
||||
password: z.string().min(1, 'Password is required'),
|
||||
inviteCode: z.string().optional(),
|
||||
})
|
||||
|
||||
type SignupSchema = z.infer<typeof signupSchema>
|
||||
|
||||
function SignupPage() {
|
||||
const navigate = useNavigate()
|
||||
const search = Route.useSearch()
|
||||
const inviteCode = (search as { inviteCode?: string }).inviteCode
|
||||
const [error, setError] = useState<string | null>(null)
|
||||
const [loading, setLoading] = useState(false)
|
||||
|
||||
const { data: inviteInfo } = useQuery({
|
||||
queryKey: ['invite', inviteCode],
|
||||
queryFn: async () => {
|
||||
const res = await client.api.invite[':code'].$get({
|
||||
param: { code: inviteCode! },
|
||||
})
|
||||
if (!res.ok) {
|
||||
throw new Error('Failed to fetch invite info')
|
||||
}
|
||||
return await res.json()
|
||||
},
|
||||
enabled: !!inviteCode,
|
||||
})
|
||||
|
||||
const { data: signupInfo, isLoading: isSignupInfoLoading } = useQuery({
|
||||
queryKey: ['/signup-info'],
|
||||
queryFn: async () => {
|
||||
const res = await client.api['signup-info'].$get()
|
||||
if (!res.ok) throw new Error('Failed to fetch signup info')
|
||||
return await res.json()
|
||||
},
|
||||
})
|
||||
|
||||
const setUser = useAuthStore((state) => state.setUser)
|
||||
|
||||
const form = useForm<SignupSchema>({
|
||||
resolver: zodResolver(signupSchema),
|
||||
defaultValues: {
|
||||
inviteCode: inviteCode,
|
||||
},
|
||||
})
|
||||
|
||||
const onSubmit = async (data: SignupSchema) => {
|
||||
setLoading(true)
|
||||
setError(null)
|
||||
const { data: session, error: signUpError } = await signUp.email({
|
||||
email: data.email,
|
||||
password: data.password,
|
||||
name: data.name,
|
||||
inviteCode: data.inviteCode,
|
||||
// Cast to any because inviteCode is a custom field handled in Better Auth hooks
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
} as any)
|
||||
|
||||
setLoading(false)
|
||||
if (signUpError) {
|
||||
setError(signUpError.message || 'Signup failed')
|
||||
return
|
||||
}
|
||||
|
||||
if (session) {
|
||||
setUser(session.user)
|
||||
navigate({ to: '/' })
|
||||
}
|
||||
}
|
||||
|
||||
if (isSignupInfoLoading) {
|
||||
return (
|
||||
<div className="flex items-center justify-center min-h-screen">
|
||||
<Loader2 className="h-8 w-8 animate-spin" />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
const isFirstUser = signupInfo?.userCount === 0
|
||||
const isPublicSignupDisabled = !isFirstUser && !signupInfo?.enablePublicSignup && !inviteCode
|
||||
|
||||
if (isPublicSignupDisabled) {
|
||||
return (
|
||||
<div className="flex items-center justify-center min-h-screen">
|
||||
<Card className="w-full max-w-sm">
|
||||
<CardHeader>
|
||||
<CardTitle>Registration Disabled</CardTitle>
|
||||
<CardDescription>
|
||||
Public registration is disabled. You need an invite code to join.
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
<CardFooter className="text-center text-sm">
|
||||
Already have an account?{' '}
|
||||
<a href="/login" className="text-blue-500 hover:underline">
|
||||
Login
|
||||
</a>
|
||||
</CardFooter>
|
||||
</Card>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="flex items-center justify-center min-h-screen py-8">
|
||||
<Card className="w-full max-w-sm">
|
||||
<CardHeader>
|
||||
<CardTitle>Sign Up</CardTitle>
|
||||
<CardDescription>Create an account to get started.</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
{error && <p className="text-red-500 text-sm text-center mb-4">{error}</p>}
|
||||
{isFirstUser && (
|
||||
<div className="mb-4 p-3 bg-blue-100 dark:bg-blue-900/30 text-blue-800 dark:text-blue-200 rounded-md text-sm">
|
||||
You will be the owner of the default team.
|
||||
</div>
|
||||
)}
|
||||
{inviteInfo && !('error' in inviteInfo) && (
|
||||
<div className="mb-4 p-3 bg-muted rounded-md text-sm">
|
||||
<span className="font-semibold">{inviteInfo.inviterName}</span> invited you to join{' '}
|
||||
<span className="font-semibold">{inviteInfo.teamName || inviteInfo.projectName}</span>{' '}
|
||||
as <span className="font-semibold">{inviteInfo.role}</span>.
|
||||
</div>
|
||||
)}
|
||||
<form onSubmit={form.handleSubmit(onSubmit)} className="space-y-4">
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="name">Name</Label>
|
||||
<Input id="name" {...form.register('name')} placeholder="Your name" />
|
||||
{form.formState.errors.name && (
|
||||
<p className="text-red-500 text-sm">{form.formState.errors.name.message}</p>
|
||||
)}
|
||||
</div>
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="email">Email</Label>
|
||||
<Input
|
||||
id="email"
|
||||
{...form.register('email')}
|
||||
placeholder="you@example.com"
|
||||
type="email"
|
||||
/>
|
||||
{form.formState.errors.email && (
|
||||
<p className="text-red-500 text-sm">{form.formState.errors.email.message}</p>
|
||||
)}
|
||||
</div>
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="password">Password</Label>
|
||||
<Input
|
||||
id="password"
|
||||
type="password"
|
||||
{...form.register('password')}
|
||||
placeholder="Your password"
|
||||
/>
|
||||
{form.formState.errors.password && (
|
||||
<p className="text-red-500 text-sm">{form.formState.errors.password.message}</p>
|
||||
)}
|
||||
</div>
|
||||
<Button type="submit" className="w-full" disabled={loading}>
|
||||
{loading ? 'Creating account...' : 'Sign Up'}
|
||||
</Button>
|
||||
</form>
|
||||
</CardContent>
|
||||
<CardFooter className="text-center text-sm">
|
||||
Already have an account?{' '}
|
||||
<a href="/login" className="text-blue-500 hover:underline">
|
||||
Login
|
||||
</a>
|
||||
</CardFooter>
|
||||
</Card>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export const Route = createFileRoute('/signup')({
|
||||
component: SignupPage,
|
||||
validateSearch: (search: Record<string, unknown>) => {
|
||||
return {
|
||||
inviteCode: (search.inviteCode as string) || undefined,
|
||||
}
|
||||
},
|
||||
beforeLoad: () => {
|
||||
if (useAuthStore.getState().user) {
|
||||
throw redirect({
|
||||
to: '/',
|
||||
})
|
||||
}
|
||||
},
|
||||
})
|
||||
@@ -0,0 +1,311 @@
|
||||
import type { ProjectInfo } from '@/dtos/project'
|
||||
import { client } from '@/ui/api/client'
|
||||
import { useMutation } from '@tanstack/react-query'
|
||||
import type { InferRequestType, InferResponseType } from 'hono/client'
|
||||
import { MembersDialog } from '@/ui/components/members-dialog'
|
||||
import { ProjectDialog } from '@/ui/components/project-dialog'
|
||||
import { SortDropdown } from '@/ui/components/sort-dropdown'
|
||||
import {
|
||||
AlertDialog,
|
||||
AlertDialogAction,
|
||||
AlertDialogCancel,
|
||||
AlertDialogContent,
|
||||
AlertDialogDescription,
|
||||
AlertDialogFooter,
|
||||
AlertDialogHeader,
|
||||
AlertDialogTitle,
|
||||
} from '@/ui/components/ui/alert-dialog'
|
||||
import { Avatar, AvatarFallback } from '@/ui/components/ui/avatar'
|
||||
import { Button } from '@/ui/components/ui/button'
|
||||
import { Card } from '@/ui/components/ui/card'
|
||||
import {
|
||||
DropdownMenu,
|
||||
DropdownMenuContent,
|
||||
DropdownMenuItem,
|
||||
DropdownMenuTrigger,
|
||||
} from '@/ui/components/ui/dropdown-menu'
|
||||
import { ShumaiLogo } from '@/ui/components/ui/icons'
|
||||
import { formatDateAgo } from '@/ui/lib/time'
|
||||
import { useQuery, useSuspenseQuery } from '@tanstack/react-query'
|
||||
import { createFileRoute, useNavigate } from '@tanstack/react-router'
|
||||
import { MoreHorizontal, PlusIcon } from 'lucide-react'
|
||||
import { useState } from 'react'
|
||||
|
||||
function TeamPage() {
|
||||
const { teamId } = Route.useParams()
|
||||
const navigate = useNavigate()
|
||||
|
||||
// State for Project Dialog
|
||||
const [isProjectDialogOpen, setIsProjectDialogOpen] = useState(false)
|
||||
const [projectDialogMode, setProjectDialogMode] = useState<'create' | 'edit'>('create')
|
||||
const [selectedProject, setSelectedProject] = useState<ProjectInfo | undefined>(undefined)
|
||||
|
||||
// State for Delete Alert
|
||||
const [isDeleteDialogOpen, setIsDeleteDialogOpen] = useState(false)
|
||||
const [projectToDelete, setProjectToDelete] = useState<ProjectInfo | undefined>(undefined)
|
||||
|
||||
// State for Members Dialog
|
||||
const [isMembersDialogOpen, setIsMembersDialogOpen] = useState(false)
|
||||
|
||||
// Sort State
|
||||
const [sortBy, setSortBy] = useState<string>('name')
|
||||
const [sortDirection, setSortDirection] = useState<'asc' | 'desc'>('asc')
|
||||
|
||||
const $getProjects = client.api.teams[':teamId'].projects.$get
|
||||
const { data: projects } = useSuspenseQuery({
|
||||
queryKey: ['teams', teamId, 'projects', sortBy, sortDirection],
|
||||
queryFn: async () => {
|
||||
const res = await $getProjects({
|
||||
param: { teamId: teamId },
|
||||
query: { sortBy, sortDirection },
|
||||
})
|
||||
if (!res.ok) throw new Error('Failed to fetch projects')
|
||||
return await res.json()
|
||||
},
|
||||
})
|
||||
|
||||
const { data: members } = useQuery({
|
||||
queryKey: ['teams', teamId, 'members'],
|
||||
queryFn: async () => {
|
||||
const res = await client.api.teams[':teamId'].members.$get({
|
||||
param: { teamId: teamId },
|
||||
query: {},
|
||||
})
|
||||
if (!res.ok) throw new Error('Failed to fetch members')
|
||||
return await res.json()
|
||||
},
|
||||
})
|
||||
|
||||
const { data: me } = useQuery({
|
||||
queryKey: ['teams', teamId, 'me'],
|
||||
queryFn: async () => {
|
||||
const res = await client.api.teams[':teamId'].me.$get({
|
||||
param: { teamId: teamId },
|
||||
})
|
||||
if (!res.ok) throw new Error('Failed to fetch me')
|
||||
return await res.json()
|
||||
},
|
||||
})
|
||||
|
||||
const $inviteTeam = client.api.teams[':teamId'].invite.$post
|
||||
const inviteMutation = useMutation<
|
||||
InferResponseType<typeof $inviteTeam>,
|
||||
Error,
|
||||
InferRequestType<typeof $inviteTeam>
|
||||
>({
|
||||
mutationFn: async (args) => {
|
||||
const res = await $inviteTeam(args)
|
||||
if (!res.ok) {
|
||||
throw new Error('Failed to invite')
|
||||
}
|
||||
return await res.json()
|
||||
},
|
||||
})
|
||||
|
||||
const handleCreateProjectClick = () => {
|
||||
setProjectDialogMode('create')
|
||||
setSelectedProject(undefined)
|
||||
setIsProjectDialogOpen(true)
|
||||
}
|
||||
|
||||
const handleEditProjectClick = (project: ProjectInfo) => {
|
||||
setProjectDialogMode('edit')
|
||||
setSelectedProject(project)
|
||||
setIsProjectDialogOpen(true)
|
||||
}
|
||||
|
||||
const handleDeleteProjectClick = (project: ProjectInfo) => {
|
||||
setProjectToDelete(project)
|
||||
setIsDeleteDialogOpen(true)
|
||||
}
|
||||
|
||||
const handleConfirmDelete = () => {
|
||||
if (projectToDelete) {
|
||||
console.log('Delete project', projectToDelete.id)
|
||||
}
|
||||
setIsDeleteDialogOpen(false)
|
||||
}
|
||||
|
||||
const handleCardClick = (projectId: string) => {
|
||||
navigate({
|
||||
to: '/projects/$projectId',
|
||||
params: { projectId },
|
||||
})
|
||||
}
|
||||
|
||||
const handleInvite = async (role: 'editor' | 'reviewer') => {
|
||||
const res = await inviteMutation.mutateAsync({
|
||||
param: { teamId: teamId },
|
||||
json: { role },
|
||||
})
|
||||
return res.code
|
||||
}
|
||||
|
||||
const getInitials = (name?: string) => {
|
||||
if (!name) return '??'
|
||||
return name
|
||||
.split(' ')
|
||||
.map((n) => n[0])
|
||||
.slice(0, 2)
|
||||
.join('')
|
||||
.toUpperCase()
|
||||
}
|
||||
|
||||
const handleSortChange = (newSortBy: string, newSortDirection: 'asc' | 'desc') => {
|
||||
setSortBy(newSortBy)
|
||||
setSortDirection(newSortDirection)
|
||||
}
|
||||
|
||||
const safeMembers = Array.isArray(members) ? members : []
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div className="flex h-14 flex-wrap items-center justify-center gap-2 border-b border-border bg-card px-4 py-2">
|
||||
<ShumaiLogo className="w-10 h-10 text-orange-600" />
|
||||
</div>
|
||||
<div className="p-4">
|
||||
<div className="flex flex-wrap items-center justify-between mb-4 gap-4">
|
||||
<h1 className="text-2xl font-bold">Projects</h1>
|
||||
<div className="flex flex-wrap items-center gap-4">
|
||||
<div
|
||||
className="flex items-center -space-x-2 cursor-pointer hover:opacity-90"
|
||||
onClick={() => setIsMembersDialogOpen(true)}
|
||||
>
|
||||
{safeMembers.slice(0, 3).map((member) => (
|
||||
<Avatar key={member.id} className="border-2 border-background w-8 h-8">
|
||||
<AvatarFallback className="text-[10px]">
|
||||
{getInitials(member.name)}
|
||||
</AvatarFallback>
|
||||
</Avatar>
|
||||
))}
|
||||
{safeMembers.length > 3 && (
|
||||
<div className="flex items-center justify-center w-8 h-8 rounded-full border-2 border-background bg-muted text-[10px] font-medium">
|
||||
+{safeMembers.length - 3}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<SortDropdown
|
||||
sortBy={sortBy}
|
||||
sortDirection={sortDirection}
|
||||
onSortChange={handleSortChange}
|
||||
/>
|
||||
<Button
|
||||
className="bg-orange-600 hover:bg-orange-700 text-white gap-2"
|
||||
onClick={handleCreateProjectClick}
|
||||
>
|
||||
<PlusIcon className="w-4 h-4" />
|
||||
Create Project
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
<div className="grid grid-cols-1 sm:grid-cols-3 md:grid-cols-5 lg:grid-cols-7 gap-4">
|
||||
{projects.data?.map((project: ProjectInfo) => (
|
||||
<div key={project.id} className="shadow-md relative border rounded-xl overflow-hidden">
|
||||
<div
|
||||
className="cursor-pointer flex flex-col"
|
||||
onClick={() => handleCardClick(project.id!)}
|
||||
>
|
||||
<div className="relative w-full h-full aspect-square flex items-center justify-center bg-zinc-400/20">
|
||||
{project.coverImage ? (
|
||||
<img
|
||||
src={project.coverImage}
|
||||
alt={project.name}
|
||||
className="w-full h-full object-cover rounded"
|
||||
/>
|
||||
) : (
|
||||
<div className="text-center text-muted-foreground font-bold tracking-wider z-10">
|
||||
<ShumaiLogo className="w-8 h-8 text-zinc-400" />
|
||||
</div>
|
||||
)}
|
||||
<div className="absolute bottom-0 left-0 w-full h-[65%] bg-linear-to-t from-black/35 to-black/0" />
|
||||
<p className="absolute left-1 bottom-2 text-white">{project.name}</p>
|
||||
</div>
|
||||
<div className="px-2 h-10 flex justify-between items-center">
|
||||
<p className="truncate pr-1 text-xs text-muted-foreground">
|
||||
Updated {formatDateAgo((project.updatedAt as string) ?? '')}
|
||||
</p>
|
||||
<div>
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<button className="hover:bg-muted outline-none flex px-1">
|
||||
<MoreHorizontal className="w-5 h-5 text-muted-foreground" />
|
||||
</button>
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent align="end">
|
||||
<DropdownMenuItem
|
||||
onClick={(e) => {
|
||||
e.stopPropagation()
|
||||
handleEditProjectClick(project)
|
||||
}}
|
||||
>
|
||||
Project Settings
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem
|
||||
className="text-destructive focus:text-destructive"
|
||||
onClick={() => handleDeleteProjectClick(project)}
|
||||
>
|
||||
Delete
|
||||
</DropdownMenuItem>
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
<Card
|
||||
className="flex items-center justify-center hover:shadow-lg transition-shadow cursor-pointer"
|
||||
onClick={handleCreateProjectClick}
|
||||
>
|
||||
<div className="text-center">
|
||||
<PlusIcon className="w-8 h-8 mx-auto text-muted-foreground" />
|
||||
<p className="mt-2 text-sm text-muted-foreground">Create Project</p>
|
||||
</div>
|
||||
</Card>
|
||||
</div>
|
||||
|
||||
<ProjectDialog
|
||||
open={isProjectDialogOpen}
|
||||
onOpenChange={setIsProjectDialogOpen}
|
||||
mode={projectDialogMode}
|
||||
teamId={teamId}
|
||||
project={selectedProject}
|
||||
/>
|
||||
|
||||
<AlertDialog open={isDeleteDialogOpen} onOpenChange={setIsDeleteDialogOpen}>
|
||||
<AlertDialogContent>
|
||||
<AlertDialogHeader>
|
||||
<AlertDialogTitle>Are you absolutely sure?</AlertDialogTitle>
|
||||
<AlertDialogDescription>
|
||||
This action cannot be undone. This will permanently delete the project "
|
||||
{projectToDelete?.name}".
|
||||
</AlertDialogDescription>
|
||||
</AlertDialogHeader>
|
||||
<AlertDialogFooter>
|
||||
<AlertDialogCancel>Cancel</AlertDialogCancel>
|
||||
<AlertDialogAction
|
||||
onClick={handleConfirmDelete}
|
||||
className="bg-destructive text-destructive-foreground hover:bg-destructive/90"
|
||||
>
|
||||
Delete
|
||||
</AlertDialogAction>
|
||||
</AlertDialogFooter>
|
||||
</AlertDialogContent>
|
||||
</AlertDialog>
|
||||
|
||||
<MembersDialog
|
||||
open={isMembersDialogOpen}
|
||||
onOpenChange={setIsMembersDialogOpen}
|
||||
title="Team Members"
|
||||
members={safeMembers}
|
||||
isOwner={me?.role === 'owner'}
|
||||
onInvite={handleInvite}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export const Route = createFileRoute('/teams/$teamId/')({
|
||||
component: TeamPage,
|
||||
})
|
||||
@@ -0,0 +1,410 @@
|
||||
import { client } from '@/ui/api/client'
|
||||
import { VideoTranscodeStrategy, ImageTranscodeStrategy } from '@/dtos/team'
|
||||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/ui/components/ui/card'
|
||||
import { Switch } from '@/ui/components/ui/switch'
|
||||
import { useQueryClient, useQuery, useMutation } from '@tanstack/react-query'
|
||||
import { createFileRoute } from '@tanstack/react-router'
|
||||
import { Loader2, User, Film, Cpu, Puzzle } from 'lucide-react'
|
||||
import { cn } from '@/ui/lib/utils'
|
||||
import { useState } from 'react'
|
||||
import { ProvidersSettings } from '@/ui/components/settings/ProvidersSettings'
|
||||
import { SkillsConfigCard } from '@/ui/components/settings/SkillsConfigCard'
|
||||
import { AgentsSettings } from '@/ui/components/settings/AgentsSettings'
|
||||
import { Bot } from 'lucide-react'
|
||||
|
||||
type SettingsTab = 'general' | 'transcode' | 'skills' | 'providers' | 'agents'
|
||||
|
||||
function TeamSettingsPage() {
|
||||
const { teamId } = Route.useParams()
|
||||
const queryClient = useQueryClient()
|
||||
const [activeTab, setActiveTab] = useState<SettingsTab>('general')
|
||||
|
||||
const {
|
||||
data: settings,
|
||||
isLoading: isSettingsLoading,
|
||||
error: settingsError,
|
||||
} = useQuery({
|
||||
queryKey: ['teams', teamId, 'settings'],
|
||||
queryFn: async () => {
|
||||
const res = await client.api.teams[':teamId'].settings.$get({
|
||||
param: { teamId: teamId },
|
||||
})
|
||||
if (!res.ok) throw new Error('Failed to fetch settings')
|
||||
return await res.json()
|
||||
},
|
||||
})
|
||||
|
||||
const { data: me, isLoading: isMeLoading } = useQuery({
|
||||
queryKey: ['teams', teamId, 'me'],
|
||||
queryFn: async () => {
|
||||
const res = await client.api.teams[':teamId'].me.$get({
|
||||
param: { teamId: teamId },
|
||||
})
|
||||
if (!res.ok) throw new Error('Failed to fetch me')
|
||||
return await res.json()
|
||||
},
|
||||
enabled: !!teamId,
|
||||
})
|
||||
|
||||
const { mutate: updateSettings } = useMutation({
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
mutationFn: async (data: { teamId: string; data: { key: string; value: any } }) => {
|
||||
const res = await client.api.teams[':teamId'].settings.$patch({
|
||||
param: { teamId: data.teamId },
|
||||
json: { key: data.data.key, value: data.data.value },
|
||||
})
|
||||
if (!res.ok) throw new Error('Failed to update settings')
|
||||
return await res.json()
|
||||
},
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: ['teams', teamId, 'settings'],
|
||||
})
|
||||
},
|
||||
})
|
||||
|
||||
const handleVideoStrategyChange = (value: VideoTranscodeStrategy) => {
|
||||
updateSettings({
|
||||
teamId,
|
||||
data: {
|
||||
key: 'transcode.videoStrategy',
|
||||
value: value,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
const handleImageStrategyChange = (value: ImageTranscodeStrategy) => {
|
||||
updateSettings({
|
||||
teamId,
|
||||
data: {
|
||||
key: 'transcode.imageStrategy',
|
||||
value: value,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
if (isSettingsLoading || isMeLoading) {
|
||||
return (
|
||||
<div className="flex h-screen items-center justify-center">
|
||||
<Loader2 className="h-8 w-8 animate-spin text-muted-foreground" />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
if (settingsError) {
|
||||
return <div className="p-8 text-center text-red-500">Failed to load settings.</div>
|
||||
}
|
||||
|
||||
const currentVideoStrategy =
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
(settings as any)?.transcode?.videoStrategy || VideoTranscodeStrategy.single
|
||||
|
||||
const currentImageStrategy =
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
(settings as any)?.transcode?.imageStrategy || ImageTranscodeStrategy.single
|
||||
|
||||
return (
|
||||
<div className="min-h-screen bg-slate-50 dark:bg-slate-950 font-sans selection:bg-blue-100 dark:selection:bg-blue-900 transition-colors duration-300">
|
||||
<div className="flex flex-col md:flex-row min-h-screen">
|
||||
{/* Sidebar */}
|
||||
<aside className="w-full md:w-72 bg-white dark:bg-slate-900 border-b md:border-b-0 md:border-r border-slate-200 dark:border-slate-800 flex-shrink-0 z-10 md:fixed md:inset-y-0 md:left-16 overflow-y-auto transition-colors duration-300">
|
||||
<nav className="p-4 space-y-1 mt-4">
|
||||
<div className="mb-2 px-4 text-xs font-semibold text-slate-400 dark:text-slate-500 uppercase tracking-wider">
|
||||
Settings
|
||||
</div>
|
||||
|
||||
<button
|
||||
onClick={() => setActiveTab('general')}
|
||||
className={cn(
|
||||
'w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all',
|
||||
activeTab === 'general'
|
||||
? 'bg-blue-50 dark:bg-blue-900/20 text-blue-700 dark:text-blue-300 ring-1 ring-blue-200 dark:ring-blue-800'
|
||||
: 'text-slate-600 dark:text-slate-400 hover:bg-slate-50 dark:hover:bg-slate-800 hover:text-slate-900 dark:hover:text-white',
|
||||
)}
|
||||
>
|
||||
<User className="w-5 h-5" />
|
||||
General
|
||||
{activeTab === 'general' && (
|
||||
<div className="ml-auto w-1.5 h-1.5 rounded-full bg-blue-600 dark:bg-blue-400" />
|
||||
)}
|
||||
</button>
|
||||
|
||||
<button
|
||||
onClick={() => setActiveTab('transcode')}
|
||||
className={cn(
|
||||
'w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all',
|
||||
activeTab === 'transcode'
|
||||
? 'bg-blue-50 dark:bg-blue-900/20 text-blue-700 dark:text-blue-300 ring-1 ring-blue-200 dark:ring-blue-800'
|
||||
: 'text-slate-600 dark:text-slate-400 hover:bg-slate-50 dark:hover:bg-slate-800 hover:text-slate-900 dark:hover:text-white',
|
||||
)}
|
||||
>
|
||||
<Film className="w-5 h-5" />
|
||||
Media Processing
|
||||
{activeTab === 'transcode' && (
|
||||
<div className="ml-auto w-1.5 h-1.5 rounded-full bg-blue-600 dark:bg-blue-400" />
|
||||
)}
|
||||
</button>
|
||||
|
||||
<div className="mt-6 mb-2 px-4 text-xs font-semibold text-slate-400 dark:text-slate-500 uppercase tracking-wider pt-4 border-t border-slate-100 dark:border-slate-800">
|
||||
AI
|
||||
</div>
|
||||
|
||||
<button
|
||||
onClick={() => setActiveTab('providers')}
|
||||
className={cn(
|
||||
'w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all',
|
||||
activeTab === 'providers'
|
||||
? 'bg-blue-50 dark:bg-blue-900/20 text-blue-700 dark:text-blue-300 ring-1 ring-blue-200 dark:ring-blue-800'
|
||||
: 'text-slate-600 dark:text-slate-400 hover:bg-slate-50 dark:hover:bg-slate-800 hover:text-slate-900 dark:hover:text-white',
|
||||
)}
|
||||
>
|
||||
<Cpu className="w-5 h-5" />
|
||||
Providers
|
||||
{activeTab === 'providers' && (
|
||||
<div className="ml-auto w-1.5 h-1.5 rounded-full bg-blue-600 dark:bg-blue-400" />
|
||||
)}
|
||||
</button>
|
||||
|
||||
<button
|
||||
onClick={() => setActiveTab('skills')}
|
||||
className={cn(
|
||||
'w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all',
|
||||
activeTab === 'skills'
|
||||
? 'bg-blue-50 dark:bg-blue-900/20 text-blue-700 dark:text-blue-300 ring-1 ring-blue-200 dark:ring-blue-800'
|
||||
: 'text-slate-600 dark:text-slate-400 hover:bg-slate-50 dark:hover:bg-slate-800 hover:text-slate-900 dark:hover:text-white',
|
||||
)}
|
||||
>
|
||||
<Puzzle className="w-5 h-5" />
|
||||
Skills
|
||||
{activeTab === 'skills' && (
|
||||
<div className="ml-auto w-1.5 h-1.5 rounded-full bg-blue-600 dark:bg-blue-400" />
|
||||
)}
|
||||
</button>
|
||||
|
||||
<button
|
||||
onClick={() => setActiveTab('agents')}
|
||||
className={cn(
|
||||
'w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all',
|
||||
activeTab === 'agents'
|
||||
? 'bg-blue-50 dark:bg-blue-900/20 text-blue-700 dark:text-blue-300 ring-1 ring-blue-200 dark:ring-blue-800'
|
||||
: 'text-slate-600 dark:text-slate-400 hover:bg-slate-50 dark:hover:bg-slate-800 hover:text-slate-900 dark:hover:text-white',
|
||||
)}
|
||||
>
|
||||
<Bot className="w-5 h-5" />
|
||||
Agents
|
||||
{activeTab === 'agents' && (
|
||||
<div className="ml-auto w-1.5 h-1.5 rounded-full bg-blue-600 dark:bg-blue-400" />
|
||||
)}
|
||||
</button>
|
||||
</nav>
|
||||
</aside>
|
||||
|
||||
{/* Main Content Area */}
|
||||
<main className="flex-1 bg-slate-50/50 dark:bg-slate-950 md:ml-72 h-screen flex flex-col transition-colors duration-300 overflow-hidden">
|
||||
<div className="flex-1 flex flex-col max-w-4xl w-full mx-auto p-6 md:p-10 overflow-hidden">
|
||||
<div className="flex-none flex items-center justify-between mb-6">
|
||||
<div>
|
||||
<h2 className="text-2xl font-bold text-slate-900 dark:text-white">
|
||||
{activeTab === 'general' && 'General Settings'}
|
||||
{activeTab === 'transcode' && 'Media Processing'}
|
||||
{activeTab === 'skills' && 'Skills Management'}
|
||||
{activeTab === 'providers' && 'AI Providers'}
|
||||
{activeTab === 'agents' && 'AI Agents'}
|
||||
</h2>
|
||||
<p className="text-sm text-slate-500 dark:text-slate-400 mt-1">
|
||||
{activeTab === 'general' && 'View your personal information and team role.'}
|
||||
{activeTab === 'transcode' &&
|
||||
"Manage your team's media transcoding configurations."}
|
||||
{activeTab === 'skills' && 'Add, update and configure AI skills for the team.'}
|
||||
{activeTab === 'providers' &&
|
||||
'Configure AI providers and their models for this team.'}
|
||||
{activeTab === 'agents' && 'Manage AI agents and their personalities.'}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="flex-1 overflow-hidden animate-in fade-in slide-in-from-bottom-4 duration-500">
|
||||
{activeTab === 'general' && (
|
||||
<div className="h-full overflow-y-auto space-y-6 pr-1">
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle>Personal Info</CardTitle>
|
||||
<CardDescription>View your personal information.</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<div className="flex flex-col space-y-2">
|
||||
<span className="text-sm font-medium text-muted-foreground">Name</span>
|
||||
<span className="text-lg">{me?.name}</span>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
{me?.role === 'owner' && (
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle>Team Settings</CardTitle>
|
||||
<CardDescription>Manage your team's general settings.</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<div className="flex items-center justify-between">
|
||||
<div className="space-y-0.5">
|
||||
<h3 className="text-base font-medium">Enable Public Signup</h3>
|
||||
<p className="text-sm text-muted-foreground">
|
||||
Allow users to sign up without an invite code.
|
||||
</p>
|
||||
</div>
|
||||
<Switch
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
checked={(settings as any)?.enablePublicSignup || false}
|
||||
onCheckedChange={(checked) =>
|
||||
updateSettings({
|
||||
teamId,
|
||||
data: {
|
||||
key: 'enablePublicSignup',
|
||||
value: checked,
|
||||
},
|
||||
})
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{activeTab === 'transcode' && (
|
||||
<div className="h-full overflow-y-auto pr-1">
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle>Transcode Settings</CardTitle>
|
||||
<CardDescription>
|
||||
<span className="block mb-2">
|
||||
Manage your team's media transcoding configurations.
|
||||
</span>
|
||||
<span className="block">
|
||||
Strategy: We select the best resolution from your list that supports the
|
||||
input quality. Content is never upscaled.
|
||||
</span>
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-6">
|
||||
{/* Video Strategy */}
|
||||
<div className="space-y-3">
|
||||
<h3 className="text-lg font-medium">Video Strategy</h3>
|
||||
<div className="space-y-3">
|
||||
<div
|
||||
className={cn(
|
||||
'cursor-pointer rounded-lg border p-4 transition-all hover:border-primary',
|
||||
currentVideoStrategy === VideoTranscodeStrategy.single
|
||||
? 'border-primary bg-primary/5'
|
||||
: 'border-border',
|
||||
)}
|
||||
onClick={() => handleVideoStrategyChange(VideoTranscodeStrategy.single)}
|
||||
>
|
||||
<div className="font-semibold">Best match</div>
|
||||
<div className="text-sm text-muted-foreground">
|
||||
Generates a single optimal resolution matching the source quality.
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div
|
||||
className={cn(
|
||||
'cursor-pointer rounded-lg border p-4 transition-all hover:border-primary',
|
||||
currentVideoStrategy === VideoTranscodeStrategy.full
|
||||
? 'border-primary bg-primary/5'
|
||||
: 'border-border',
|
||||
)}
|
||||
onClick={() => handleVideoStrategyChange(VideoTranscodeStrategy.full)}
|
||||
>
|
||||
<div className="font-semibold">All resolutions</div>
|
||||
<div className="text-sm text-muted-foreground">
|
||||
Generates all supported resolutions up to the source quality.
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div
|
||||
className={cn(
|
||||
'cursor-pointer rounded-lg border p-4 transition-all hover:border-primary',
|
||||
currentVideoStrategy === VideoTranscodeStrategy.disable
|
||||
? 'border-primary bg-primary/5'
|
||||
: 'border-border',
|
||||
)}
|
||||
onClick={() =>
|
||||
handleVideoStrategyChange(VideoTranscodeStrategy.disable)
|
||||
}
|
||||
>
|
||||
<div className="font-semibold">Disable</div>
|
||||
<div className="text-sm text-muted-foreground">
|
||||
Transcoding is disabled. Only system artifacts are generated.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Image Strategy */}
|
||||
<div className="space-y-3">
|
||||
<h3 className="text-lg font-medium">Image Strategy</h3>
|
||||
<div className="space-y-3">
|
||||
<div
|
||||
className={cn(
|
||||
'cursor-pointer rounded-lg border p-4 transition-all hover:border-primary',
|
||||
currentImageStrategy === ImageTranscodeStrategy.single
|
||||
? 'border-primary bg-primary/5'
|
||||
: 'border-border',
|
||||
)}
|
||||
onClick={() => handleImageStrategyChange(ImageTranscodeStrategy.single)}
|
||||
>
|
||||
<div className="font-semibold">Best match</div>
|
||||
<div className="text-sm text-muted-foreground">
|
||||
Generates a single optimal resolution matching the source quality.
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div
|
||||
className={cn(
|
||||
'cursor-pointer rounded-lg border p-4 transition-all hover:border-primary',
|
||||
currentImageStrategy === ImageTranscodeStrategy.disable
|
||||
? 'border-primary bg-primary/5'
|
||||
: 'border-border',
|
||||
)}
|
||||
onClick={() =>
|
||||
handleImageStrategyChange(ImageTranscodeStrategy.disable)
|
||||
}
|
||||
>
|
||||
<div className="font-semibold">Disable</div>
|
||||
<div className="text-sm text-muted-foreground">
|
||||
Transcoding is disabled. Only system thumbnails are generated.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{activeTab === 'skills' && (
|
||||
<div className="h-full overflow-y-auto pr-1">
|
||||
<SkillsConfigCard teamId={teamId} />
|
||||
</div>
|
||||
)}
|
||||
|
||||
{activeTab === 'providers' && <ProvidersSettings teamId={teamId} />}
|
||||
|
||||
{activeTab === 'agents' && (
|
||||
<div className="h-full overflow-y-auto pr-1">
|
||||
<AgentsSettings teamId={teamId} />
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export const Route = createFileRoute('/teams/$teamId/settings')({
|
||||
component: TeamSettingsPage,
|
||||
})
|
||||
Reference in New Issue
Block a user