rapida-partner 7.1.0 → 8.0.0

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 (43) hide show
  1. package/README.md +6 -0
  2. package/index.ts +5 -0
  3. package/package.json +1 -1
  4. package/src/interfaces/dashboard-widget.interface.ts +58 -0
  5. package/src/interfaces/data-chart.interface.ts +23 -1
  6. package/src/interfaces/data-stat.interface.ts +115 -0
  7. package/src/interfaces/list.interface.ts +19 -0
  8. package/src/interfaces/project-backend.interface.ts +6 -6
  9. package/src/interfaces/project.interface.ts +19 -1
  10. package/src/interfaces/store-blog-post.interface.ts +1 -1
  11. package/src/interfaces/store-coupon.interface.ts +2 -2
  12. package/src/interfaces/store-order.interface.ts +2 -2
  13. package/src/interfaces/store-return.interface.ts +1 -1
  14. package/src/interfaces/store-review.interface.ts +1 -1
  15. package/src/interfaces/store-settings.interface.ts +1 -1
  16. package/src/interfaces/tone.interface.ts +2 -0
  17. package/src/schemas/component-one-of.ref.json +5 -2
  18. package/src/schemas/dashboard-budget-monitor.ref.json +16 -0
  19. package/src/schemas/dashboard-empty-state.ref.json +37 -0
  20. package/src/schemas/dashboard-item-one-of.ref.json +16 -0
  21. package/src/schemas/dashboard-link-action.ref.json +15 -0
  22. package/src/schemas/dashboard-quick-create.ref.json +19 -0
  23. package/src/schemas/data-chart.ref.json +36 -2
  24. package/src/schemas/data-stat.ref.json +146 -0
  25. package/src/schemas/list.ref.json +57 -0
  26. package/src/schemas/module.ref.json +5 -2
  27. package/src/schemas/project.schema.json +7 -1
  28. package/src/schemas/quick-create-item.ref.json +19 -0
  29. package/src/schemas/tone.ref.json +6 -0
  30. package/src/utils/list-references.ts +51 -0
  31. package/src/modules/store-blog/store-blog.module.ts +0 -108
  32. package/src/modules/store-coupons/store-coupons.module.ts +0 -127
  33. package/src/modules/store-orders/store-order.elements.ts +0 -82
  34. package/src/modules/store-orders/store-orders.module.ts +0 -108
  35. package/src/modules/store-returns/store-return.elements.ts +0 -70
  36. package/src/modules/store-returns/store-returns.module.ts +0 -101
  37. package/src/modules/store-reviews/store-reviews.module.ts +0 -132
  38. package/src/modules/store-settings/contact-legal.elements.ts +0 -57
  39. package/src/modules/store-settings/features.elements.ts +0 -93
  40. package/src/modules/store-settings/identity-visual.elements.ts +0 -101
  41. package/src/modules/store-settings/pages-showcase.elements.ts +0 -100
  42. package/src/modules/store-settings/store-settings.module.ts +0 -80
  43. package/src/modules/store-settings/translations.ts +0 -7
