Files
kandev/apps/web/components/integrations/workspace-scoped-section.tsx
T
João Salavisa 0e82887ef6 feat(i18n): localize Settings → Integrations → GitHub connection and auth (#2155)
Co-authored-by: Kandev Agent <agent@kandev.dev>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-02 14:16:26 +02:00

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>;
}