change api organization
This commit is contained in:
parent
5ffccd656d
commit
d9d288d83b
@ -25,7 +25,7 @@ const ModalCreatePlaylist = ({ opened, handler, addPlaylist }) => {
|
|||||||
<Modal.Body>
|
<Modal.Body>
|
||||||
<PlaylistViewEditor
|
<PlaylistViewEditor
|
||||||
buttonText="Create"
|
buttonText="Create"
|
||||||
APICall={API.createPlaylist}
|
APICall={API.playlists.create}
|
||||||
handler={(item) => validated(item)}
|
handler={(item) => validated(item)}
|
||||||
/>
|
/>
|
||||||
</Modal.Body>
|
</Modal.Body>
|
||||||
|
@ -8,7 +8,7 @@ import { Button } from '@mantine/core';
|
|||||||
import GrantAccess, { Perm } from '../../tools/grant-access';
|
import GrantAccess, { Perm } from '../../tools/grant-access';
|
||||||
|
|
||||||
const Playlists = () => {
|
const Playlists = () => {
|
||||||
const [showCreate, setShowCreate] = useState(false);
|
const [showCreate, setShowCreate] = useState(true);
|
||||||
const [showUpdate, setShowUpdate] = useState(false);
|
const [showUpdate, setShowUpdate] = useState(false);
|
||||||
const [, setItem] = useState({});
|
const [, setItem] = useState({});
|
||||||
const [page, setPage] = useState(0);
|
const [page, setPage] = useState(0);
|
||||||
@ -20,7 +20,7 @@ const Playlists = () => {
|
|||||||
const [playlists, setPlaylist] = useState([]);
|
const [playlists, setPlaylist] = useState([]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
API.listPlaylists(limit, page)
|
API.playlists.list(limit, page)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
if (res.status === 200) {
|
if (res.status === 200) {
|
||||||
if (playlists.length === 0) setPlaylist(res.data);
|
if (playlists.length === 0) setPlaylist(res.data);
|
||||||
|
@ -24,7 +24,7 @@ const ModalUpdatePlaylist = ({ item, opened, handler, updatePlaylist }) => {
|
|||||||
<PlaylistViewEditor
|
<PlaylistViewEditor
|
||||||
item={item}
|
item={item}
|
||||||
buttonText="Update"
|
buttonText="Update"
|
||||||
APICall={API.updatePlaylist}
|
APICall={API.playlists.update}
|
||||||
handler={(playlist) => validated(playlist)}
|
handler={(playlist) => validated(playlist)}
|
||||||
/>
|
/>
|
||||||
</Modal.Body>
|
</Modal.Body>
|
||||||
|
@ -22,7 +22,7 @@ const Users = () => {
|
|||||||
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
API.listUsers()
|
API.users.list()
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
if (res.status === 200) {
|
if (res.status === 200) {
|
||||||
if (users.length === 0) setUsers(res.data);
|
if (users.length === 0) setUsers(res.data);
|
||||||
@ -32,7 +32,7 @@ const Users = () => {
|
|||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
setNotification(true, err);
|
setNotification(true, err);
|
||||||
});
|
});
|
||||||
API.listRoles()
|
API.roles.list()
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
if (res.status === 200) {
|
if (res.status === 200) {
|
||||||
if (roles.length === 0) setRoles(res.data);
|
if (roles.length === 0) setRoles(res.data);
|
||||||
@ -86,14 +86,14 @@ const Users = () => {
|
|||||||
opened={showCreate}
|
opened={showCreate}
|
||||||
handler={(item) => addUser(item)}
|
handler={(item) => addUser(item)}
|
||||||
handlerClose={toggleModalCreate}
|
handlerClose={toggleModalCreate}
|
||||||
APICall={API.createUser}
|
APICall={API.users.create}
|
||||||
name="Create"
|
name="Create"
|
||||||
/>
|
/>
|
||||||
<ModalUserEditor
|
<ModalUserEditor
|
||||||
opened={showUpdate}
|
opened={showUpdate}
|
||||||
handler={(item) => updateUser(item)}
|
handler={(item) => updateUser(item)}
|
||||||
handlerClose={toggleModalUpdate}
|
handlerClose={toggleModalUpdate}
|
||||||
APICall={API.updateUser}
|
APICall={API.users.update}
|
||||||
item={itemToUse}
|
item={itemToUse}
|
||||||
name="Update"
|
name="Update"
|
||||||
/>
|
/>
|
||||||
|
@ -41,7 +41,7 @@ const ModalUserView = ({ opened, handler, ...props }) => {
|
|||||||
opened={showEdit}
|
opened={showEdit}
|
||||||
handler={(item) => setUser(item)}
|
handler={(item) => setUser(item)}
|
||||||
handlerClose={toggleModalEdit}
|
handlerClose={toggleModalEdit}
|
||||||
APICall={API.updateUser}
|
APICall={API.users.update}
|
||||||
item={user}
|
item={user}
|
||||||
name="Update"
|
name="Update"
|
||||||
/>
|
/>
|
||||||
|
@ -17,7 +17,7 @@ const Line = ({ user, ...props }) => {
|
|||||||
const [isLoading, setIsLoading] = useState(false);
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
const deleteUser = () => {
|
const deleteUser = () => {
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
API.deleteUser(user.id)
|
API.users.delete(user.id)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
if (res.status === 200) {
|
if (res.status === 200) {
|
||||||
|
@ -7,6 +7,62 @@ const caller = (url = '/api') => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const API = {
|
const API = {
|
||||||
|
playlists: {
|
||||||
|
create(data) {
|
||||||
|
return caller().post('/playlists', data);
|
||||||
|
},
|
||||||
|
get(id) {
|
||||||
|
return caller().get(`/playlists/${id}`);
|
||||||
|
},
|
||||||
|
list(data) {
|
||||||
|
return caller().get('/playlists', data);
|
||||||
|
},
|
||||||
|
update(playlistId, data) {
|
||||||
|
return caller().put(`/playlists/${playlistId}/update`, data);
|
||||||
|
},
|
||||||
|
activate(playlistId) {
|
||||||
|
return caller().post(`/playlists/${playlistId}/activate`);
|
||||||
|
},
|
||||||
|
disactivate(playlistId) {
|
||||||
|
return caller().post(`/playlists/${playlistId}/disactivate`);
|
||||||
|
},
|
||||||
|
addFile(playlistId, file) {
|
||||||
|
return caller().post(`/playlists/${playlistId}`, file);
|
||||||
|
},
|
||||||
|
removeFile(playlistId, data) {
|
||||||
|
return caller().post(`/playlists/${playlistId}/remove_file`, data);
|
||||||
|
},
|
||||||
|
changeOrder(playlistId, data) {
|
||||||
|
return caller().post(`/playlists/${playlistId}/order`, data);
|
||||||
|
},
|
||||||
|
changeSeconds(playlistId, data) {
|
||||||
|
return caller().post(`/playlists/${playlistId}/seconds`, data);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
roles: {
|
||||||
|
list(data) {
|
||||||
|
return caller().get('/roles', data);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
users: {
|
||||||
|
create(data) {
|
||||||
|
return caller().post('/users', data);
|
||||||
|
},
|
||||||
|
delete(userId) {
|
||||||
|
return caller().delete(`/users/${userId}`);
|
||||||
|
},
|
||||||
|
list(data) {
|
||||||
|
return caller().get('/users', data);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
files: {
|
||||||
|
upload(data) {
|
||||||
|
return caller().post('/file', data);
|
||||||
|
},
|
||||||
|
list() {
|
||||||
|
return caller().get('/file');
|
||||||
|
},
|
||||||
|
},
|
||||||
profile() {
|
profile() {
|
||||||
return caller().get('/auth/profile');
|
return caller().get('/auth/profile');
|
||||||
},
|
},
|
||||||
@ -16,54 +72,6 @@ const API = {
|
|||||||
login(data) {
|
login(data) {
|
||||||
return caller().post('/auth/login', data);
|
return caller().post('/auth/login', data);
|
||||||
},
|
},
|
||||||
listUsers(data) {
|
|
||||||
return caller().get('/users', data);
|
|
||||||
},
|
|
||||||
listRoles(data) {
|
|
||||||
return caller().get('/roles', data);
|
|
||||||
},
|
|
||||||
listPlaylists(data) {
|
|
||||||
return caller().get('/playlists', data);
|
|
||||||
},
|
|
||||||
createPlaylist(data) {
|
|
||||||
return caller().post('/playlists', data);
|
|
||||||
},
|
|
||||||
updatePlaylist(playlistId, data) {
|
|
||||||
return caller().put(`/playlists/${playlistId}/update`, data);
|
|
||||||
},
|
|
||||||
activate(playlistId) {
|
|
||||||
return caller().post(`/playlists/${playlistId}/activate`);
|
|
||||||
},
|
|
||||||
disactivate(playlistId) {
|
|
||||||
return caller().post(`/playlists/${playlistId}/disactivate`);
|
|
||||||
},
|
|
||||||
getPlaylist(id) {
|
|
||||||
return caller().get(`/playlists/${id}`);
|
|
||||||
},
|
|
||||||
upload(data) {
|
|
||||||
return caller().post('/file', data);
|
|
||||||
},
|
|
||||||
getFiles() {
|
|
||||||
return caller().get('/file');
|
|
||||||
},
|
|
||||||
addFileToPlaylist(playlistId, file) {
|
|
||||||
return caller().post(`/playlists/${playlistId}`, file);
|
|
||||||
},
|
|
||||||
playlistChangeOrder(playlistId, data) {
|
|
||||||
return caller().post(`/playlists/${playlistId}/order`, data);
|
|
||||||
},
|
|
||||||
playlistChangeSeconds(playlistId, data) {
|
|
||||||
return caller().post(`/playlists/${playlistId}/seconds`, data);
|
|
||||||
},
|
|
||||||
playlistRemoveFile(playlistId, data) {
|
|
||||||
return caller().post(`/playlists/${playlistId}/remove_file`, data);
|
|
||||||
},
|
|
||||||
createUser(data) {
|
|
||||||
return caller().post('/users', data);
|
|
||||||
},
|
|
||||||
deleteUser(userId) {
|
|
||||||
return caller().delete(`/users/${userId}`);
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default API;
|
export default API;
|
||||||
|
Loading…
Reference in New Issue
Block a user