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 validated = (item) => {
|
||||
if (item) {
|
||||
addPlaylist(item);
|
||||
}
|
||||
console.log("call handler")
|
||||
handler();
|
||||
};
|
||||
|
||||
|
@ -5,6 +5,7 @@ import { useState } from 'react';
|
||||
const PlaylistViewEditor = ({ item, handler, buttonText, APICall }) => {
|
||||
const handleClose = (playlist) => {
|
||||
form.reset();
|
||||
console.log('call jiezf');
|
||||
handler(playlist);
|
||||
};
|
||||
|
||||
@ -25,10 +26,15 @@ const PlaylistViewEditor = ({ item, handler, buttonText, APICall }) => {
|
||||
if (form.validate().hasErrors) return;
|
||||
try {
|
||||
setIsLoading(true);
|
||||
const res = await APICall(item?.id, { name: form.values.name });
|
||||
setIsLoading(false);
|
||||
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);
|
||||
} catch (error) {
|
||||
setIsLoading(false);
|
||||
// todo
|
||||
|
Loading…
Reference in New Issue
Block a user