Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(front): add a route to go admin panel with password requirement #81

Merged
merged 3 commits into from
Jun 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading