godeep-states 1.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 +158 -0
- package/dist/module.d.mts +8 -0
- package/dist/module.json +9 -0
- package/dist/module.mjs +28 -0
- package/dist/runtime/composables/useHeader.d.ts +2 -0
- package/dist/runtime/composables/useHeader.js +33 -0
- package/dist/runtime/plugin.d.ts +2 -0
- package/dist/runtime/plugin.js +3 -0
- package/dist/runtime/server/api/[...slug].d.ts +2 -0
- package/dist/runtime/server/api/[...slug].js +66 -0
- package/dist/runtime/server/routes/robots.d.ts +2 -0
- package/dist/runtime/server/routes/robots.js +37 -0
- package/dist/runtime/server/routes/robots.txt.d.ts +2 -0
- package/dist/runtime/server/routes/robots.txt.js +37 -0
- package/dist/runtime/server/tsconfig.json +3 -0
- package/dist/runtime/stores/.vscode/settings.json +3 -0
- package/dist/runtime/stores/avaliacoes.d.ts +53 -0
- package/dist/runtime/stores/avaliacoes.js +63 -0
- package/dist/runtime/stores/banner.d.ts +6 -0
- package/dist/runtime/stores/banner.js +88 -0
- package/dist/runtime/stores/busca.d.ts +8 -0
- package/dist/runtime/stores/busca.js +51 -0
- package/dist/runtime/stores/cadastro.d.ts +6 -0
- package/dist/runtime/stores/cadastro.js +117 -0
- package/dist/runtime/stores/carrinho.d.ts +8 -0
- package/dist/runtime/stores/carrinho.js +219 -0
- package/dist/runtime/stores/categoria.d.ts +10 -0
- package/dist/runtime/stores/categoria.js +137 -0
- package/dist/runtime/stores/configuracoes.d.ts +16 -0
- package/dist/runtime/stores/configuracoes.js +85 -0
- package/dist/runtime/stores/dados-cadastrais.d.ts +7 -0
- package/dist/runtime/stores/dados-cadastrais.js +89 -0
- package/dist/runtime/stores/enderecos.d.ts +7 -0
- package/dist/runtime/stores/enderecos.js +217 -0
- package/dist/runtime/stores/favoritos.d.ts +7 -0
- package/dist/runtime/stores/favoritos.js +120 -0
- package/dist/runtime/stores/filtros.d.ts +9 -0
- package/dist/runtime/stores/filtros.js +63 -0
- package/dist/runtime/stores/home.d.ts +5 -0
- package/dist/runtime/stores/home.js +59 -0
- package/dist/runtime/stores/login.d.ts +13 -0
- package/dist/runtime/stores/login.js +195 -0
- package/dist/runtime/stores/menus.d.ts +5 -0
- package/dist/runtime/stores/menus.js +35 -0
- package/dist/runtime/stores/newsletter.d.ts +6 -0
- package/dist/runtime/stores/newsletter.js +80 -0
- package/dist/runtime/stores/pagamentos.d.ts +5 -0
- package/dist/runtime/stores/pagamentos.js +35 -0
- package/dist/runtime/stores/paginas.d.ts +5 -0
- package/dist/runtime/stores/paginas.js +35 -0
- package/dist/runtime/stores/pedidos.d.ts +7 -0
- package/dist/runtime/stores/pedidos.js +59 -0
- package/dist/runtime/stores/produto.d.ts +9 -0
- package/dist/runtime/stores/produto.js +141 -0
- package/dist/runtime/stores/redes-sociais.d.ts +5 -0
- package/dist/runtime/stores/redes-sociais.js +38 -0
- package/dist/runtime/stores/vitrine.d.ts +13 -0
- package/dist/runtime/stores/vitrine.js +192 -0
- package/dist/runtime/types.d.ts +7 -0
- package/dist/runtime/utils/alerta.d.ts +10 -0
- package/dist/runtime/utils/alerta.js +7 -0
- package/dist/runtime/utils/erros.d.ts +15 -0
- package/dist/runtime/utils/erros.js +20 -0
- package/dist/types.d.mts +3 -0
- package/package.json +73 -0
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { traduzirResultadosBusca } from "godeep-types/translate";
|
|
2
|
+
import { defineStore } from "pinia";
|
|
3
|
+
export const storeBusca = defineStore("busca", {
|
|
4
|
+
state: () => ({
|
|
5
|
+
resultados: [],
|
|
6
|
+
carregando: false,
|
|
7
|
+
mostrarResultados: false,
|
|
8
|
+
abrirResultados: false,
|
|
9
|
+
maisBuscados: false
|
|
10
|
+
}),
|
|
11
|
+
getters: {
|
|
12
|
+
recuperarBuscaResultados: (state) => state.resultados,
|
|
13
|
+
buscaCarregando: (state) => state.carregando,
|
|
14
|
+
buscaMostrarResultados: (state) => state.mostrarResultados
|
|
15
|
+
},
|
|
16
|
+
actions: {
|
|
17
|
+
toggleAbrirResultados() {
|
|
18
|
+
this.abrirResultados = !this.abrirResultados;
|
|
19
|
+
},
|
|
20
|
+
async resetarBusca() {
|
|
21
|
+
this.resultados = [];
|
|
22
|
+
this.carregando = false;
|
|
23
|
+
this.mostrarResultados = false;
|
|
24
|
+
this.abrirResultados = false;
|
|
25
|
+
},
|
|
26
|
+
async busca(termo) {
|
|
27
|
+
if (termo.trim().length === 0) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
try {
|
|
31
|
+
this.carregando = true;
|
|
32
|
+
const resultadosTraduzidos = traduzirResultadosBusca(await $fetch("/api/front-api/f1search/autocomplete", { method: "POST", body: JSON.stringify({ busca: termo }) }));
|
|
33
|
+
this.resultados = resultadosTraduzidos;
|
|
34
|
+
this.mostrarResultados = true;
|
|
35
|
+
this.carregando = false;
|
|
36
|
+
this.maisBuscados = false;
|
|
37
|
+
} catch {
|
|
38
|
+
this.resultados = [];
|
|
39
|
+
this.carregando = false;
|
|
40
|
+
this.mostrarResultados = false;
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
async irParaBusca(termo) {
|
|
44
|
+
const router = useRouter();
|
|
45
|
+
router.push({ path: "/busca", query: { q: termo } });
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
persist: {
|
|
49
|
+
storage: piniaPluginPersistedstate.sessionStorage()
|
|
50
|
+
}
|
|
51
|
+
});
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { StorefrontCamposCadastroResponse, CadastroCompleto } from 'godeep-types/types';
|
|
2
|
+
export declare const storeCadastro: import("pinia").StoreDefinition<"cadastro", {
|
|
3
|
+
carregando: boolean;
|
|
4
|
+
camposObrigatorios: StorefrontCamposCadastroResponse;
|
|
5
|
+
camposCadastro: CadastroCompleto;
|
|
6
|
+
}, {}, {}>;
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { defineStore } from "pinia";
|
|
2
|
+
import { useRouter } from "#imports";
|
|
3
|
+
import { alerta } from "../utils/alerta.js";
|
|
4
|
+
import { extrairMensagensErro } from "../utils/erros.js";
|
|
5
|
+
import {
|
|
6
|
+
reverterCadastroPF,
|
|
7
|
+
reverterCadastroPJ,
|
|
8
|
+
traduzirCamposCadastroResponse
|
|
9
|
+
} from "godeep-types/translate";
|
|
10
|
+
export const storeCadastro = defineStore("cadastro", {
|
|
11
|
+
state: () => ({
|
|
12
|
+
carregando: false,
|
|
13
|
+
camposObrigatorios: {},
|
|
14
|
+
camposCadastro: {}
|
|
15
|
+
}),
|
|
16
|
+
getters: {
|
|
17
|
+
recuperarCamposObrigatorios: (state) => state.camposObrigatorios,
|
|
18
|
+
recuperarCamposCadastro: (state) => state.camposCadastro
|
|
19
|
+
},
|
|
20
|
+
actions: {
|
|
21
|
+
resetarCadastro() {
|
|
22
|
+
this.carregando = false;
|
|
23
|
+
this.camposObrigatorios = {};
|
|
24
|
+
this.camposCadastro = {};
|
|
25
|
+
},
|
|
26
|
+
async cadastrarPF(dados) {
|
|
27
|
+
this.carregando = true;
|
|
28
|
+
const router = useRouter();
|
|
29
|
+
const fallback = "N\xE3o foi poss\xEDvel criar sua conta. Verifique os dados e tente novamente.";
|
|
30
|
+
try {
|
|
31
|
+
await $fetch("/api/front-api/clientes/PF", {
|
|
32
|
+
method: "POST",
|
|
33
|
+
body: reverterCadastroPF(dados)
|
|
34
|
+
});
|
|
35
|
+
alerta.adicionar({
|
|
36
|
+
titulo: "Cadastro realizado com sucesso!",
|
|
37
|
+
descricao: "Sua conta foi criada. Voc\xEA j\xE1 pode fazer login.",
|
|
38
|
+
cor: "success",
|
|
39
|
+
variantes: ["dashed", "soft"]
|
|
40
|
+
});
|
|
41
|
+
setTimeout(() => {
|
|
42
|
+
router.push("/");
|
|
43
|
+
}, 2e3);
|
|
44
|
+
return { sucesso: true, mensagensErro: {} };
|
|
45
|
+
} catch (error) {
|
|
46
|
+
const { mensagemGeral, mensagensErro } = extrairMensagensErro(
|
|
47
|
+
error,
|
|
48
|
+
fallback
|
|
49
|
+
);
|
|
50
|
+
alerta.adicionar({
|
|
51
|
+
titulo: "Erro no cadastro",
|
|
52
|
+
descricao: mensagemGeral,
|
|
53
|
+
cor: "error",
|
|
54
|
+
variantes: ["dashed", "soft"]
|
|
55
|
+
});
|
|
56
|
+
return { sucesso: false, erro: error, mensagensErro };
|
|
57
|
+
} finally {
|
|
58
|
+
this.carregando = false;
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
async cadastrarPJ(dados) {
|
|
62
|
+
this.carregando = true;
|
|
63
|
+
const router = useRouter();
|
|
64
|
+
const fallback = "N\xE3o foi poss\xEDvel cadastrar sua empresa. Verifique os dados e tente novamente.";
|
|
65
|
+
try {
|
|
66
|
+
await $fetch("/api/front-api/clientes/PJ", {
|
|
67
|
+
method: "POST",
|
|
68
|
+
body: reverterCadastroPJ(dados)
|
|
69
|
+
});
|
|
70
|
+
alerta.adicionar({
|
|
71
|
+
titulo: "Cadastro realizado com sucesso!",
|
|
72
|
+
descricao: "Sua empresa foi cadastrada. Voc\xEA j\xE1 pode fazer login.",
|
|
73
|
+
cor: "success",
|
|
74
|
+
variantes: ["dashed", "soft"]
|
|
75
|
+
});
|
|
76
|
+
setTimeout(() => {
|
|
77
|
+
router.push("/");
|
|
78
|
+
this.resetarCadastro();
|
|
79
|
+
}, 2e3);
|
|
80
|
+
return { sucesso: true, mensagensErro: {} };
|
|
81
|
+
} catch (error) {
|
|
82
|
+
const { mensagemGeral, mensagensErro } = extrairMensagensErro(
|
|
83
|
+
error,
|
|
84
|
+
fallback
|
|
85
|
+
);
|
|
86
|
+
alerta.adicionar({
|
|
87
|
+
titulo: "Erro no cadastro",
|
|
88
|
+
descricao: mensagemGeral,
|
|
89
|
+
cor: "error",
|
|
90
|
+
variantes: ["dashed", "soft"]
|
|
91
|
+
});
|
|
92
|
+
return { sucesso: false, erro: error, mensagensErro };
|
|
93
|
+
} finally {
|
|
94
|
+
this.carregando = false;
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
async buscarCamposCadastro() {
|
|
98
|
+
try {
|
|
99
|
+
console.log("Iniciando busca de campos de cadastro...");
|
|
100
|
+
const data = await $fetch(
|
|
101
|
+
"/api/front-api/clientes-validation",
|
|
102
|
+
{
|
|
103
|
+
method: "GET"
|
|
104
|
+
}
|
|
105
|
+
);
|
|
106
|
+
console.log("Dados recebidos:", data);
|
|
107
|
+
this.camposObrigatorios = traduzirCamposCadastroResponse(data);
|
|
108
|
+
} catch (error) {
|
|
109
|
+
console.error("Erro ao buscar campos de cadastro:", error);
|
|
110
|
+
throw error;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
persist: {
|
|
115
|
+
storage: piniaPluginPersistedstate.sessionStorage()
|
|
116
|
+
}
|
|
117
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { StorefrontCarrinho, StorefrontCarrinhoInfo } from 'godeep-types/types';
|
|
2
|
+
export declare const storeCarrinho: import("pinia").StoreDefinition<"carrinho", {
|
|
3
|
+
carrinho: StorefrontCarrinho;
|
|
4
|
+
isLoaded: boolean;
|
|
5
|
+
carrinhoAberto: boolean;
|
|
6
|
+
cartId: string;
|
|
7
|
+
info: StorefrontCarrinhoInfo;
|
|
8
|
+
}, {}, {}>;
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
import { traduzirCarrinho, traduzirCarrinhoProduto } from "godeep-types/translate";
|
|
2
|
+
import { defineStore } from "pinia";
|
|
3
|
+
import { navigateTo } from "#imports";
|
|
4
|
+
import { alerta } from "../utils/alerta.js";
|
|
5
|
+
const carrinhoDefault = {
|
|
6
|
+
id: "",
|
|
7
|
+
produtos: []
|
|
8
|
+
};
|
|
9
|
+
const infoDefault = {
|
|
10
|
+
valorTotalAVista: "",
|
|
11
|
+
valorTotalAPrazo: "",
|
|
12
|
+
valorFrete: 0,
|
|
13
|
+
valorProdutosAPrazo: "",
|
|
14
|
+
valorProdutosAVista: "",
|
|
15
|
+
valorNominalProdutos: "",
|
|
16
|
+
quantidadeItens: 0,
|
|
17
|
+
numeroMaximoParcelas: 0,
|
|
18
|
+
valorParcela: "",
|
|
19
|
+
valorDescontoProdutos: 0,
|
|
20
|
+
valorTotalEmbalagens: 0
|
|
21
|
+
};
|
|
22
|
+
export const storeCarrinho = defineStore("carrinho", {
|
|
23
|
+
state: () => ({
|
|
24
|
+
carrinho: carrinhoDefault,
|
|
25
|
+
isLoaded: false,
|
|
26
|
+
carrinhoAberto: false,
|
|
27
|
+
cartId: "",
|
|
28
|
+
info: infoDefault
|
|
29
|
+
}),
|
|
30
|
+
getters: {
|
|
31
|
+
totalItens: (state) => (state.carrinho?.produtos ?? []).reduce(
|
|
32
|
+
(total, item) => total + item.quantidade,
|
|
33
|
+
0
|
|
34
|
+
),
|
|
35
|
+
quantidadeProdutos: (state) => state.carrinho?.produtos?.length || 0,
|
|
36
|
+
carrinhoVazio: (state) => !state.carrinho?.produtos || state.carrinho.produtos.length === 0
|
|
37
|
+
},
|
|
38
|
+
actions: {
|
|
39
|
+
preencherCarrinho(produtos, cartId, info) {
|
|
40
|
+
const produtosTraduzidos = produtos?.length ? produtos.map((produto) => traduzirCarrinhoProduto(produto)) : [];
|
|
41
|
+
const carrinhoTraduzido = traduzirCarrinho(cartId, {
|
|
42
|
+
...info,
|
|
43
|
+
produtos
|
|
44
|
+
});
|
|
45
|
+
this.carrinho = {
|
|
46
|
+
id: cartId ?? "",
|
|
47
|
+
produtos: produtosTraduzidos,
|
|
48
|
+
info: carrinhoTraduzido.info
|
|
49
|
+
};
|
|
50
|
+
this.info = carrinhoTraduzido.info ?? infoDefault;
|
|
51
|
+
this.cartId = cartId ?? "";
|
|
52
|
+
this.isLoaded = true;
|
|
53
|
+
this.carrinhoAberto = true;
|
|
54
|
+
},
|
|
55
|
+
async alterarQuantidadeProdutoCarrinho(idProduto, quantidade) {
|
|
56
|
+
try {
|
|
57
|
+
const response = await $fetch(
|
|
58
|
+
`/api/front-api/basket/${idProduto}/v2`,
|
|
59
|
+
{
|
|
60
|
+
method: "PUT",
|
|
61
|
+
headers: {
|
|
62
|
+
"cart-id": this.cartId
|
|
63
|
+
},
|
|
64
|
+
body: {
|
|
65
|
+
qtd: quantidade
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
);
|
|
69
|
+
this.preencherCarrinho(
|
|
70
|
+
response.data?.produtos ?? [],
|
|
71
|
+
response?.basket?.cart_id ?? response?.cartId ?? "",
|
|
72
|
+
response?.data ?? infoDefault
|
|
73
|
+
);
|
|
74
|
+
} catch (error) {
|
|
75
|
+
console.error("Erro ao alterar quantidade do produto:", error);
|
|
76
|
+
this.carrinho = carrinhoDefault;
|
|
77
|
+
this.info = infoDefault;
|
|
78
|
+
this.isLoaded = true;
|
|
79
|
+
this.carrinhoAberto = false;
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
async adicionarProdutosCarrinho(produtos) {
|
|
83
|
+
const itensCarrinho = Array.isArray(this.carrinho?.produtos) ? this.carrinho.produtos : [];
|
|
84
|
+
let algumAlterado = false;
|
|
85
|
+
const itensParaAdicionar = [];
|
|
86
|
+
for (const itemNovo of produtos) {
|
|
87
|
+
const existente = itensCarrinho.find((item) => item.id === itemNovo.id);
|
|
88
|
+
if (existente && existente.id) {
|
|
89
|
+
const novaQuantidade = existente.quantidade + itemNovo.quantidade;
|
|
90
|
+
algumAlterado = true;
|
|
91
|
+
await this.alterarQuantidadeProdutoCarrinho(
|
|
92
|
+
existente.id,
|
|
93
|
+
novaQuantidade
|
|
94
|
+
);
|
|
95
|
+
} else {
|
|
96
|
+
itensParaAdicionar.push(itemNovo);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
if (itensParaAdicionar.length > 0) {
|
|
100
|
+
try {
|
|
101
|
+
const response = await $fetch(
|
|
102
|
+
"/api/front-api/basket/v2",
|
|
103
|
+
{
|
|
104
|
+
method: "POST",
|
|
105
|
+
body: {
|
|
106
|
+
basket: {
|
|
107
|
+
cart_id: this.cartId,
|
|
108
|
+
products: itensParaAdicionar.map((item) => ({
|
|
109
|
+
id: item.id,
|
|
110
|
+
quantidade: item.quantidade
|
|
111
|
+
}))
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
);
|
|
116
|
+
this.preencherCarrinho(
|
|
117
|
+
response.data?.produtos ?? [],
|
|
118
|
+
response?.cartId ?? response?.basket?.cart_id ?? "",
|
|
119
|
+
response?.data ?? infoDefault
|
|
120
|
+
);
|
|
121
|
+
} catch (error) {
|
|
122
|
+
console.error("Erro ao adicionar ao carrinho:", error);
|
|
123
|
+
this.carrinho = carrinhoDefault;
|
|
124
|
+
this.isLoaded = true;
|
|
125
|
+
this.carrinhoAberto = false;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
if (algumAlterado) return;
|
|
129
|
+
},
|
|
130
|
+
async removerItemCarrinho(idProduto) {
|
|
131
|
+
try {
|
|
132
|
+
const response = await $fetch(
|
|
133
|
+
`/api/front-api/basket/${idProduto}/v2`,
|
|
134
|
+
{
|
|
135
|
+
method: "DELETE",
|
|
136
|
+
headers: {
|
|
137
|
+
"cart-id": this.cartId
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
);
|
|
141
|
+
this.preencherCarrinho(
|
|
142
|
+
response.data?.produtos ?? [],
|
|
143
|
+
response?.cartId ?? response?.basket?.cart_id ?? "",
|
|
144
|
+
response?.data ?? infoDefault
|
|
145
|
+
);
|
|
146
|
+
} catch (error) {
|
|
147
|
+
console.error("Erro ao remover produto do carrinho:", error);
|
|
148
|
+
this.carrinho = carrinhoDefault;
|
|
149
|
+
this.info = infoDefault;
|
|
150
|
+
this.isLoaded = true;
|
|
151
|
+
this.carrinhoAberto = false;
|
|
152
|
+
}
|
|
153
|
+
},
|
|
154
|
+
async limparCarrinho() {
|
|
155
|
+
try {
|
|
156
|
+
const response = await $fetch(
|
|
157
|
+
"/api/front-api/delete-carrinho",
|
|
158
|
+
{
|
|
159
|
+
method: "POST",
|
|
160
|
+
body: {
|
|
161
|
+
cartId: this.cartId
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
);
|
|
165
|
+
this.preencherCarrinho(
|
|
166
|
+
response.data?.produtos ?? [],
|
|
167
|
+
response?.cartId ?? response?.basket?.cart_id ?? "",
|
|
168
|
+
response?.data ?? infoDefault
|
|
169
|
+
);
|
|
170
|
+
} catch (error) {
|
|
171
|
+
console.error("Erro ao limpar carrinho:", error);
|
|
172
|
+
this.carrinho = carrinhoDefault;
|
|
173
|
+
this.info = infoDefault;
|
|
174
|
+
this.isLoaded = true;
|
|
175
|
+
this.carrinhoAberto = false;
|
|
176
|
+
}
|
|
177
|
+
},
|
|
178
|
+
async finalizar() {
|
|
179
|
+
try {
|
|
180
|
+
const response = await $fetch("/api/front-api/checkout", {
|
|
181
|
+
method: "GET",
|
|
182
|
+
headers: {
|
|
183
|
+
"cart.id": this.cartId,
|
|
184
|
+
"Cookie": `cart.id=${this.cartId}`,
|
|
185
|
+
"sec-fetch-site": "same-origin",
|
|
186
|
+
"origin": "checkout-newfront.f1b2c.com.br",
|
|
187
|
+
"referer": "checkout-newfront.f1b2c.com.br",
|
|
188
|
+
"user-agent": "Mozilla/5.0",
|
|
189
|
+
"accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
|
|
190
|
+
"accept-language": "pt-BR,pt;q=0.9,en-US;q=0.8,en;q=0.7",
|
|
191
|
+
"accept-encoding": "gzip, deflate, br",
|
|
192
|
+
"connection": "keep-alive",
|
|
193
|
+
"cache-control": "max-age=0",
|
|
194
|
+
"upgrade-insecure-requests": "1"
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
if (response?.urlCheckout) {
|
|
198
|
+
await navigateTo(
|
|
199
|
+
`https://${response.urlCheckout}/meu-carrinho?cart-id=${this.cartId}`,
|
|
200
|
+
{ external: true }
|
|
201
|
+
);
|
|
202
|
+
} else {
|
|
203
|
+
await navigateTo("/", { external: false });
|
|
204
|
+
alerta.adicionar({
|
|
205
|
+
titulo: "Erro ao finalizar compra",
|
|
206
|
+
descricao: "Por favor, tente novamente mais tarde",
|
|
207
|
+
cor: "error",
|
|
208
|
+
variantes: ["dashed", "soft"]
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
} catch (error) {
|
|
212
|
+
console.error("Erro ao finalizar compra:", error);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
},
|
|
216
|
+
persist: {
|
|
217
|
+
storage: piniaPluginPersistedstate.sessionStorage()
|
|
218
|
+
}
|
|
219
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { StorefrontCategoriaListagem } from 'godeep-types/types';
|
|
2
|
+
type FiltrosSelecionados = Record<string, string[]>;
|
|
3
|
+
export declare const storeCategoria: import("pinia").StoreDefinition<"categoria", {
|
|
4
|
+
categoria: StorefrontCategoriaListagem;
|
|
5
|
+
carregando: boolean;
|
|
6
|
+
paginaAtual: number;
|
|
7
|
+
ordenacao: string;
|
|
8
|
+
filtrosAtivos: FiltrosSelecionados;
|
|
9
|
+
}, {}, {}>;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { traduzirCategoriaListagem } from "godeep-types/translate";
|
|
2
|
+
import { defineStore } from "pinia";
|
|
3
|
+
export const storeCategoria = defineStore("categoria", {
|
|
4
|
+
state: () => ({
|
|
5
|
+
categoria: {},
|
|
6
|
+
carregando: false,
|
|
7
|
+
paginaAtual: 1,
|
|
8
|
+
ordenacao: "",
|
|
9
|
+
filtrosAtivos: {}
|
|
10
|
+
}),
|
|
11
|
+
getters: {
|
|
12
|
+
recuperarCategoria: (state) => state.categoria,
|
|
13
|
+
categoriaCarregando: (state) => state.carregando,
|
|
14
|
+
recuperarProdutos: (state) => state.categoria?.produtos ?? [],
|
|
15
|
+
totalPaginas: (state) => state.categoria?.paginador?.ultimaPagina ?? 1,
|
|
16
|
+
recuperarPaginaAtual: (state) => state.categoria?.paginador?.paginaAtual ?? state.paginaAtual,
|
|
17
|
+
recuperarOrdenacao: (state) => state.ordenacao,
|
|
18
|
+
recuperarFiltros: (state) => state.filtrosAtivos
|
|
19
|
+
},
|
|
20
|
+
actions: {
|
|
21
|
+
resetarCategoria() {
|
|
22
|
+
this.categoria = {};
|
|
23
|
+
this.carregando = false;
|
|
24
|
+
this.paginaAtual = 1;
|
|
25
|
+
this.ordenacao = "";
|
|
26
|
+
this.filtrosAtivos = {};
|
|
27
|
+
},
|
|
28
|
+
definirPagina(pagina) {
|
|
29
|
+
this.paginaAtual = pagina > 0 ? pagina : 1;
|
|
30
|
+
},
|
|
31
|
+
definirOrdenacao(ordenacao) {
|
|
32
|
+
this.ordenacao = ordenacao;
|
|
33
|
+
this.paginaAtual = 1;
|
|
34
|
+
},
|
|
35
|
+
alternarFiltro(secaoId, valor) {
|
|
36
|
+
const valoresAtuais = this.filtrosAtivos[secaoId] ?? [];
|
|
37
|
+
const existe = valoresAtuais.includes(valor);
|
|
38
|
+
this.filtrosAtivos = {
|
|
39
|
+
...this.filtrosAtivos,
|
|
40
|
+
[secaoId]: existe ? valoresAtuais.filter((item) => item !== valor) : [...valoresAtuais, valor]
|
|
41
|
+
};
|
|
42
|
+
if (this.filtrosAtivos[secaoId]?.length === 0) {
|
|
43
|
+
const { [secaoId]: _, ...resto } = this.filtrosAtivos;
|
|
44
|
+
this.filtrosAtivos = resto;
|
|
45
|
+
}
|
|
46
|
+
this.paginaAtual = 1;
|
|
47
|
+
},
|
|
48
|
+
aplicarFiltroPreco(min, max) {
|
|
49
|
+
this.filtrosAtivos = {
|
|
50
|
+
...this.filtrosAtivos,
|
|
51
|
+
preco: [`${min}:${max}`]
|
|
52
|
+
};
|
|
53
|
+
this.paginaAtual = 1;
|
|
54
|
+
},
|
|
55
|
+
limparFiltros() {
|
|
56
|
+
this.filtrosAtivos = {};
|
|
57
|
+
this.paginaAtual = 1;
|
|
58
|
+
},
|
|
59
|
+
carregarFiltrosDaUrl(query) {
|
|
60
|
+
const filtros = {};
|
|
61
|
+
const processar = (chave, destino) => {
|
|
62
|
+
const valor = query[chave];
|
|
63
|
+
if (!valor) return;
|
|
64
|
+
const lista = Array.isArray(valor) ? valor : [valor];
|
|
65
|
+
const strings = lista.filter(
|
|
66
|
+
(item) => typeof item === "string"
|
|
67
|
+
);
|
|
68
|
+
if (strings.length > 0) {
|
|
69
|
+
filtros[destino] = strings;
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
processar("precos", "preco");
|
|
73
|
+
processar("marcas", "marca");
|
|
74
|
+
processar("filtro", "filtro");
|
|
75
|
+
processar("grade", "grade");
|
|
76
|
+
const pagina = query.page;
|
|
77
|
+
if (pagina && typeof pagina === "string") {
|
|
78
|
+
const numero = Number.parseInt(pagina);
|
|
79
|
+
if (!Number.isNaN(numero) && numero > 0) {
|
|
80
|
+
this.paginaAtual = numero;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
const order = query.order;
|
|
84
|
+
if (order && typeof order === "string") {
|
|
85
|
+
this.ordenacao = order;
|
|
86
|
+
}
|
|
87
|
+
this.filtrosAtivos = filtros;
|
|
88
|
+
},
|
|
89
|
+
construirParametros(slug) {
|
|
90
|
+
const parametros = {
|
|
91
|
+
slug,
|
|
92
|
+
page: this.paginaAtual
|
|
93
|
+
};
|
|
94
|
+
if (this.ordenacao) {
|
|
95
|
+
parametros.order = this.ordenacao;
|
|
96
|
+
}
|
|
97
|
+
Object.entries(this.filtrosAtivos).forEach(([secao, valores]) => {
|
|
98
|
+
if (!valores || valores.length === 0) return;
|
|
99
|
+
if (secao === "preco") {
|
|
100
|
+
parametros.precos = valores;
|
|
101
|
+
} else if (secao === "marca") {
|
|
102
|
+
parametros.marcas = valores;
|
|
103
|
+
} else if (secao === "filtro") {
|
|
104
|
+
parametros.filtro = valores;
|
|
105
|
+
} else if (secao === "grade") {
|
|
106
|
+
parametros.grade = valores[0] ?? "";
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
return parametros;
|
|
110
|
+
},
|
|
111
|
+
normalizarSlug(path) {
|
|
112
|
+
return path.startsWith("/") ? path.slice(1) : path;
|
|
113
|
+
},
|
|
114
|
+
async buscarCategoria(path) {
|
|
115
|
+
try {
|
|
116
|
+
this.carregando = true;
|
|
117
|
+
const slug = this.normalizarSlug(path);
|
|
118
|
+
const parametros = this.construirParametros(slug);
|
|
119
|
+
const resposta = await $fetch(
|
|
120
|
+
"/api/front-api/categorias",
|
|
121
|
+
{
|
|
122
|
+
method: "GET",
|
|
123
|
+
params: parametros
|
|
124
|
+
}
|
|
125
|
+
);
|
|
126
|
+
this.categoria = resposta ? traduzirCategoriaListagem(resposta) : {};
|
|
127
|
+
} catch {
|
|
128
|
+
this.categoria = {};
|
|
129
|
+
} finally {
|
|
130
|
+
this.carregando = false;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
persist: {
|
|
135
|
+
storage: piniaPluginPersistedstate.sessionStorage()
|
|
136
|
+
}
|
|
137
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { StorefrontConfiguracoes } from 'godeep-types/types';
|
|
2
|
+
export declare const storeConfiguracoes: import("pinia").StoreDefinition<"configuracoes", {
|
|
3
|
+
configuracoes: StorefrontConfiguracoes;
|
|
4
|
+
carregando: boolean;
|
|
5
|
+
logotipo: string;
|
|
6
|
+
logotipoRodape: string;
|
|
7
|
+
favicon: string;
|
|
8
|
+
nomeLoja: string;
|
|
9
|
+
fraseRodape: string;
|
|
10
|
+
mensagemTopo: string;
|
|
11
|
+
emailSAC: string;
|
|
12
|
+
telefoneSAC: string;
|
|
13
|
+
horarioAtendimento: string;
|
|
14
|
+
enderecoLoja: string;
|
|
15
|
+
enderecoGoogleMaps: string;
|
|
16
|
+
}, {}, {}>;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { traduzirConfiguracoes } from "godeep-types/translate";
|
|
2
|
+
import { defineStore } from "pinia";
|
|
3
|
+
export const storeConfiguracoes = defineStore("configuracoes", {
|
|
4
|
+
state: () => ({
|
|
5
|
+
configuracoes: {},
|
|
6
|
+
carregando: false,
|
|
7
|
+
logotipo: "",
|
|
8
|
+
logotipoRodape: "",
|
|
9
|
+
favicon: "",
|
|
10
|
+
nomeLoja: "",
|
|
11
|
+
fraseRodape: "",
|
|
12
|
+
mensagemTopo: "",
|
|
13
|
+
emailSAC: "",
|
|
14
|
+
telefoneSAC: "",
|
|
15
|
+
horarioAtendimento: "",
|
|
16
|
+
enderecoLoja: "",
|
|
17
|
+
enderecoGoogleMaps: ""
|
|
18
|
+
}),
|
|
19
|
+
getters: {
|
|
20
|
+
recuperarConfiguracoes: (state) => state.configuracoes,
|
|
21
|
+
configuracoesCarregando: (state) => state.carregando,
|
|
22
|
+
dadosLoja: (state) => state.configuracoes?.dadosLoja,
|
|
23
|
+
layout: (state) => state.configuracoes?.layout,
|
|
24
|
+
modulos: (state) => state.configuracoes?.modulos,
|
|
25
|
+
parametros: (state) => state.configuracoes?.parametros,
|
|
26
|
+
logotipo: (state) => {
|
|
27
|
+
const dado = state.configuracoes?.dadosLoja;
|
|
28
|
+
if (dado?.logotipo?.real) return dado.logotipo.real;
|
|
29
|
+
if (dado?.logotipo?.urlResizer && dado?.logotipo?.urlParametro) {
|
|
30
|
+
return `${dado.logotipo.urlResizer}${dado.logotipo.urlParametro}`;
|
|
31
|
+
}
|
|
32
|
+
return "/logo.svg";
|
|
33
|
+
},
|
|
34
|
+
logotipoRodape: (state) => {
|
|
35
|
+
const dado = state.configuracoes?.dadosLoja;
|
|
36
|
+
if (dado?.logotipoRodape?.real) return dado.logotipoRodape.real;
|
|
37
|
+
if (dado?.logotipoRodape?.urlResizer && dado?.logotipoRodape?.urlParametro) {
|
|
38
|
+
return `${dado.logotipoRodape.urlResizer}${dado.logotipoRodape.urlParametro}`;
|
|
39
|
+
}
|
|
40
|
+
return state.configuracoes?.dadosLoja?.logotipo?.real ?? "/logo.svg";
|
|
41
|
+
},
|
|
42
|
+
favicon: (state) => state.configuracoes?.dadosLoja?.favicon ?? "/favicon.ico",
|
|
43
|
+
nomeLoja: (state) => state.configuracoes?.dadosLoja?.nomeFantasia ?? state.configuracoes?.dadosLoja?.nomeLoja ?? state.configuracoes?.dadosLoja?.razaoSocial ?? "Loja",
|
|
44
|
+
fraseRodape: (state) => state.configuracoes?.dadosLoja?.fraseRodape ?? "",
|
|
45
|
+
mensagemTopo: (state) => state.configuracoes?.layout?.topo?.mensagem ?? "",
|
|
46
|
+
emailSAC: (state) => state.configuracoes?.dadosLoja?.emailSAC ?? "",
|
|
47
|
+
telefoneSAC: (state) => state.configuracoes?.dadosLoja?.telefoneSAC ?? "",
|
|
48
|
+
horarioAtendimento: (state) => state.configuracoes?.dadosLoja?.horarioAtendimento ?? "",
|
|
49
|
+
enderecoLoja: (state) => state.configuracoes?.dadosLoja?.enderecoLoja ?? "",
|
|
50
|
+
enderecoGoogleMaps: (state) => state.configuracoes?.dadosLoja?.enderecoGoogleMaps ?? "",
|
|
51
|
+
numeroWhatsapp: (state) => state.configuracoes?.dadosLoja?.numeroWhatsapp ?? "",
|
|
52
|
+
exibirWhatsapp: (state) => state.configuracoes?.dadosLoja?.exibirWhatsapp === true,
|
|
53
|
+
copyright: (_getters) => {
|
|
54
|
+
const frase = _getters.fraseRodape;
|
|
55
|
+
if (frase) return frase;
|
|
56
|
+
const ano = (/* @__PURE__ */ new Date()).getFullYear();
|
|
57
|
+
const nome = _getters.nomeLoja;
|
|
58
|
+
return `\xA9 ${ano} ${nome}, todos os direitos reservados.`;
|
|
59
|
+
},
|
|
60
|
+
moduloAtivo: (state) => (nomeModulo) => {
|
|
61
|
+
const modulo = state.configuracoes?.modulos?.[nomeModulo];
|
|
62
|
+
return modulo?.ativo === true;
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
actions: {
|
|
66
|
+
resetarConfiguracoes() {
|
|
67
|
+
this.configuracoes = {};
|
|
68
|
+
this.carregando = false;
|
|
69
|
+
},
|
|
70
|
+
async buscarConfiguracoes() {
|
|
71
|
+
try {
|
|
72
|
+
this.carregando = true;
|
|
73
|
+
const resposta = await $fetch("/api/front-api/configuracoes");
|
|
74
|
+
this.configuracoes = resposta ? traduzirConfiguracoes(resposta) : {};
|
|
75
|
+
this.carregando = false;
|
|
76
|
+
} catch {
|
|
77
|
+
this.carregando = false;
|
|
78
|
+
this.configuracoes = {};
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
persist: {
|
|
83
|
+
storage: piniaPluginPersistedstate.sessionStorage()
|
|
84
|
+
}
|
|
85
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { StorefrontDadosCadastrais, StorefrontDadosCadastraisPF, StorefrontDadosCadastraisPJ, TipoCadastro } from 'godeep-types/types';
|
|
2
|
+
export declare const storeDadosCadastrais: import("pinia").StoreDefinition<"dados-cadastrais", {
|
|
3
|
+
dados: StorefrontDadosCadastrais | StorefrontDadosCadastraisPF | StorefrontDadosCadastraisPJ | null;
|
|
4
|
+
tipoPessoa: TipoCadastro;
|
|
5
|
+
carregando: boolean;
|
|
6
|
+
salvando: boolean;
|
|
7
|
+
}, {}, {}>;
|