feat: discount toggle flag, hide price from success popup

- Admin: "Добавить скидку" toggle — OFF hides discount fields and sets to 0
- Public: discount line hidden when discountPrice=0
- Success popup: removed price/booking count info
This commit is contained in:
2026-03-24 23:07:06 +03:00
parent eb6ec5aeb6
commit d0fad4aae5
3 changed files with 57 additions and 41 deletions

View File

@@ -2,7 +2,7 @@
import { useState, useEffect, useMemo, useCallback } from "react";
import {
Plus, X, Loader2, Calendar, Trash2, Ban, CheckCircle2, RotateCcw,
Plus, X, Loader2, Calendar, Trash2, Ban, CheckCircle2, RotateCcw, Sparkles,
} from "lucide-react";
import { adminFetch } from "@/lib/csrf";
import { ParticipantLimits } from "../_components/FormField";
@@ -100,16 +100,35 @@ function EventSettings({
/>
</div>
<div className="grid gap-4 sm:grid-cols-3">
<div>
<label className="block text-sm text-neutral-400 mb-1.5">Цена за занятие (BYN)</label>
<input
type="number"
value={event.pricePerClass}
onChange={(e) => onChange({ pricePerClass: parseInt(e.target.value) || 0 })}
className="w-full rounded-lg border border-white/10 bg-neutral-800 px-4 py-2.5 text-white outline-none focus:border-gold transition-colors"
className="w-full rounded-lg border border-white/10 bg-neutral-800 px-4 py-2.5 text-white outline-none focus:border-gold transition-colors sm:max-w-xs"
/>
</div>
{/* Discount toggle + fields */}
<div>
<button
type="button"
onClick={() => {
if (event.discountPrice > 0) onChange({ discountPrice: 0, discountThreshold: 0 });
else onChange({ discountPrice: event.pricePerClass - 5, discountThreshold: 3 });
}}
className={`flex items-center gap-2 rounded-full px-4 py-2 text-sm font-medium transition-all ${
event.discountPrice > 0
? "bg-gold/15 text-gold border border-gold/30"
: "bg-neutral-800 text-neutral-400 border border-white/10 hover:text-white"
}`}
>
<Sparkles size={14} />
{event.discountPrice > 0 ? "Скидка включена" : "Добавить скидку"}
</button>
{event.discountPrice > 0 && (
<div className="grid gap-4 sm:grid-cols-2 mt-3">
<div>
<label className="block text-sm text-neutral-400 mb-1.5">Цена со скидкой (BYN)</label>
<input
@@ -129,6 +148,8 @@ function EventSettings({
/>
</div>
</div>
)}
</div>
<ParticipantLimits
min={event.minBookings}
@@ -151,7 +172,7 @@ function EventSettings({
{event.active ? "Опубликовано" : "Черновик"}
</button>
<span className="text-xs text-neutral-500">
{event.pricePerClass} BYN / занятие, от {event.discountThreshold} {event.discountPrice} BYN
{event.pricePerClass} BYN / занятие{event.discountPrice > 0 && event.discountThreshold > 0 && `, от ${event.discountThreshold}${event.discountPrice} BYN`}
</span>
</div>
</div>

View File

@@ -67,10 +67,12 @@ export function OpenDay({ data }: OpenDayProps) {
<p className="text-lg font-semibold text-white">
{event.pricePerClass} BYN <span className="text-neutral-400 font-normal text-sm">за занятие</span>
</p>
{event.discountPrice > 0 && event.discountThreshold > 0 && (
<p className="text-sm text-gold">
<Sparkles size={12} className="inline mr-1" />
От {event.discountThreshold} занятий {event.discountPrice} BYN за каждое!
</p>
)}
</div>
</Reveal>

View File

@@ -178,13 +178,6 @@ export function SignupModal({
{successMessage || "Вы записаны!"}
</h3>
{subtitle && <p className="mt-1 text-sm text-neutral-400">{subtitle}</p>}
{successData?.totalBookings !== undefined && (
<p className="mt-3 text-sm text-white">
Вы записаны на <span className="text-gold font-semibold">{String(successData.totalBookings)}</span> занятий.
<br />
Стоимость: <span className="text-gold font-semibold">{String(successData.pricePerClass)} BYN</span> за занятие
</p>
)}
</>
)}
<button