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" && (
{/* Pickup */}
-
-
🏪 Самовывоз
-
-
setFormPickupMode("link")}
- className={["flex-1 rounded-lg border px-3 py-2 text-sm font-medium transition",
- formPickupMode === "link" ? "border-[#22c55e] bg-[rgba(34,197,94,0.1)] text-[#22c55e]" : "border-[var(--color-border)] text-[var(--color-text-muted)] hover:bg-[var(--color-surface)]"].join(" ")}
- >
- 🔗 Ссылка
-
-
setFormPickupMode("notification")}
- className={["flex-1 rounded-lg border px-3 py-2 text-sm font-medium transition",
- formPickupMode === "notification" ? "border-[#3b82f6] bg-[rgba(59,130,246,0.1)] text-[#3b82f6]" : "border-[var(--color-border)] text-[var(--color-text-muted)] hover:bg-[var(--color-surface)]"].join(" ")}
- >
- 📢 Уведомление
-
+
+
🏪 Самовывоз
+
+ setFormPickupMode("link"))} />
+ setFormPickupMode("notification"))} />
{formPickupMode === "notification" && (
{/* Toggles row */}
-
-
+
+
setFormSecondSms(!formSecondSms)} label="2-я SMS (повтор)" />
-
+
setFormPaidStorage(!formPaidStorage)} label="SMS: платное хранение" />
{/* Note */}
-
-
+
+
setFormNote(e.target.value)}
placeholder="Например: Ялта — доставка без согласования"
- className={inputCls}
+ style={inputStyle}
/>
@@ -318,7 +331,11 @@ export const SmsCityProfilesPanel = () => {
type="button"
disabled={saving}
onClick={handleSave}
- className="rounded-xl bg-[var(--color-accent)] px-5 py-2.5 text-sm font-semibold text-white transition hover:opacity-90 disabled:opacity-40"
+ style={{
+ borderRadius: "12px", backgroundColor: "var(--color-accent)", padding: "10px 20px",
+ fontSize: "14px", fontWeight: 600, color: "#fff", border: "none", cursor: "pointer",
+ opacity: saving ? 0.4 : 1,
+ }}
>
{saving ? "Сохранение..." : editingId ? "Обновить профиль" : "Сохранить профиль"}
@@ -326,44 +343,52 @@ export const SmsCityProfilesPanel = () => {
)}
{/* Profiles list */}
-
-
+
+
Профили ({profiles.length})
{loading ? (
- Загрузка...
+ Загрузка...
) : profiles.length === 0 ? (
-
-
+
+
Профилей нет. Города без профиля используют стандартный флоу (ссылка на согласование).
) : (
-
+
{profiles.map((p) => (
-
+
{/* Header row */}
-
-
-
{p.city}
+
+
+ {p.city}
{!p.sms_enabled ? (
- SMS OFF
+ SMS OFF
) : (
- SMS ON
+ SMS ON
)}
-
+
handleEdit(p)}
- className="rounded-lg border border-[var(--color-border)] px-2.5 py-1 text-xs font-medium text-[var(--color-text)] hover:bg-[var(--color-surface)]"
+ style={{
+ borderRadius: "8px", border: "1px solid var(--color-border)", padding: "4px 10px",
+ fontSize: "12px", fontWeight: 500, color: "var(--color-text)", cursor: "pointer",
+ backgroundColor: "transparent",
+ }}
>
✏️ Изменить
handleDelete(p.id)}
- className="rounded-lg p-1.5 text-[var(--color-text-muted)] hover:bg-[var(--color-surface)] hover:text-[var(--color-danger)]"
+ style={{
+ borderRadius: "8px", padding: "4px 8px", fontSize: "14px",
+ color: "var(--color-text-muted)", cursor: "pointer", backgroundColor: "transparent",
+ border: "none",
+ }}
title="Удалить"
>
✕
@@ -372,41 +397,39 @@ export const SmsCityProfilesPanel = () => {
{/* Config grid */}
-
- {/* Delivery */}
-
-
-
📦 Доставка
+
+
+
+ 📦 Доставка
{p.delivery_text && (
-
"{p.delivery_text}"
+
"{p.delivery_text}"
)}
- {/* Pickup */}
-
-
-
🏪 Самовывоз
+
+
+ 🏪 Самовывоз
{p.pickup_text && (
-
"{p.pickup_text}"
+
"{p.pickup_text}"
)}
{/* Toggles row */}
-
-
+
+
2-я SMS: {p.second_sms_enabled ? "✅" : "❌"}
-
+
Платное хранение: {p.paid_storage_enabled ? "✅" : "❌"}
{p.note && (
- 💬 {p.note}
+ 💬 {p.note}
)}
))}