install skill

This commit is contained in:
phaichayon
2026-07-02 09:45:34 +07:00
parent ed28ff6b50
commit f7c9037ba4
147 changed files with 29394 additions and 1 deletions

View File

@@ -558,6 +558,9 @@ function MappingDialog({
function TemplateDetailCard({ templateId }: { templateId: string }) {
const { data } = useSuspenseQuery(documentTemplateByIdOptions(templateId));
const template = data.template;
const [selectedVersionId, setSelectedVersionId] = React.useState<string | undefined>(
template.versions[0]?.id
);
const [versionDialogState, setVersionDialogState] = React.useState<{
open: boolean;
version?: DocumentTemplateVersionDetail;
@@ -573,6 +576,19 @@ function TemplateDetailCard({ templateId }: { templateId: string }) {
onError: (error) => toast.error(error instanceof Error ? error.message : 'Delete failed')
});
React.useEffect(() => {
if (template.versions.length === 0) {
setSelectedVersionId(undefined);
return;
}
setSelectedVersionId((current) =>
current && template.versions.some((version) => version.id === current)
? current
: template.versions[0]?.id
);
}, [template.versions]);
return (
<div className='space-y-4'>
<div className='grid gap-4 md:grid-cols-4'>
@@ -594,7 +610,11 @@ function TemplateDetailCard({ templateId }: { templateId: string }) {
</div>
</div>
<Tabs defaultValue={template.versions[0]?.id ?? 'empty'} className='space-y-4'>
<Tabs
value={selectedVersionId ?? 'empty'}
onValueChange={setSelectedVersionId}
className='space-y-4'
>
<div className='flex items-center justify-between gap-4'>
<TabsList className='flex flex-wrap'>
{template.versions.map((version) => (