Skip to content

Commit

Permalink
fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
BaptTF committed Apr 27, 2024
1 parent 20e7a43 commit 739d503
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 81 deletions.
2 changes: 1 addition & 1 deletion backend/internal/db/mongo/item_misc.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func (b *Backend) GetItems(ctx context.Context, categoryID string, page, size ui
if fournisseur != "" {
filter["fournisseur"] = fournisseur
}

cursor, err := b.db.Collection(ItemsCollection).Find(ctx, filter, options.Find().SetSkip(int64(page*size)).SetLimit(int64(size)))
if err != nil {
return nil, err
Expand Down
4 changes: 2 additions & 2 deletions backend/internal/models/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ func (o *Account) VerifyPin(pwd string) bool {
}

func (o *Account) VerifyPassword(pwd string) bool {
if (o.Account.Password != nil) {
if o.Account.Password != nil {
ok, _ := hash.Verify(*o.Account.Password, pwd)
return ok
return ok
}
return false
}
Expand Down
8 changes: 4 additions & 4 deletions frontend/src/lib/components/panel/modules.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,12 @@
name: 'Fournisseur',
color: 'bg-green-600',
link: '/panel/products/fournisseur'
})
});
modules.push({
name: "Course",
color: "bg-green-600",
name: 'Course',
color: 'bg-green-600',
link: '/panel/products/course'
})
});
// Sort the modules by name
modules.sort((a, b) => a.name.localeCompare(b.name));
Expand Down
139 changes: 71 additions & 68 deletions frontend/src/routes/panel/products/course/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,79 +4,82 @@
import type { CourseItem, Item, RestockType } from '$lib/api';
let items: CourseItem[] = [];
let fournisseur = "promocash";
function reloadCourse() {
CourseApi()
.getCourse(fournisseur, {
withCredentials: true
})
.then((res) => {
if (res.data.items != null) {
items = res.data.items;
} else {
items = [];
}
});
}
reloadCourse()
let fournisseur = 'promocash';
function reloadCourse() {
CourseApi()
.getCourse(fournisseur, {
withCredentials: true
})
.then((res) => {
if (res.data.items != null) {
items = res.data.items;
} else {
items = [];
}
});
}
reloadCourse();
</script>

<div class="relative mt-4 w-96 md:mt-0">
<!-- filter by state -->
<select
id="fournisseur"
name="fournisseur"
class="py-3 px-4 block w-full border-gray-200 border-2 rounded-md text-sm focus:border-blue-500 focus:ring-blue-500 dark:bg-gray-800 dark:border-gray-700 dark:text-gray-400"
required
aria-describedby="text-error"
on:change={(e) => {
// @ts-ignore
let val = e.target?.value;
fournisseur = val;
reloadCourse();
}}
>
<option value="promocash">Promocash</option>
<option value="auchan_drive">Auchan drive</option>
<option value="auchan">Auchan</option>
<option value="viennoiserie">Boulangerie Benoist</option>
</select>
<!-- filter by state -->
<select
id="fournisseur"
name="fournisseur"
class="py-3 px-4 block w-full border-gray-200 border-2 rounded-md text-sm focus:border-blue-500 focus:ring-blue-500 dark:bg-gray-800 dark:border-gray-700 dark:text-gray-400"
required
aria-describedby="text-error"
on:change={(e) => {
// @ts-ignore
let val = e.target?.value;
fournisseur = val;
reloadCourse();
}}
>
<option value="promocash">Promocash</option>
<option value="auchan_drive">Auchan drive</option>
<option value="auchan">Auchan</option>
<option value="viennoiserie">Boulangerie Benoist</option>
</select>
</div>

<table class="min-w-full divide-y divide-gray-200 dark:divide-gray-700">
<thead class="bg-gray-50 dark:bg-slate-800">
<tr>
<th scope="col" class="px-6 py-3">
<span
class="text-center text-xs font-semibold uppercase tracking-wide text-gray-800 dark:text-gray-200"
>
Nom
</span>
</th>
<th scope="col" class="px-6 py-3">
<span
class="text-center text-xs font-semibold uppercase tracking-wide text-gray-800 dark:text-gray-200"
>
Nombre à acheter
</span>
</th>
</tr>
</thead>
<tbody class="divide-y divide-gray-200 dark:divide-gray-700">
<td>
{#each items as item}
<p class="py-3 px-2 block border-gray-200 border-2 rounded-md text-sm focus:border-blue-500 focus:ring-blue-500 dark:bg-gray-800 dark:border-gray-700 dark:text-gray-400">
{item.item.name}
</p>
{/each}
</td>
<td>
{#each items as item}
<p class="py-3 px-2 block border-gray-200 border-2 rounded-md text-sm focus:border-blue-500 focus:ring-blue-500 dark:bg-gray-800 dark:border-gray-700 dark:text-gray-400">
{item.amountToBuy}
</p>
{/each}
</td>
</tbody>
<tr>
<th scope="col" class="px-6 py-3">
<span
class="text-center text-xs font-semibold uppercase tracking-wide text-gray-800 dark:text-gray-200"
>
Nom
</span>
</th>
<th scope="col" class="px-6 py-3">
<span
class="text-center text-xs font-semibold uppercase tracking-wide text-gray-800 dark:text-gray-200"
>
Nombre à acheter
</span>
</th>
</tr>
</thead>
<tbody class="divide-y divide-gray-200 dark:divide-gray-700">
<td>
{#each items as item}
<p
class="py-3 px-2 block border-gray-200 border-2 rounded-md text-sm focus:border-blue-500 focus:ring-blue-500 dark:bg-gray-800 dark:border-gray-700 dark:text-gray-400"
>
{item.item.name}
</p>
{/each}
</td>
<td>
{#each items as item}
<p
class="py-3 px-2 block border-gray-200 border-2 rounded-md text-sm focus:border-blue-500 focus:ring-blue-500 dark:bg-gray-800 dark:border-gray-700 dark:text-gray-400"
>
{item.amountToBuy}
</p>
{/each}
</td>
</tbody>
</table>

16 changes: 10 additions & 6 deletions frontend/src/routes/panel/products/fournisseur/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
ItemPrices,
UpdateItem,
AccountPriceRole,
RestockType,
RestockType
} from '$lib/api';
import ConfirmationPopup from '$lib/components/confirmationPopup.svelte';
import { api } from '$lib/config/config';
Expand All @@ -31,7 +31,7 @@
staff_bar: 0,
coutant: 0,
privilegies: 0,
menu: 0,
menu: 0
} as ItemPrices,
amount_left: 0,
buy_limit: undefined,
Expand Down Expand Up @@ -464,12 +464,12 @@
</div>

{#if deletingItem}
<ConfirmationPopup
<ConfirmationPopup
message={confirmationMessage}
confirm_text="Supprimer"
cancel_callback={() => {
deletingItem = false;
}}
}}
confirm_callback={deleteItemCallback}
/>
{/if}
Expand Down Expand Up @@ -778,7 +778,11 @@
on:input={(e) => {
// @ts-ignore
let amount_per_bundle = parseInt(e.target?.value);
editItem(item.id, { amount_per_bundle: amount_per_bundle }, item.category_id);
editItem(
item.id,
{ amount_per_bundle: amount_per_bundle },
item.category_id
);
}}
/>
</div>
Expand Down Expand Up @@ -859,7 +863,7 @@
deleteItemCallback = () => {
deletingItem = false;
deleteItem(item.id, item.category_id);
}
};
confirmationMessage = "Supprimer '" + item.name + "' ?";
deletingItem = true;
}}
Expand Down

0 comments on commit 739d503

Please sign in to comment.