@burdenoff/microfe-workspaces 2026.529.5 → 2026.530.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/WorkspaceCard.js +1 -0
- package/dist/components/WorkspaceCard.js.map +1 -1
- package/dist/hooks/useProjects.js +5 -1
- package/dist/hooks/useProjects.js.map +1 -1
- package/dist/hooks/useWorkspaceMembers.js +5 -1
- package/dist/hooks/useWorkspaceMembers.js.map +1 -1
- package/dist/pages/WorkspacesListPage.js +71 -63
- package/dist/pages/WorkspacesListPage.js.map +1 -1
- package/package.json +1 -1
|
@@ -19,6 +19,7 @@ function m({ workspace: m }) {
|
|
|
19
19
|
role: "button",
|
|
20
20
|
tabIndex: 0,
|
|
21
21
|
"aria-label": `Open workspace ${m.name}`,
|
|
22
|
+
"data-tour": "workspaces-card",
|
|
22
23
|
children: [/* @__PURE__ */ o(d, { children: /* @__PURE__ */ s("div", {
|
|
23
24
|
className: "flex items-center gap-3",
|
|
24
25
|
children: [/* @__PURE__ */ o("div", {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WorkspaceCard.js","names":[],"sources":["../../src/components/WorkspaceCard.tsx"],"sourcesContent":["import { Building2, Users, FolderKanban } from 'lucide-react';\nimport { useNavigate } from 'react-router-dom';\nimport { Card, CardHeader, CardTitle, CardContent, Badge } from '@burdenoff/fe-libs/ui';\nimport type { Workspace } from '../types';\nimport { useWorkspacesContext } from '../providers/WorkspacesProvider';\nimport { getWorkspaceStatusClasses } from '../utils/tokenHelpers';\nimport { useScopedNavigation } from '../hooks/useScopedNavigation';\n\ninterface WorkspaceCardProps {\n workspace: Workspace;\n}\n\nexport function WorkspaceCard({ workspace }: WorkspaceCardProps) {\n const navigate = useNavigate();\n const { basePath = '/' } = useWorkspacesContext();\n const { withCurrentSearch } = useScopedNavigation();\n\n const openWorkspace = () => {\n navigate(withCurrentSearch(`${basePath}/${workspace.id}`));\n };\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLDivElement>) => {\n if (event.key === 'Enter' || event.key === ' ') {\n event.preventDefault();\n openWorkspace();\n }\n };\n\n return (\n <Card\n className=\"cursor-pointer\"\n onClick={openWorkspace}\n onKeyDown={handleKeyDown}\n role=\"button\"\n tabIndex={0}\n aria-label={`Open workspace ${workspace.name}`}\n >\n <CardHeader>\n <div className=\"flex items-center gap-3\">\n <div className=\"p-3 rounded-lg bg-primary/10 transition-colors\">\n <Building2 className=\"text-primary\" size={24} />\n </div>\n <div className=\"flex-1 min-w-0\">\n <CardTitle className=\"text-lg truncate\">{workspace.name}</CardTitle>\n <div className=\"flex items-center gap-2 mt-1\">\n <Badge variant=\"outline\" className=\"text-xs\">\n {workspace.type}\n </Badge>\n <Badge className={`text-xs border ${getWorkspaceStatusClasses(workspace.status)}`}>\n {workspace.status}\n </Badge>\n </div>\n </div>\n </div>\n </CardHeader>\n <CardContent>\n <div className=\"flex flex-wrap gap-4 text-sm text-muted-foreground\">\n {typeof workspace.memberCount === 'number' && workspace.memberCount > 0 && (\n <div className=\"flex items-center gap-1\">\n <Users size={16} aria-hidden=\"true\" />\n <span>\n {workspace.memberCount} member{workspace.memberCount === 1 ? '' : 's'}\n </span>\n </div>\n )}\n {typeof workspace.projectCount === 'number' && workspace.projectCount > 0 && (\n <div className=\"flex items-center gap-1\">\n <FolderKanban size={16} aria-hidden=\"true\" />\n <span>\n {workspace.projectCount} project{workspace.projectCount === 1 ? '' : 's'}\n </span>\n </div>\n )}\n </div>\n {workspace.domain && (\n <p className=\"mt-2 truncate text-xs text-muted-foreground\">{workspace.domain}</p>\n )}\n </CardContent>\n </Card>\n );\n}\n"],"mappings":";;;;;;;;AAYA,SAAgB,EAAc,EAAE,gBAAiC;CAC/D,IAAM,IAAW,GAAa,EACxB,EAAE,cAAW,QAAQ,GAAsB,EAC3C,EAAE,yBAAsB,GAAqB,EAE7C,UAAsB;AAC1B,IAAS,EAAkB,GAAG,EAAS,GAAG,EAAU,KAAK,CAAC;;AAU5D,QACE,kBAAC,GAAD;EACE,WAAU;EACV,SAAS;EACT,YAXmB,MAA+C;AACpE,IAAI,EAAM,QAAQ,WAAW,EAAM,QAAQ,SACzC,EAAM,gBAAgB,EACtB,GAAe;;EASf,MAAK;EACL,UAAU;EACV,cAAY,kBAAkB,EAAU;
|
|
1
|
+
{"version":3,"file":"WorkspaceCard.js","names":[],"sources":["../../src/components/WorkspaceCard.tsx"],"sourcesContent":["import { Building2, Users, FolderKanban } from 'lucide-react';\nimport { useNavigate } from 'react-router-dom';\nimport { Card, CardHeader, CardTitle, CardContent, Badge } from '@burdenoff/fe-libs/ui';\nimport type { Workspace } from '../types';\nimport { useWorkspacesContext } from '../providers/WorkspacesProvider';\nimport { getWorkspaceStatusClasses } from '../utils/tokenHelpers';\nimport { useScopedNavigation } from '../hooks/useScopedNavigation';\n\ninterface WorkspaceCardProps {\n workspace: Workspace;\n}\n\nexport function WorkspaceCard({ workspace }: WorkspaceCardProps) {\n const navigate = useNavigate();\n const { basePath = '/' } = useWorkspacesContext();\n const { withCurrentSearch } = useScopedNavigation();\n\n const openWorkspace = () => {\n navigate(withCurrentSearch(`${basePath}/${workspace.id}`));\n };\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLDivElement>) => {\n if (event.key === 'Enter' || event.key === ' ') {\n event.preventDefault();\n openWorkspace();\n }\n };\n\n return (\n <Card\n className=\"cursor-pointer\"\n onClick={openWorkspace}\n onKeyDown={handleKeyDown}\n role=\"button\"\n tabIndex={0}\n aria-label={`Open workspace ${workspace.name}`}\n data-tour=\"workspaces-card\"\n >\n <CardHeader>\n <div className=\"flex items-center gap-3\">\n <div className=\"p-3 rounded-lg bg-primary/10 transition-colors\">\n <Building2 className=\"text-primary\" size={24} />\n </div>\n <div className=\"flex-1 min-w-0\">\n <CardTitle className=\"text-lg truncate\">{workspace.name}</CardTitle>\n <div className=\"flex items-center gap-2 mt-1\">\n <Badge variant=\"outline\" className=\"text-xs\">\n {workspace.type}\n </Badge>\n <Badge className={`text-xs border ${getWorkspaceStatusClasses(workspace.status)}`}>\n {workspace.status}\n </Badge>\n </div>\n </div>\n </div>\n </CardHeader>\n <CardContent>\n <div className=\"flex flex-wrap gap-4 text-sm text-muted-foreground\">\n {typeof workspace.memberCount === 'number' && workspace.memberCount > 0 && (\n <div className=\"flex items-center gap-1\">\n <Users size={16} aria-hidden=\"true\" />\n <span>\n {workspace.memberCount} member{workspace.memberCount === 1 ? '' : 's'}\n </span>\n </div>\n )}\n {typeof workspace.projectCount === 'number' && workspace.projectCount > 0 && (\n <div className=\"flex items-center gap-1\">\n <FolderKanban size={16} aria-hidden=\"true\" />\n <span>\n {workspace.projectCount} project{workspace.projectCount === 1 ? '' : 's'}\n </span>\n </div>\n )}\n </div>\n {workspace.domain && (\n <p className=\"mt-2 truncate text-xs text-muted-foreground\">{workspace.domain}</p>\n )}\n </CardContent>\n </Card>\n );\n}\n"],"mappings":";;;;;;;;AAYA,SAAgB,EAAc,EAAE,gBAAiC;CAC/D,IAAM,IAAW,GAAa,EACxB,EAAE,cAAW,QAAQ,GAAsB,EAC3C,EAAE,yBAAsB,GAAqB,EAE7C,UAAsB;AAC1B,IAAS,EAAkB,GAAG,EAAS,GAAG,EAAU,KAAK,CAAC;;AAU5D,QACE,kBAAC,GAAD;EACE,WAAU;EACV,SAAS;EACT,YAXmB,MAA+C;AACpE,IAAI,EAAM,QAAQ,WAAW,EAAM,QAAQ,SACzC,EAAM,gBAAgB,EACtB,GAAe;;EASf,MAAK;EACL,UAAU;EACV,cAAY,kBAAkB,EAAU;EACxC,aAAU;YAPZ,CASE,kBAAC,GAAD,EAAA,UACE,kBAAC,OAAD;GAAK,WAAU;aAAf,CACE,kBAAC,OAAD;IAAK,WAAU;cACb,kBAAC,GAAD;KAAW,WAAU;KAAe,MAAM;KAAM,CAAA;IAC5C,CAAA,EACN,kBAAC,OAAD;IAAK,WAAU;cAAf,CACE,kBAAC,GAAD;KAAW,WAAU;eAAoB,EAAU;KAAiB,CAAA,EACpE,kBAAC,OAAD;KAAK,WAAU;eAAf,CACE,kBAAC,GAAD;MAAO,SAAQ;MAAU,WAAU;gBAChC,EAAU;MACL,CAAA,EACR,kBAAC,GAAD;MAAO,WAAW,kBAAkB,EAA0B,EAAU,OAAO;gBAC5E,EAAU;MACL,CAAA,CACJ;OACF;MACF;MACK,CAAA,EACb,kBAAC,GAAD,EAAA,UAAA,CACE,kBAAC,OAAD;GAAK,WAAU;aAAf,CACG,OAAO,EAAU,eAAgB,YAAY,EAAU,cAAc,KACpE,kBAAC,OAAD;IAAK,WAAU;cAAf,CACE,kBAAC,GAAD;KAAO,MAAM;KAAI,eAAY;KAAS,CAAA,EACtC,kBAAC,QAAD,EAAA,UAAA;KACG,EAAU;KAAY;KAAQ,EAAU,gBAAgB,IAAI,KAAK;KAC7D,EAAA,CAAA,CACH;OAEP,OAAO,EAAU,gBAAiB,YAAY,EAAU,eAAe,KACtE,kBAAC,OAAD;IAAK,WAAU;cAAf,CACE,kBAAC,GAAD;KAAc,MAAM;KAAI,eAAY;KAAS,CAAA,EAC7C,kBAAC,QAAD,EAAA,UAAA;KACG,EAAU;KAAa;KAAS,EAAU,iBAAiB,IAAI,KAAK;KAChE,EAAA,CAAA,CACH;MAEJ;MACL,EAAU,UACT,kBAAC,KAAD;GAAG,WAAU;aAA+C,EAAU;GAAW,CAAA,CAEvE,EAAA,CAAA,CACT"}
|
|
@@ -58,7 +58,11 @@ var r = "\n query GetProjects($filter: ProjectFilterInput, $pagination: Paginat
|
|
|
58
58
|
}, l = (r) => {
|
|
59
59
|
let { authToken: i, workspaceId: o } = e();
|
|
60
60
|
return t({
|
|
61
|
-
queryKey: [
|
|
61
|
+
queryKey: [
|
|
62
|
+
"myProjects",
|
|
63
|
+
o,
|
|
64
|
+
r
|
|
65
|
+
],
|
|
62
66
|
queryFn: async () => {
|
|
63
67
|
let e = await n({
|
|
64
68
|
gateway: "workspace",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useProjects.js","names":[],"sources":["../../src/hooks/useProjects.ts"],"sourcesContent":["import { useQuery } from '@tanstack/react-query';\nimport { graphqlFetch } from '@burdenoff/fe-libs/shared/graphql';\nimport { useWorkspacesContext } from '../providers/WorkspacesProvider';\nimport type { ProjectFilters, ProjectList, Project, PaginationInput } from '../types';\n\nconst GET_PROJECTS_QUERY = `\n query GetProjects($filter: ProjectFilterInput, $pagination: PaginationInput) {\n projects(filter: $filter, pagination: $pagination) {\n items {\n id\n name\n key\n workspaceId\n creatorId\n status\n config\n tags\n archived\n createdAt\n updatedAt\n deletedAt\n }\n total\n hasMore\n }\n }\n`;\n\nconst GET_PROJECT_QUERY = `\n query GetProject($id: ID!) {\n project(id: $id) {\n id\n name\n key\n workspaceId\n creatorId\n status\n config\n tags\n archived\n createdAt\n updatedAt\n deletedAt\n }\n }\n`;\n\nconst GET_MY_PROJECTS_QUERY = `\n query GetMyProjects($pagination: PaginationInput) {\n myProjects(pagination: $pagination) {\n items {\n id\n name\n key\n workspaceId\n status\n tags\n archived\n createdAt\n updatedAt\n }\n total\n hasMore\n }\n }\n`;\n\nconst GET_PROJECT_MEMBERS_COUNT = `\n query GetProjectMembersCount($projectId: ID!) {\n projectMembers(filter: { projectId: $projectId }, pagination: { limit: 1 }) {\n total\n }\n }\n`;\n\n/**\n * Hook to fetch all projects with filtering and pagination\n */\nexport const useProjects = (\n filters?: ProjectFilters,\n pagination?: PaginationInput,\n workspaceIdOverride?: string\n) => {\n const { authToken, workspaceId } = useWorkspacesContext();\n const effectiveWorkspaceId = filters?.workspaceId || workspaceIdOverride || workspaceId;\n\n return useQuery({\n queryKey: ['projects', effectiveWorkspaceId, filters, pagination],\n queryFn: async (): Promise<ProjectList> => {\n const result = await graphqlFetch<{ projects: ProjectList }>({\n gateway: 'workspace',\n authToken: authToken || undefined,\n query: GET_PROJECTS_QUERY,\n variables: {\n filter: {\n ...filters,\n workspaceId: effectiveWorkspaceId,\n },\n pagination,\n },\n workspaceId: effectiveWorkspaceId || undefined,\n workspaceToken: true, // Auto-read from profile context for x-workspace-id header (required by gateway RBAC)\n });\n\n if (result.errors?.length) {\n throw new Error(result.errors[0]?.message || 'GraphQL error');\n }\n\n return result.data!.projects;\n },\n enabled: !!effectiveWorkspaceId,\n staleTime: 5 * 60 * 1000,\n });\n};\n\n/**\n * Hook to fetch a single project by ID\n */\nexport const useProject = (id: string, workspaceIdOverride?: string) => {\n const { authToken, workspaceId } = useWorkspacesContext();\n const effectiveWorkspaceId = workspaceIdOverride || workspaceId;\n\n return useQuery({\n queryKey: ['project', effectiveWorkspaceId, id],\n queryFn: async (): Promise<Project> => {\n const result = await graphqlFetch<{ project: Project }>({\n gateway: 'workspace',\n authToken: authToken || undefined,\n query: GET_PROJECT_QUERY,\n variables: { id },\n workspaceId: effectiveWorkspaceId || undefined,\n workspaceToken: true, // Auto-read from profile context for x-workspace-id header (required by gateway RBAC)\n });\n\n if (result.errors?.length) {\n throw new Error(result.errors[0]?.message || 'GraphQL error');\n }\n\n return result.data!.project;\n },\n enabled: !!id,\n staleTime: 5 * 60 * 1000,\n });\n};\n\n/**\n * Hook to fetch current user's projects\n */\nexport const useMyProjects = (pagination?: PaginationInput) => {\n const { authToken, workspaceId } = useWorkspacesContext();\n\n return useQuery({\n queryKey: ['myProjects', pagination],\n queryFn: async (): Promise<ProjectList> => {\n const result = await graphqlFetch<{ myProjects: ProjectList }>({\n gateway: 'workspace',\n authToken: authToken || undefined,\n query: GET_MY_PROJECTS_QUERY,\n variables: { pagination },\n workspaceId: workspaceId || undefined,\n workspaceToken: true, // Auto-read from profile context for x-workspace-id header (required by gateway RBAC)\n });\n\n if (result.errors?.length) {\n throw new Error(result.errors[0]?.message || 'GraphQL error');\n }\n\n return result.data!.myProjects;\n },\n staleTime: 5 * 60 * 1000,\n });\n};\n\nexport const useProjectMembersCount = (projectId: string, workspaceIdOverride?: string) => {\n const { authToken, workspaceId } = useWorkspacesContext();\n const effectiveWorkspaceId = workspaceIdOverride || workspaceId;\n\n return useQuery({\n queryKey: ['projectMembersCount', effectiveWorkspaceId, projectId],\n queryFn: async (): Promise<number> => {\n const result = await graphqlFetch<{\n projectMembers: { total: number };\n }>({\n gateway: 'workspace',\n authToken: authToken || undefined,\n query: GET_PROJECT_MEMBERS_COUNT,\n variables: { projectId },\n workspaceId: effectiveWorkspaceId || undefined,\n workspaceToken: true,\n });\n\n if (result.errors?.length) {\n throw new Error(result.errors[0]?.message || 'GraphQL error');\n }\n\n return result.data?.projectMembers.total ?? 0;\n },\n enabled: !!projectId && !!effectiveWorkspaceId,\n staleTime: 60 * 1000,\n });\n};\n"],"mappings":";;;;AAKA,IAAM,IAAqB,0ZAuBrB,IAAoB,0PAmBpB,IAAwB,0TAoBxB,IAA4B,qKAWrB,KACX,GACA,GACA,MACG;CACH,IAAM,EAAE,cAAW,mBAAgB,GAAsB,EACnD,IAAuB,GAAS,eAAe,KAAuB;AAE5E,QAAO,EAAS;EACd,UAAU;GAAC;GAAY;GAAsB;GAAS;GAAW;EACjE,SAAS,YAAkC;GACzC,IAAM,IAAS,MAAM,EAAwC;IAC3D,SAAS;IACT,WAAW,KAAa,KAAA;IACxB,OAAO;IACP,WAAW;KACT,QAAQ;MACN,GAAG;MACH,aAAa;MACd;KACD;KACD;IACD,aAAa,KAAwB,KAAA;IACrC,gBAAgB;IACjB,CAAC;AAEF,OAAI,EAAO,QAAQ,OACjB,OAAU,MAAM,EAAO,OAAO,IAAI,WAAW,gBAAgB;AAG/D,UAAO,EAAO,KAAM;;EAEtB,SAAS,CAAC,CAAC;EACX,WAAW,MAAS;EACrB,CAAC;GAMS,KAAc,GAAY,MAAiC;CACtE,IAAM,EAAE,cAAW,mBAAgB,GAAsB,EACnD,IAAuB,KAAuB;AAEpD,QAAO,EAAS;EACd,UAAU;GAAC;GAAW;GAAsB;GAAG;EAC/C,SAAS,YAA8B;GACrC,IAAM,IAAS,MAAM,EAAmC;IACtD,SAAS;IACT,WAAW,KAAa,KAAA;IACxB,OAAO;IACP,WAAW,EAAE,OAAI;IACjB,aAAa,KAAwB,KAAA;IACrC,gBAAgB;IACjB,CAAC;AAEF,OAAI,EAAO,QAAQ,OACjB,OAAU,MAAM,EAAO,OAAO,IAAI,WAAW,gBAAgB;AAG/D,UAAO,EAAO,KAAM;;EAEtB,SAAS,CAAC,CAAC;EACX,WAAW,MAAS;EACrB,CAAC;GAMS,KAAiB,MAAiC;CAC7D,IAAM,EAAE,cAAW,mBAAgB,GAAsB;AAEzD,QAAO,EAAS;EACd,UAAU
|
|
1
|
+
{"version":3,"file":"useProjects.js","names":[],"sources":["../../src/hooks/useProjects.ts"],"sourcesContent":["import { useQuery } from '@tanstack/react-query';\nimport { graphqlFetch } from '@burdenoff/fe-libs/shared/graphql';\nimport { useWorkspacesContext } from '../providers/WorkspacesProvider';\nimport type { ProjectFilters, ProjectList, Project, PaginationInput } from '../types';\n\nconst GET_PROJECTS_QUERY = `\n query GetProjects($filter: ProjectFilterInput, $pagination: PaginationInput) {\n projects(filter: $filter, pagination: $pagination) {\n items {\n id\n name\n key\n workspaceId\n creatorId\n status\n config\n tags\n archived\n createdAt\n updatedAt\n deletedAt\n }\n total\n hasMore\n }\n }\n`;\n\nconst GET_PROJECT_QUERY = `\n query GetProject($id: ID!) {\n project(id: $id) {\n id\n name\n key\n workspaceId\n creatorId\n status\n config\n tags\n archived\n createdAt\n updatedAt\n deletedAt\n }\n }\n`;\n\nconst GET_MY_PROJECTS_QUERY = `\n query GetMyProjects($pagination: PaginationInput) {\n myProjects(pagination: $pagination) {\n items {\n id\n name\n key\n workspaceId\n status\n tags\n archived\n createdAt\n updatedAt\n }\n total\n hasMore\n }\n }\n`;\n\nconst GET_PROJECT_MEMBERS_COUNT = `\n query GetProjectMembersCount($projectId: ID!) {\n projectMembers(filter: { projectId: $projectId }, pagination: { limit: 1 }) {\n total\n }\n }\n`;\n\n/**\n * Hook to fetch all projects with filtering and pagination\n */\nexport const useProjects = (\n filters?: ProjectFilters,\n pagination?: PaginationInput,\n workspaceIdOverride?: string\n) => {\n const { authToken, workspaceId } = useWorkspacesContext();\n const effectiveWorkspaceId = filters?.workspaceId || workspaceIdOverride || workspaceId;\n\n return useQuery({\n queryKey: ['projects', effectiveWorkspaceId, filters, pagination],\n queryFn: async (): Promise<ProjectList> => {\n const result = await graphqlFetch<{ projects: ProjectList }>({\n gateway: 'workspace',\n authToken: authToken || undefined,\n query: GET_PROJECTS_QUERY,\n variables: {\n filter: {\n ...filters,\n workspaceId: effectiveWorkspaceId,\n },\n pagination,\n },\n workspaceId: effectiveWorkspaceId || undefined,\n workspaceToken: true, // Auto-read from profile context for x-workspace-id header (required by gateway RBAC)\n });\n\n if (result.errors?.length) {\n throw new Error(result.errors[0]?.message || 'GraphQL error');\n }\n\n return result.data!.projects;\n },\n enabled: !!effectiveWorkspaceId,\n staleTime: 5 * 60 * 1000,\n });\n};\n\n/**\n * Hook to fetch a single project by ID\n */\nexport const useProject = (id: string, workspaceIdOverride?: string) => {\n const { authToken, workspaceId } = useWorkspacesContext();\n const effectiveWorkspaceId = workspaceIdOverride || workspaceId;\n\n return useQuery({\n queryKey: ['project', effectiveWorkspaceId, id],\n queryFn: async (): Promise<Project> => {\n const result = await graphqlFetch<{ project: Project }>({\n gateway: 'workspace',\n authToken: authToken || undefined,\n query: GET_PROJECT_QUERY,\n variables: { id },\n workspaceId: effectiveWorkspaceId || undefined,\n workspaceToken: true, // Auto-read from profile context for x-workspace-id header (required by gateway RBAC)\n });\n\n if (result.errors?.length) {\n throw new Error(result.errors[0]?.message || 'GraphQL error');\n }\n\n return result.data!.project;\n },\n enabled: !!id,\n staleTime: 5 * 60 * 1000,\n });\n};\n\n/**\n * Hook to fetch current user's projects\n */\nexport const useMyProjects = (pagination?: PaginationInput) => {\n const { authToken, workspaceId } = useWorkspacesContext();\n\n return useQuery({\n queryKey: ['myProjects', workspaceId, pagination],\n queryFn: async (): Promise<ProjectList> => {\n const result = await graphqlFetch<{ myProjects: ProjectList }>({\n gateway: 'workspace',\n authToken: authToken || undefined,\n query: GET_MY_PROJECTS_QUERY,\n variables: { pagination },\n workspaceId: workspaceId || undefined,\n workspaceToken: true, // Auto-read from profile context for x-workspace-id header (required by gateway RBAC)\n });\n\n if (result.errors?.length) {\n throw new Error(result.errors[0]?.message || 'GraphQL error');\n }\n\n return result.data!.myProjects;\n },\n staleTime: 5 * 60 * 1000,\n });\n};\n\nexport const useProjectMembersCount = (projectId: string, workspaceIdOverride?: string) => {\n const { authToken, workspaceId } = useWorkspacesContext();\n const effectiveWorkspaceId = workspaceIdOverride || workspaceId;\n\n return useQuery({\n queryKey: ['projectMembersCount', effectiveWorkspaceId, projectId],\n queryFn: async (): Promise<number> => {\n const result = await graphqlFetch<{\n projectMembers: { total: number };\n }>({\n gateway: 'workspace',\n authToken: authToken || undefined,\n query: GET_PROJECT_MEMBERS_COUNT,\n variables: { projectId },\n workspaceId: effectiveWorkspaceId || undefined,\n workspaceToken: true,\n });\n\n if (result.errors?.length) {\n throw new Error(result.errors[0]?.message || 'GraphQL error');\n }\n\n return result.data?.projectMembers.total ?? 0;\n },\n enabled: !!projectId && !!effectiveWorkspaceId,\n staleTime: 60 * 1000,\n });\n};\n"],"mappings":";;;;AAKA,IAAM,IAAqB,0ZAuBrB,IAAoB,0PAmBpB,IAAwB,0TAoBxB,IAA4B,qKAWrB,KACX,GACA,GACA,MACG;CACH,IAAM,EAAE,cAAW,mBAAgB,GAAsB,EACnD,IAAuB,GAAS,eAAe,KAAuB;AAE5E,QAAO,EAAS;EACd,UAAU;GAAC;GAAY;GAAsB;GAAS;GAAW;EACjE,SAAS,YAAkC;GACzC,IAAM,IAAS,MAAM,EAAwC;IAC3D,SAAS;IACT,WAAW,KAAa,KAAA;IACxB,OAAO;IACP,WAAW;KACT,QAAQ;MACN,GAAG;MACH,aAAa;MACd;KACD;KACD;IACD,aAAa,KAAwB,KAAA;IACrC,gBAAgB;IACjB,CAAC;AAEF,OAAI,EAAO,QAAQ,OACjB,OAAU,MAAM,EAAO,OAAO,IAAI,WAAW,g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AAE,cAAW;IACxB,aAAa,KAAwB,KAAA;IACrC,gBAAgB;IACjB,CAAC;AAEF,OAAI,EAAO,QAAQ,OACjB,OAAU,MAAM,EAAO,OAAO,IAAI,WAAW,gBAAgB;AAG/D,UAAO,EAAO,MAAM,eAAe,SAAS;;EAE9C,SAAS,CAAC,CAAC,KAAa,CAAC,CAAC;EAC1B,WAAW,KAAK;EACjB,CAAC"}
|
|
@@ -33,7 +33,11 @@ var l = (t, n) => {
|
|
|
33
33
|
}, u = (t) => {
|
|
34
34
|
let { authToken: n, workspaceId: r } = e();
|
|
35
35
|
return o({
|
|
36
|
-
queryKey: [
|
|
36
|
+
queryKey: [
|
|
37
|
+
"workspaceMember",
|
|
38
|
+
r,
|
|
39
|
+
t
|
|
40
|
+
],
|
|
37
41
|
queryFn: async () => {
|
|
38
42
|
let e = await c({
|
|
39
43
|
gateway: "workspace",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useWorkspaceMembers.js","names":[],"sources":["../../src/hooks/useWorkspaceMembers.ts"],"sourcesContent":["import { useQuery } from '@tanstack/react-query';\nimport { print } from 'graphql';\nimport { graphqlFetch } from '@burdenoff/fe-libs/shared/graphql';\nimport { useWorkspacesContext } from '../providers/WorkspacesProvider';\nimport {\n GetWorkspaceMembersDocument,\n GetWorkspaceMemberDocument,\n GetUserWorkspacesDocument,\n GetWorkspaceInvitationsDocument,\n GetInvitationDocument,\n} from '../generated/wspace-operations';\nimport type {\n MemberList,\n WorkspaceMember,\n WorkspaceInvitation,\n InvitationList,\n PaginationInput,\n InvitationStatus,\n} from '../types';\n\n/**\n * Hook to fetch all members of the current workspace\n */\nexport const useWorkspaceMembers = (workspaceId: string, pagination?: PaginationInput) => {\n const { authToken } = useWorkspacesContext();\n\n return useQuery({\n queryKey: ['workspaceMembers', workspaceId, pagination],\n queryFn: async (): Promise<MemberList> => {\n const result = await graphqlFetch<{ workspaceMembers: MemberList }>({\n gateway: 'workspace',\n authToken: authToken || undefined,\n query: print(GetWorkspaceMembersDocument),\n variables: { workspaceId, pagination },\n workspaceId,\n workspaceToken: true, // Auto-read from profile context for x-workspace-id header (required by gateway RBAC)\n });\n\n if (result.errors?.length) {\n throw new Error(result.errors[0]?.message || 'GraphQL error');\n }\n\n return result.data!.workspaceMembers;\n },\n enabled: !!workspaceId,\n staleTime: 5 * 60 * 1000,\n });\n};\n\n/**\n * Hook to fetch a single workspace member by ID\n */\nexport const useWorkspaceMember = (id: string) => {\n const { authToken, workspaceId } = useWorkspacesContext();\n\n return useQuery({\n queryKey: ['workspaceMember', id],\n queryFn: async (): Promise<WorkspaceMember> => {\n const result = await graphqlFetch<{ workspaceMember: WorkspaceMember }>({\n gateway: 'workspace',\n authToken: authToken || undefined,\n query: print(GetWorkspaceMemberDocument),\n variables: { id },\n workspaceId: workspaceId || undefined,\n workspaceToken: true, // Required by gateway RBAC for wspace-scoped operations\n });\n\n if (result.errors?.length) {\n throw new Error(result.errors[0]?.message || 'GraphQL error');\n }\n\n return result.data!.workspaceMember;\n },\n enabled: !!id,\n staleTime: 5 * 60 * 1000,\n });\n};\n\n/**\n * Hook to fetch all workspaces a user is a member of\n */\nexport const useUserWorkspaces = (userId: string, pagination?: PaginationInput) => {\n const { authToken, workspaceId } = useWorkspacesContext();\n\n return useQuery({\n queryKey: ['userWorkspaces', userId, pagination],\n queryFn: async (): Promise<MemberList> => {\n const result = await graphqlFetch<{ userWorkspaces: MemberList }>({\n gateway: 'workspace',\n authToken: authToken || undefined,\n query: print(GetUserWorkspacesDocument),\n variables: { userId, pagination },\n workspaceId: workspaceId || undefined,\n workspaceToken: true, // Required by gateway RBAC for wspace-scoped operations\n });\n\n if (result.errors?.length) {\n throw new Error(result.errors[0]?.message || 'GraphQL error');\n }\n\n return result.data!.userWorkspaces;\n },\n enabled: !!userId,\n staleTime: 5 * 60 * 1000,\n });\n};\n\n/**\n * Hook to fetch workspace invitations\n * Requires x-workspace-id header for workspace context\n */\nexport const useWorkspaceInvitations = (\n workspaceId: string,\n status?: InvitationStatus,\n pagination?: PaginationInput\n) => {\n const { authToken } = useWorkspacesContext();\n\n return useQuery({\n queryKey: ['workspaceInvitations', workspaceId, status, pagination],\n queryFn: async (): Promise<InvitationList> => {\n const result = await graphqlFetch<{ workspaceInvitations: InvitationList }>({\n gateway: 'workspace',\n authToken: authToken || undefined,\n query: print(GetWorkspaceInvitationsDocument),\n variables: { status, pagination },\n workspaceId,\n workspaceToken: true, // Auto-read from profile context for x-workspace-id header\n });\n\n if (result.errors?.length) {\n throw new Error(result.errors[0]?.message || 'GraphQL error');\n }\n\n return result.data!.workspaceInvitations;\n },\n enabled: !!workspaceId,\n staleTime: 5 * 60 * 1000,\n });\n};\n\n/**\n * Hook to get a single invitation by ID (for acceptance page)\n */\nexport const useInvitation = (id: string, enabled = true) => {\n const { authToken, workspaceId } = useWorkspacesContext();\n\n return useQuery({\n queryKey: ['invitation', id],\n queryFn: async (): Promise<WorkspaceInvitation> => {\n const result = await graphqlFetch<{ invitation: WorkspaceInvitation }>({\n gateway: 'workspace',\n authToken: authToken || undefined,\n query: print(GetInvitationDocument),\n variables: { id },\n });\n\n if (result.errors?.length) {\n throw new Error(result.errors[0]?.message || 'Failed to fetch invitation');\n }\n\n if (!result.data?.invitation) {\n throw new Error('Invitation not found');\n }\n\n return result.data.invitation;\n },\n enabled: !!id && enabled,\n retry: 1,\n staleTime: 5 * 60 * 1000,\n });\n};\n"],"mappings":";;;;;;AAuBA,IAAa,KAAuB,GAAqB,MAAiC;CACxF,IAAM,EAAE,iBAAc,GAAsB;AAE5C,QAAO,EAAS;EACd,UAAU;GAAC;GAAoB;GAAa;GAAW;EACvD,SAAS,YAAiC;GACxC,IAAM,IAAS,MAAM,EAA+C;IAClE,SAAS;IACT,WAAW,KAAa,KAAA;IACxB,OAAO,EAAM,EAA4B;IACzC,WAAW;KAAE;KAAa;KAAY;IACtC;IACA,gBAAgB;IACjB,CAAC;AAEF,OAAI,EAAO,QAAQ,OACjB,OAAU,MAAM,EAAO,OAAO,IAAI,WAAW,gBAAgB;AAG/D,UAAO,EAAO,KAAM;;EAEtB,SAAS,CAAC,CAAC;EACX,WAAW,MAAS;EACrB,CAAC;GAMS,KAAsB,MAAe;CAChD,IAAM,EAAE,cAAW,mBAAgB,GAAsB;AAEzD,QAAO,EAAS;EACd,UAAU
|
|
1
|
+
{"version":3,"file":"useWorkspaceMembers.js","names":[],"sources":["../../src/hooks/useWorkspaceMembers.ts"],"sourcesContent":["import { useQuery } from '@tanstack/react-query';\nimport { print } from 'graphql';\nimport { graphqlFetch } from '@burdenoff/fe-libs/shared/graphql';\nimport { useWorkspacesContext } from '../providers/WorkspacesProvider';\nimport {\n GetWorkspaceMembersDocument,\n GetWorkspaceMemberDocument,\n GetUserWorkspacesDocument,\n GetWorkspaceInvitationsDocument,\n GetInvitationDocument,\n} from '../generated/wspace-operations';\nimport type {\n MemberList,\n WorkspaceMember,\n WorkspaceInvitation,\n InvitationList,\n PaginationInput,\n InvitationStatus,\n} from '../types';\n\n/**\n * Hook to fetch all members of the current workspace\n */\nexport const useWorkspaceMembers = (workspaceId: string, pagination?: PaginationInput) => {\n const { authToken } = useWorkspacesContext();\n\n return useQuery({\n queryKey: ['workspaceMembers', workspaceId, pagination],\n queryFn: async (): Promise<MemberList> => {\n const result = await graphqlFetch<{ workspaceMembers: MemberList }>({\n gateway: 'workspace',\n authToken: authToken || undefined,\n query: print(GetWorkspaceMembersDocument),\n variables: { workspaceId, pagination },\n workspaceId,\n workspaceToken: true, // Auto-read from profile context for x-workspace-id header (required by gateway RBAC)\n });\n\n if (result.errors?.length) {\n throw new Error(result.errors[0]?.message || 'GraphQL error');\n }\n\n return result.data!.workspaceMembers;\n },\n enabled: !!workspaceId,\n staleTime: 5 * 60 * 1000,\n });\n};\n\n/**\n * Hook to fetch a single workspace member by ID\n */\nexport const useWorkspaceMember = (id: string) => {\n const { authToken, workspaceId } = useWorkspacesContext();\n\n return useQuery({\n queryKey: ['workspaceMember', workspaceId, id],\n queryFn: async (): Promise<WorkspaceMember> => {\n const result = await graphqlFetch<{ workspaceMember: WorkspaceMember }>({\n gateway: 'workspace',\n authToken: authToken || undefined,\n query: print(GetWorkspaceMemberDocument),\n variables: { id },\n workspaceId: workspaceId || undefined,\n workspaceToken: true, // Required by gateway RBAC for wspace-scoped operations\n });\n\n if (result.errors?.length) {\n throw new Error(result.errors[0]?.message || 'GraphQL error');\n }\n\n return result.data!.workspaceMember;\n },\n enabled: !!id,\n staleTime: 5 * 60 * 1000,\n });\n};\n\n/**\n * Hook to fetch all workspaces a user is a member of\n */\nexport const useUserWorkspaces = (userId: string, pagination?: PaginationInput) => {\n const { authToken, workspaceId } = useWorkspacesContext();\n\n return useQuery({\n queryKey: ['userWorkspaces', userId, pagination],\n queryFn: async (): Promise<MemberList> => {\n const result = await graphqlFetch<{ userWorkspaces: MemberList }>({\n gateway: 'workspace',\n authToken: authToken || undefined,\n query: print(GetUserWorkspacesDocument),\n variables: { userId, pagination },\n workspaceId: workspaceId || undefined,\n workspaceToken: true, // Required by gateway RBAC for wspace-scoped operations\n });\n\n if (result.errors?.length) {\n throw new Error(result.errors[0]?.message || 'GraphQL error');\n }\n\n return result.data!.userWorkspaces;\n },\n enabled: !!userId,\n staleTime: 5 * 60 * 1000,\n });\n};\n\n/**\n * Hook to fetch workspace invitations\n * Requires x-workspace-id header for workspace context\n */\nexport const useWorkspaceInvitations = (\n workspaceId: string,\n status?: InvitationStatus,\n pagination?: PaginationInput\n) => {\n const { authToken } = useWorkspacesContext();\n\n return useQuery({\n queryKey: ['workspaceInvitations', workspaceId, status, pagination],\n queryFn: async (): Promise<InvitationList> => {\n const result = await graphqlFetch<{ workspaceInvitations: InvitationList }>({\n gateway: 'workspace',\n authToken: authToken || undefined,\n query: print(GetWorkspaceInvitationsDocument),\n variables: { status, pagination },\n workspaceId,\n workspaceToken: true, // Auto-read from profile context for x-workspace-id header\n });\n\n if (result.errors?.length) {\n throw new Error(result.errors[0]?.message || 'GraphQL error');\n }\n\n return result.data!.workspaceInvitations;\n },\n enabled: !!workspaceId,\n staleTime: 5 * 60 * 1000,\n });\n};\n\n/**\n * Hook to get a single invitation by ID (for acceptance page)\n */\nexport const useInvitation = (id: string, enabled = true) => {\n const { authToken, workspaceId } = useWorkspacesContext();\n\n return useQuery({\n queryKey: ['invitation', id],\n queryFn: async (): Promise<WorkspaceInvitation> => {\n const result = await graphqlFetch<{ invitation: WorkspaceInvitation }>({\n gateway: 'workspace',\n authToken: authToken || undefined,\n query: print(GetInvitationDocument),\n variables: { id },\n });\n\n if (result.errors?.length) {\n throw new Error(result.errors[0]?.message || 'Failed to fetch invitation');\n }\n\n if (!result.data?.invitation) {\n throw new Error('Invitation not found');\n }\n\n return result.data.invitation;\n },\n enabled: !!id && enabled,\n retry: 1,\n staleTime: 5 * 60 * 1000,\n });\n};\n"],"mappings":";;;;;;AAuBA,IAAa,KAAuB,GAAqB,MAAiC;CACxF,IAAM,EAAE,iBAAc,GAAsB;AAE5C,QAAO,EAAS;EACd,UAAU;GAAC;GAAoB;GAAa;GAAW;EACvD,SAAS,YAAiC;GACxC,IAAM,IAAS,MAAM,EAA+C;IAClE,SAAS;IACT,WAAW,KAAa,KAAA;IACxB,OAAO,EAAM,EAA4B;IACzC,WAAW;KAAE;KAAa;KAAY;IACtC;IACA,gBAAgB;IACjB,CAAC;AAEF,OAAI,EAAO,QAAQ,OACjB,OAAU,MAAM,EAAO,OAAO,IAAI,WAAW,gBAAgB;AAG/D,UAAO,EAAO,KAAM;;EAEtB,SAAS,CAAC,CAAC;EACX,WAAW,MAAS;EACrB,CAAC;GAMS,KAAsB,MAAe;CAChD,IAAM,EAAE,cAAW,mBAAgB,GAAsB;AAEzD,QAAO,EAAS;EACd,UAAU;GAAC;GAAmB;GAAa;GAAG;EAC9C,SAAS,YAAsC;GAC7C,IAAM,IAAS,MAAM,EAAmD;IACtE,SAAS;IACT,WAAW,KAAa,KAAA;IACxB,OAAO,EAAM,EAA2B;IACxC,WAAW,EAAE,OAAI;IACjB,a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AC,cAAc,EAAG;EAC5B,SAAS,YAA0C;GACjD,IAAM,IAAS,MAAM,EAAkD;IACrE,SAAS;IACT,WAAW,KAAa,KAAA;IACxB,OAAO,EAAM,EAAsB;IACnC,WAAW,EAAE,OAAI;IAClB,CAAC;AAEF,OAAI,EAAO,QAAQ,OACjB,OAAU,MAAM,EAAO,OAAO,IAAI,WAAW,6BAA6B;AAG5E,OAAI,CAAC,EAAO,MAAM,WAChB,OAAU,MAAM,uBAAuB;AAGzC,UAAO,EAAO,KAAK;;EAErB,SAAS,CAAC,CAAC,KAAM;EACjB,OAAO;EACP,WAAW,MAAS;EACrB,CAAC"}
|
|
@@ -49,6 +49,7 @@ function w() {
|
|
|
49
49
|
children: [
|
|
50
50
|
/* @__PURE__ */ g("div", {
|
|
51
51
|
className: "flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3",
|
|
52
|
+
"data-tour": "workspaces-list-header",
|
|
52
53
|
children: [/* @__PURE__ */ g("div", { children: [/* @__PURE__ */ h("h1", {
|
|
53
54
|
className: "text-2xl sm:text-3xl font-bold",
|
|
54
55
|
children: o(w, "workspacesList.title", "Workspaces")
|
|
@@ -57,6 +58,7 @@ function w() {
|
|
|
57
58
|
children: o(w, "workspacesList.description", "Manage and organize your workspaces")
|
|
58
59
|
})] }), /* @__PURE__ */ g("div", {
|
|
59
60
|
className: "flex items-center gap-2",
|
|
61
|
+
"data-tour": "workspaces-list-actions",
|
|
60
62
|
children: [
|
|
61
63
|
/* @__PURE__ */ h(_, {
|
|
62
64
|
variant: O === "grid" ? "default" : "outline",
|
|
@@ -83,6 +85,7 @@ function w() {
|
|
|
83
85
|
children: /* @__PURE__ */ g(_, {
|
|
84
86
|
onClick: M,
|
|
85
87
|
className: "gap-2",
|
|
88
|
+
"data-tour": "workspaces-create-button",
|
|
86
89
|
children: [
|
|
87
90
|
/* @__PURE__ */ h(f, { size: 20 }),
|
|
88
91
|
/* @__PURE__ */ h("span", {
|
|
@@ -101,6 +104,7 @@ function w() {
|
|
|
101
104
|
}),
|
|
102
105
|
/* @__PURE__ */ g("div", {
|
|
103
106
|
className: "relative",
|
|
107
|
+
"data-tour": "workspaces-search-input",
|
|
104
108
|
children: [/* @__PURE__ */ h(p, {
|
|
105
109
|
className: "absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground",
|
|
106
110
|
size: 20
|
|
@@ -113,70 +117,74 @@ function w() {
|
|
|
113
117
|
className: "pl-[3.25rem]"
|
|
114
118
|
})]
|
|
115
119
|
}),
|
|
116
|
-
|
|
117
|
-
className: "
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
className: "
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
children:
|
|
120
|
+
/* @__PURE__ */ h("div", {
|
|
121
|
+
className: "space-y-4 sm:space-y-6",
|
|
122
|
+
"data-tour": "workspaces-view-container",
|
|
123
|
+
children: L ? /* @__PURE__ */ h("div", {
|
|
124
|
+
className: "grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-4",
|
|
125
|
+
children: Array.from({ length: 6 }).map((e, t) => /* @__PURE__ */ g("div", {
|
|
126
|
+
className: "space-y-3 p-6 border rounded-lg",
|
|
127
|
+
children: [/* @__PURE__ */ g("div", {
|
|
128
|
+
className: "flex items-center gap-3",
|
|
129
|
+
children: [/* @__PURE__ */ h(y, { className: "size-12 rounded-lg" }), /* @__PURE__ */ g("div", {
|
|
130
|
+
className: "space-y-2 flex-1",
|
|
131
|
+
children: [/* @__PURE__ */ h(y, { className: "h-4 w-3/4" }), /* @__PURE__ */ h(y, { className: "h-3 w-1/2" })]
|
|
132
|
+
})]
|
|
133
|
+
}), /* @__PURE__ */ h(y, { className: "h-3 w-1/3" })]
|
|
134
|
+
}, t))
|
|
135
|
+
}) : z?.items.length === 0 ? /* @__PURE__ */ g("div", {
|
|
136
|
+
className: "flex flex-col items-center justify-center py-12 text-center",
|
|
137
|
+
children: [
|
|
138
|
+
/* @__PURE__ */ h("div", {
|
|
139
|
+
className: "rounded-full bg-muted p-6 mb-4",
|
|
140
|
+
children: /* @__PURE__ */ h(u, {
|
|
141
|
+
size: 48,
|
|
142
|
+
className: "text-muted-foreground"
|
|
143
|
+
})
|
|
144
|
+
}),
|
|
145
|
+
/* @__PURE__ */ h("h3", {
|
|
146
|
+
className: "text-lg font-semibold mb-2",
|
|
147
|
+
children: o(w, "workspacesList.emptyTitle", "No workspaces found")
|
|
148
|
+
}),
|
|
149
|
+
/* @__PURE__ */ h("p", {
|
|
150
|
+
className: "text-muted-foreground mb-4 max-w-sm",
|
|
151
|
+
children: A.search ? o(w, "workspacesList.emptySearchHint", "Try adjusting your search criteria") : o(w, "workspacesList.emptyCreateHint", "Get started by creating your first workspace")
|
|
152
|
+
}),
|
|
153
|
+
!A.search && /* @__PURE__ */ h(S, {
|
|
154
|
+
permission: a.WORKSPACE_CREATE,
|
|
155
|
+
deniedBehavior: "disable",
|
|
156
|
+
deniedTooltip: o(w, "workspacesList.createDeniedTooltip", "You don't have permission to create workspaces"),
|
|
157
|
+
children: /* @__PURE__ */ g(_, {
|
|
158
|
+
onClick: M,
|
|
159
|
+
className: "gap-2",
|
|
160
|
+
children: [/* @__PURE__ */ h(f, { size: 20 }), o(w, "workspacesList.createFirstButton", "Create Your First Workspace")]
|
|
161
|
+
})
|
|
154
162
|
})
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
z.
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
})]
|
|
179
|
-
})
|
|
163
|
+
]
|
|
164
|
+
}) : /* @__PURE__ */ g(m, { children: [O === "list" ? /* @__PURE__ */ h("div", {
|
|
165
|
+
className: "space-y-3",
|
|
166
|
+
children: z?.items.map((e) => /* @__PURE__ */ h(i, { workspace: e }, e.id))
|
|
167
|
+
}) : /* @__PURE__ */ h("div", {
|
|
168
|
+
className: "grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-4",
|
|
169
|
+
children: z?.items.map((e) => /* @__PURE__ */ h(i, { workspace: e }, e.id))
|
|
170
|
+
}), z && z.total > 0 && /* @__PURE__ */ g("div", {
|
|
171
|
+
className: "flex items-center justify-between text-sm text-muted-foreground",
|
|
172
|
+
children: [/* @__PURE__ */ g("p", { children: [
|
|
173
|
+
o(w, "workspacesList.showing", "Showing"),
|
|
174
|
+
" ",
|
|
175
|
+
z.items.length,
|
|
176
|
+
" ",
|
|
177
|
+
o(w, "workspacesList.of", "of"),
|
|
178
|
+
" ",
|
|
179
|
+
z.total,
|
|
180
|
+
" ",
|
|
181
|
+
z.total === 1 ? o(w, "workspacesList.workspace", "workspace") : o(w, "workspacesList.workspaces", "workspaces")
|
|
182
|
+
] }), z.hasMore && /* @__PURE__ */ h("p", {
|
|
183
|
+
className: "text-xs",
|
|
184
|
+
children: o(w, "workspacesList.moreAvailable", "More workspaces available - pagination coming soon")
|
|
185
|
+
})]
|
|
186
|
+
})] })
|
|
187
|
+
})
|
|
180
188
|
]
|
|
181
189
|
});
|
|
182
190
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WorkspacesListPage.js","names":[],"sources":["../../src/pages/WorkspacesListPage.tsx"],"sourcesContent":["import { Plus, Grid3X3, List as ListIcon, Search } from 'lucide-react';\nimport { Button, Input, Skeleton } from '@burdenoff/fe-libs/ui';\nimport { useNavigate } from 'react-router-dom';\nimport { useWorkspacesStore } from '../store/workspacesStore';\nimport { useMyWorkspaces } from '../hooks/useWorkspaces';\nimport { WorkspaceCard } from '../components/WorkspaceCard';\nimport { useWorkspacesContext } from '../providers/WorkspacesProvider';\nimport { useDebounce } from '@burdenoff/fe-libs/shared/hooks';\nimport { PermissionButton } from '@burdenoff/fe-libs/shared/components';\nimport { WORKSPACE_PERMISSIONS } from '../constants/permissions';\nimport { useState, useEffect } from 'react';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\nimport { tWithFallback } from '../utils/i18n';\nimport { useScopedNavigation } from '../hooks/useScopedNavigation';\nimport { useWorkspacesPageView } from '../hooks/useWorkspacesPageView';\n\nexport function WorkspacesListPage() {\n useWorkspacesPageView('workspaces.list');\n const { t } = useI18n();\n\n const navigate = useNavigate();\n const { basePath = '/' } = useWorkspacesContext();\n const { withCurrentSearch } = useScopedNavigation();\n const { viewMode, setViewMode, workspaceFilters, setWorkspaceFilters } = useWorkspacesStore();\n\n // Navigate to unified workspace creation page\n const handleCreateWorkspace = () => {\n navigate(withCurrentSearch(`${basePath}/new`));\n };\n\n const [searchValue, setSearchValue] = useState(workspaceFilters.search || '');\n const debouncedSearch = useDebounce(searchValue, 500);\n\n // Update filters when debounced search changes\n useEffect(() => {\n if (debouncedSearch !== workspaceFilters.search) {\n setWorkspaceFilters({ search: debouncedSearch });\n }\n }, [debouncedSearch, workspaceFilters.search, setWorkspaceFilters]);\n\n const { data: rawData, isLoading, error } = useMyWorkspaces();\n\n // Client-side search filtering (myWorkspaces doesn't accept filter args)\n const data = rawData\n ? {\n ...rawData,\n items: debouncedSearch\n ? rawData.items.filter((ws) =>\n ws.name.toLowerCase().includes(debouncedSearch.toLowerCase())\n )\n : rawData.items,\n total: debouncedSearch\n ? rawData.items.filter((ws) =>\n ws.name.toLowerCase().includes(debouncedSearch.toLowerCase())\n ).length\n : rawData.total,\n }\n : undefined;\n\n const handleSearchChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n setSearchValue(e.target.value);\n };\n\n if (error) {\n return (\n <div className=\"space-y-4 sm:space-y-6 p-3 sm:p-6\">\n <div className=\"flex flex-col items-center justify-center py-12\">\n <p className=\"text-destructive text-lg font-semibold\">\n {tWithFallback(t, 'workspacesList.loadError', 'Error loading workspaces')}\n </p>\n <p className=\"text-muted-foreground text-sm mt-2\">\n {error instanceof Error\n ? error.message\n : tWithFallback(t, 'workspacesList.unknownError', 'Unknown error')}\n </p>\n </div>\n </div>\n );\n }\n\n return (\n <div className=\"space-y-4 sm:space-y-6 p-3 sm:p-6\">\n {/* Header with title + actions */}\n <div className=\"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3\">\n <div>\n <h1 className=\"text-2xl sm:text-3xl font-bold\">\n {tWithFallback(t, 'workspacesList.title', 'Workspaces')}\n </h1>\n <p className=\"text-sm sm:text-base text-muted-foreground\">\n {tWithFallback(t, 'workspacesList.description', 'Manage and organize your workspaces')}\n </p>\n </div>\n <div className=\"flex items-center gap-2\">\n {/* View mode toggle */}\n <Button\n variant={viewMode === 'grid' ? 'default' : 'outline'}\n size=\"icon\"\n onClick={() => setViewMode('grid')}\n className=\"hidden sm:flex\"\n aria-label={tWithFallback(\n t,\n 'workspacesList.gridViewAriaLabel',\n 'Show workspaces in grid view'\n )}\n title={tWithFallback(t, 'workspacesList.gridViewTitle', 'Grid view')}\n >\n <Grid3X3 size={20} />\n </Button>\n <Button\n variant={viewMode === 'list' ? 'default' : 'outline'}\n size=\"icon\"\n onClick={() => setViewMode('list')}\n className=\"hidden sm:flex\"\n aria-label={tWithFallback(\n t,\n 'workspacesList.listViewAriaLabel',\n 'Show workspaces in list view'\n )}\n title={tWithFallback(t, 'workspacesList.listViewTitle', 'List view')}\n >\n <ListIcon size={20} />\n </Button>\n {/* Create button - requires workspace:create permission */}\n <PermissionButton\n permission={WORKSPACE_PERMISSIONS.WORKSPACE_CREATE}\n deniedBehavior=\"disable\"\n deniedTooltip={tWithFallback(\n t,\n 'workspacesList.createDeniedTooltip',\n \"You don't have permission to create workspaces\"\n )}\n >\n <Button onClick={handleCreateWorkspace} className=\"gap-2\">\n <Plus size={20} />\n <span className=\"hidden sm:inline\">\n {tWithFallback(t, 'workspacesList.createButton', 'Create Workspace')}\n </span>\n <span className=\"sm:hidden\">\n {tWithFallback(t, 'workspacesList.createButtonShort', 'Create')}\n </span>\n </Button>\n </PermissionButton>\n </div>\n </div>\n\n {/* Search */}\n <div className=\"relative\">\n <Search\n className=\"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground\"\n size={20}\n />\n <Input\n placeholder={tWithFallback(t, 'workspacesList.searchPlaceholder', 'Search workspaces...')}\n value={searchValue}\n onChange={handleSearchChange}\n className=\"pl-[3.25rem]\"\n />\n </div>\n\n {/* Content */}\n {isLoading ? (\n <div className=\"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-4\">\n {Array.from({ length: 6 }).map((_, i) => (\n <div key={i} className=\"space-y-3 p-6 border rounded-lg\">\n <div className=\"flex items-center gap-3\">\n <Skeleton className=\"size-12 rounded-lg\" />\n <div className=\"space-y-2 flex-1\">\n <Skeleton className=\"h-4 w-3/4\" />\n <Skeleton className=\"h-3 w-1/2\" />\n </div>\n </div>\n <Skeleton className=\"h-3 w-1/3\" />\n </div>\n ))}\n </div>\n ) : data?.items.length === 0 ? (\n <div className=\"flex flex-col items-center justify-center py-12 text-center\">\n <div className=\"rounded-full bg-muted p-6 mb-4\">\n <Grid3X3 size={48} className=\"text-muted-foreground\" />\n </div>\n <h3 className=\"text-lg font-semibold mb-2\">\n {tWithFallback(t, 'workspacesList.emptyTitle', 'No workspaces found')}\n </h3>\n <p className=\"text-muted-foreground mb-4 max-w-sm\">\n {workspaceFilters.search\n ? tWithFallback(\n t,\n 'workspacesList.emptySearchHint',\n 'Try adjusting your search criteria'\n )\n : tWithFallback(\n t,\n 'workspacesList.emptyCreateHint',\n 'Get started by creating your first workspace'\n )}\n </p>\n {!workspaceFilters.search && (\n <PermissionButton\n permission={WORKSPACE_PERMISSIONS.WORKSPACE_CREATE}\n deniedBehavior=\"disable\"\n deniedTooltip={tWithFallback(\n t,\n 'workspacesList.createDeniedTooltip',\n \"You don't have permission to create workspaces\"\n )}\n >\n <Button onClick={handleCreateWorkspace} className=\"gap-2\">\n <Plus size={20} />\n {tWithFallback(\n t,\n 'workspacesList.createFirstButton',\n 'Create Your First Workspace'\n )}\n </Button>\n </PermissionButton>\n )}\n </div>\n ) : (\n <>\n {/* View */}\n {viewMode === 'list' ? (\n <div className=\"space-y-3\">\n {data?.items.map((workspace) => (\n <WorkspaceCard key={workspace.id} workspace={workspace} />\n ))}\n </div>\n ) : (\n <div className=\"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-4\">\n {data?.items.map((workspace) => (\n <WorkspaceCard key={workspace.id} workspace={workspace} />\n ))}\n </div>\n )}\n\n {/* Pagination info */}\n {data && data.total > 0 && (\n <div className=\"flex items-center justify-between text-sm text-muted-foreground\">\n <p>\n {tWithFallback(t, 'workspacesList.showing', 'Showing')} {data.items.length}{' '}\n {tWithFallback(t, 'workspacesList.of', 'of')} {data.total}{' '}\n {data.total !== 1\n ? tWithFallback(t, 'workspacesList.workspaces', 'workspaces')\n : tWithFallback(t, 'workspacesList.workspace', 'workspace')}\n </p>\n {data.hasMore && (\n <p className=\"text-xs\">\n {tWithFallback(\n t,\n 'workspacesList.moreAvailable',\n 'More workspaces available - pagination coming soon'\n )}\n </p>\n )}\n </div>\n )}\n </>\n )}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAgBA,SAAgB,IAAqB;AACnC,GAAsB,kBAAkB;CACxC,IAAM,EAAE,SAAM,GAAS,EAEjB,IAAW,GAAa,EACxB,EAAE,cAAW,QAAQ,GAAsB,EA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AAD,EAAA,UAAA;KACG,EAAc,GAAG,0BAA0B,UAAU;KAAC;KAAE,EAAK,MAAM;KAAQ;KAC3E,EAAc,GAAG,qBAAqB,KAAK;KAAC;KAAE,EAAK;KAAO;KAC1D,EAAK,UAAU,IAEZ,EAAc,GAAG,4BAA4B,YAAY,GADzD,EAAc,GAAG,6BAA6B,aAAa;KAE7D,EAAA,CAAA,EACH,EAAK,WACJ,kBAAC,KAAD;KAAG,WAAU;eACV,EACC,GACA,gCACA,qDACD;KACC,CAAA,CAEF;MAEP,EAAA,CAAA;GAED"}
|
|
1
|
+
{"version":3,"file":"WorkspacesListPage.js","names":[],"sources":["../../src/pages/WorkspacesListPage.tsx"],"sourcesContent":["import { Plus, Grid3X3, List as ListIcon, Search } from 'lucide-react';\nimport { Button, Input, Skeleton } from '@burdenoff/fe-libs/ui';\nimport { useNavigate } from 'react-router-dom';\nimport { useWorkspacesStore } from '../store/workspacesStore';\nimport { useMyWorkspaces } from '../hooks/useWorkspaces';\nimport { WorkspaceCard } from '../components/WorkspaceCard';\nimport { useWorkspacesContext } from '../providers/WorkspacesProvider';\nimport { useDebounce } from '@burdenoff/fe-libs/shared/hooks';\nimport { PermissionButton } from '@burdenoff/fe-libs/shared/components';\nimport { WORKSPACE_PERMISSIONS } from '../constants/permissions';\nimport { useState, useEffect } from 'react';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\nimport { tWithFallback } from '../utils/i18n';\nimport { useScopedNavigation } from '../hooks/useScopedNavigation';\nimport { useWorkspacesPageView } from '../hooks/useWorkspacesPageView';\n\nexport function WorkspacesListPage() {\n useWorkspacesPageView('workspaces.list');\n const { t } = useI18n();\n\n const navigate = useNavigate();\n const { basePath = '/' } = useWorkspacesContext();\n const { withCurrentSearch } = useScopedNavigation();\n const { viewMode, setViewMode, workspaceFilters, setWorkspaceFilters } = useWorkspacesStore();\n\n // Navigate to unified workspace creation page\n const handleCreateWorkspace = () => {\n navigate(withCurrentSearch(`${basePath}/new`));\n };\n\n const [searchValue, setSearchValue] = useState(workspaceFilters.search || '');\n const debouncedSearch = useDebounce(searchValue, 500);\n\n // Update filters when debounced search changes\n useEffect(() => {\n if (debouncedSearch !== workspaceFilters.search) {\n setWorkspaceFilters({ search: debouncedSearch });\n }\n }, [debouncedSearch, workspaceFilters.search, setWorkspaceFilters]);\n\n const { data: rawData, isLoading, error } = useMyWorkspaces();\n\n // Client-side search filtering (myWorkspaces doesn't accept filter args)\n const data = rawData\n ? {\n ...rawData,\n items: debouncedSearch\n ? rawData.items.filter((ws) =>\n ws.name.toLowerCase().includes(debouncedSearch.toLowerCase())\n )\n : rawData.items,\n total: debouncedSearch\n ? rawData.items.filter((ws) =>\n ws.name.toLowerCase().includes(debouncedSearch.toLowerCase())\n ).length\n : rawData.total,\n }\n : undefined;\n\n const handleSearchChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n setSearchValue(e.target.value);\n };\n\n if (error) {\n return (\n <div className=\"space-y-4 sm:space-y-6 p-3 sm:p-6\">\n <div className=\"flex flex-col items-center justify-center py-12\">\n <p className=\"text-destructive text-lg font-semibold\">\n {tWithFallback(t, 'workspacesList.loadError', 'Error loading workspaces')}\n </p>\n <p className=\"text-muted-foreground text-sm mt-2\">\n {error instanceof Error\n ? error.message\n : tWithFallback(t, 'workspacesList.unknownError', 'Unknown error')}\n </p>\n </div>\n </div>\n );\n }\n\n return (\n <div className=\"space-y-4 sm:space-y-6 p-3 sm:p-6\">\n {/* Header with title + actions */}\n <div\n className=\"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3\"\n data-tour=\"workspaces-list-header\"\n >\n <div>\n <h1 className=\"text-2xl sm:text-3xl font-bold\">\n {tWithFallback(t, 'workspacesList.title', 'Workspaces')}\n </h1>\n <p className=\"text-sm sm:text-base text-muted-foreground\">\n {tWithFallback(t, 'workspacesList.description', 'Manage and organize your workspaces')}\n </p>\n </div>\n <div className=\"flex items-center gap-2\" data-tour=\"workspaces-list-actions\">\n {/* View mode toggle */}\n <Button\n variant={viewMode === 'grid' ? 'default' : 'outline'}\n size=\"icon\"\n onClick={() => setViewMode('grid')}\n className=\"hidden sm:flex\"\n aria-label={tWithFallback(\n t,\n 'workspacesList.gridViewAriaLabel',\n 'Show workspaces in grid view'\n )}\n title={tWithFallback(t, 'workspacesList.gridViewTitle', 'Grid view')}\n >\n <Grid3X3 size={20} />\n </Button>\n <Button\n variant={viewMode === 'list' ? 'default' : 'outline'}\n size=\"icon\"\n onClick={() => setViewMode('list')}\n className=\"hidden sm:flex\"\n aria-label={tWithFallback(\n t,\n 'workspacesList.listViewAriaLabel',\n 'Show workspaces in list view'\n )}\n title={tWithFallback(t, 'workspacesList.listViewTitle', 'List view')}\n >\n <ListIcon size={20} />\n </Button>\n {/* Create button - requires workspace:create permission */}\n <PermissionButton\n permission={WORKSPACE_PERMISSIONS.WORKSPACE_CREATE}\n deniedBehavior=\"disable\"\n deniedTooltip={tWithFallback(\n t,\n 'workspacesList.createDeniedTooltip',\n \"You don't have permission to create workspaces\"\n )}\n >\n <Button\n onClick={handleCreateWorkspace}\n className=\"gap-2\"\n data-tour=\"workspaces-create-button\"\n >\n <Plus size={20} />\n <span className=\"hidden sm:inline\">\n {tWithFallback(t, 'workspacesList.createButton', 'Create Workspace')}\n </span>\n <span className=\"sm:hidden\">\n {tWithFallback(t, 'workspacesList.createButtonShort', 'Create')}\n </span>\n </Button>\n </PermissionButton>\n </div>\n </div>\n\n {/* Search */}\n <div className=\"relative\" data-tour=\"workspaces-search-input\">\n <Search\n className=\"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground\"\n size={20}\n />\n <Input\n placeholder={tWithFallback(t, 'workspacesList.searchPlaceholder', 'Search workspaces...')}\n value={searchValue}\n onChange={handleSearchChange}\n className=\"pl-[3.25rem]\"\n />\n </div>\n\n {/* Content */}\n <div className=\"space-y-4 sm:space-y-6\" data-tour=\"workspaces-view-container\">\n {isLoading ? (\n <div className=\"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-4\">\n {Array.from({ length: 6 }).map((_, i) => (\n <div key={i} className=\"space-y-3 p-6 border rounded-lg\">\n <div className=\"flex items-center gap-3\">\n <Skeleton className=\"size-12 rounded-lg\" />\n <div className=\"space-y-2 flex-1\">\n <Skeleton className=\"h-4 w-3/4\" />\n <Skeleton className=\"h-3 w-1/2\" />\n </div>\n </div>\n <Skeleton className=\"h-3 w-1/3\" />\n </div>\n ))}\n </div>\n ) : data?.items.length === 0 ? (\n <div className=\"flex flex-col items-center justify-center py-12 text-center\">\n <div className=\"rounded-full bg-muted p-6 mb-4\">\n <Grid3X3 size={48} className=\"text-muted-foreground\" />\n </div>\n <h3 className=\"text-lg font-semibold mb-2\">\n {tWithFallback(t, 'workspacesList.emptyTitle', 'No workspaces found')}\n </h3>\n <p className=\"text-muted-foreground mb-4 max-w-sm\">\n {workspaceFilters.search\n ? tWithFallback(\n t,\n 'workspacesList.emptySearchHint',\n 'Try adjusting your search criteria'\n )\n : tWithFallback(\n t,\n 'workspacesList.emptyCreateHint',\n 'Get started by creating your first workspace'\n )}\n </p>\n {!workspaceFilters.search && (\n <PermissionButton\n permission={WORKSPACE_PERMISSIONS.WORKSPACE_CREATE}\n deniedBehavior=\"disable\"\n deniedTooltip={tWithFallback(\n t,\n 'workspacesList.createDeniedTooltip',\n \"You don't have permission to create workspaces\"\n )}\n >\n <Button onClick={handleCreateWorkspace} className=\"gap-2\">\n <Plus size={20} />\n {tWithFallback(\n t,\n 'workspacesList.createFirstButton',\n 'Create Your First Workspace'\n )}\n </Button>\n </PermissionButton>\n )}\n </div>\n ) : (\n <>\n {/* View */}\n {viewMode === 'list' ? (\n <div className=\"space-y-3\">\n {data?.items.map((workspace) => (\n <WorkspaceCard key={workspace.id} workspace={workspace} />\n ))}\n </div>\n ) : (\n <div className=\"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-4\">\n {data?.items.map((workspace) => (\n <WorkspaceCard key={workspace.id} workspace={workspace} />\n ))}\n </div>\n )}\n\n {/* Pagination info */}\n {data && data.total > 0 && (\n <div className=\"flex items-center justify-between text-sm text-muted-foreground\">\n <p>\n {tWithFallback(t, 'workspacesList.showing', 'Showing')} {data.items.length}{' '}\n {tWithFallback(t, 'workspacesList.of', 'of')} {data.total}{' '}\n {data.total !== 1\n ? tWithFallback(t, 'workspacesList.workspaces', 'workspaces')\n : tWithFallback(t, 'workspacesList.workspace', 'workspace')}\n </p>\n {data.hasMore && (\n <p className=\"text-xs\">\n {tWithFallback(\n t,\n 'workspacesList.moreAvailable',\n 'More workspaces available - pagination coming soon'\n )}\n </p>\n )}\n </div>\n )}\n </>\n )}\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAgBA,SAAgB,IAAqB;AACnC,GAAsB,kBAAkB;CACxC,IAAM,EAAE,SAAM,GAAS,EAEjB,IAAW,GAAa,EACxB,EAAE,cAAW,QAAQ,GAAsB,EAC3C,EAAE,yBAAsB,GAAqB,EAC7C,EAAE,aAAU,gBAAa,qBAAkB,2BAAwB,GAAoB,EAGvF,UAA8B;AAClC,IAAS,EAAkB,GAAG,EAAS,MAAM,CAAC;IAG1C,CAAC,GAAa,KAAkB,EAAS,EAAiB,UAAU,GAAG,EACvE,IAAkB,EAAY,GAAa,IAAI;AAGrD,SAAgB;AACd,EAAI,MAAoB,EAAiB,UACvC,EAAoB,EAAE,QAAQ,GAAiB,CAAC;IAEjD;EAAC;EAAiB,EAAiB;EAAQ;EAAoB,CAAC;CAEnE,IAAM,EAAE,MAAM,GAAS,cAAW,aAAU,GAAiB,EAGvD,IAAO,IACT;EACE,GAAG;EACH,OAAO,IACH,EAAQ,MAAM,QAAQ,MACpB,EAAG,KAAK,aAAa,CAAC,SAAS,EAAgB,aAAa,CAAC,CAC9D,GACD,EAAQ;EACZ,OAAO,IACH,EAAQ,MAAM,QAAQ,MACpB,EAAG,KAAK,aAAa,CAAC,SAAS,EAAgB,aAAa,CAAC,CAC9D,CAAC,SACF,EAAQ;EACb,GACD,KAA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