Skip to content

Commit

Permalink
add action logic
Browse files Browse the repository at this point in the history
  • Loading branch information
birdpump committed May 10, 2024
1 parent e3a90a1 commit 1491a4f
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 3 deletions.
25 changes: 25 additions & 0 deletions src/lib/services/admin/mainApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,3 +115,28 @@ export async function updateUserEditData(user, data) {
throw error;
}
}


export async function postRemoveUsersLocker(user) {
try {
return await axios.post(`https://locker-api.cvapps.net/admin/edit/remove-users-locker/${user}`,
{
withCredentials: true
}
);
} catch (error) {
throw error;
}
}

export async function postDeleteUser(user) {
try {
return await axios.post(`https://locker-api.cvapps.net/admin/edit/delete-user/${user}`,
{
withCredentials: true
}
);
} catch (error) {
throw error;
}
}
22 changes: 19 additions & 3 deletions src/routes/(admin)/admin/edit/Editmodal.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script>
import {getUserEditData, updateUserEditData} from "$lib/services/admin/mainApi.js";
import {getUserEditData, updateUserEditData, postRemoveUsersLocker, postDeleteUser} from "$lib/services/admin/mainApi.js";
export let showModal; // boolean
export let data;
Expand All @@ -24,6 +24,22 @@
}
}
async function deleteUser(){
let response = await postDeleteUser(userData.studentId);
if (response.status === 200) {
dialog.close();
}
}
async function removeLocker(){
let response = await postRemoveUsersLocker(userData.studentId);
if (response.status === 200) {
dialog.close();
}
}
$: if (dialog && showModal) {
fetchData();
}
Expand Down Expand Up @@ -251,8 +267,8 @@


<div class="action-cont">
<div class="action-btn material-symbols-outlined" on:click={() => dialog.close()}>delete</div>
<div class="action-btn material-symbols-outlined" on:click={() => dialog.close()}>person_remove</div>
<div class="action-btn material-symbols-outlined" on:click={deleteUser}>delete</div>
<div class="action-btn material-symbols-outlined" on:click={removeLocker}>person_remove</div>
</div>
</div>
{/if}
Expand Down

0 comments on commit 1491a4f

Please sign in to comment.