fix
This commit is contained in:
parent
d89b5b002c
commit
8ad4bd41e1
@ -9,6 +9,7 @@ import type {
|
|||||||
ListOptionDefinition,
|
ListOptionDefinition,
|
||||||
NavigationConditionDefinition,
|
NavigationConditionDefinition,
|
||||||
ScreenDefinition,
|
ScreenDefinition,
|
||||||
|
ScreenVariantDefinition,
|
||||||
} from "@/lib/funnel/types";
|
} from "@/lib/funnel/types";
|
||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
|
|
||||||
@ -235,7 +236,11 @@ function VariantSummary({
|
|||||||
screenTitleMap: Record<string, string>;
|
screenTitleMap: Record<string, string>;
|
||||||
listOptionsMap: Record<string, ListOptionDefinition[]>;
|
listOptionsMap: Record<string, ListOptionDefinition[]>;
|
||||||
}) {
|
}) {
|
||||||
const variants = (screen as ScreenDefinition & { variants?: ScreenDefinition["variants"] }).variants;
|
const variants = (
|
||||||
|
screen as ScreenDefinition & {
|
||||||
|
variants?: ScreenVariantDefinition<ScreenDefinition>[];
|
||||||
|
}
|
||||||
|
).variants;
|
||||||
|
|
||||||
if (!variants || variants.length === 0) {
|
if (!variants || variants.length === 0) {
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@ -63,13 +63,16 @@ function VariantOverridesEditor({
|
|||||||
}, [baseScreen]);
|
}, [baseScreen]);
|
||||||
|
|
||||||
const mergedScreen = useMemo(
|
const mergedScreen = useMemo(
|
||||||
() => mergeScreenWithOverrides(baseWithoutVariants, overrides),
|
() => mergeScreenWithOverrides<BuilderScreen>(baseWithoutVariants, overrides) as BuilderScreen,
|
||||||
[baseWithoutVariants, overrides]
|
[baseWithoutVariants, overrides]
|
||||||
);
|
);
|
||||||
|
|
||||||
const handleUpdate = useCallback(
|
const handleUpdate = useCallback(
|
||||||
(updates: Partial<ScreenDefinition>) => {
|
(updates: Partial<ScreenDefinition>) => {
|
||||||
const nextScreen = mergeScreenWithOverrides(mergedScreen, updates as Partial<ScreenDefinition>);
|
const nextScreen = mergeScreenWithOverrides<BuilderScreen>(
|
||||||
|
mergedScreen,
|
||||||
|
updates as Partial<BuilderScreen>
|
||||||
|
);
|
||||||
const nextOverrides = extractVariantOverrides(baseWithoutVariants, nextScreen);
|
const nextOverrides = extractVariantOverrides(baseWithoutVariants, nextScreen);
|
||||||
onChange(nextOverrides);
|
onChange(nextOverrides);
|
||||||
},
|
},
|
||||||
@ -79,7 +82,7 @@ function VariantOverridesEditor({
|
|||||||
return (
|
return (
|
||||||
<div className="space-y-3">
|
<div className="space-y-3">
|
||||||
<TemplateConfig screen={mergedScreen} onUpdate={handleUpdate} />
|
<TemplateConfig screen={mergedScreen} onUpdate={handleUpdate} />
|
||||||
<Button variant="outline" size="sm" onClick={() => onChange({})}>
|
<Button variant="outline" className="h-8 px-3 text-xs" onClick={() => onChange({})}>
|
||||||
Сбросить переопределения
|
Сбросить переопределения
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
@ -294,7 +297,7 @@ export function ScreenVariantsConfig({ screen, allScreens, onChange }: ScreenVar
|
|||||||
<p className="text-xs text-muted-foreground">
|
<p className="text-xs text-muted-foreground">
|
||||||
Настройте альтернативные варианты контента без изменения переходов.
|
Настройте альтернативные варианты контента без изменения переходов.
|
||||||
</p>
|
</p>
|
||||||
<Button size="sm" onClick={addVariant} disabled={listScreens.length === 0}>
|
<Button className="h-8 px-3 text-xs" onClick={addVariant} disabled={listScreens.length === 0}>
|
||||||
Добавить вариант
|
Добавить вариант
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
@ -326,12 +329,16 @@ export function ScreenVariantsConfig({ screen, allScreens, onChange }: ScreenVar
|
|||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
<Button
|
<Button
|
||||||
variant="outline"
|
variant="outline"
|
||||||
size="sm"
|
className="h-8 px-3 text-xs"
|
||||||
onClick={() => setExpandedVariant(isExpanded ? null : index)}
|
onClick={() => setExpandedVariant(isExpanded ? null : index)}
|
||||||
>
|
>
|
||||||
{isExpanded ? "Свернуть" : "Редактировать"}
|
{isExpanded ? "Свернуть" : "Редактировать"}
|
||||||
</Button>
|
</Button>
|
||||||
<Button variant="ghost" size="sm" className="text-destructive" onClick={() => removeVariant(index)}>
|
<Button
|
||||||
|
variant="ghost"
|
||||||
|
className="h-8 px-3 text-xs text-destructive"
|
||||||
|
onClick={() => removeVariant(index)}
|
||||||
|
>
|
||||||
Удалить
|
Удалить
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user