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.
- package/README.md +6 -0
- package/package.json +1 -1
- package/src/interfaces/project-backend.interface.ts +6 -6
- package/src/interfaces/store-blog-post.interface.ts +1 -1
- package/src/interfaces/store-coupon.interface.ts +2 -2
- package/src/interfaces/store-order.interface.ts +2 -2
- package/src/interfaces/store-return.interface.ts +1 -1
- package/src/interfaces/store-review.interface.ts +1 -1
- package/src/interfaces/store-settings.interface.ts +1 -1
- package/src/modules/store-blog/store-blog.module.ts +0 -108
- package/src/modules/store-coupons/store-coupons.module.ts +0 -127
- package/src/modules/store-orders/store-order.elements.ts +0 -82
- package/src/modules/store-orders/store-orders.module.ts +0 -108
- package/src/modules/store-returns/store-return.elements.ts +0 -70
- package/src/modules/store-returns/store-returns.module.ts +0 -101
- package/src/modules/store-reviews/store-reviews.module.ts +0 -132
- package/src/modules/store-settings/contact-legal.elements.ts +0 -57
- package/src/modules/store-settings/features.elements.ts +0 -93
- package/src/modules/store-settings/identity-visual.elements.ts +0 -101
- package/src/modules/store-settings/pages-showcase.elements.ts +0 -100
- package/src/modules/store-settings/store-settings.module.ts +0 -80
- package/src/modules/store-settings/translations.ts +0 -7
package/README.md
CHANGED
|
@@ -65,6 +65,12 @@ Para criar seu próprio "mapa", utilize as interfaces TypeScript disponíveis na
|
|
|
65
65
|
- `form.interface.ts`, `list.interface.ts`, `data-table.interface.ts`, `data-chart.interface.ts`, etc.: Definem os tipos de componentes de UI e suas propriedades (campos de formulário, listas, tabelas, gráficos, etc.).
|
|
66
66
|
|
|
67
67
|
|
|
68
|
+
#### O que fica (e o que não fica) neste pacote
|
|
69
|
+
|
|
70
|
+
O `rapida-partner` guarda só o **contrato** da DSL: interfaces (`src/interfaces/`), enums (`src/enums/`), schemas (`src/schemas/`) e o `index.ts` que monta e valida o `rapidaObject.json`.
|
|
71
|
+
|
|
72
|
+
Instâncias da DSL — módulos, forms, lists e elements prontos para um projeto usar — ficam no `rapida-projects` (por exemplo, os módulos do Backoffice do vendedor da loja estão em `rapida-projects/src/modules/store/`). Quando um contrato de integração exige nomes de campos fixos (como `IStoreSettings` e `IStoreOrder`), a interface fica aqui e o módulo que a preenche fica lá, tipado contra ela.
|
|
73
|
+
|
|
68
74
|
### 5. Como Funciona a Validação
|
|
69
75
|
|
|
70
76
|
A validação é feita através do módulo `src/utils/json.ts`, que utiliza as bibliotecas `ajv` e `ajv-formats`. O processo:
|
package/package.json
CHANGED
|
@@ -68,7 +68,7 @@ interface IMarketplace {
|
|
|
68
68
|
// vem daqui e o backend calcula o valor do pedido; sem ele, usa product.price.
|
|
69
69
|
productSellingSettingsEndpoint?: string;
|
|
70
70
|
// Endpoint, na mesma base de productBaseUrl, da configuração da loja
|
|
71
|
-
// (IStoreSettings) salva no Backoffice do vendedor pelo módulo
|
|
71
|
+
// (IStoreSettings) salva no Backoffice do vendedor pelo módulo de rapida-projects
|
|
72
72
|
// getStoreSettingsModule. Sem ele, a loja usa só IProject.store.defaults.
|
|
73
73
|
storeSettingsEndpoint?: string;
|
|
74
74
|
// Workspace do vendedor (dono dos dados). A loja só lê produtos, preços e
|
|
@@ -86,7 +86,7 @@ interface IMarketplace {
|
|
|
86
86
|
// movimentações (ex.: "/stock-ins/aggregations/balance").
|
|
87
87
|
stockInAggregateEndpoint?: string;
|
|
88
88
|
stockOutAggregateEndpoint?: string;
|
|
89
|
-
// Pedidos enviados ao vendedor (módulo
|
|
89
|
+
// Pedidos enviados ao vendedor (módulo de rapida-projects getStoreOrdersModule, contrato
|
|
90
90
|
// público com access "trustedCallers"). A loja cria o pedido aprovado e lê
|
|
91
91
|
// dali o andamento da entrega (em separação, enviado, entregue, rastreio).
|
|
92
92
|
storeOrdersEndpoint?: string;
|
|
@@ -96,17 +96,17 @@ interface IMarketplace {
|
|
|
96
96
|
// Em que campo do produto do vendedor está cada informação usada pela
|
|
97
97
|
// vitrine. O gerador tem um padrão para cada campo omitido.
|
|
98
98
|
productFieldMap?: IMarketplaceProductFieldMap;
|
|
99
|
-
// Cupons do vendedor (módulo
|
|
99
|
+
// Cupons do vendedor (módulo de rapida-projects getStoreCouponsModule, funcionalidade
|
|
100
100
|
// "coupons"). A loja valida o código e desconta no servidor.
|
|
101
101
|
couponsEndpoint?: string;
|
|
102
|
-
// Avaliações (módulo
|
|
102
|
+
// Avaliações (módulo de rapida-projects getStoreReviewsModule, funcionalidade
|
|
103
103
|
// "reviews"). A loja cria a avaliação de quem recebeu o pedido e lê as
|
|
104
104
|
// aprovadas; a nota média vem da agregação "<endpoint>/aggregations/rating".
|
|
105
105
|
reviewsEndpoint?: string;
|
|
106
|
-
// Pedidos de devolução e troca (módulo
|
|
106
|
+
// Pedidos de devolução e troca (módulo de rapida-projects getStoreReturnsModule,
|
|
107
107
|
// funcionalidade "returns").
|
|
108
108
|
returnsEndpoint?: string;
|
|
109
|
-
// Artigos do blog (módulo
|
|
109
|
+
// Artigos do blog (módulo de rapida-projects getStoreBlogModule, funcionalidade "blog").
|
|
110
110
|
blogPostsEndpoint?: string;
|
|
111
111
|
}
|
|
112
112
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Artigo do blog da loja (funcionalidade "blog"), escrito no Backoffice do
|
|
3
|
-
* vendedor pelo módulo
|
|
3
|
+
* vendedor pelo módulo de rapida-projects getStoreBlogModule e lido pela loja por
|
|
4
4
|
* IMarketplace.blogPostsEndpoint. Os campos são os nomes do form.
|
|
5
5
|
*/
|
|
6
6
|
export interface IStoreBlogPost {
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
export type TStoreCouponDiscountType = "percentage" | "value";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
* Cupom de desconto cadastrado no Backoffice do vendedor pelo módulo
|
|
5
|
+
* Cupom de desconto cadastrado no Backoffice do vendedor pelo módulo de rapida-projects
|
|
6
6
|
* getStoreCouponsModule e lido pela loja por IMarketplace.couponsEndpoint. A
|
|
7
7
|
* loja valida e desconta no servidor; o uso é contado pelos pedidos da loja.
|
|
8
|
-
* Os campos são os nomes do form do módulo
|
|
8
|
+
* Os campos são os nomes do form do módulo de rapida-projects.
|
|
9
9
|
*/
|
|
10
10
|
export interface IStoreCoupon {
|
|
11
11
|
// Código digitado pelo cliente; um por workspace, sem diferenciar maiúsculas.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Andamento da entrega de um pedido no vendedor. O pagamento continua sendo da
|
|
3
|
-
* loja; separação, envio e rastreio são do vendedor (módulo
|
|
3
|
+
* loja; separação, envio e rastreio são do vendedor (módulo de rapida-projects
|
|
4
4
|
* getStoreOrdersModule).
|
|
5
5
|
*/
|
|
6
6
|
export type TStoreOrderFulfillmentStatus = "received" | "preparing" | "shipped" | "delivered" | "cancelled";
|
|
@@ -14,7 +14,7 @@ export interface IStoreOrderItem {
|
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* Pedido aprovado que a loja envia ao vendedor por IMarketplace.storeOrdersEndpoint.
|
|
17
|
-
* Os campos são os nomes do form do módulo
|
|
17
|
+
* Os campos são os nomes do form do módulo de rapida-projects.
|
|
18
18
|
*/
|
|
19
19
|
export interface IStoreOrder {
|
|
20
20
|
// Id do pedido na loja; um pedido por storeOrderId.
|
|
@@ -14,7 +14,7 @@ export interface IStoreReturnItem {
|
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* Pedido de devolução ou troca aberto pelo cliente em Minha conta e enviado
|
|
17
|
-
* pela loja ao vendedor (IMarketplace.returnsEndpoint, módulo
|
|
17
|
+
* pela loja ao vendedor (IMarketplace.returnsEndpoint, módulo de rapida-projects
|
|
18
18
|
* getStoreReturnsModule). O vendedor aprova ou recusa e acompanha o retorno;
|
|
19
19
|
* o reembolso continua sendo da loja (estorno no gateway). Os campos são os
|
|
20
20
|
* nomes do form.
|
|
@@ -3,7 +3,7 @@ export type TStoreReviewStatus = "pending" | "approved" | "rejected";
|
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Avaliação de produto enviada pela loja ao vendedor (IMarketplace.reviewsEndpoint,
|
|
6
|
-
* módulo
|
|
6
|
+
* módulo de rapida-projects getStoreReviewsModule). Só cliente com pedido entregue avalia;
|
|
7
7
|
* o vendedor modera e pode responder. Os campos são os nomes do form.
|
|
8
8
|
*/
|
|
9
9
|
export interface IStoreReview {
|
|
@@ -27,7 +27,7 @@ export type TStoreRadius = "none" | "soft" | "rounded";
|
|
|
27
27
|
/**
|
|
28
28
|
* Configuração da loja: identidade, visual, contato, dados legais, redes,
|
|
29
29
|
* comercial e liga e desliga. É o registro único editado no Backoffice do
|
|
30
|
-
* vendedor pelo módulo
|
|
30
|
+
* vendedor pelo módulo de rapida-projects `getStoreSettingsModule` (os nomes dos campos do
|
|
31
31
|
* form são estas mesmas chaves) e também o formato dos valores iniciais em
|
|
32
32
|
* `IProjectStore.defaults`.
|
|
33
33
|
*
|
|
@@ -1,108 +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 { tr } from "../store-settings/translations";
|
|
7
|
-
|
|
8
|
-
export const STORE_BLOG_POSTS_ENDPOINT = "/store-blog-posts";
|
|
9
|
-
|
|
10
|
-
export interface IStoreBlogModuleOptions {
|
|
11
|
-
publicAccess?: IPublicContract["access"];
|
|
12
|
-
allowedOrigins?: string[];
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
const ENTITY = "storeBlogPosts";
|
|
16
|
-
|
|
17
|
-
const postElements: IFormElement[] = [
|
|
18
|
-
{ type: "input", name: "title", dataType: EDataType.TEXT, label: tr("Título", "Title", "Título"), isRequired: true, space: 2 },
|
|
19
|
-
{
|
|
20
|
-
type: "input",
|
|
21
|
-
name: "slug",
|
|
22
|
-
dataType: EDataType.TEXT,
|
|
23
|
-
label: tr("Nome na URL", "URL name", "Nombre en la URL"),
|
|
24
|
-
tooltip: tr("Letras minúsculas, números e hífen (ex.: como-guardar-blu-ray)", "Lowercase letters, numbers and hyphens (e.g. how-to-store-blu-ray)", "Letras minúsculas, números y guion (ej.: como-guardar-blu-ray)"),
|
|
25
|
-
isRequired: true,
|
|
26
|
-
isUnique: true,
|
|
27
|
-
space: 2,
|
|
28
|
-
},
|
|
29
|
-
{ type: "input", name: "excerpt", dataType: EDataType.TEXT, label: tr("Resumo", "Excerpt", "Resumen") },
|
|
30
|
-
{
|
|
31
|
-
type: "file",
|
|
32
|
-
name: "coverImage",
|
|
33
|
-
dataType: EDataType.TEXT,
|
|
34
|
-
label: tr("Imagem de capa", "Cover image", "Imagen de portada"),
|
|
35
|
-
validators: ["onlyImages"],
|
|
36
|
-
storageConfig: { path: "store-blog-posts", fileNameStrategy: "uuid", visibility: "public" },
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
type: "input",
|
|
40
|
-
name: "content",
|
|
41
|
-
dataType: EDataType.WYSIWYG,
|
|
42
|
-
label: tr("Conteúdo", "Content", "Contenido"),
|
|
43
|
-
isRequired: true,
|
|
44
|
-
storageConfig: { path: "store-blog-posts", fileNameStrategy: "uuid", visibility: "public" },
|
|
45
|
-
},
|
|
46
|
-
{ type: "datepicker", name: "publishedAt", label: tr("Publicar em", "Publish on", "Publicar el") },
|
|
47
|
-
{ type: "switch", name: "isPublished", label: tr("Publicado", "Published", "Publicado") },
|
|
48
|
-
];
|
|
49
|
-
|
|
50
|
-
export const getStoreBlogPostForm = (options: IStoreBlogModuleOptions = {}): IForm => ({
|
|
51
|
-
componentType: "form",
|
|
52
|
-
id: "storeBlogPostForm",
|
|
53
|
-
title: tr("Artigo do blog", "Blog post", "Artículo del blog"),
|
|
54
|
-
icon: "newspaper",
|
|
55
|
-
guards: "isAuthorized",
|
|
56
|
-
elements: postElements,
|
|
57
|
-
contracts: [
|
|
58
|
-
{
|
|
59
|
-
id: ENTITY,
|
|
60
|
-
endpoint: STORE_BLOG_POSTS_ENDPOINT,
|
|
61
|
-
actions: ["create", "get", "getById", "update", "softDelete"],
|
|
62
|
-
request: { entity: ENTITY, fields: [] },
|
|
63
|
-
},
|
|
64
|
-
],
|
|
65
|
-
publicContracts: [
|
|
66
|
-
{
|
|
67
|
-
id: "storeBlogPostsFromStore",
|
|
68
|
-
endpoint: STORE_BLOG_POSTS_ENDPOINT,
|
|
69
|
-
actions: ["get", "getById"],
|
|
70
|
-
access: options.publicAccess ?? "trustedCallers",
|
|
71
|
-
...(options.allowedOrigins ? { allowedOrigins: options.allowedOrigins } : {}),
|
|
72
|
-
request: { entity: ENTITY, fields: [] },
|
|
73
|
-
},
|
|
74
|
-
],
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
export const getStoreBlogPostList = (): IList => ({
|
|
78
|
-
componentType: "list",
|
|
79
|
-
id: "storeBlogPostList",
|
|
80
|
-
title: tr("Blog", "Blog", "Blog"),
|
|
81
|
-
guards: ["isAuthorized"],
|
|
82
|
-
dataSource: { endpoint: STORE_BLOG_POSTS_ENDPOINT, paramType: "query", hasAuthentication: true },
|
|
83
|
-
listItems: [
|
|
84
|
-
{ property: "title", type: "title", label: tr("Título", "Title", "Título"), dataType: EDataType.TEXT },
|
|
85
|
-
{ property: "excerpt", type: "subtitle", label: tr("Resumo", "Excerpt", "Resumen"), dataType: EDataType.TEXT },
|
|
86
|
-
{ property: "publishedAt", label: tr("Publicar em", "Publish on", "Publicar el"), dataType: EDataType.DATE },
|
|
87
|
-
],
|
|
88
|
-
contracts: [
|
|
89
|
-
{
|
|
90
|
-
id: ENTITY,
|
|
91
|
-
endpoint: STORE_BLOG_POSTS_ENDPOINT,
|
|
92
|
-
actions: ["get", "getById", "update", "softDelete"],
|
|
93
|
-
request: { entity: ENTITY, fields: [] },
|
|
94
|
-
},
|
|
95
|
-
],
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* Módulo pronto "Blog", para o Backoffice do vendedor (funcionalidade
|
|
100
|
-
* "blog"). A loja lista os artigos publicados por IMarketplace.blogPostsEndpoint
|
|
101
|
-
* (STORE_BLOG_POSTS_ENDPOINT).
|
|
102
|
-
*/
|
|
103
|
-
export const getStoreBlogModule = (options: IStoreBlogModuleOptions = {}): IModule => ({
|
|
104
|
-
id: "storeBlogModule",
|
|
105
|
-
title: tr("Blog", "Blog", "Blog"),
|
|
106
|
-
icon: "newspaper",
|
|
107
|
-
components: [getStoreBlogPostList(), getStoreBlogPostForm(options)],
|
|
108
|
-
});
|
|
@@ -1,127 +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 { TStoreCouponDiscountType } from "../../interfaces/store-coupon.interface";
|
|
7
|
-
import { tr } from "../store-settings/translations";
|
|
8
|
-
|
|
9
|
-
export const STORE_COUPONS_ENDPOINT = "/store-coupons";
|
|
10
|
-
|
|
11
|
-
export interface IStoreCouponsModuleOptions {
|
|
12
|
-
// Quem lê os cupons sem login. "trustedCallers" (padrão): só o backend da
|
|
13
|
-
// loja, com o token de serviço de IMarketplace.sellerServiceAuth.
|
|
14
|
-
publicAccess?: IPublicContract["access"];
|
|
15
|
-
allowedOrigins?: string[];
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const ENTITY = "storeCoupons";
|
|
19
|
-
|
|
20
|
-
const DISCOUNT_TYPE_LABELS: Record<TStoreCouponDiscountType, ReturnType<typeof tr>> = {
|
|
21
|
-
percentage: tr("Percentual (%)", "Percentage (%)", "Porcentaje (%)"),
|
|
22
|
-
value: tr("Valor fixo", "Fixed amount", "Monto fijo"),
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
const couponElements: IFormElement[] = [
|
|
26
|
-
{
|
|
27
|
-
type: "input",
|
|
28
|
-
name: "code",
|
|
29
|
-
dataType: EDataType.TEXT,
|
|
30
|
-
label: tr("Código", "Code", "Código"),
|
|
31
|
-
tooltip: tr("O que o cliente digita no carrinho (ex.: BEMVINDO10)", "What the customer types in the cart (e.g. WELCOME10)", "Lo que el cliente escribe en el carrito (ej.: BIENVENIDO10)"),
|
|
32
|
-
isRequired: true,
|
|
33
|
-
isUnique: true,
|
|
34
|
-
space: 2,
|
|
35
|
-
},
|
|
36
|
-
{ type: "input", name: "description", dataType: EDataType.TEXT, label: tr("Descrição", "Description", "Descripción"), space: 2 },
|
|
37
|
-
{
|
|
38
|
-
type: "select",
|
|
39
|
-
name: "discountType",
|
|
40
|
-
dataType: EDataType.TEXT,
|
|
41
|
-
label: tr("Tipo de desconto", "Discount type", "Tipo de descuento"),
|
|
42
|
-
isRequired: true,
|
|
43
|
-
options: (Object.keys(DISCOUNT_TYPE_LABELS) as TStoreCouponDiscountType[]).map((value) => ({
|
|
44
|
-
label: DISCOUNT_TYPE_LABELS[value],
|
|
45
|
-
value,
|
|
46
|
-
isSelected: value === "percentage",
|
|
47
|
-
})),
|
|
48
|
-
space: 2,
|
|
49
|
-
},
|
|
50
|
-
{ type: "input", name: "discountValue", dataType: EDataType.NUMBER, label: tr("Desconto", "Discount", "Descuento"), isRequired: true, space: 2 },
|
|
51
|
-
{ type: "input", name: "minimumSubtotal", dataType: EDataType.CURRENCY, label: tr("Pedido mínimo", "Minimum order", "Pedido mínimo"), space: 2 },
|
|
52
|
-
{ type: "datepicker", name: "startDate", label: tr("Válido a partir de", "Valid from", "Válido desde") },
|
|
53
|
-
{ type: "datepicker", name: "endDate", label: tr("Válido até", "Valid until", "Válido hasta") },
|
|
54
|
-
{ type: "input", name: "usageLimit", dataType: EDataType.INTEGER, label: tr("Limite de usos", "Usage limit", "Límite de usos"), space: 2 },
|
|
55
|
-
{
|
|
56
|
-
type: "input",
|
|
57
|
-
name: "usageLimitPerCustomer",
|
|
58
|
-
dataType: EDataType.INTEGER,
|
|
59
|
-
label: tr("Limite por cliente", "Limit per customer", "Límite por cliente"),
|
|
60
|
-
space: 2,
|
|
61
|
-
},
|
|
62
|
-
{ type: "switch", name: "isActive", label: tr("Ativo", "Active", "Activo") },
|
|
63
|
-
];
|
|
64
|
-
|
|
65
|
-
// Um código por workspace; fica no contrato interno, de onde o gerador cria o índice único.
|
|
66
|
-
const UNIQUE_CODE = [{ identificator: "storeCouponCodePerWorkspace", fields: ["code"] }];
|
|
67
|
-
|
|
68
|
-
export const getStoreCouponForm = (options: IStoreCouponsModuleOptions = {}): IForm => ({
|
|
69
|
-
componentType: "form",
|
|
70
|
-
id: "storeCouponForm",
|
|
71
|
-
title: tr("Cupom", "Coupon", "Cupón"),
|
|
72
|
-
icon: "ticket-percent",
|
|
73
|
-
guards: "isAuthorized",
|
|
74
|
-
elements: couponElements,
|
|
75
|
-
contracts: [
|
|
76
|
-
{
|
|
77
|
-
id: ENTITY,
|
|
78
|
-
endpoint: STORE_COUPONS_ENDPOINT,
|
|
79
|
-
actions: ["create", "get", "getById", "update", "softDelete"],
|
|
80
|
-
request: { entity: ENTITY, fields: [], uniqueConstraints: UNIQUE_CODE },
|
|
81
|
-
},
|
|
82
|
-
],
|
|
83
|
-
publicContracts: [
|
|
84
|
-
{
|
|
85
|
-
id: "storeCouponsFromStore",
|
|
86
|
-
endpoint: STORE_COUPONS_ENDPOINT,
|
|
87
|
-
actions: ["get"],
|
|
88
|
-
access: options.publicAccess ?? "trustedCallers",
|
|
89
|
-
...(options.allowedOrigins ? { allowedOrigins: options.allowedOrigins } : {}),
|
|
90
|
-
request: { entity: ENTITY, fields: [] },
|
|
91
|
-
},
|
|
92
|
-
],
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
export const getStoreCouponList = (): IList => ({
|
|
96
|
-
componentType: "list",
|
|
97
|
-
id: "storeCouponList",
|
|
98
|
-
title: tr("Cupons", "Coupons", "Cupones"),
|
|
99
|
-
guards: ["isAuthorized"],
|
|
100
|
-
dataSource: { endpoint: STORE_COUPONS_ENDPOINT, paramType: "query", hasAuthentication: true },
|
|
101
|
-
listItems: [
|
|
102
|
-
{ property: "code", type: "title", label: tr("Código", "Code", "Código"), dataType: EDataType.TEXT },
|
|
103
|
-
{ property: "description", type: "subtitle", label: tr("Descrição", "Description", "Descripción"), dataType: EDataType.TEXT },
|
|
104
|
-
{ property: "discountValue", type: "description", label: tr("Desconto", "Discount", "Descuento"), dataType: EDataType.NUMBER },
|
|
105
|
-
{ property: "endDate", label: tr("Válido até", "Valid until", "Válido hasta"), dataType: EDataType.DATE },
|
|
106
|
-
],
|
|
107
|
-
contracts: [
|
|
108
|
-
{
|
|
109
|
-
id: ENTITY,
|
|
110
|
-
endpoint: STORE_COUPONS_ENDPOINT,
|
|
111
|
-
actions: ["get", "getById", "update", "softDelete"],
|
|
112
|
-
request: { entity: ENTITY, fields: [] },
|
|
113
|
-
},
|
|
114
|
-
],
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* Módulo pronto "Cupons", para o Backoffice do vendedor (funcionalidade
|
|
119
|
-
* "coupons"). A loja lê os cupons por IMarketplace.couponsEndpoint
|
|
120
|
-
* (STORE_COUPONS_ENDPOINT), valida o código e desconta no servidor.
|
|
121
|
-
*/
|
|
122
|
-
export const getStoreCouponsModule = (options: IStoreCouponsModuleOptions = {}): IModule => ({
|
|
123
|
-
id: "storeCouponsModule",
|
|
124
|
-
title: tr("Cupons", "Coupons", "Cupones"),
|
|
125
|
-
icon: "ticket-percent",
|
|
126
|
-
components: [getStoreCouponList(), getStoreCouponForm(options)],
|
|
127
|
-
});
|
|
@@ -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
|
-
];
|