rapida-partner 7.3.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.
@@ -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
- ]);
@@ -1,101 +0,0 @@
1
- import { EDataType } from "../../enums/form.enum";
2
- import type { IFormElement } from "../../interfaces/form.interface";
3
- import type { IStorageConfig } from "../../interfaces/form-file.interface";
4
- import type { TStoreFont, TStoreRadius } from "../../interfaces/store-settings.interface";
5
- import { tr } from "./translations";
6
-
7
- const storageConfig: IStorageConfig = {
8
- path: "store-settings",
9
- fileNameStrategy: "uuid",
10
- visibility: "public",
11
- };
12
-
13
- const FONTS: { value: TStoreFont; label: string }[] = [
14
- { value: "inter", label: "Inter" },
15
- { value: "poppins", label: "Poppins" },
16
- { value: "nunito", label: "Nunito" },
17
- { value: "montserrat", label: "Montserrat" },
18
- { value: "roboto", label: "Roboto" },
19
- { value: "lato", label: "Lato" },
20
- ];
21
-
22
- const RADII: { value: TStoreRadius; label: ReturnType<typeof tr> }[] = [
23
- { value: "none", label: tr("Reto", "Square", "Recto") },
24
- { value: "soft", label: tr("Suave", "Soft", "Suave") },
25
- { value: "rounded", label: tr("Arredondado", "Rounded", "Redondeado") },
26
- ];
27
-
28
- export const identityElements: IFormElement[] = [
29
- {
30
- type: "input",
31
- name: "name",
32
- dataType: EDataType.TEXT,
33
- label: tr("Nome da loja", "Store name", "Nombre de la tienda"),
34
- isRequired: true,
35
- },
36
- {
37
- type: "input",
38
- name: "tagline",
39
- dataType: EDataType.TEXT,
40
- label: tr("Slogan", "Tagline", "Eslogan"),
41
- maxLength: 120,
42
- },
43
- {
44
- type: "file",
45
- name: "logo",
46
- dataType: EDataType.FILE,
47
- label: tr("Logo", "Logo", "Logotipo"),
48
- validators: ["onlyImages"],
49
- storageConfig,
50
- },
51
- {
52
- type: "file",
53
- name: "favicon",
54
- dataType: EDataType.FILE,
55
- label: tr("Ícone da aba (favicon)", "Tab icon (favicon)", "Icono de la pestaña (favicon)"),
56
- validators: ["onlyImages"],
57
- storageConfig,
58
- },
59
- ];
60
-
61
- export const visualElements: IFormElement[] = [
62
- {
63
- type: "input",
64
- name: "primaryColor",
65
- dataType: EDataType.COLOR,
66
- label: tr("Cor primária", "Primary color", "Color primario"),
67
- },
68
- {
69
- type: "input",
70
- name: "secondaryColor",
71
- dataType: EDataType.COLOR,
72
- label: tr("Cor secundária", "Secondary color", "Color secundario"),
73
- },
74
- {
75
- type: "input",
76
- name: "inkColor",
77
- dataType: EDataType.COLOR,
78
- label: tr("Cor escura (cabeçalho, rodapé e botões)", "Dark color (header, footer and buttons)", "Color oscuro (encabezado, pie y botones)"),
79
- },
80
- {
81
- type: "select",
82
- name: "font",
83
- dataType: EDataType.TEXT,
84
- label: tr("Fonte", "Font", "Fuente"),
85
- options: FONTS.map((font) => ({ label: font.label, value: font.value, isSelected: font.value === "inter" })),
86
- },
87
- {
88
- type: "select",
89
- name: "radius",
90
- dataType: EDataType.TEXT,
91
- label: tr("Arredondamento", "Corner style", "Redondeo"),
92
- options: RADII.map((radius) => ({ label: radius.label, value: radius.value, isSelected: radius.value === "soft" })),
93
- },
94
- {
95
- type: "input",
96
- name: "pageSize",
97
- dataType: EDataType.INTEGER,
98
- label: tr("Produtos por página", "Products per page", "Productos por página"),
99
- defaultValue: 12,
100
- },
101
- ];
@@ -1,100 +0,0 @@
1
- import { EDataType } from "../../enums/form.enum";
2
- import type { IFormElement } from "../../interfaces/form.interface";
3
- import type { IStorageConfig } from "../../interfaces/form-file.interface";
4
- import { tr } from "./translations";
5
-
6
- const storageConfig: IStorageConfig = {
7
- path: "store-settings",
8
- fileNameStrategy: "uuid",
9
- visibility: "public",
10
- };
11
-
12
- const richText = (name: string, label: ReturnType<typeof tr>): IFormElement => ({
13
- type: "input",
14
- name,
15
- dataType: EDataType.WYSIWYG,
16
- label,
17
- storageConfig,
18
- });
19
-
20
- /** Páginas institucionais e legais (L20): cada uma só é publicada quando tem texto. */
21
- export const pagesElements: IFormElement[] = [
22
- richText("aboutText", tr("Sobre a loja", "About the store", "Sobre la tienda")),
23
- richText("privacyPolicyText", tr("Política de privacidade", "Privacy policy", "Política de privacidad")),
24
- richText("termsText", tr("Termos de uso", "Terms of use", "Términos de uso")),
25
- richText("returnsPolicyText", tr("Trocas e devoluções", "Returns and exchanges", "Cambios y devoluciones")),
26
- {
27
- type: "input",
28
- name: "cookieNoticeText",
29
- dataType: EDataType.TEXT,
30
- label: tr("Aviso de cookies", "Cookie notice", "Aviso de cookies"),
31
- tooltip: tr("Sem texto, o aviso não aparece.", "Without text, the notice is not shown.", "Sin texto, el aviso no aparece."),
32
- },
33
- ];
34
-
35
- export interface IFeaturedProductsApi {
36
- // Endpoint dos produtos do vendedor (padrão "/products").
37
- endpoint?: string;
38
- // Campos mostrados na escolha (padrão ["name"]).
39
- labelField?: string[];
40
- }
41
-
42
- /** Home da vitrine (L25): banners, benefícios e produtos em destaque. */
43
- export const getShowcaseElements = (productsApi: IFeaturedProductsApi = {}): IFormElement[] => [
44
- {
45
- type: "array",
46
- name: "banners",
47
- label: tr("Banners", "Banners", "Banners"),
48
- elements: [
49
- {
50
- type: "file",
51
- name: "image",
52
- dataType: EDataType.TEXT,
53
- label: tr("Imagem", "Image", "Imagen"),
54
- validators: ["onlyImages"],
55
- storageConfig,
56
- },
57
- { type: "input", name: "title", dataType: EDataType.TEXT, label: tr("Título", "Title", "Título"), isRequired: true },
58
- { type: "input", name: "subtitle", dataType: EDataType.TEXT, label: tr("Subtítulo", "Subtitle", "Subtítulo") },
59
- {
60
- type: "input",
61
- name: "linkUrl",
62
- dataType: EDataType.TEXT,
63
- label: tr("Link do botão", "Button link", "Enlace del botón"),
64
- tooltip: tr("Caminho da loja (ex.: /busca?categoria=blu-ray) ou URL", "Store path (e.g. /busca?categoria=blu-ray) or URL", "Ruta de la tienda (ej.: /busca?categoria=blu-ray) o URL"),
65
- },
66
- { type: "input", name: "linkLabel", dataType: EDataType.TEXT, label: tr("Texto do botão", "Button text", "Texto del botón") },
67
- ],
68
- },
69
- {
70
- type: "array",
71
- name: "benefits",
72
- label: tr("Benefícios", "Benefits", "Beneficios"),
73
- elements: [
74
- {
75
- type: "input",
76
- name: "icon",
77
- dataType: EDataType.TEXT,
78
- label: tr("Ícone", "Icon", "Ícono"),
79
- tooltip: tr("Nome de um ícone Lucide (ex.: truck, shield-check)", "Lucide icon name (e.g. truck, shield-check)", "Nombre de un ícono Lucide (ej.: truck, shield-check)"),
80
- },
81
- { type: "input", name: "title", dataType: EDataType.TEXT, label: tr("Título", "Title", "Título"), isRequired: true },
82
- { type: "input", name: "text", dataType: EDataType.TEXT, label: tr("Texto", "Text", "Texto") },
83
- ],
84
- },
85
- {
86
- type: "autocomplete",
87
- name: "featuredProductIds",
88
- dataType: EDataType.UNIQUEIDENTIFIER,
89
- label: tr("Produtos em destaque", "Featured products", "Productos destacados"),
90
- isMultiple: true,
91
- optionsApi: {
92
- endpoint: productsApi.endpoint ?? "/products",
93
- relatedEntity: "products",
94
- labelField: productsApi.labelField ?? ["name"],
95
- valueField: "_id",
96
- paramsToFilter: productsApi.labelField ?? ["name"],
97
- paramType: "query",
98
- },
99
- },
100
- ];
@@ -1,80 +0,0 @@
1
- import type { IPublicContract } from "../../interfaces/form-contract.interface";
2
- import type { IForm } from "../../interfaces/form.interface";
3
- import type { IFormTab } from "../../interfaces/form-tab.interface";
4
- import type { IModule } from "../../interfaces/project.interface";
5
- import type { TStoreFeature } from "../../interfaces/store-settings.interface";
6
- import { contactElements, legalElements, socialElements } from "./contact-legal.elements";
7
- import { getFeatureElements } from "./features.elements";
8
- import { identityElements, visualElements } from "./identity-visual.elements";
9
- import { getShowcaseElements, pagesElements, type IFeaturedProductsApi } from "./pages-showcase.elements";
10
- import { tr } from "./translations";
11
-
12
- export const STORE_SETTINGS_ENDPOINT = "/store-settings";
13
-
14
- export interface IStoreSettingsModuleOptions {
15
- // A mesma lista de IProjectStore.features da loja que lê esta configuração.
16
- features?: TStoreFeature[];
17
- // Quem lê a configuração sem login. "trustedCallers" (padrão): só o backend
18
- // da loja, com o token de serviço de IMarketplace.sellerServiceAuth.
19
- publicAccess?: IPublicContract["access"];
20
- allowedOrigins?: string[];
21
- // Produtos do vendedor oferecidos em "Produtos em destaque" (aba Vitrine).
22
- featuredProductsApi?: IFeaturedProductsApi;
23
- }
24
-
25
- const buildTabs = (features: TStoreFeature[], productsApi?: IFeaturedProductsApi): IFormTab => ({
26
- type: "tab",
27
- id: "storeSettingsTabs",
28
- tabs: [
29
- { id: "identity", title: tr("Identidade", "Identity", "Identidad"), elements: identityElements },
30
- { id: "visual", title: tr("Visual", "Look and feel", "Apariencia"), elements: visualElements },
31
- { id: "contact", title: tr("Contato", "Contact", "Contacto"), elements: contactElements },
32
- { id: "legal", title: tr("Dados legais", "Legal data", "Datos legales"), elements: legalElements },
33
- { id: "social", title: tr("Redes sociais", "Social media", "Redes sociales"), elements: socialElements },
34
- { id: "showcase", title: tr("Vitrine", "Storefront", "Escaparate"), elements: getShowcaseElements(productsApi) },
35
- { id: "pages", title: tr("Páginas", "Pages", "Páginas"), elements: pagesElements },
36
- ...(features.length
37
- ? [{ id: "features", title: tr("Funcionalidades", "Features", "Funcionalidades"), elements: getFeatureElements(features) }]
38
- : []),
39
- ],
40
- });
41
-
42
- export const getStoreSettingsForm = (options: IStoreSettingsModuleOptions = {}): IForm => ({
43
- componentType: "form",
44
- id: "storeSettingsForm",
45
- title: tr("Configuração da loja", "Store settings", "Configuración de la tienda"),
46
- icon: "palette",
47
- guards: "isAuthorized",
48
- isSingleRecord: true,
49
- elements: [buildTabs(options.features ?? [], options.featuredProductsApi)],
50
- contracts: [
51
- {
52
- id: "storeSettings",
53
- endpoint: STORE_SETTINGS_ENDPOINT,
54
- actions: ["create", "get", "update"],
55
- request: { entity: "storeSettings", fields: [] },
56
- },
57
- ],
58
- publicContracts: [
59
- {
60
- id: "storeSettings",
61
- endpoint: STORE_SETTINGS_ENDPOINT,
62
- actions: ["get"],
63
- access: options.publicAccess ?? "trustedCallers",
64
- ...(options.allowedOrigins ? { allowedOrigins: options.allowedOrigins } : {}),
65
- request: { entity: "storeSettings", fields: [] },
66
- },
67
- ],
68
- });
69
-
70
- /**
71
- * Módulo pronto "Configuração da loja", para o Backoffice do vendedor. A loja
72
- * lê o registro salvo aqui por IMarketplace.storeSettingsEndpoint
73
- * (STORE_SETTINGS_ENDPOINT).
74
- */
75
- export const getStoreSettingsModule = (options: IStoreSettingsModuleOptions = {}): IModule => ({
76
- id: "storeSettingsModule",
77
- title: tr("Configuração da loja", "Store settings", "Configuración de la tienda"),
78
- icon: "palette",
79
- components: [getStoreSettingsForm(options)],
80
- });