@tabres/react 1.0.52 → 1.0.54

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.
Files changed (55) hide show
  1. package/dist/index.esm.js +1 -1
  2. package/dist/index.esm.js.map +1 -1
  3. package/dist/index.js +1 -1
  4. package/dist/index.js.map +1 -1
  5. package/dist/models/index.d.ts +1 -0
  6. package/dist/models/index.esm.js +1 -1
  7. package/dist/models/index.esm.js.map +1 -1
  8. package/dist/models/index.js +1 -1
  9. package/dist/models/index.js.map +1 -1
  10. package/dist/models/models/index.d.ts +1 -0
  11. package/dist/models/modules/addon/models.d.ts +3 -2
  12. package/dist/models/modules/branch/models.d.ts +7 -2
  13. package/dist/models/modules/category/models.d.ts +2 -1
  14. package/dist/models/modules/localization/models.d.ts +10 -0
  15. package/dist/models/modules/localization/utils.d.ts +22 -0
  16. package/dist/models/modules/menu/models.d.ts +3 -2
  17. package/dist/models/modules/order/hooks.d.ts +4 -0
  18. package/dist/models/modules/order/models.d.ts +2 -1
  19. package/dist/models/modules/order/utils.d.ts +15 -1
  20. package/dist/models/modules/product/models.d.ts +3 -2
  21. package/dist/models/modules/product/utils.d.ts +1 -1
  22. package/dist/modules/addon/models.d.ts +3 -2
  23. package/dist/modules/addon/utils.d.ts +8 -3
  24. package/dist/modules/branch/models.d.ts +7 -2
  25. package/dist/modules/category/models.d.ts +2 -1
  26. package/dist/modules/localization/index.d.ts +2 -0
  27. package/dist/modules/localization/models.d.ts +10 -0
  28. package/dist/modules/localization/utils.d.ts +22 -0
  29. package/dist/modules/localization/utils.test.d.ts +1 -0
  30. package/dist/modules/menu/models.d.ts +3 -2
  31. package/dist/modules/order/hooks.d.ts +4 -0
  32. package/dist/modules/order/models.d.ts +2 -1
  33. package/dist/modules/order/utils.d.ts +15 -1
  34. package/dist/modules/product/models.d.ts +3 -2
  35. package/dist/modules/product/utils.d.ts +1 -1
  36. package/dist/utils/index.d.ts +1 -0
  37. package/dist/utils/index.esm.js +1 -1
  38. package/dist/utils/index.esm.js.map +1 -1
  39. package/dist/utils/index.js +1 -1
  40. package/dist/utils/index.js.map +1 -1
  41. package/dist/utils/models/index.d.ts +1 -0
  42. package/dist/utils/modules/addon/models.d.ts +3 -2
  43. package/dist/utils/modules/addon/utils.d.ts +8 -3
  44. package/dist/utils/modules/branch/models.d.ts +7 -2
  45. package/dist/utils/modules/category/models.d.ts +2 -1
  46. package/dist/utils/modules/localization/models.d.ts +10 -0
  47. package/dist/utils/modules/localization/utils.d.ts +22 -0
  48. package/dist/utils/modules/menu/models.d.ts +3 -2
  49. package/dist/utils/modules/order/hooks.d.ts +4 -0
  50. package/dist/utils/modules/order/models.d.ts +2 -1
  51. package/dist/utils/modules/order/utils.d.ts +15 -1
  52. package/dist/utils/modules/product/models.d.ts +3 -2
  53. package/dist/utils/modules/product/utils.d.ts +1 -1
  54. package/dist/utils/utils/index.d.ts +1 -0
  55. package/package.json +1 -1
@@ -11,6 +11,7 @@ export * from "../modules/table/models";
11
11
  export * from "../modules/user/models";
12
12
  export * from "../modules/category/models";
13
13
  export * from "../modules/menu/models";
14
+ export * from "../modules/localization/models";
14
15
  export * from "../modules/video/models";
15
16
  export * from "../modules/pos/models";
16
17
  export * from "../components/PublicMenu/ProductsGridItem/ProductsGridItem.types";
