Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
638d1dad52 |
@@ -88,7 +88,19 @@ export default function CategoriesPage() {
|
|||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
setSaving(true);
|
setSaving(true);
|
||||||
try {
|
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) {
|
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",
|
||||||
@@ -120,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();
|
||||||
|
|||||||
Reference in New Issue
Block a user