fix update/create playlist
This commit is contained in:
parent
1efa52321a
commit
a84a6f836a
@ -4,7 +4,10 @@ import API from '../../services/api';
|
|||||||
|
|
||||||
const ModalCreatePlaylist = ({ opened, handler, addPlaylist }) => {
|
const ModalCreatePlaylist = ({ opened, handler, addPlaylist }) => {
|
||||||
const validated = (item) => {
|
const validated = (item) => {
|
||||||
addPlaylist(item);
|
if (item) {
|
||||||
|
addPlaylist(item);
|
||||||
|
}
|
||||||
|
console.log("call handler")
|
||||||
handler();
|
handler();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@ import { useState } from 'react';
|
|||||||
const PlaylistViewEditor = ({ item, handler, buttonText, APICall }) => {
|
const PlaylistViewEditor = ({ item, handler, buttonText, APICall }) => {
|
||||||
const handleClose = (playlist) => {
|
const handleClose = (playlist) => {
|
||||||
form.reset();
|
form.reset();
|
||||||
|
console.log('call jiezf');
|
||||||
handler(playlist);
|
handler(playlist);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -25,10 +26,15 @@ const PlaylistViewEditor = ({ item, handler, buttonText, APICall }) => {
|
|||||||
if (form.validate().hasErrors) return;
|
if (form.validate().hasErrors) return;
|
||||||
try {
|
try {
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
const res = await APICall(item?.id, { name: form.values.name });
|
if (item) {
|
||||||
|
await APICall(item?.id, { name: form.values.name });
|
||||||
|
item.name = form.values.name;
|
||||||
|
handleClose(item);
|
||||||
|
} else {
|
||||||
|
const res = await APICall({ name: form.values.name });
|
||||||
|
handleClose(res.data);
|
||||||
|
}
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
item.name = form.values.name;
|
|
||||||
handleClose(item);
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
// todo
|
// todo
|
||||||
|
Loading…
Reference in New Issue
Block a user