@@ -1,82 +0,0 @@
1
- import { EDataType } from "../../enums/form.enum";
2
- import type { IFormElement } from "../../interfaces/form.interface";
3
- import type { TStoreOrderFulfillmentStatus } from "../../interfaces/store-order.interface";
4
- import { tr } from "../store-settings/translations";
5
-
6
- type TLabel = ReturnType<typeof tr>;
7
-
8
- const text = (name: string, label: TLabel, extra: Partial<{ isRequired: boolean; isDisabled: boolean }> = {}): IFormElement => ({
9
- type: "input",
10
- name,
11
- dataType: EDataType.TEXT,
12
- label,
13
- ...extra,
14
- });
15
-
16
- const money = (name: string, label: TLabel): IFormElement => ({
17
- type: "input",
18
- name,
19
- dataType: EDataType.CURRENCY,
20
- label,
21
- isDisabled: true,
22
- });
23
-
24
- export const STORE_ORDER_STATUS_LABELS: Record<TStoreOrderFulfillmentStatus, TLabel> = {
25
- received: tr("Recebido", "Received", "Recibido"),
26
- preparing: tr("Em separação", "Preparing", "En preparación"),
27
- shipped: tr("Enviado", "Shipped", "Enviado"),
28
- delivered: tr("Entregue", "Delivered", "Entregado"),
29
- cancelled: tr("Cancelado", "Cancelled", "Cancelado"),
30
- };
31
-
32
- export const fulfillmentElements: IFormElement[] = [
33
- {
34
- type: "select",
35
- name: "status",
36
- dataType: EDataType.TEXT,
37
- label: tr("Andamento", "Status", "Estado"),
38
- isRequired: true,
39
- options: (Object.keys(STORE_ORDER_STATUS_LABELS) as TStoreOrderFulfillmentStatus[]).map((status) => ({
40
- label: STORE_ORDER_STATUS_LABELS[status],
41
- value: status,
42
- isSelected: status === "received",
43
- })),
44
- },
45
- text("trackingCode", tr("Código de rastreio", "Tracking code", "Código de seguimiento")),
46
- text("trackingUrl", tr("Link de rastreio", "Tracking link", "Enlace de seguimiento")),
47
- text("notes", tr("Observações", "Notes", "Observaciones")),
48
- ];
49
-
50
- export const orderElements: IFormElement[] = [
51
- text("storeOrderId", tr("Pedido na loja", "Store order", "Pedido en la tienda"), { isRequired: true, isDisabled: true }),
52
- text("storeName", tr("Loja", "Store", "Tienda"), { isDisabled: true }),
53
- text("customerName", tr("Cliente", "Customer", "Cliente"), { isDisabled: true }),
54
- text("customerEmail", tr("E-mail do cliente", "Customer e-mail", "Correo del cliente"), { isDisabled: true }),
55
- {
56
- type: "array",
57
- name: "items",
58
- label: tr("Itens", "Items", "Artículos"),
59
- elements: [
60
- text("productId", tr("Produto (id)", "Product (id)", "Producto (id)"), { isRequired: true, isDisabled: true }),
61
- text("name", tr("Produto", "Product", "Producto"), { isRequired: true, isDisabled: true }),
62
- { type: "input", name: "quantity", dataType: EDataType.INTEGER, label: tr("Quantidade", "Quantity", "Cantidad"), isRequired: true, isDisabled: true },
63
- money("unitPrice", tr("Preço unitário", "Unit price", "Precio unitario")),
64
- ],
65
- },
66
- money("subtotal", tr("Subtotal", "Subtotal", "Subtotal")),
67
- money("discount", tr("Desconto", "Discount", "Descuento")),
68
- money("shipping", tr("Frete", "Shipping", "Envío")),
69
- money("total", tr("Total", "Total", "Total")),
70
- text("currency", tr("Moeda", "Currency", "Moneda"), { isDisabled: true }),
71
- ];
72
-
73
- export const addressElements: IFormElement[] = [
74
- text("addressZipCode", tr("CEP", "ZIP code", "Código postal"), { isDisabled: true }),
75
- text("addressStreet", tr("Logradouro", "Street", "Calle"), { isDisabled: true }),
76
- text("addressNumber", tr("Número", "Number", "Número"), { isDisabled: true }),
77
- text("addressComplement", tr("Complemento", "Complement", "Complemento"), { isDisabled: true }),
78
- text("addressDistrict", tr("Bairro", "District", "Barrio"), { isDisabled: true }),
79
- text("addressCity", tr("Cidade", "City", "Ciudad"), { isDisabled: true }),
80
- text("addressState", tr("Estado", "State", "Estado"), { isDisabled: true }),
81
- text("addressCountry", tr("País", "Country", "País"), { isDisabled: true }),
82
- ];
@@ -1,108 +0,0 @@
1
- import { EDataType } from "../../enums/form.enum";
2
- import type { IPublicContract } from "../../interfaces/form-contract.interface";
3
- import type { IForm } from "../../interfaces/form.interface";
4
- import type { IList } from "../../interfaces/list.interface";
5
- import type { IModule } from "../../interfaces/project.interface";
6
- import { tr } from "../store-settings/translations";
7
- import { STORE_ORDER_STATUS_LABELS, addressElements, fulfillmentElements, orderElements } from "./store-order.elements";
8
-
9
- export const STORE_ORDERS_ENDPOINT = "/store-orders";
10
-
11
- export interface IStoreOrdersModuleOptions {
12
- // Quem cria e lê os pedidos sem login. "trustedCallers" (padrão): só o
13
- // backend da loja, com o token de serviço de IMarketplace.sellerServiceAuth.
14
- publicAccess?: IPublicContract["access"];
15
- allowedOrigins?: string[];
16
- }
17
-
18
- const ENTITY = "storeOrders";
19
-
20
- // Um pedido por storeOrderId em cada workspace. Fica no contrato interno do
21
- // form, de onde o gerador cria o índice único, e não no público: o reenvio do
22
- // mesmo pedido pela loja é recusado em vez de duplicar.
23
- const UNIQUE_STORE_ORDER = [{ identificator: "storeOrderIdPerWorkspace", fields: ["storeOrderId"] }];
24
-
25
- export const getStoreOrderForm = (options: IStoreOrdersModuleOptions = {}): IForm => ({
26
- componentType: "form",
27
- id: "storeOrderForm",
28
- title: tr("Pedido da loja", "Store order", "Pedido de la tienda"),
29
- icon: "truck",
30
- guards: "isAuthorized",
31
- elements: [
32
- {
33
- type: "tab",
34
- id: "storeOrderTabs",
35
- tabs: [
36
- { id: "fulfillment", title: tr("Entrega", "Fulfillment", "Entrega"), elements: fulfillmentElements },
37
- { id: "order", title: tr("Pedido", "Order", "Pedido"), elements: orderElements },
38
- { id: "address", title: tr("Endereço", "Address", "Dirección"), elements: addressElements },
39
- ],
40
- },
41
- ],
42
- contracts: [
43
- {
44
- id: ENTITY,
45
- endpoint: STORE_ORDERS_ENDPOINT,
46
- actions: ["get", "getById", "update"],
47
- request: { entity: ENTITY, fields: [], uniqueConstraints: UNIQUE_STORE_ORDER },
48
- },
49
- ],
50
- publicContracts: [
51
- {
52
- id: "storeOrdersFromStore",
53
- endpoint: STORE_ORDERS_ENDPOINT,
54
- actions: ["create", "get", "update"],
55
- access: options.publicAccess ?? "trustedCallers",
56
- ...(options.allowedOrigins ? { allowedOrigins: options.allowedOrigins } : {}),
57
- request: { entity: ENTITY, fields: [] },
58
- },
59
- ],
60
- });
61
-
62
- export const getStoreOrderList = (): IList => ({
63
- componentType: "list",
64
- id: "storeOrderList",
65
- title: tr("Pedidos da loja", "Store orders", "Pedidos de la tienda"),
66
- guards: ["isAuthorized"],
67
- dataSource: { endpoint: STORE_ORDERS_ENDPOINT, paramType: "query", hasAuthentication: true },
68
- listItems: [
69
- { property: "storeOrderId", type: "title", label: tr("Pedido", "Order", "Pedido"), dataType: EDataType.TEXT },
70
- { property: "customerName", type: "subtitle", label: tr("Cliente", "Customer", "Cliente"), dataType: EDataType.TEXT },
71
- { property: "total", type: "description", label: tr("Total", "Total", "Total"), dataType: EDataType.CURRENCY },
72
- { property: "status", type: "badge", label: tr("Andamento", "Status", "Estado"), dataType: EDataType.TEXT },
73
- { property: "createdAt", label: tr("Recebido em", "Received at", "Recibido el"), dataType: EDataType.DATE, isTimestamp: true },
74
- ],
75
- listFilters: [
76
- {
77
- type: "select",
78
- name: "status",
79
- dataType: EDataType.TEXT,
80
- label: tr("Andamento", "Status", "Estado"),
81
- options: (Object.keys(STORE_ORDER_STATUS_LABELS) as (keyof typeof STORE_ORDER_STATUS_LABELS)[]).map((status) => ({
82
- label: STORE_ORDER_STATUS_LABELS[status],
83
- value: status,
84
- })),
85
- },
86
- ],
87
- contracts: [
88
- {
89
- id: ENTITY,
90
- endpoint: STORE_ORDERS_ENDPOINT,
91
- actions: ["get", "getById", "update"],
92
- request: { entity: ENTITY, fields: [] },
93
- },
94
- ],
95
- });
96
-
97
- /**
98
- * Módulo pronto "Pedidos da loja", para o Backoffice do vendedor. A loja cria
99
- * aqui cada pedido aprovado (IStoreOrder) por IMarketplace.storeOrdersEndpoint
100
- * (STORE_ORDERS_ENDPOINT) e lê o andamento da entrega; o vendedor atualiza
101
- * status e rastreio.
102
- */
103
- export const getStoreOrdersModule = (options: IStoreOrdersModuleOptions = {}): IModule => ({
104
- id: "storeOrdersModule",
105
- title: tr("Pedidos da loja", "Store orders", "Pedidos de la tienda"),
106
- icon: "truck",
107
- components: [getStoreOrderList(), getStoreOrderForm(options)],
108
- });
@@ -1,70 +0,0 @@
1
- import { EDataType } from "../../enums/form.enum";
2
- import type { IFormElement } from "../../interfaces/form.interface";
3
- import type { TStoreReturnReason, TStoreReturnStatus, TStoreReturnType } from "../../interfaces/store-return.interface";
4
- import { tr } from "../store-settings/translations";
5
-
6
- type TLabel = ReturnType<typeof tr>;
7
-
8
- const readOnly = (name: string, label: TLabel, dataType: EDataType.TEXT | EDataType.INTEGER = EDataType.TEXT): IFormElement => ({
9
- type: "input",
10
- name,
11
- dataType,
12
- label,
13
- isDisabled: true,
14
- });
15
-
16
- const options = <T extends string>(labels: Record<T, TLabel>, selected?: T) =>
17
- (Object.keys(labels) as T[]).map((value: T) => ({ label: labels[value], value, ...(value === selected ? { isSelected: true } : {}) }));
18
-
19
- export const STORE_RETURN_STATUS_LABELS: Record<TStoreReturnStatus, TLabel> = {
20
- requested: tr("Solicitado", "Requested", "Solicitado"),
21
- approved: tr("Aprovado", "Approved", "Aprobado"),
22
- rejected: tr("Recusado", "Rejected", "Rechazado"),
23
- received: tr("Produto recebido", "Item received", "Producto recibido"),
24
- completed: tr("Concluído", "Completed", "Concluido"),
25
- };
26
-
27
- export const STORE_RETURN_TYPE_LABELS: Record<TStoreReturnType, TLabel> = {
28
- return: tr("Devolução", "Return", "Devolución"),
29
- exchange: tr("Troca", "Exchange", "Cambio"),
30
- };
31
-
32
- export const STORE_RETURN_REASON_LABELS: Record<TStoreReturnReason, TLabel> = {
33
- defect: tr("Produto com defeito", "Defective item", "Producto defectuoso"),
34
- wrongItem: tr("Produto errado", "Wrong item", "Producto equivocado"),
35
- notAsDescribed: tr("Diferente do anunciado", "Not as described", "Distinto de lo anunciado"),
36
- regret: tr("Desistência", "Changed my mind", "Desistimiento"),
37
- other: tr("Outro", "Other", "Otro"),
38
- };
39
-
40
- export const resolutionElements: IFormElement[] = [
41
- {
42
- type: "select",
43
- name: "status",
44
- dataType: EDataType.TEXT,
45
- label: tr("Andamento", "Status", "Estado"),
46
- isRequired: true,
47
- options: options(STORE_RETURN_STATUS_LABELS, "requested"),
48
- },
49
- { type: "input", name: "resolutionNotes", dataType: EDataType.TEXT, label: tr("Resposta ao cliente", "Reply to the customer", "Respuesta al cliente") },
50
- { type: "input", name: "returnTrackingCode", dataType: EDataType.TEXT, label: tr("Código de postagem", "Return tracking code", "Código de envío") },
51
- ];
52
-
53
- export const requestElements: IFormElement[] = [
54
- readOnly("storeOrderId", tr("Pedido na loja", "Store order", "Pedido en la tienda")),
55
- { type: "select", name: "type", dataType: EDataType.TEXT, label: tr("Tipo", "Type", "Tipo"), isRequired: true, isDisabled: true, options: options(STORE_RETURN_TYPE_LABELS) },
56
- { type: "select", name: "reason", dataType: EDataType.TEXT, label: tr("Motivo", "Reason", "Motivo"), isRequired: true, isDisabled: true, options: options(STORE_RETURN_REASON_LABELS) },
57
- readOnly("comment", tr("Comentário do cliente", "Customer comment", "Comentario del cliente")),
58
- readOnly("customerName", tr("Cliente", "Customer", "Cliente")),
59
- readOnly("customerEmail", tr("E-mail do cliente", "Customer e-mail", "Correo del cliente")),
60
- {
61
- type: "array",
62
- name: "items",
63
- label: tr("Itens", "Items", "Artículos"),
64
- elements: [
65
- readOnly("productId", tr("Produto (id)", "Product (id)", "Producto (id)")),
66
- readOnly("name", tr("Produto", "Product", "Producto")),
67
- readOnly("quantity", tr("Quantidade", "Quantity", "Cantidad"), EDataType.INTEGER),
68
- ],
69
- },
70
- ];
@@ -1,101 +0,0 @@
1
- import { EDataType } from "../../enums/form.enum";
2
- import type { IPublicContract } from "../../interfaces/form-contract.interface";
3
- import type { IForm } from "../../interfaces/form.interface";
4
- import type { IList } from "../../interfaces/list.interface";
5
- import type { IModule } from "../../interfaces/project.interface";
6
- import type { TStoreReturnStatus } from "../../interfaces/store-return.interface";
7
- import { tr } from "../store-settings/translations";
8
- import { STORE_RETURN_STATUS_LABELS, requestElements, resolutionElements } from "./store-return.elements";
9
-
10
- export const STORE_RETURNS_ENDPOINT = "/store-returns";
11
-
12
- export interface IStoreReturnsModuleOptions {
13
- publicAccess?: IPublicContract["access"];
14
- allowedOrigins?: string[];
15
- }
16
-
17
- const ENTITY = "storeReturns";
18
-
19
- export const getStoreReturnForm = (options: IStoreReturnsModuleOptions = {}): IForm => ({
20
- componentType: "form",
21
- id: "storeReturnForm",
22
- title: tr("Devolução ou troca", "Return or exchange", "Devolución o cambio"),
23
- icon: "undo-2",
24
- guards: "isAuthorized",
25
- elements: [
26
- {
27
- type: "tab",
28
- id: "storeReturnTabs",
29
- tabs: [
30
- { id: "resolution", title: tr("Resposta", "Resolution", "Respuesta"), elements: resolutionElements },
31
- { id: "request", title: tr("Pedido do cliente", "Customer request", "Solicitud del cliente"), elements: requestElements },
32
- ],
33
- },
34
- ],
35
- contracts: [
36
- {
37
- id: ENTITY,
38
- endpoint: STORE_RETURNS_ENDPOINT,
39
- actions: ["get", "getById", "update"],
40
- request: { entity: ENTITY, fields: [] },
41
- },
42
- ],
43
- publicContracts: [
44
- {
45
- id: "storeReturnsFromStore",
46
- endpoint: STORE_RETURNS_ENDPOINT,
47
- actions: ["create", "get"],
48
- access: options.publicAccess ?? "trustedCallers",
49
- ...(options.allowedOrigins ? { allowedOrigins: options.allowedOrigins } : {}),
50
- request: { entity: ENTITY, fields: [] },
51
- },
52
- ],
53
- });
54
-
55
- export const getStoreReturnList = (): IList => ({
56
- componentType: "list",
57
- id: "storeReturnList",
58
- title: tr("Devoluções e trocas", "Returns and exchanges", "Devoluciones y cambios"),
59
- guards: ["isAuthorized"],
60
- dataSource: { endpoint: STORE_RETURNS_ENDPOINT, paramType: "query", hasAuthentication: true },
61
- listItems: [
62
- { property: "storeOrderId", type: "title", label: tr("Pedido", "Order", "Pedido"), dataType: EDataType.TEXT },
63
- { property: "customerName", type: "subtitle", label: tr("Cliente", "Customer", "Cliente"), dataType: EDataType.TEXT },
64
- { property: "type", type: "description", label: tr("Tipo", "Type", "Tipo"), dataType: EDataType.TEXT },
65
- { property: "status", type: "badge", label: tr("Andamento", "Status", "Estado"), dataType: EDataType.TEXT },
66
- { property: "createdAt", label: tr("Pedido em", "Requested at", "Solicitado el"), dataType: EDataType.DATE, isTimestamp: true },
67
- ],
68
- listFilters: [
69
- {
70
- type: "select",
71
- name: "status",
72
- dataType: EDataType.TEXT,
73
- label: tr("Andamento", "Status", "Estado"),
74
- options: (Object.keys(STORE_RETURN_STATUS_LABELS) as TStoreReturnStatus[]).map((status) => ({
75
- label: STORE_RETURN_STATUS_LABELS[status],
76
- value: status,
77
- })),
78
- },
79
- ],
80
- contracts: [
81
- {
82
- id: ENTITY,
83
- endpoint: STORE_RETURNS_ENDPOINT,
84
- actions: ["get", "getById", "update"],
85
- request: { entity: ENTITY, fields: [] },
86
- },
87
- ],
88
- });
89
-
90
- /**
91
- * Módulo pronto "Devoluções e trocas", para o Backoffice do vendedor
92
- * (funcionalidade "returns"). A loja abre aqui o pedido do cliente
93
- * (IMarketplace.returnsEndpoint) e lê dali o andamento; o vendedor aprova,
94
- * recusa e acompanha o retorno do produto. O reembolso continua na loja.
95
- */
96
- export const getStoreReturnsModule = (options: IStoreReturnsModuleOptions = {}): IModule => ({
97
- id: "storeReturnsModule",
98
- title: tr("Devoluções e trocas", "Returns and exchanges", "Devoluciones y cambios"),
99
- icon: "undo-2",
100
- components: [getStoreReturnList(), getStoreReturnForm(options)],
101
- });
@@ -1,132 +0,0 @@
1
- import { EDataType } from "../../enums/form.enum";
2
- import type { IPublicContract } from "../../interfaces/form-contract.interface";
3
- import type { IForm, IFormElement } from "../../interfaces/form.interface";
4
- import type { IList } from "../../interfaces/list.interface";
5
- import type { IModule } from "../../interfaces/project.interface";
6
- import type { TStoreReviewStatus } from "../../interfaces/store-review.interface";
7
- import { tr } from "../store-settings/translations";
8
-
9
- export const STORE_REVIEWS_ENDPOINT = "/store-reviews";
10
- // Nota média por produto: GET <endpoint>/aggregations/rating (soma de rating e count).
11
- export const STORE_REVIEWS_RATING_AGGREGATION = "rating";
12
-
13
- export interface IStoreReviewsModuleOptions {
14
- publicAccess?: IPublicContract["access"];
15
- allowedOrigins?: string[];
16
- }
17
-
18
- const ENTITY = "storeReviews";
19
-
20
- export const STORE_REVIEW_STATUS_LABELS: Record<TStoreReviewStatus, ReturnType<typeof tr>> = {
21
- pending: tr("Aguardando moderação", "Awaiting moderation", "Esperando moderación"),
22
- approved: tr("Aprovada", "Approved", "Aprobada"),
23
- rejected: tr("Recusada", "Rejected", "Rechazada"),
24
- };
25
-
26
- const readOnly = (name: string, label: ReturnType<typeof tr>, dataType: EDataType.TEXT | EDataType.INTEGER = EDataType.TEXT): IFormElement => ({
27
- type: "input",
28
- name,
29
- dataType,
30
- label,
31
- isDisabled: true,
32
- });
33
-
34
- const reviewElements: IFormElement[] = [
35
- {
36
- type: "select",
37
- name: "status",
38
- dataType: EDataType.TEXT,
39
- label: tr("Moderação", "Moderation", "Moderación"),
40
- isRequired: true,
41
- options: (Object.keys(STORE_REVIEW_STATUS_LABELS) as TStoreReviewStatus[]).map((status) => ({
42
- label: STORE_REVIEW_STATUS_LABELS[status],
43
- value: status,
44
- isSelected: status === "pending",
45
- })),
46
- },
47
- { type: "input", name: "reply", dataType: EDataType.TEXT, label: tr("Resposta do vendedor", "Seller reply", "Respuesta del vendedor") },
48
- readOnly("rating", tr("Nota (1 a 5)", "Rating (1 to 5)", "Nota (1 a 5)"), EDataType.INTEGER),
49
- readOnly("title", tr("Título", "Title", "Título")),
50
- readOnly("comment", tr("Comentário", "Comment", "Comentario")),
51
- readOnly("customerName", tr("Cliente", "Customer", "Cliente")),
52
- readOnly("productId", tr("Produto (id)", "Product (id)", "Producto (id)")),
53
- readOnly("storeOrderId", tr("Pedido na loja", "Store order", "Pedido en la tienda")),
54
- ];
55
-
56
- // Uma avaliação por produto em cada pedido da loja.
57
- const UNIQUE_REVIEW = [{ identificator: "storeReviewPerOrderProduct", fields: ["storeOrderId", "productId"] }];
58
-
59
- export const getStoreReviewForm = (options: IStoreReviewsModuleOptions = {}): IForm => ({
60
- componentType: "form",
61
- id: "storeReviewForm",
62
- title: tr("Avaliação", "Review", "Reseña"),
63
- icon: "star",
64
- guards: "isAuthorized",
65
- elements: reviewElements,
66
- contracts: [
67
- {
68
- id: ENTITY,
69
- endpoint: STORE_REVIEWS_ENDPOINT,
70
- actions: ["get", "getById", "update", "softDelete"],
71
- request: { entity: ENTITY, fields: [], uniqueConstraints: UNIQUE_REVIEW },
72
- },
73
- ],
74
- publicContracts: [
75
- {
76
- id: "storeReviewsFromStore",
77
- endpoint: STORE_REVIEWS_ENDPOINT,
78
- actions: ["create", "get"],
79
- access: options.publicAccess ?? "trustedCallers",
80
- ...(options.allowedOrigins ? { allowedOrigins: options.allowedOrigins } : {}),
81
- aggregations: [{ id: STORE_REVIEWS_RATING_AGGREGATION, groupBy: "productId", sum: ["rating"], count: true }],
82
- request: { entity: ENTITY, fields: [] },
83
- },
84
- ],
85
- });
86
-
87
- export const getStoreReviewList = (): IList => ({
88
- componentType: "list",
89
- id: "storeReviewList",
90
- title: tr("Avaliações", "Reviews", "Reseñas"),
91
- guards: ["isAuthorized"],
92
- dataSource: { endpoint: STORE_REVIEWS_ENDPOINT, paramType: "query", hasAuthentication: true },
93
- listItems: [
94
- { property: "title", type: "title", label: tr("Título", "Title", "Título"), dataType: EDataType.TEXT },
95
- { property: "customerName", type: "subtitle", label: tr("Cliente", "Customer", "Cliente"), dataType: EDataType.TEXT },
96
- { property: "rating", type: "description", label: tr("Nota", "Rating", "Nota"), dataType: EDataType.INTEGER },
97
- { property: "status", type: "badge", label: tr("Moderação", "Moderation", "Moderación"), dataType: EDataType.TEXT },
98
- { property: "createdAt", label: tr("Recebida em", "Received at", "Recibida el"), dataType: EDataType.DATE, isTimestamp: true },
99
- ],
100
- listFilters: [
101
- {
102
- type: "select",
103
- name: "status",
104
- dataType: EDataType.TEXT,
105
- label: tr("Moderação", "Moderation", "Moderación"),
106
- options: (Object.keys(STORE_REVIEW_STATUS_LABELS) as TStoreReviewStatus[]).map((status) => ({
107
- label: STORE_REVIEW_STATUS_LABELS[status],
108
- value: status,
109
- })),
110
- },
111
- ],
112
- contracts: [
113
- {
114
- id: ENTITY,
115
- endpoint: STORE_REVIEWS_ENDPOINT,
116
- actions: ["get", "getById", "update", "softDelete"],
117
- request: { entity: ENTITY, fields: [] },
118
- },
119
- ],
120
- });
121
-
122
- /**
123
- * Módulo pronto "Avaliações", para o Backoffice do vendedor (funcionalidade
124
- * "reviews"). A loja cria aqui a avaliação de quem recebeu o pedido
125
- * (IMarketplace.reviewsEndpoint) e lê as aprovadas e a nota média.
126
- */
127
- export const getStoreReviewsModule = (options: IStoreReviewsModuleOptions = {}): IModule => ({
128
- id: "storeReviewsModule",
129
- title: tr("Avaliações", "Reviews", "Reseñas"),
130
- icon: "star",
131
- components: [getStoreReviewList(), getStoreReviewForm(options)],
132
- });
@@ -1,57 +0,0 @@
1
- import { EDataType } from "../../enums/form.enum";
2
- import type { IFormElement } from "../../interfaces/form.interface";
3
- import { tr } from "./translations";
4
-
5
- const textInput = (name: string, label: ReturnType<typeof tr>): IFormElement => ({
6
- type: "input",
7
- name,
8
- dataType: EDataType.TEXT,
9
- label,
10
- });
11
-
12
- export const contactElements: IFormElement[] = [
13
- {
14
- type: "input",
15
- name: "whatsappNumber",
16
- dataType: EDataType.TEXT,
17
- label: tr("WhatsApp de vendas", "Sales WhatsApp", "WhatsApp de ventas"),
18
- tooltip: tr("Somente dígitos, com DDI (ex.: 5582999999999)", "Digits only, with country code (e.g. 5582999999999)", "Solo dígitos, con código de país (ej.: 5582999999999)"),
19
- validators: ["onlyNumbers"],
20
- },
21
- {
22
- type: "input",
23
- name: "phone",
24
- dataType: EDataType.TEXT,
25
- label: tr("Telefone", "Phone", "Teléfono"),
26
- validators: ["phone"],
27
- },
28
- {
29
- type: "input",
30
- name: "email",
31
- dataType: EDataType.EMAIL,
32
- label: tr("E-mail de contato", "Contact e-mail", "Correo de contacto"),
33
- validators: ["email"],
34
- },
35
- textInput("weekdayHours", tr("Horário em dias úteis", "Weekday hours", "Horario entre semana")),
36
- textInput("saturdayHours", tr("Horário no sábado", "Saturday hours", "Horario del sábado")),
37
- ];
38
-
39
- export const legalElements: IFormElement[] = [
40
- textInput("companyName", tr("Razão social", "Legal name", "Razón social")),
41
- {
42
- type: "input",
43
- name: "cnpj",
44
- dataType: EDataType.TEXT,
45
- label: tr("CNPJ", "CNPJ", "CNPJ"),
46
- mask: "00.000.000/0000-00",
47
- validators: ["cnpj"],
48
- },
49
- textInput("address", tr("Endereço", "Address", "Dirección")),
50
- ];
51
-
52
- export const socialElements: IFormElement[] = [
53
- textInput("instagramUrl", tr("Instagram (link)", "Instagram (link)", "Instagram (enlace)")),
54
- textInput("facebookUrl", tr("Facebook (link)", "Facebook (link)", "Facebook (enlace)")),
55
- textInput("tiktokUrl", tr("TikTok (link)", "TikTok (link)", "TikTok (enlace)")),
56
- textInput("youtubeUrl", tr("YouTube (link)", "YouTube (link)", "YouTube (enlace)")),
57
- ];
@@ -1,93 +0,0 @@
1
- import { EDataType } from "../../enums/form.enum";
2
- import type { IFormElement } from "../../interfaces/form.interface";
3
- import type { TStoreFeature } from "../../interfaces/store-settings.interface";
4
- import { tr } from "./translations";
5
-
6
- const FEATURE_LABELS: Record<TStoreFeature, ReturnType<typeof tr>> = {
7
- whatsappButton: tr("Mostrar botão de WhatsApp", "Show WhatsApp button", "Mostrar botón de WhatsApp"),
8
- stockAvailability: tr("Mostrar \"esgotado\" e filtro \"só em estoque\"", "Show \"sold out\" and \"in stock only\" filter", "Mostrar \"agotado\" y filtro \"solo en stock\""),
9
- cashDiscount: tr("Anunciar desconto à vista", "Show cash discount", "Anunciar descuento al contado"),
10
- installments: tr("Anunciar parcelas sem juros", "Show interest-free installments", "Anunciar cuotas sin interés"),
11
- favorites: tr("Favoritos", "Favorites", "Favoritos"),
12
- blog: tr("Blog", "Blog", "Blog"),
13
- shipping: tr("Cobrar frete por faixa de CEP", "Charge shipping by ZIP code range", "Cobrar envío por rango de código postal"),
14
- coupons: tr("Aceitar cupons de desconto", "Accept discount coupons", "Aceptar cupones de descuento"),
15
- reviews: tr("Avaliações de produtos", "Product reviews", "Reseñas de productos"),
16
- returns: tr("Pedidos de devolução e troca", "Return and exchange requests", "Solicitudes de devolución y cambio"),
17
- };
18
-
19
- const shippingElements: IFormElement[] = [
20
- {
21
- type: "input",
22
- name: "originZipCode",
23
- dataType: EDataType.TEXT,
24
- label: tr("CEP de origem", "Origin ZIP code", "Código postal de origen"),
25
- tooltip: tr("Somente dígitos (ex.: 57035000)", "Digits only (e.g. 57035000)", "Solo dígitos (ej.: 57035000)"),
26
- validators: ["onlyNumbers"],
27
- },
28
- {
29
- type: "input",
30
- name: "freeShippingAbove",
31
- dataType: EDataType.CURRENCY,
32
- label: tr("Frete grátis acima de", "Free shipping above", "Envío gratis a partir de"),
33
- },
34
- {
35
- type: "array",
36
- name: "shippingRanges",
37
- label: tr("Faixas de CEP", "ZIP code ranges", "Rangos de código postal"),
38
- elements: [
39
- { type: "input", name: "label", dataType: EDataType.TEXT, label: tr("Nome da faixa", "Range name", "Nombre del rango") },
40
- { type: "input", name: "zipCodeStart", dataType: EDataType.TEXT, label: tr("CEP inicial", "First ZIP code", "Código postal inicial"), isRequired: true, validators: ["onlyNumbers"] },
41
- { type: "input", name: "zipCodeEnd", dataType: EDataType.TEXT, label: tr("CEP final", "Last ZIP code", "Código postal final"), isRequired: true, validators: ["onlyNumbers"] },
42
- { type: "input", name: "price", dataType: EDataType.CURRENCY, label: tr("Valor do frete", "Shipping price", "Precio del envío"), isRequired: true },
43
- { type: "input", name: "deliveryDays", dataType: EDataType.INTEGER, label: tr("Prazo (dias úteis)", "Delivery time (business days)", "Plazo (días hábiles)"), isRequired: true },
44
- ],
45
- },
46
- ];
47
-
48
- const featureDetails = (feature: TStoreFeature): IFormElement[] => {
49
- if (feature === "cashDiscount") {
50
- return [
51
- {
52
- type: "input",
53
- name: "cashDiscountPercent",
54
- dataType: EDataType.NUMBER,
55
- label: tr("Desconto à vista (%)", "Cash discount (%)", "Descuento al contado (%)"),
56
- suffix: "%",
57
- },
58
- ];
59
- }
60
- if (feature === "installments") {
61
- return [
62
- {
63
- type: "input",
64
- name: "maxInstallments",
65
- dataType: EDataType.INTEGER,
66
- label: tr("Parcelas sem juros (máximo)", "Interest-free installments (max)", "Cuotas sin interés (máximo)"),
67
- },
68
- ];
69
- }
70
- if (feature === "shipping") return shippingElements;
71
- if (feature === "returns") {
72
- return [
73
- {
74
- type: "input",
75
- name: "returnWindowDays",
76
- dataType: EDataType.INTEGER,
77
- label: tr("Prazo para pedir (dias após a entrega)", "Request window (days after delivery)", "Plazo para solicitar (días tras la entrega)"),
78
- },
79
- ];
80
- }
81
- return [];
82
- };
83
-
84
- /** Liga e desliga só das funcionalidades que a loja gera, cada um seguido dos seus campos. */
85
- export const getFeatureElements = (features: TStoreFeature[]): IFormElement[] =>
86
- features.flatMap((feature: TStoreFeature): IFormElement[] => [
87
- {
88
- type: "switch",
89
- name: `${feature}Enabled`,
90
- label: FEATURE_LABELS[feature],
91
- },
92
- ...featureDetails(feature),
93
- ]);