@open-tender/utils 0.1.8 → 0.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -142,7 +142,21 @@ export declare const decrementItem: (cart: Cart, index: number) => {
142
142
  cart: Cart;
143
143
  cartCounts: Record<string, number>;
144
144
  };
145
- export declare const makeSimpleCart: (cart: Cart) => {
145
+ export declare const makeSimpleCart: <C extends {
146
+ id: number;
147
+ quantity: number;
148
+ groups: T[];
149
+ madeFor?: string | null | undefined;
150
+ made_for?: string | null | undefined;
151
+ notes?: string | null | undefined;
152
+ }[], T extends {
153
+ id: number;
154
+ options: K[];
155
+ }, K extends {
156
+ id: number;
157
+ quantity: number;
158
+ groups: T[];
159
+ }>(cart: C) => {
146
160
  id: number;
147
161
  quantity: number;
148
162
  groups: SimpleCartGroups;
@@ -596,13 +596,37 @@ const makeSimpleCart = (cart) => {
596
596
  id: i.id,
597
597
  quantity: i.quantity,
598
598
  groups: makeSimpleGroups(i.groups),
599
- made_for: i.madeFor || '',
599
+ made_for: i.madeFor || i.made_for || '',
600
600
  notes: i.notes || ''
601
601
  };
602
602
  });
603
603
  return simpleCart;
604
604
  };
605
605
  exports.makeSimpleCart = makeSimpleCart;
606
+ // const makeSimpleGroups = (groups: CartItemGroups): SimpleCartGroups => {
607
+ // return groups.map(g => {
608
+ // const options = g.options
609
+ // .filter(o => o.quantity !== 0)
610
+ // .map(o => ({
611
+ // id: o.id,
612
+ // quantity: o.quantity,
613
+ // groups: makeSimpleGroups(o.groups || [])
614
+ // }))
615
+ // return { id: g.id, options: options }
616
+ // })
617
+ // }
618
+ // export const makeSimpleCart = (cart: Cart) => {
619
+ // const simpleCart = cart.map(i => {
620
+ // return {
621
+ // id: i.id,
622
+ // quantity: i.quantity,
623
+ // groups: makeSimpleGroups(i.groups),
624
+ // made_for: i.madeFor || '',
625
+ // notes: i.notes || ''
626
+ // }
627
+ // })
628
+ // return simpleCart
629
+ // }
606
630
  const makeSimpleGroupsFromOrder = (groups) => {
607
631
  return groups.map(g => {
608
632
  const options = g.options
@@ -142,7 +142,21 @@ export declare const decrementItem: (cart: Cart, index: number) => {
142
142
  cart: Cart;
143
143
  cartCounts: Record<string, number>;
144
144
  };
145
- export declare const makeSimpleCart: (cart: Cart) => {
145
+ export declare const makeSimpleCart: <C extends {
146
+ id: number;
147
+ quantity: number;
148
+ groups: T[];
149
+ madeFor?: string | null | undefined;
150
+ made_for?: string | null | undefined;
151
+ notes?: string | null | undefined;
152
+ }[], T extends {
153
+ id: number;
154
+ options: K[];
155
+ }, K extends {
156
+ id: number;
157
+ quantity: number;
158
+ groups: T[];
159
+ }>(cart: C) => {
146
160
  id: number;
147
161
  quantity: number;
148
162
  groups: SimpleCartGroups;
@@ -565,12 +565,36 @@ export const makeSimpleCart = (cart) => {
565
565
  id: i.id,
566
566
  quantity: i.quantity,
567
567
  groups: makeSimpleGroups(i.groups),
568
- made_for: i.madeFor || '',
568
+ made_for: i.madeFor || i.made_for || '',
569
569
  notes: i.notes || ''
570
570
  };
571
571
  });
572
572
  return simpleCart;
573
573
  };
574
+ // const makeSimpleGroups = (groups: CartItemGroups): SimpleCartGroups => {
575
+ // return groups.map(g => {
576
+ // const options = g.options
577
+ // .filter(o => o.quantity !== 0)
578
+ // .map(o => ({
579
+ // id: o.id,
580
+ // quantity: o.quantity,
581
+ // groups: makeSimpleGroups(o.groups || [])
582
+ // }))
583
+ // return { id: g.id, options: options }
584
+ // })
585
+ // }
586
+ // export const makeSimpleCart = (cart: Cart) => {
587
+ // const simpleCart = cart.map(i => {
588
+ // return {
589
+ // id: i.id,
590
+ // quantity: i.quantity,
591
+ // groups: makeSimpleGroups(i.groups),
592
+ // made_for: i.madeFor || '',
593
+ // notes: i.notes || ''
594
+ // }
595
+ // })
596
+ // return simpleCart
597
+ // }
574
598
  const makeSimpleGroupsFromOrder = (groups) => {
575
599
  return groups.map(g => {
576
600
  const options = g.options
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-tender/utils",
3
- "version": "0.1.8",
3
+ "version": "0.1.9",
4
4
  "description": "A library of utils for use with Open Tender applications that utilize our cloud-based Order API.",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "module": "./dist/esm/index.js",