Skip to content

Commit

Permalink
Merge pull request #81 from CETEN-OpenBar/feature/route_comptoir_to_a…
Browse files Browse the repository at this point in the history
…dmin_panel

feat(front): add a route to go admin panel with password requirement
  • Loading branch information
aripot007 committed Jun 2, 2024
2 parents bac6781 + 1148ef3 commit 6e600fc
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 11 deletions.
5 changes: 5 additions & 0 deletions frontend/src/lib/components/panel/modules.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@
color: 'bg-green-600',
link: '/panel/products/course'
});
modules.push({
name: 'Comptoir',
color: 'bg-yellow-600',
link: '/comptoir/c/transactions'
});
// Sort the modules by name
modules.sort((a, b) => a.name.localeCompare(b.name));
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/routes/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts">
import type { Account, Callback200Response, ConnectCardRequest } from '$lib/api';
import type { Account, ConnectCard200Response, ConnectCardRequest } from '$lib/api';
import { accountsApi, authApi } from '$lib/requests/requests';
import Button from '$lib/components/button.svelte';
Expand All @@ -21,7 +21,7 @@
withCredentials: true
})
.then((res: any) => {
let data: Callback200Response = res.data;
let data: ConnectCard200Response = res.data;
account = data.account;
});
});
Expand Down
33 changes: 24 additions & 9 deletions frontend/src/routes/comptoir/c/transactions/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
<script lang="ts">
import { goto } from '$app/navigation';
import Pin from '$lib/components/borne/pin.svelte';
import Transactions from '$lib/components/comptoir/transactions.svelte';
import ReadCard from '$lib/components/readCard.svelte';
import { open_caisse, open_door, open_ventilo } from '$lib/local/local';
import NewRefill from '$lib/components/comptoir/newRefill.svelte';
import { authApi } from '$lib/requests/requests';
import ChangePassword from '$lib/components/comptoir/changePassword.svelte';
import Password from '$lib/components/password.svelte';
import type { ConnectPasswordRequest } from '$lib/api';
import { transactionsApi } from '$lib/requests/requests';
import type { TransactionItem } from '$lib/api';
import TransactionsItems from '$lib/components/comptoir/transactionsItems.svelte';
function reset() {
Expand All @@ -29,7 +26,7 @@
let askForPassword = false;
let newRefill = false;
let changePassword = false;
let info: ConnectPasswordRequest;
function close() {
newRefill = false;
}
Expand All @@ -47,8 +44,19 @@
});
}
let showTransactionItems = false;
const go_admin_panel = (card_id: string, password: string) => {
info = {
card_id: card_id,
password: password,
}
authApi()
.connectPassword(info, { withCredentials: true })
.then(() => {
goto('/panel');
});
};
let showTransactionItems = false;
</script>

{#if askForCard}
Expand Down Expand Up @@ -129,6 +137,13 @@
askForCard = true;
}}>caisse</button
>
<button
class="text-xl bg-blue-700 p-2 rounded-xl hover:bg-blue-900 transition-all ml-2"
on:click={() => {
to_call = go_admin_panel;
askForCard = true;
}}>Admin panel</button
>
</div>

<button
Expand All @@ -138,15 +153,15 @@
{#if showTransactionItems}
<button
class="text-3xl bg-blue-700 p-2 rounded-xl hover:bg-blue-900 transition-all"
on:click={() => showTransactionItems = false}>Liste des commandes</button
on:click={() => (showTransactionItems = false)}>Liste des commandes</button
>
{:else}
<button
class="text-3xl bg-blue-700 p-2 rounded-xl hover:bg-blue-900 transition-all"
on:click={() => showTransactionItems = true}>Résumé des commandes</button
on:click={() => (showTransactionItems = true)}>Résumé des commandes</button
>
{/if}

<button
class="text-3xl bg-blue-700 p-2 rounded-xl hover:bg-blue-900 transition-all mr-2"
on:click={() => (newRefill = true)}>Nouvelle Recharge</button
Expand Down

0 comments on commit 6e600fc

Please sign in to comment.