diff --git a/src/components/admin/SmsCityProfilesPanel.jsx b/src/components/admin/SmsCityProfilesPanel.jsx index 9868ea0..f3718d1 100644 --- a/src/components/admin/SmsCityProfilesPanel.jsx +++ b/src/components/admin/SmsCityProfilesPanel.jsx @@ -1,12 +1,6 @@ /** * @file SmsCityProfilesPanel.jsx * @description Профили SMS по городам. - * Для каждого города настраивается: - * - Доставка: ссылка на согласование | уведомление без ссылки + кастомный текст - * - Самовывоз: ссылка на согласование | уведомление без ссылки + кастомный текст - * - 2-я SMS: вкл/выкл - * - Платное хранение: вкл/выкл - * - SMS вообще: вкл/выкл (мастер-выключатель) */ import React, { useState, useEffect, useCallback } from "react"; import { Panel } from "../UI/Panel"; @@ -20,7 +14,6 @@ export const SmsCityProfilesPanel = () => { const [saving, setSaving] = useState(false); const [message, setMessage] = useState(""); - // Form state const [formCity, setFormCity] = useState("Ялта"); const [formDeliveryMode, setFormDeliveryMode] = useState("notification"); const [formDeliveryText, setFormDeliveryText] = useState(""); @@ -30,8 +23,6 @@ export const SmsCityProfilesPanel = () => { const [formPaidStorage, setFormPaidStorage] = useState(true); const [formSmsEnabled, setFormSmsEnabled] = useState(true); const [formNote, setFormNote] = useState(""); - - // Edit state const [editingId, setEditingId] = useState(null); const fetchProfiles = useCallback(async () => { @@ -80,16 +71,11 @@ export const SmsCityProfilesPanel = () => { note: formNote || "", }; if (editingId) { - const { error } = await supabase - .from("sms_city_profiles") - .update(payload) - .eq("id", editingId); + const { error } = await supabase.from("sms_city_profiles").update(payload).eq("id", editingId); if (error) throw error; setMessage("✅ Профиль обновлён"); } else { - const { error } = await supabase - .from("sms_city_profiles") - .insert(payload); + const { error } = await supabase.from("sms_city_profiles").insert(payload); if (error) throw error; setMessage("✅ Профиль добавлен"); } @@ -120,10 +106,7 @@ export const SmsCityProfilesPanel = () => { const handleDelete = async (id) => { try { - const { error } = await supabase - .from("sms_city_profiles") - .delete() - .eq("id", id); + const { error } = await supabase.from("sms_city_profiles").delete().eq("id", id); if (error) throw error; fetchProfiles(); } catch (e) { @@ -133,10 +116,7 @@ export const SmsCityProfilesPanel = () => { const handleQuickToggle = async (profile, field) => { try { - const { error } = await supabase - .from("sms_city_profiles") - .update({ [field]: !profile[field] }) - .eq("id", profile.id); + const { error } = await supabase.from("sms_city_profiles").update({ [field]: !profile[field] }).eq("id", profile.id); if (error) throw error; fetchProfiles(); } catch (e) { @@ -144,42 +124,100 @@ export const SmsCityProfilesPanel = () => { } }; + // ── Styles ────────────────────────────────────────────────────────────── + // Карточка профиля — лёгкий зелёный оттенок, виден на белом Panel + const profileCardStyle = { + backgroundColor: "var(--color-accent-soft)", + border: "1px solid var(--color-border)", + borderRadius: "16px", + padding: "16px", + }; + + // Внутренний блок (Доставка/Самовывоз) — непрозрачный, контраст с карточкой + const innerBlockStyle = { + backgroundColor: "var(--color-surface-strong)", + border: "1px solid var(--color-border)", + borderRadius: "10px", + padding: "12px", + }; + + // Инпут — фон базовый + const inputStyle = { + backgroundColor: "var(--color-base)", + border: "1px solid var(--color-border)", + borderRadius: "10px", + padding: "8px 12px", + color: "var(--color-text)", + width: "100%", + fontSize: "14px", + }; + + const labelStyle = { + fontSize: "12px", + fontWeight: 500, + color: "var(--color-text-muted)", + }; + // ── UI helpers ────────────────────────────────────────────────────────── const ModeBadge = ({ mode }) => { if (mode === "notification") { - return Уведомление; + return Уведомление; } - return Ссылка; + return Ссылка; }; const Toggle = ({ checked, onChange, label }) => ( -
+
- {label && {label}} + {label && {label}}
); - const inputCls = "w-full rounded-lg border border-[var(--color-border)] bg-[var(--color-base)] px-3 py-2 text-sm text-[var(--color-text)] placeholder:text-[var(--color-text-muted)]"; - const cardCls = "rounded-xl border border-[var(--color-border)] bg-[var(--color-base)] p-4 space-y-3"; + const modeButton = (active, activeColor, activeBg, label, onClick) => ({ + type: "button", + onClick, + style: { + flex: 1, + borderRadius: "10px", + border: `1px solid ${active ? activeColor : "var(--color-border)"}`, + backgroundColor: active ? activeBg : "transparent", + color: active ? activeColor : "var(--color-text-muted)", + padding: "8px 12px", + fontSize: "14px", + fontWeight: 500, + cursor: "pointer", + transition: "all 0.15s", + }, + children: label, + }); return ( -
+
{/* Header */} - -
-
- 🏙️ + +
+
+ 🏙️
-

+

Профили SMS по городам

-

+

Настройка поведения SMS для каждого города: согласование по ссылке или уведомление.

@@ -187,64 +225,53 @@ export const SmsCityProfilesPanel = () => {
- {message && {message}} + {message && {message}} {/* Add/Edit form */} {showForm && ( - -

+ +

{editingId ? "Редактировать профиль" : "Новый профиль города"}

{/* City + master toggle */} -
-
- +
+
+
-
+
setFormSmsEnabled(!formSmsEnabled)} label="SMS включены для города" /> {!formSmsEnabled && ( -

⚠ Все SMS в этот город отключены

+

⚠ Все SMS в этот город отключены

)}
{/* Delivery */} -
-
📦 Доставка
-
- - +
+
📦 Доставка
+
+
{formDeliveryMode === "notification" && (