Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
376e3e9473 | ||
|
|
01ad88adf9 | ||
|
|
638d1dad52 | ||
|
|
dec17b537e | ||
|
|
2a3bbd30fb | ||
|
|
4ac190f161 |
@@ -25,6 +25,7 @@ interface Announcement {
|
|||||||
title?: string;
|
title?: string;
|
||||||
description?: string;
|
description?: string;
|
||||||
link?: string;
|
link?: string;
|
||||||
|
button_text?: string;
|
||||||
start_date?: string | null;
|
start_date?: string | null;
|
||||||
end_date?: string | null;
|
end_date?: string | null;
|
||||||
image_id?: number | null;
|
image_id?: number | null;
|
||||||
@@ -57,6 +58,7 @@ export default function AnnouncementsPage() {
|
|||||||
const [title, setTitle] = useState("");
|
const [title, setTitle] = useState("");
|
||||||
const [description, setDescription] = useState("");
|
const [description, setDescription] = useState("");
|
||||||
const [link, setLink] = useState("");
|
const [link, setLink] = useState("");
|
||||||
|
const [buttonText, setButtonText] = useState("");
|
||||||
const [startDate, setStartDate] = useState("");
|
const [startDate, setStartDate] = useState("");
|
||||||
const [endDate, setEndDate] = useState("");
|
const [endDate, setEndDate] = useState("");
|
||||||
const [imageId, setImageId] = useState<number | null>(null);
|
const [imageId, setImageId] = useState<number | null>(null);
|
||||||
@@ -71,6 +73,7 @@ export default function AnnouncementsPage() {
|
|||||||
setTitle("");
|
setTitle("");
|
||||||
setDescription("");
|
setDescription("");
|
||||||
setLink("");
|
setLink("");
|
||||||
|
setButtonText("");
|
||||||
setStartDate("");
|
setStartDate("");
|
||||||
setEndDate("");
|
setEndDate("");
|
||||||
setImageId(null);
|
setImageId(null);
|
||||||
@@ -82,6 +85,7 @@ export default function AnnouncementsPage() {
|
|||||||
setTitle(row.title ?? "");
|
setTitle(row.title ?? "");
|
||||||
setDescription(row.description ?? "");
|
setDescription(row.description ?? "");
|
||||||
setLink(row.link ?? "");
|
setLink(row.link ?? "");
|
||||||
|
setButtonText(row.button_text ?? "");
|
||||||
setStartDate(toDateInput(row.start_date));
|
setStartDate(toDateInput(row.start_date));
|
||||||
setEndDate(toDateInput(row.end_date));
|
setEndDate(toDateInput(row.end_date));
|
||||||
setImageId(row.image_id ?? null);
|
setImageId(row.image_id ?? null);
|
||||||
@@ -99,6 +103,7 @@ export default function AnnouncementsPage() {
|
|||||||
title,
|
title,
|
||||||
description,
|
description,
|
||||||
link,
|
link,
|
||||||
|
button_text: buttonText,
|
||||||
start_date: startDate,
|
start_date: startDate,
|
||||||
end_date: endDate,
|
end_date: endDate,
|
||||||
image_id: imageId,
|
image_id: imageId,
|
||||||
@@ -270,6 +275,14 @@ export default function AnnouncementsPage() {
|
|||||||
/>
|
/>
|
||||||
</Field>
|
</Field>
|
||||||
|
|
||||||
|
<Field label="متن دکمه" hint="اختیاری">
|
||||||
|
<Input
|
||||||
|
value={buttonText}
|
||||||
|
onChange={(e) => setButtonText(e.target.value)}
|
||||||
|
placeholder="مثلاً مشاهده"
|
||||||
|
/>
|
||||||
|
</Field>
|
||||||
|
|
||||||
<div className="grid grid-cols-2 gap-4">
|
<div className="grid grid-cols-2 gap-4">
|
||||||
<Field label="تاریخ شروع">
|
<Field label="تاریخ شروع">
|
||||||
<Input
|
<Input
|
||||||
|
|||||||
@@ -129,7 +129,8 @@ export default function BreathingPage() {
|
|||||||
duration: numOrUndefined(form.duration),
|
duration: numOrUndefined(form.duration),
|
||||||
description: form.description,
|
description: form.description,
|
||||||
image_id: numOrUndefined(form.image_id),
|
image_id: numOrUndefined(form.image_id),
|
||||||
breathing_color_id: breathingColorId ?? undefined,
|
// Send null (not undefined) so choosing "بدون رنگ" actually clears it.
|
||||||
|
breathing_color_id: breathingColorId,
|
||||||
};
|
};
|
||||||
if (editing) {
|
if (editing) {
|
||||||
// Update is JSON on /breathing-templates/:id
|
// Update is JSON on /breathing-templates/:id
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ interface Category {
|
|||||||
id: number;
|
id: number;
|
||||||
name: string;
|
name: string;
|
||||||
type: CategoryType;
|
type: CategoryType;
|
||||||
|
order?: number;
|
||||||
description?: string | null;
|
description?: string | null;
|
||||||
icon?: string | null;
|
icon?: string | null;
|
||||||
subcategories_count?: number;
|
subcategories_count?: number;
|
||||||
@@ -56,6 +57,7 @@ export default function CategoriesPage() {
|
|||||||
const [open, setOpen] = useState(false);
|
const [open, setOpen] = useState(false);
|
||||||
const [name, setName] = useState("");
|
const [name, setName] = useState("");
|
||||||
const [type, setType] = useState<CategoryType>("media");
|
const [type, setType] = useState<CategoryType>("media");
|
||||||
|
const [order, setOrder] = useState("0");
|
||||||
const [description, setDescription] = useState("");
|
const [description, setDescription] = useState("");
|
||||||
const [icon, setIcon] = useState<File | null>(null);
|
const [icon, setIcon] = useState<File | null>(null);
|
||||||
const [saving, setSaving] = useState(false);
|
const [saving, setSaving] = useState(false);
|
||||||
@@ -67,6 +69,7 @@ export default function CategoriesPage() {
|
|||||||
setEditing(null);
|
setEditing(null);
|
||||||
setName("");
|
setName("");
|
||||||
setType(typeFilter);
|
setType(typeFilter);
|
||||||
|
setOrder("0");
|
||||||
setDescription("");
|
setDescription("");
|
||||||
setIcon(null);
|
setIcon(null);
|
||||||
setOpen(true);
|
setOpen(true);
|
||||||
@@ -75,6 +78,7 @@ export default function CategoriesPage() {
|
|||||||
setEditing(row);
|
setEditing(row);
|
||||||
setName(row.name ?? "");
|
setName(row.name ?? "");
|
||||||
setType(row.type ?? "media");
|
setType(row.type ?? "media");
|
||||||
|
setOrder(String(row.order ?? 0));
|
||||||
setDescription(row.description ?? "");
|
setDescription(row.description ?? "");
|
||||||
setIcon(null);
|
setIcon(null);
|
||||||
setOpen(true);
|
setOpen(true);
|
||||||
@@ -84,12 +88,25 @@ export default function CategoriesPage() {
|
|||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
setSaving(true);
|
setSaving(true);
|
||||||
try {
|
try {
|
||||||
if (editing) {
|
// Playlist categories live in the music_categories table, so their writes
|
||||||
|
// go to /music-categories (image is the `image` field, not `icon`).
|
||||||
|
const targetType = editing ? editing.type : type;
|
||||||
|
if (targetType === "playlist") {
|
||||||
|
const body = toFormData({ name, description, order, image: icon });
|
||||||
|
if (editing) {
|
||||||
|
await apiFetch(`/music-categories/${editing.id}`, { method: "POST", body });
|
||||||
|
toast.success("دستهبندی ویرایش شد.");
|
||||||
|
} else {
|
||||||
|
await apiFetch("/music-categories", { method: "POST", body });
|
||||||
|
toast.success("دستهبندی افزوده شد.");
|
||||||
|
}
|
||||||
|
} else if (editing) {
|
||||||
// Icon is a file, so update goes through POST + Laravel method spoofing.
|
// Icon is a file, so update goes through POST + Laravel method spoofing.
|
||||||
const body = toFormData({
|
const body = toFormData({
|
||||||
_method: "PUT",
|
_method: "PUT",
|
||||||
name,
|
name,
|
||||||
type,
|
type,
|
||||||
|
order,
|
||||||
description,
|
description,
|
||||||
icon,
|
icon,
|
||||||
});
|
});
|
||||||
@@ -98,7 +115,7 @@ export default function CategoriesPage() {
|
|||||||
} else {
|
} else {
|
||||||
await apiFetch("/categories", {
|
await apiFetch("/categories", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
body: toFormData({ name, type, description, icon }),
|
body: toFormData({ name, type, order, description, icon }),
|
||||||
});
|
});
|
||||||
toast.success("دستهبندی افزوده شد.");
|
toast.success("دستهبندی افزوده شد.");
|
||||||
}
|
}
|
||||||
@@ -115,7 +132,11 @@ export default function CategoriesPage() {
|
|||||||
if (!deleting) return;
|
if (!deleting) return;
|
||||||
setRemoving(true);
|
setRemoving(true);
|
||||||
try {
|
try {
|
||||||
await apiFetch(`/categories/${deleting.id}`, { method: "DELETE" });
|
const path =
|
||||||
|
deleting.type === "playlist"
|
||||||
|
? `/music-categories/${deleting.id}`
|
||||||
|
: `/categories/${deleting.id}`;
|
||||||
|
await apiFetch(path, { method: "DELETE" });
|
||||||
toast.success("دستهبندی حذف شد.");
|
toast.success("دستهبندی حذف شد.");
|
||||||
setDeleting(null);
|
setDeleting(null);
|
||||||
reload();
|
reload();
|
||||||
@@ -135,6 +156,12 @@ export default function CategoriesPage() {
|
|||||||
<MediaPreview kind="image" src={pickUrl(r, ICON_KEYS)} label={r.name} />
|
<MediaPreview kind="image" src={pickUrl(r, ICON_KEYS)} label={r.name} />
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
key: "order",
|
||||||
|
header: "ترتیب",
|
||||||
|
render: (r) => toFa(r.order ?? 0),
|
||||||
|
className: "w-20",
|
||||||
|
},
|
||||||
{ key: "name", header: "نام دستهبندی" },
|
{ key: "name", header: "نام دستهبندی" },
|
||||||
{
|
{
|
||||||
key: "type",
|
key: "type",
|
||||||
@@ -249,6 +276,15 @@ export default function CategoriesPage() {
|
|||||||
/>
|
/>
|
||||||
</Field>
|
</Field>
|
||||||
|
|
||||||
|
<Field label="ترتیب" hint="عدد کوچکتر بالاتر نمایش داده میشود.">
|
||||||
|
<Input
|
||||||
|
type="number"
|
||||||
|
value={order}
|
||||||
|
onChange={(e) => setOrder(e.target.value)}
|
||||||
|
dir="ltr"
|
||||||
|
/>
|
||||||
|
</Field>
|
||||||
|
|
||||||
<Field label="توضیحات">
|
<Field label="توضیحات">
|
||||||
<Textarea
|
<Textarea
|
||||||
value={description}
|
value={description}
|
||||||
|
|||||||
@@ -16,10 +16,10 @@ import {
|
|||||||
Textarea,
|
Textarea,
|
||||||
} from "@/components/ui";
|
} from "@/components/ui";
|
||||||
import { EditIcon, PlusIcon, TrashIcon } from "@/components/icons";
|
import { EditIcon, PlusIcon, TrashIcon } from "@/components/icons";
|
||||||
import { toFa } from "@/lib/utils";
|
|
||||||
import { MediaPreview } from "@/components/MediaPreview";
|
|
||||||
import { ImagePicker } from "@/components/ImagePicker";
|
import { ImagePicker } from "@/components/ImagePicker";
|
||||||
|
import { MediaPreview } from "@/components/MediaPreview";
|
||||||
import { pickUrl, IMAGE_KEYS } from "@/lib/media";
|
import { pickUrl, IMAGE_KEYS } from "@/lib/media";
|
||||||
|
import { toFa } from "@/lib/utils";
|
||||||
|
|
||||||
interface SliderAction {
|
interface SliderAction {
|
||||||
path?: string;
|
path?: string;
|
||||||
@@ -37,7 +37,7 @@ interface Slider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const ACTION_TYPES = [
|
const ACTION_TYPES = [
|
||||||
{ value: "screen", label: "صفحه (screen)" },
|
{ value: "navigation", label: "صفحه (navigation)" },
|
||||||
{ value: "link", label: "لینک (link)" },
|
{ value: "link", label: "لینک (link)" },
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -51,7 +51,7 @@ export default function SlidersPage() {
|
|||||||
const [description, setDescription] = useState("");
|
const [description, setDescription] = useState("");
|
||||||
const [url, setUrl] = useState("");
|
const [url, setUrl] = useState("");
|
||||||
const [actionPath, setActionPath] = useState("");
|
const [actionPath, setActionPath] = useState("");
|
||||||
const [actionType, setActionType] = useState("screen");
|
const [actionType, setActionType] = useState("navigation");
|
||||||
const [imageId, setImageId] = useState<number | null>(null);
|
const [imageId, setImageId] = useState<number | null>(null);
|
||||||
const [imageFile, setImageFile] = useState<File | null>(null);
|
const [imageFile, setImageFile] = useState<File | null>(null);
|
||||||
const [saving, setSaving] = useState(false);
|
const [saving, setSaving] = useState(false);
|
||||||
@@ -65,7 +65,7 @@ export default function SlidersPage() {
|
|||||||
setDescription("");
|
setDescription("");
|
||||||
setUrl("");
|
setUrl("");
|
||||||
setActionPath("");
|
setActionPath("");
|
||||||
setActionType("screen");
|
setActionType("navigation");
|
||||||
setImageId(null);
|
setImageId(null);
|
||||||
setImageFile(null);
|
setImageFile(null);
|
||||||
setOpen(true);
|
setOpen(true);
|
||||||
@@ -76,7 +76,7 @@ export default function SlidersPage() {
|
|||||||
setDescription(row.description ?? "");
|
setDescription(row.description ?? "");
|
||||||
setUrl(row.url ?? "");
|
setUrl(row.url ?? "");
|
||||||
setActionPath(row.action?.path ?? "");
|
setActionPath(row.action?.path ?? "");
|
||||||
setActionType(row.action?.type ?? "screen");
|
setActionType(row.action?.type ?? "navigation");
|
||||||
setImageId(row.image_id ?? null);
|
setImageId(row.image_id ?? null);
|
||||||
setImageFile(null);
|
setImageFile(null);
|
||||||
setOpen(true);
|
setOpen(true);
|
||||||
@@ -86,9 +86,8 @@ export default function SlidersPage() {
|
|||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
setSaving(true);
|
setSaving(true);
|
||||||
try {
|
try {
|
||||||
// Both create and edit go through multipart (the image is a file). The
|
// Multipart for both (so an image file can be uploaded). Bracket keys
|
||||||
// nested action uses literal bracket keys; edit posts to /slider/:id,
|
// build the nested action object; update uses POST /slider/:id.
|
||||||
// which the backend also accepts as a multipart update.
|
|
||||||
const body = toFormData({
|
const body = toFormData({
|
||||||
title,
|
title,
|
||||||
description,
|
description,
|
||||||
@@ -102,6 +101,7 @@ export default function SlidersPage() {
|
|||||||
await apiFetch(`/slider/${editing.id}`, { method: "POST", body });
|
await apiFetch(`/slider/${editing.id}`, { method: "POST", body });
|
||||||
toast.success("اسلایدر ویرایش شد.");
|
toast.success("اسلایدر ویرایش شد.");
|
||||||
} else {
|
} else {
|
||||||
|
await apiFetch("/slider", { method: "POST", body });
|
||||||
await apiFetch("/slider", { method: "POST", body });
|
await apiFetch("/slider", { method: "POST", body });
|
||||||
toast.success("اسلایدر افزوده شد.");
|
toast.success("اسلایدر افزوده شد.");
|
||||||
}
|
}
|
||||||
@@ -132,7 +132,7 @@ export default function SlidersPage() {
|
|||||||
const columns: Column<Slider>[] = [
|
const columns: Column<Slider>[] = [
|
||||||
{ key: "id", header: "شناسه", render: (r) => toFa(r.id), className: "w-24" },
|
{ key: "id", header: "شناسه", render: (r) => toFa(r.id), className: "w-24" },
|
||||||
{
|
{
|
||||||
key: "thumbnail",
|
key: "image",
|
||||||
header: "تصویر",
|
header: "تصویر",
|
||||||
className: "w-20",
|
className: "w-20",
|
||||||
render: (r) => (
|
render: (r) => (
|
||||||
@@ -236,6 +236,16 @@ export default function SlidersPage() {
|
|||||||
/>
|
/>
|
||||||
</Field>
|
</Field>
|
||||||
|
|
||||||
|
<Field label="تصویر">
|
||||||
|
<ImagePicker
|
||||||
|
imageId={imageId}
|
||||||
|
onPickId={setImageId}
|
||||||
|
file={imageFile}
|
||||||
|
onPickFile={setImageFile}
|
||||||
|
existingUrl={editing ? pickUrl(editing, IMAGE_KEYS) : null}
|
||||||
|
/>
|
||||||
|
</Field>
|
||||||
|
|
||||||
<Field label="توضیحات">
|
<Field label="توضیحات">
|
||||||
<Textarea
|
<Textarea
|
||||||
value={description}
|
value={description}
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ interface AppVersion {
|
|||||||
version_name?: string;
|
version_name?: string;
|
||||||
version_code?: number;
|
version_code?: number;
|
||||||
link?: string;
|
link?: string;
|
||||||
|
button_text?: string;
|
||||||
image_id?: number | null;
|
image_id?: number | null;
|
||||||
image?: unknown;
|
image?: unknown;
|
||||||
}
|
}
|
||||||
@@ -42,6 +43,7 @@ export default function VersionsPage() {
|
|||||||
const [versionName, setVersionName] = useState("");
|
const [versionName, setVersionName] = useState("");
|
||||||
const [versionCode, setVersionCode] = useState("");
|
const [versionCode, setVersionCode] = useState("");
|
||||||
const [link, setLink] = useState("");
|
const [link, setLink] = useState("");
|
||||||
|
const [buttonText, setButtonText] = useState("");
|
||||||
const [imageId, setImageId] = useState<number | null>(null);
|
const [imageId, setImageId] = useState<number | null>(null);
|
||||||
const [imageFile, setImageFile] = useState<File | null>(null);
|
const [imageFile, setImageFile] = useState<File | null>(null);
|
||||||
const [saving, setSaving] = useState(false);
|
const [saving, setSaving] = useState(false);
|
||||||
@@ -56,6 +58,7 @@ export default function VersionsPage() {
|
|||||||
setVersionName("");
|
setVersionName("");
|
||||||
setVersionCode("");
|
setVersionCode("");
|
||||||
setLink("");
|
setLink("");
|
||||||
|
setButtonText("");
|
||||||
setImageId(null);
|
setImageId(null);
|
||||||
setImageFile(null);
|
setImageFile(null);
|
||||||
setOpen(true);
|
setOpen(true);
|
||||||
@@ -67,6 +70,7 @@ export default function VersionsPage() {
|
|||||||
setVersionName(row.version_name ?? "");
|
setVersionName(row.version_name ?? "");
|
||||||
setVersionCode(row.version_code != null ? String(row.version_code) : "");
|
setVersionCode(row.version_code != null ? String(row.version_code) : "");
|
||||||
setLink(row.link ?? "");
|
setLink(row.link ?? "");
|
||||||
|
setButtonText(row.button_text ?? "");
|
||||||
setImageId(row.image_id ?? null);
|
setImageId(row.image_id ?? null);
|
||||||
setImageFile(null);
|
setImageFile(null);
|
||||||
setOpen(true);
|
setOpen(true);
|
||||||
@@ -84,6 +88,7 @@ export default function VersionsPage() {
|
|||||||
version_name: versionName,
|
version_name: versionName,
|
||||||
version_code: versionCode,
|
version_code: versionCode,
|
||||||
link,
|
link,
|
||||||
|
button_text: buttonText,
|
||||||
image_id: imageId,
|
image_id: imageId,
|
||||||
image: imageFile,
|
image: imageFile,
|
||||||
});
|
});
|
||||||
@@ -274,6 +279,14 @@ export default function VersionsPage() {
|
|||||||
dir="ltr"
|
dir="ltr"
|
||||||
/>
|
/>
|
||||||
</Field>
|
</Field>
|
||||||
|
|
||||||
|
<Field label="متن دکمه" hint="اختیاری">
|
||||||
|
<Input
|
||||||
|
value={buttonText}
|
||||||
|
onChange={(e) => setButtonText(e.target.value)}
|
||||||
|
placeholder="مثلاً بهروزرسانی"
|
||||||
|
/>
|
||||||
|
</Field>
|
||||||
</form>
|
</form>
|
||||||
</Modal>
|
</Modal>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user