Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
638d1dad52 |
@@ -88,7 +88,19 @@ export default function CategoriesPage() {
|
||||
e.preventDefault();
|
||||
setSaving(true);
|
||||
try {
|
||||
// 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.
|
||||
const body = toFormData({
|
||||
_method: "PUT",
|
||||
@@ -120,7 +132,11 @@ export default function CategoriesPage() {
|
||||
if (!deleting) return;
|
||||
setRemoving(true);
|
||||
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("دستهبندی حذف شد.");
|
||||
setDeleting(null);
|
||||
reload();
|
||||
|
||||
Reference in New Issue
Block a user