diff --git a/app/src/components/Endpoint.svelte b/app/src/components/Endpoint.svelte index 0ea64e8e..1360169b 100644 --- a/app/src/components/Endpoint.svelte +++ b/app/src/components/Endpoint.svelte @@ -18,11 +18,18 @@ async function handleUpdatePaidEndpoint(status) { disabled = true; - const result = await update_paid_endpoint(id, status); - const parsedResult = JSON.parse(result); - success = parsedResult.success; - disabled = false; - sendDataToParent(success); + for (let i = 0; i < id.length; i++) { + try { + const result = await update_paid_endpoint(id[i], status); + const parsedResult = JSON.parse(result); + success = parsedResult.success; + } catch (error) { + console.error(`Error Updating endpoint status: ${error}`); + } + + disabled = false; + sendDataToParent(success); + } } diff --git a/app/src/components/EnpointPermission.svelte b/app/src/components/EnpointPermission.svelte index 885d9ddc..d2393609 100644 --- a/app/src/components/EnpointPermission.svelte +++ b/app/src/components/EnpointPermission.svelte @@ -9,8 +9,28 @@ async function getAllPaidEndpoint() { const endpoints = await list_all_paid_endpoint(); const parsedEndpoints = JSON.parse(endpoints); + const endpointsObj = {}; + const tempAllEndpoints = []; if (parsedEndpoints.success) { - allEndpoints = [...parsedEndpoints.endpoints]; + for (let i = 0; i < parsedEndpoints.endpoints.length; i++) { + const parsedEndpoint = parsedEndpoints.endpoints[i]; + const routeDescription = parsedEndpoint.route_description; + if (endpointsObj[routeDescription]) { + endpointsObj[routeDescription].id.push(parsedEndpoint.id); + } else { + endpointsObj[routeDescription] = { + id: [parsedEndpoint.id], + route_description: routeDescription, + price: parsedEndpoint.price, + endpoint: parsedEndpoint.endpoint, + status: parsedEndpoint.status, + }; + } + } + for (let key in endpointsObj) { + tempAllEndpoints.push(endpointsObj[key]); + } + allEndpoints = [...tempAllEndpoints]; } } @@ -37,7 +57,7 @@ {/if} - {#each allEndpoints as endpoint, index (endpoint.id)} + {#each allEndpoints as endpoint, index (endpoint.route_description)} @@ -508,6 +524,7 @@ flex-direction: column; margin-top: 1.38rem; gap: 1.38rem; + margin-bottom: 1.5rem; } .checkbox-container {