Skip to content

Commit

Permalink
add single locker selection
Browse files Browse the repository at this point in the history
  • Loading branch information
birdpump committed Apr 27, 2024
1 parent 73d0eb6 commit 48a3102
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 22 deletions.
18 changes: 10 additions & 8 deletions src/lib/services/admin/mainApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,20 @@ export async function fetchEnabledGrades() {
return await response.json();
}

export async function fetchUserData(){
const response = await fetch('https://locker-api.cvapps.net/admin/data/user-data?page=1&pageSize=10', {
method: 'get',
credentials: 'include'
});

return await response.json();
export async function fetchUserData() {
try {
const response = await axios.get('https://locker-api.cvapps.net/admin/data/user-data', {
withCredentials: true
});
return response.data;
} catch (error) {
throw error; // Rethrow the error to handle it elsewhere if needed
}
}

export async function fetchLockerData() {
try {
const response = await axios.get('https://locker-api.cvapps.net/admin/data/locker-data?page=1&pageSize=10', {
const response = await axios.get('https://locker-api.cvapps.net/admin/data/locker-data', {
withCredentials: true
});
return response.data;
Expand Down
2 changes: 1 addition & 1 deletion src/routes/(admin)/admin/edit/views/LockerEdit.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
<Grid
{columns}
pagination={{ enabled: true, limit: 11 }}

sort
search
{data}
{style}
Expand Down
4 changes: 2 additions & 2 deletions src/routes/(admin)/admin/edit/views/UserEdit.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,10 @@
<Grid
{columns}
pagination={{ enabled: true, limit: 11 }}

sort
search
{data}
{style}
/>
{/if}
</div>
</div>
29 changes: 18 additions & 11 deletions src/routes/(app)/register/views/Selection.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
let areas = {};
let data1 = [];
let data2 = [];
let data3 = ['Top', 'Single', 'Bottom'];
let data3 = [];
let value1;
let value2;
Expand All @@ -26,10 +26,6 @@
areas = await fetchAvailableLockers();
// Update data1 based on fetched areas
data1 = Object.keys(areas);
// Check if value1 is selected and update data2 accordingly
if (value1 && areas[value1.value]) {
data2 = areas[value1.value];
}
}
async function next() {
Expand All @@ -38,6 +34,8 @@
floor: value2.label,
level: value3.label,
});
if(value3.label === "Single") singleLocker.set(true);
console.log($selectedLocation);
pageView.set(2);
}
Expand All @@ -49,17 +47,26 @@
// Watch for changes in value1 and update data2 accordingly
$: {
if (value1 && areas[value1.value]) {
console.log("feuj")
data2 = areas[value1.value];
clear();
data2 = Object.keys(areas[value1.value]);
clear(1);
}
}
$:{
if (value2 && areas[value1.value][value2.value]) {
data3 = areas[value1.value][value2.value]['Levels']
clear(2);
}
}
function clear(){
value2 = null;
value3 = null;
function clear(number){
if(number === 1) value2 = null;
if(number === 2) value3 = null;
}
</script>
Expand Down

0 comments on commit 48a3102

Please sign in to comment.