coyotte508 HF staff commited on
Commit
c6195db
1 Parent(s): acf4634

🏷️ Add stock for product

Browse files
src/lib/types/Product.ts CHANGED
@@ -8,6 +8,7 @@ export interface Product extends Timestamps {
8
  price: number;
9
  kind: 'armchair' | 'cushion' | 'chair' | 'couch' | 'tufting';
10
  state: 'draft' | 'published' | 'retired';
 
11
 
12
  photos: Picture[];
13
  }
 
8
  price: number;
9
  kind: 'armchair' | 'cushion' | 'chair' | 'couch' | 'tufting';
10
  state: 'draft' | 'published' | 'retired';
11
+ stock: number;
12
 
13
  photos: Picture[];
14
  }
src/routes/admin/produits/[id]/+page.server.ts CHANGED
@@ -33,6 +33,7 @@ export const actions: Actions = {
33
  description: (formData.get('description') as string).replaceAll('\r', '')
34
  }),
35
  ...(formData.get('price') && { price: Number(formData.get('price')) }),
 
36
  updatedAt: new Date()
37
  };
38
 
 
33
  description: (formData.get('description') as string).replaceAll('\r', '')
34
  }),
35
  ...(formData.get('price') && { price: Number(formData.get('price')) }),
36
+ ...(formData.get('stock') && { stock: Number(formData.get('stock')) }),
37
  updatedAt: new Date()
38
  };
39
 
src/routes/admin/produits/nouveau/+page.server.ts CHANGED
@@ -59,6 +59,7 @@ export const actions: Actions = {
59
  name: fields.name,
60
  price: +fields.price,
61
  photos: [],
 
62
  state: 'draft'
63
  },
64
  { session }
 
59
  name: fields.name,
60
  price: +fields.price,
61
  photos: [],
62
+ stock: 1,
63
  state: 'draft'
64
  },
65
  { session }