@@ -1,3 +1,4 @@
1
+ import { LocalizedText } from "src/modules/localization/models";
1
2
  export declare enum MenuAddonSelectType {
2
3
  SINGLE = "SINGLE",
3
4
  MULTIPLE = "MULTIPLE"
@@ -12,7 +13,7 @@ export interface MenuAddonOption {
12
13
  * supplied (e.g. addon detached from a branch tax setup).
13
14
  */
14
15
  listingPrice: number;
15
- title: Record<string, string>;
16
+ title: LocalizedText;
16
17
  remove?: boolean;
17
18
  }
18
19
  export interface MenuAddon {
@@ -20,5 +21,5 @@ export interface MenuAddon {
20
21
  selectType: MenuAddonSelectType;
21
22
  options: MenuAddonOption[];
22
23
  businessId?: number;
23
- title: Record<string, string>;
24
+ title: LocalizedText;
24
25
  }
@@ -1,5 +1,10 @@
1
1
  import { MenuAddon, MenuAddonOption } from "./models";
2
- export declare const getAddonTranslation: (addon: MenuAddon, language: string) => string;
3
- export declare const getAddonOptionTranslation: (option: MenuAddonOption, language: string) => string;
2
+ /**
3
+ * An addon's title, or one of its options'.
4
+ *
5
+ * Both sides of an addon carry the same `LocalizedText` shape and fall back the
6
+ * same way, so one resolver serves the group heading ("Size") and the choices
7
+ * under it ("Small", "Large") alike.
8
+ */
9
+ export declare const getAddonTitle: (addon: MenuAddon | MenuAddonOption | null | undefined, language: string) => string;
4
10
  export declare const getOptionTitles: (options: MenuAddonOption[], optionIds: number | number[], language: string) => string;
5
- export declare const getAddonTitle: (addon: MenuAddon, language: string) => string;
@@ -1,3 +1,4 @@
1
+ import { LocalizedText } from "src/modules/localization/models";
1
2
  export type BranchWorkHour = {
2
3
  openAt: string;
3
4
  closeAt: string;
@@ -20,6 +21,8 @@ export interface BranchSettings {
20
21
  serviceChargePercentage: number;
21
22
  addToOrderEnabled: boolean;
22
23
  guestOrderEnabled: boolean;
24
+ primaryPaymentMethods?: string[] | null;
25
+ secondaryPaymentMethods?: string[] | null;
23
26
  }
24
27
  export declare enum BranchSetting {
25
28
  MAX_DELIVERY_DISTANCE = "maxDeliveryDistance",
@@ -31,7 +34,9 @@ export declare enum BranchSetting {
31
34
  SERVICE_CHARGE_ENABLED = "serviceChargeEnabled",
32
35
  SERVICE_CHARGE_PERCENTAGE = "serviceChargePercentage",
33
36
  ADD_TO_ORDER_ENABLED = "addToOrderEnabled",
34
- GUEST_ORDER_ENABLED = "guestOrderEnabled"
37
+ GUEST_ORDER_ENABLED = "guestOrderEnabled",
38
+ PRIMARY_PAYMENT_METHODS = "primaryPaymentMethods",
39
+ SECONDARY_PAYMENT_METHODS = "secondaryPaymentMethods"
35
40
  }
36
41
  export interface Branch {
37
42
  id: number;
@@ -76,7 +81,7 @@ export type BranchTax = {
76
81
  businessId: number;
77
82
  branchId: number;
78
83
  taxClassId?: number;
79
- name: Record<string, string>;
84
+ name: LocalizedText;
80
85
  rate: number;
81
86
  type: BranchTaxType;
82
87
  isActive: boolean;
@@ -1,3 +1,4 @@
1
+ import { LocalizedText } from "src/modules/localization/models";
1
2
  export interface Category {
2
3
  id: number;
3
4
  businessId: number;
@@ -5,7 +6,7 @@ export interface Category {
5
6
  * Category name keyed by language code, e.g. { en: "Drinks", az: "İçkilər" }.
6
7
  * Mirrors the `name` JSONB column returned by the API
7
8
  */
8
- name: Record<string, string>;
9
+ name: LocalizedText;
9
10
  /** Display order within the business; lower comes first. */
10
11
  position: number;
11
12
  }
@@ -0,0 +1,10 @@
1
+ /**
2
+ * A field the business authors once per language, keyed by language code —
3
+ * e.g. `{ en: "Drinks", az: "İçkilər" }`. Category names, addon titles, tax
4
+ * labels and product copy all arrive in this shape.
5
+ *
6
+ * The map travels whole rather than pre-resolved because the public menu is
7
+ * served from one language-agnostic cached payload: the guest switches
8
+ * language locally and every row has to relabel without a refetch.
9
+ */
10
+ export type LocalizedText = Record<string, string>;
@@ -0,0 +1,22 @@
1
+ import { LocalizedText } from "./models";
2
+ /**
3
+ * `source` in `language`, falling back when the business left that language
4
+ * blank.
5
+ *
6
+ * A menu is authored language by language and is rarely finished in all of
7
+ * them — a dish gets its Azerbaijani name today and its English one next week.
8
+ * A name in the wrong language still tells the guest what they are looking at,
9
+ * which an empty row does not, so a missing, null or empty value falls through
10
+ * to the next best language instead of rendering nothing.
11
+ */
12
+ export declare const getLocalizedText: (source: LocalizedText | null | undefined, language?: string) => string;
13
+ /**
14
+ * `source` in `language`, resolved field by field.
15
+ *
16
+ * Product copy arrives as a record per language — `{ name, description }` — and
17
+ * the fields are filled in independently: a dish is named in Turkish long
18
+ * before anyone writes its Turkish description. Falling back on the record as a
19
+ * whole would throw away the translated name the moment the description was
20
+ * blank, so each field falls back on its own.
21
+ */
22
+ export declare const getLocalizedContent: <T extends object>(source: Record<string, T> | null | undefined, language?: string) => T;
@@ -4,6 +4,7 @@ import * as categoryModels from "src/modules/category/models";
4
4
  import * as businessModels from "src/modules/business/models";
5
5
  import * as tableModels from "src/modules/table/models";
6
6
  import * as videoModels from "src/modules/video/models";
7
+ import { LocalizedText } from "src/modules/localization/models";
7
8
  export interface CategoryProductMap extends categoryModels.Category {
8
9
  products: productModels.Product[];
9
10
  }
@@ -30,8 +31,8 @@ export interface MenuDesign {
30
31
  menuPageTextColor: string;
31
32
  createdAt?: string;
32
33
  updatedAt?: string;
33
- headerText?: Record<string, string>;
34
- footerText?: Record<string, string>;
34
+ headerText?: LocalizedText;
35
+ footerText?: LocalizedText;
35
36
  }
36
37
  export interface PublicMenuData {
37
38
  business: businessModels.Business;
@@ -1,4 +1,8 @@
1
1
  import { GuestOrderPayload, Order, OrderPayload, SelectedAddons } from "./models";
2
+ export declare const usePaymentMethods: () => {
3
+ primary: import("./models").CustomerPaymentMethod[];
4
+ secondary: import("./models").CustomerPaymentMethod[];
5
+ };
2
6
  export declare const useOrderTotalRawPriceWithTax: () => number;
3
7
  export declare const useOrderTotalPriceWithTax: () => string;
4
8
  export declare const usePrepareOrder: (existingOrderData?: Partial<Order>) => OrderPayload;
@@ -1,5 +1,6 @@
1
1
  import * as customerModels from "../customer/models";
2
2
  import * as productModels from "../product/models";
3
+ import { LocalizedText } from "src/modules/localization/models";
3
4
  export declare enum OrderType {
4
5
  DINE_IN = "DINE_IN",
5
6
  PICK_UP = "PICK_UP",
@@ -178,7 +179,7 @@ export interface CalculatePreviewRequest {
178
179
  }
179
180
  export interface CalculatePreviewTax {
180
181
  branchTaxId: number;
181
- name: Record<string, string>;
182
+ name: LocalizedText;
182
183
  rate: number;
183
184
  type: "percentage" | "fixed";
184
185
  addToListingPrice: boolean;
@@ -1,5 +1,5 @@
1
1
  import { IconType } from "@sorocraft/ui";
2
- import { CalculatePreviewResponse, GuestContact, GuestContactRequest, Order, OrderAddon, OrderItem, OrderStatus, OrderType, SelectedAddons } from "./models";
2
+ import { CalculatePreviewResponse, GuestContact, GuestContactRequest, Order, OrderAddon, CustomerPaymentMethod, OrderItem, OrderStatus, OrderType, SelectedAddons } from "./models";
3
3
  import * as addonModels from "../addon/models";
4
4
  import * as branchModels from "../branch/models";
5
5
  import { OrderErrors } from "./constants";
@@ -8,6 +8,20 @@ export declare const getSelectedAddonsFromOrderItems: (item: OrderItem) => Selec
8
8
  export declare const getStatusIcon: (status: OrderStatus) => IconType;
9
9
  export declare const buildSelectedAddonsPayload: (productAddons?: addonModels.MenuAddon[], selectedAddons?: SelectedAddons) => OrderAddon[];
10
10
  export declare const getDefaultOrderType: (settings: branchModels.BranchSettings, isOpen: boolean, isDelivering: boolean) => OrderType | null;
11
+ /**
12
+ * Payment methods offered at checkout, split into the shortcuts shown up front
13
+ * and the rest folded behind the "more" disclosure.
14
+ *
15
+ * Either row can be overridden per branch. A missing or empty row means the
16
+ * venue never configured it, so it falls back to the library default instead of
17
+ * offering nothing. An unconfigured secondary row is "everything else the
18
+ * customer can settle with", which both keeps a promoted method from appearing
19
+ * twice and reproduces the stock cash/card split when neither row is set.
20
+ */
21
+ export declare const getPaymentMethods: (settings?: branchModels.BranchSettings) => {
22
+ primary: CustomerPaymentMethod[];
23
+ secondary: CustomerPaymentMethod[];
24
+ };
11
25
  export declare const isValidPreviewResponse: (data: unknown) => data is CalculatePreviewResponse;
12
26
  export declare const buildGuestContactRequest: (contact?: GuestContact) => GuestContactRequest | undefined;
13
27
  export declare const calculateTipAmount: (base: number, percentage: number) => number;
@@ -1,4 +1,5 @@
1
1
  import { MenuAddon } from "../addon/models";
2
+ import { LocalizedText } from "src/modules/localization/models";
2
3
  export interface LocalizedContent {
3
4
  name: string;
4
5
  description: string;
@@ -13,7 +14,7 @@ export interface ProductVariant {
13
14
  */
14
15
  listingPrice: number;
15
16
  /** Title keyed by language code, e.g. { en: "Large", az: "Böyük" }. */
16
- title: Record<string, string>;
17
+ title: LocalizedText;
17
18
  productId?: number;
18
19
  remove?: boolean;
19
20
  }
@@ -65,7 +66,7 @@ export interface Product {
65
66
  export interface AllergenDetail {
66
67
  code: AllergenCode;
67
68
  /** Label keyed by language code, e.g. `{ en: "Gluten", az: "Qlüten" }`. */
68
- translations: Record<string, string>;
69
+ translations: LocalizedText;
69
70
  }
70
71
  /**
71
72
  * An allergen code as it comes off the wire. Deliberately open: the API owns
@@ -1,5 +1,5 @@
1
- import { AllergenCode, LocalizedContent, Product, ProductVariant, SellUnitType } from "./models";
2
1
  import { MenuAddon } from "src/modules/addon/models";
2
+ import { AllergenCode, LocalizedContent, Product, ProductVariant, SellUnitType } from "./models";
3
3
  export declare const getProductTranslation: (product: Pick<Product, "translations">, language: string) => LocalizedContent;
4
4
  export declare const getProductVariant: (product: Pick<Product, "variants">, variantId: number) => ProductVariant;
5
5
  export declare const getProductVariantTranslation: (variant: ProductVariant, language: string) => string;
@@ -6,5 +6,6 @@ export * from "../modules/feature/utils";
6
6
  export * from "../modules/view/utils";
7
7
  export * from "../modules/category/utils";
8
8
  export * from "../modules/menu/utils";
9
+ export * from "../modules/localization/utils";
9
10
  export * from "../modules/user/utils";
10
11
  export * from "../modules/pos/utils";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tabres/react",
3
- "version": "1.0.52",
3
+ "version": "1.0.54",
4
4
  "description": "React Library by tabres.com",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.esm.js",