fix message error

This commit is contained in:
grimhilt 2023-07-31 01:38:58 +02:00
parent 5e54252514
commit 4fc95a3b7f
3 changed files with 15 additions and 5 deletions

View File

@ -20,7 +20,7 @@ const Playlist = (item) => {
const form = useForm({ const form = useForm({
initialValues: { initialValues: {
files: [{ id: 0, name: 'stuff', seconds: 60 }], files: [],
}, },
}); });
@ -39,11 +39,13 @@ const Playlist = (item) => {
API.getPlaylist(id) API.getPlaylist(id)
.then((res) => { .then((res) => {
if (res.status === 200) { if (res.status === 200) {
console.log(res.data)
setPlaylist(res.data); setPlaylist(res.data);
form.setFieldValue('files', res.data.files);
} }
}) })
.catch((err) => { .catch((err) => {
setNotification(true, err.response.data.error); setNotification(true, err.message);
}); });
API.getFiles() API.getFiles()
@ -53,7 +55,7 @@ const Playlist = (item) => {
} }
}) })
.catch((err) => { .catch((err) => {
setNotification(true, err.response.data.error); setNotification(true, err.message);
}); });
} }
// eslint-disable-next-line react-hooks/exhaustive-deps // eslint-disable-next-line react-hooks/exhaustive-deps
@ -76,8 +78,9 @@ const Playlist = (item) => {
</Button> </Button>
</Group> </Group>
<Paper p="xs" radius="sm" shadow="sm" withBorder my="md"> <Paper p="xs" radius="sm" shadow="sm" withBorder my="md">
<Content form={form} /> <Content form={form} playlistId={id}/>
</Paper> </Paper>
<Button>Save</Button>
<ModalUpdate open={update} handler={toggleUpdate} id={playlist?.id} /> <ModalUpdate open={update} handler={toggleUpdate} id={playlist?.id} />
</> </>
); );

View File

@ -25,7 +25,7 @@ const Playlists = () => {
} }
}) })
.catch((err) => { .catch((err) => {
setNotification(true, err.response.data.error); setNotification(true, err.message);
}); });
return () => {}; return () => {};

View File

@ -22,6 +22,13 @@ const API = {
getFiles() { getFiles() {
return caller().get('/file'); return caller().get('/file');
}, },
addFileToPlaylist(playlistId, file) {
return caller().post(`/playlist/${playlistId}`, file);
},
playlistChangeOrder(playlistId, data) {
return caller().post(`/playlist/${playlistId}/order`, data);
}
}; };
export default API; export default API;