0e82887ef6
Co-authored-by: Kandev Agent <agent@kandev.dev> Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
38 lines
1.2 KiB
TypeScript
38 lines
1.2 KiB
TypeScript
"use client";
|
|
|
|
import { type ReactNode } from "react";
|
|
import { Card, CardContent } from "@kandev/ui/card";
|
|
import { useAppStore } from "@/components/state-provider";
|
|
import { useTranslation } from "react-i18next";
|
|
|
|
type WorkspaceScopedSectionProps = {
|
|
emptyMessage?: string;
|
|
workspaceId?: string;
|
|
children: (workspaceId: string) => ReactNode;
|
|
};
|
|
|
|
// WorkspaceScopedSection renders per-workspace integration settings for the
|
|
// routed workspace when present, otherwise the active workspace in the store.
|
|
export function WorkspaceScopedSection({
|
|
emptyMessage,
|
|
workspaceId,
|
|
children,
|
|
}: WorkspaceScopedSectionProps) {
|
|
const { t } = useTranslation();
|
|
const workspaces = useAppStore((s) => s.workspaces.items);
|
|
const activeId = useAppStore((s) => s.workspaces.activeId);
|
|
const selected = workspaceId ?? activeId ?? workspaces[0]?.id ?? null;
|
|
|
|
if (!workspaceId && workspaces.length === 0) {
|
|
return (
|
|
<Card>
|
|
<CardContent className="py-6 text-sm text-muted-foreground">
|
|
{emptyMessage ?? t("common:createAWorkspaceToConfigureThisIntegration")}
|
|
</CardContent>
|
|
</Card>
|
|
);
|
|
}
|
|
|
|
return <div className="space-y-3">{selected ? children(selected) : null}</div>;
|
|
}
|