coyotte508 HF staff commited on
Commit
3f97f84
1 Parent(s): 23ca589

✨ Able to change stock from admin

Browse files
src/routes/admin/produits/[id]/+page.svelte CHANGED
@@ -17,6 +17,10 @@
17
  Prix
18
  <input type="number" name="price" class="input block" value={data.product.price} />
19
  </label>
 
 
 
 
20
  <label class="block w-full mt-4 leading-8">
21
  Etat
22
  <select name="state" value={data.product.state} class="block input">
 
17
  Prix
18
  <input type="number" name="price" class="input block" value={data.product.price} />
19
  </label>
20
+ <label class="block w-full mt-4 leading-8">
21
+ Stock
22
+ <input type="number" name="stock" class="input block" value={data.product.stock} />
23
+ </label>
24
  <label class="block w-full mt-4 leading-8">
25
  Etat
26
  <select name="state" value={data.product.state} class="block input">
src/routes/vente/+page.server.ts CHANGED
@@ -11,11 +11,12 @@ export const load: PageServerLoad = async () => {
11
  const byId = Object.fromEntries(products.map((p) => [p._id, p]));
12
 
13
  for (const picture of pictures) {
 
14
  byId[picture.productId!].photos = [...(byId[picture.productId!].photos || []), picture];
15
  }
16
 
17
  return {
18
- published: products.filter((p) => p.state === 'published'),
19
- retired: products.filter((p) => p.state === 'retired')
20
  };
21
  };
 
11
  const byId = Object.fromEntries(products.map((p) => [p._id, p]));
12
 
13
  for (const picture of pictures) {
14
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
15
  byId[picture.productId!].photos = [...(byId[picture.productId!].photos || []), picture];
16
  }
17
 
18
  return {
19
+ published: products.filter((p) => p.state === 'published' && p.stock),
20
+ retired: products.filter((p) => p.state === 'published' && !p.stock)
21
  };
22
  };