diff --git a/src/app/admin/pricing/page.tsx b/src/app/admin/pricing/page.tsx index fbb13f5..01b08b4 100644 --- a/src/app/admin/pricing/page.tsx +++ b/src/app/admin/pricing/page.tsx @@ -1,18 +1,52 @@ "use client"; import { SectionEditor } from "../_components/SectionEditor"; -import { InputField } from "../_components/FormField"; +import { InputField, SelectField } from "../_components/FormField"; import { ArrayEditor } from "../_components/ArrayEditor"; +interface PricingItem { + name: string; + price: string; + note?: string; + popular?: boolean; + featured?: boolean; +} + interface PricingData { title: string; subtitle: string; - items: { name: string; price: string; note?: string }[]; + items: PricingItem[]; rentalTitle: string; rentalItems: { name: string; price: string; note?: string }[]; rules: string[]; } +function PriceField({ label, value, onChange }: { label: string; value: string; onChange: (v: string) => void }) { + // Strip "BYN" suffix for editing, add back on save + const raw = value.replace(/\s*BYN\s*$/i, "").trim(); + + return ( +
+ +
+ { + const v = e.target.value; + onChange(v ? `${v} BYN` : ""); + }} + placeholder="0" + className="flex-1 bg-transparent px-4 py-2.5 text-white placeholder-neutral-500 outline-none min-w-0" + /> + + BYN + +
+
+ ); +} + export default function PricingEditorPage() { return ( sectionKey="pricing" title="Цены"> @@ -29,6 +63,48 @@ export default function PricingEditorPage() { onChange={(v) => update({ ...data, subtitle: v })} /> + {/* Popular & Featured selectors */} + {(() => { + const itemOptions = data.items + .map((it, idx) => ({ value: String(idx), label: it.name })) + .filter((o) => o.label.trim() !== ""); + const noneOption = { value: "", label: "— Нет —" }; + + const popularIdx = data.items.findIndex((it) => it.popular); + const featuredIdx = data.items.findIndex((it) => it.featured); + + return ( +
+ = 0 ? String(popularIdx) : ""} + onChange={(v) => { + const items = data.items.map((it, idx) => ({ + ...it, + popular: v ? idx === Number(v) : false, + })); + update({ ...data, items }); + }} + options={[noneOption, ...itemOptions]} + placeholder="Выберите..." + /> + = 0 ? String(featuredIdx) : ""} + onChange={(v) => { + const items = data.items.map((it, idx) => ({ + ...it, + featured: v ? idx === Number(v) : false, + })); + update({ ...data, items }); + }} + options={[noneOption, ...itemOptions]} + placeholder="Выберите..." + /> +
+ ); + })()} + updateItem({ ...item, name: v })} /> - updateItem({ ...item, price: v })} @@ -73,7 +149,7 @@ export default function PricingEditorPage() { value={item.name} onChange={(v) => updateItem({ ...item, name: v })} /> - updateItem({ ...item, price: v })} diff --git a/src/components/sections/Pricing.tsx b/src/components/sections/Pricing.tsx index b1d99d1..4544844 100644 --- a/src/components/sections/Pricing.tsx +++ b/src/components/sections/Pricing.tsx @@ -23,9 +23,9 @@ export function Pricing({ data: pricing }: PricingProps) { { id: "rules", label: "Правила", icon: }, ]; - // Split items: regular + unlimited (last item) - const regularItems = pricing.items.slice(0, -1); - const unlimitedItem = pricing.items[pricing.items.length - 1]; + // Split items: featured (big card) vs regular + const featuredItem = pricing.items.find((item) => item.featured); + const regularItems = pricing.items.filter((item) => !item.featured); return (
@@ -66,7 +66,7 @@ export function Pricing({ data: pricing }: PricingProps) { {/* Cards grid */}
{regularItems.map((item, i) => { - const isPopular = i === 0; + const isPopular = item.popular ?? false; return ( diff --git a/src/types/content.ts b/src/types/content.ts index 00aa2a4..81c5164 100644 --- a/src/types/content.ts +++ b/src/types/content.ts @@ -24,6 +24,8 @@ export interface PricingItem { name: string; price: string; note?: string; + popular?: boolean; + featured?: boolean; } export interface ScheduleClass {