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,195 @@
|
|
|
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
|
+
traduzirEsqueceuSenhaToken,
|
|
7
|
+
traduzirLoginResponse,
|
|
8
|
+
traduzirRedefinirSenha
|
|
9
|
+
} from "godeep-types/translate";
|
|
10
|
+
const usuarioDefault = {
|
|
11
|
+
id: 0,
|
|
12
|
+
nome: "",
|
|
13
|
+
email: "",
|
|
14
|
+
tipoCliente: "",
|
|
15
|
+
token: "",
|
|
16
|
+
cliente: {
|
|
17
|
+
sexo: "",
|
|
18
|
+
tipo: "",
|
|
19
|
+
validacaoCadastro: ""
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
export const storeLogin = defineStore("login", {
|
|
23
|
+
state: () => ({
|
|
24
|
+
esqueceuSenhaToken: {},
|
|
25
|
+
redefinirSenhaResposta: {},
|
|
26
|
+
usuario: usuarioDefault,
|
|
27
|
+
carregando: false,
|
|
28
|
+
dadosLembrarMe: null,
|
|
29
|
+
emailEnviado: false,
|
|
30
|
+
mensagemEsqueceuSenha: ""
|
|
31
|
+
}),
|
|
32
|
+
getters: {
|
|
33
|
+
recuperarUsuario: (state) => state.usuario,
|
|
34
|
+
usuarioCarregando: (state) => state.carregando,
|
|
35
|
+
recuperarEsqueceuSenhaToken: (state) => state.esqueceuSenhaToken,
|
|
36
|
+
recuperarRedefinirSenhaResposta: (state) => state.redefinirSenhaResposta
|
|
37
|
+
},
|
|
38
|
+
actions: {
|
|
39
|
+
resetarLogin() {
|
|
40
|
+
this.usuario = usuarioDefault;
|
|
41
|
+
this.esqueceuSenhaToken = {};
|
|
42
|
+
this.redefinirSenhaResposta = {};
|
|
43
|
+
this.carregando = false;
|
|
44
|
+
this.dadosLembrarMe = null;
|
|
45
|
+
this.emailEnviado = false;
|
|
46
|
+
this.mensagemEsqueceuSenha = "";
|
|
47
|
+
},
|
|
48
|
+
resetarEsqueceuSenha() {
|
|
49
|
+
this.esqueceuSenhaToken = {};
|
|
50
|
+
this.emailEnviado = false;
|
|
51
|
+
this.mensagemEsqueceuSenha = "";
|
|
52
|
+
},
|
|
53
|
+
async esqueceuSenha(email) {
|
|
54
|
+
try {
|
|
55
|
+
this.carregando = true;
|
|
56
|
+
this.mensagemEsqueceuSenha = "";
|
|
57
|
+
this.emailEnviado = false;
|
|
58
|
+
const router = useRouter();
|
|
59
|
+
const response = await $fetch(
|
|
60
|
+
"/api/front-api/esqueceu-senha-token",
|
|
61
|
+
{
|
|
62
|
+
method: "POST",
|
|
63
|
+
body: { email }
|
|
64
|
+
}
|
|
65
|
+
);
|
|
66
|
+
this.esqueceuSenhaToken = traduzirEsqueceuSenhaToken(response) ?? {};
|
|
67
|
+
const mensagemSucesso = "Email de recupera\xE7\xE3o enviado com sucesso. Verifique sua caixa de entrada.";
|
|
68
|
+
this.emailEnviado = true;
|
|
69
|
+
this.mensagemEsqueceuSenha = mensagemSucesso;
|
|
70
|
+
alerta.adicionar({
|
|
71
|
+
titulo: "Sucesso",
|
|
72
|
+
descricao: mensagemSucesso,
|
|
73
|
+
cor: "success",
|
|
74
|
+
variantes: ["outline"]
|
|
75
|
+
});
|
|
76
|
+
setTimeout(() => {
|
|
77
|
+
router.push("/login");
|
|
78
|
+
this.resetarEsqueceuSenha();
|
|
79
|
+
}, 8e3);
|
|
80
|
+
return { sucesso: true, mensagem: mensagemSucesso };
|
|
81
|
+
} catch (error) {
|
|
82
|
+
this.esqueceuSenhaToken = {};
|
|
83
|
+
this.emailEnviado = false;
|
|
84
|
+
const { mensagemGeral } = extrairMensagensErro(
|
|
85
|
+
error,
|
|
86
|
+
"Erro ao solicitar recupera\xE7\xE3o de senha"
|
|
87
|
+
);
|
|
88
|
+
this.mensagemEsqueceuSenha = mensagemGeral;
|
|
89
|
+
alerta.adicionar({
|
|
90
|
+
titulo: "Erro",
|
|
91
|
+
descricao: mensagemGeral,
|
|
92
|
+
cor: "error",
|
|
93
|
+
variantes: ["outline"]
|
|
94
|
+
});
|
|
95
|
+
return { sucesso: false, mensagem: mensagemGeral };
|
|
96
|
+
} finally {
|
|
97
|
+
this.carregando = false;
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
async redefinirSenha(email, token, senha, confirmarSenha) {
|
|
101
|
+
try {
|
|
102
|
+
this.carregando = true;
|
|
103
|
+
if (senha !== confirmarSenha) {
|
|
104
|
+
this.esqueceuSenhaToken = {};
|
|
105
|
+
this.carregando = false;
|
|
106
|
+
alerta.adicionar({
|
|
107
|
+
titulo: "Erro",
|
|
108
|
+
descricao: "As senhas n\xE3o coincidem",
|
|
109
|
+
cor: "error",
|
|
110
|
+
variantes: ["outline"]
|
|
111
|
+
});
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
const response = await $fetch(
|
|
115
|
+
"/api/front-api/redefinir-senha",
|
|
116
|
+
{
|
|
117
|
+
method: "POST",
|
|
118
|
+
body: { email, token, senha, confirmarSenha }
|
|
119
|
+
}
|
|
120
|
+
);
|
|
121
|
+
const redefinirSenhaTraduzido = traduzirRedefinirSenha(response);
|
|
122
|
+
this.redefinirSenhaResposta = redefinirSenhaTraduzido ?? {};
|
|
123
|
+
if (redefinirSenhaTraduzido?.mensagem) {
|
|
124
|
+
alerta.adicionar({
|
|
125
|
+
titulo: "Sucesso",
|
|
126
|
+
descricao: redefinirSenhaTraduzido.mensagem,
|
|
127
|
+
cor: "success",
|
|
128
|
+
variantes: ["outline"]
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
} catch (error) {
|
|
132
|
+
this.redefinirSenhaResposta = {};
|
|
133
|
+
alerta.adicionar({
|
|
134
|
+
titulo: "Erro",
|
|
135
|
+
descricao: extrairMensagensErro(error, "Erro ao redefinir senha").mensagemGeral,
|
|
136
|
+
cor: "error",
|
|
137
|
+
variantes: ["outline"]
|
|
138
|
+
});
|
|
139
|
+
} finally {
|
|
140
|
+
this.carregando = false;
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
async login(email, senha, lembrarMe = false) {
|
|
144
|
+
try {
|
|
145
|
+
this.carregando = true;
|
|
146
|
+
const router = useRouter();
|
|
147
|
+
const response = await $fetch(
|
|
148
|
+
"/api/front-api/login",
|
|
149
|
+
{
|
|
150
|
+
method: "POST",
|
|
151
|
+
body: { email, senha }
|
|
152
|
+
}
|
|
153
|
+
);
|
|
154
|
+
const usuarioTraduzido = traduzirLoginResponse(response);
|
|
155
|
+
if (usuarioTraduzido?.token) {
|
|
156
|
+
console.log(usuarioTraduzido, "usuarioTraduzido");
|
|
157
|
+
this.usuario = usuarioTraduzido;
|
|
158
|
+
if (lembrarMe) {
|
|
159
|
+
this.dadosLembrarMe = { email, senha };
|
|
160
|
+
} else {
|
|
161
|
+
this.dadosLembrarMe = null;
|
|
162
|
+
}
|
|
163
|
+
alerta.adicionar({
|
|
164
|
+
titulo: "Sucesso",
|
|
165
|
+
descricao: "Login realizado com sucesso",
|
|
166
|
+
cor: "success",
|
|
167
|
+
variantes: ["outline"]
|
|
168
|
+
});
|
|
169
|
+
setTimeout(() => {
|
|
170
|
+
router.push("/");
|
|
171
|
+
}, 2e3);
|
|
172
|
+
} else {
|
|
173
|
+
alerta.adicionar({
|
|
174
|
+
titulo: "Erro",
|
|
175
|
+
descricao: "Login n\xE3o realizado",
|
|
176
|
+
cor: "error",
|
|
177
|
+
variantes: ["outline"]
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
} catch (error) {
|
|
181
|
+
alerta.adicionar({
|
|
182
|
+
titulo: "Erro",
|
|
183
|
+
descricao: extrairMensagensErro(error, "Erro ao realizar login").mensagemGeral,
|
|
184
|
+
cor: "error",
|
|
185
|
+
variantes: ["outline"]
|
|
186
|
+
});
|
|
187
|
+
} finally {
|
|
188
|
+
this.carregando = false;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
},
|
|
192
|
+
persist: {
|
|
193
|
+
storage: piniaPluginPersistedstate.sessionStorage()
|
|
194
|
+
}
|
|
195
|
+
});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { traduzirMenu } from "godeep-types/translate";
|
|
2
|
+
import { defineStore } from "pinia";
|
|
3
|
+
export const storeMenus = defineStore("menus", {
|
|
4
|
+
state: () => ({
|
|
5
|
+
menus: {},
|
|
6
|
+
carregando: false
|
|
7
|
+
}),
|
|
8
|
+
getters: {
|
|
9
|
+
recuperarMenus: (state) => state.menus,
|
|
10
|
+
menuCarregando: (state) => state.carregando
|
|
11
|
+
},
|
|
12
|
+
actions: {
|
|
13
|
+
async resetarMenus() {
|
|
14
|
+
this.menus = {};
|
|
15
|
+
this.carregando = false;
|
|
16
|
+
},
|
|
17
|
+
async buscarMenus() {
|
|
18
|
+
try {
|
|
19
|
+
this.carregando = true;
|
|
20
|
+
const response = await $fetch(
|
|
21
|
+
"/api/front-api/menus"
|
|
22
|
+
);
|
|
23
|
+
const menuTraduzido = traduzirMenu(response);
|
|
24
|
+
this.menus = menuTraduzido ?? {};
|
|
25
|
+
this.carregando = false;
|
|
26
|
+
} catch {
|
|
27
|
+
this.menus = {};
|
|
28
|
+
this.carregando = false;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
persist: {
|
|
33
|
+
storage: piniaPluginPersistedstate.sessionStorage()
|
|
34
|
+
}
|
|
35
|
+
});
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { traduzirNewsletterResposta } from "godeep-types/translate";
|
|
2
|
+
import { defineStore } from "pinia";
|
|
3
|
+
import { alerta } from "../utils/alerta.js";
|
|
4
|
+
function validarEmail(email) {
|
|
5
|
+
const regex = /^[\w.%+-]+@[\w.-]+\.[a-z]{2,}$/i;
|
|
6
|
+
return regex.test(email);
|
|
7
|
+
}
|
|
8
|
+
export const storeNewsletter = defineStore("newsletter", {
|
|
9
|
+
state: () => ({
|
|
10
|
+
email: "",
|
|
11
|
+
enviando: false,
|
|
12
|
+
resposta: {}
|
|
13
|
+
}),
|
|
14
|
+
getters: {
|
|
15
|
+
recuperarEmail: (state) => state.email,
|
|
16
|
+
newsletterEnviando: (state) => state.enviando,
|
|
17
|
+
recuperarRespostaNewsletter: (state) => state.resposta
|
|
18
|
+
},
|
|
19
|
+
actions: {
|
|
20
|
+
resetarNewsletter() {
|
|
21
|
+
this.email = "";
|
|
22
|
+
this.enviando = false;
|
|
23
|
+
this.resposta = {};
|
|
24
|
+
},
|
|
25
|
+
async assinar(emailValor) {
|
|
26
|
+
const email = (emailValor ?? this.email).trim();
|
|
27
|
+
if (!email) {
|
|
28
|
+
alerta.adicionar({
|
|
29
|
+
titulo: "Email obrigat\xF3rio",
|
|
30
|
+
descricao: "Por favor, digite seu email.",
|
|
31
|
+
cor: "warning",
|
|
32
|
+
variantes: ["dashed", "soft"]
|
|
33
|
+
});
|
|
34
|
+
return { sucesso: false };
|
|
35
|
+
}
|
|
36
|
+
if (!validarEmail(email)) {
|
|
37
|
+
alerta.adicionar({
|
|
38
|
+
titulo: "Email inv\xE1lido",
|
|
39
|
+
descricao: "Por favor, digite um email v\xE1lido.",
|
|
40
|
+
cor: "warning",
|
|
41
|
+
variantes: ["dashed", "soft"]
|
|
42
|
+
});
|
|
43
|
+
return { sucesso: false };
|
|
44
|
+
}
|
|
45
|
+
this.enviando = true;
|
|
46
|
+
try {
|
|
47
|
+
const resposta = await $fetch(
|
|
48
|
+
"/api/front-api/newsletter",
|
|
49
|
+
{
|
|
50
|
+
method: "POST",
|
|
51
|
+
body: { email }
|
|
52
|
+
}
|
|
53
|
+
);
|
|
54
|
+
this.resposta = traduzirNewsletterResposta(resposta);
|
|
55
|
+
const mensagemSucesso = this.resposta.mensagens?.[0] ?? "Newsletter cadastrada!";
|
|
56
|
+
alerta.adicionar({
|
|
57
|
+
titulo: "Newsletter cadastrada!",
|
|
58
|
+
descricao: mensagemSucesso,
|
|
59
|
+
cor: "success",
|
|
60
|
+
variantes: ["dashed", "soft"]
|
|
61
|
+
});
|
|
62
|
+
this.email = "";
|
|
63
|
+
return { sucesso: true, resposta: this.resposta };
|
|
64
|
+
} catch (error) {
|
|
65
|
+
alerta.adicionar({
|
|
66
|
+
titulo: "Erro ao cadastrar",
|
|
67
|
+
descricao: "N\xE3o foi poss\xEDvel cadastrar seu email. Tente novamente.",
|
|
68
|
+
cor: "error",
|
|
69
|
+
variantes: ["dashed", "soft"]
|
|
70
|
+
});
|
|
71
|
+
return { sucesso: false, erro: error };
|
|
72
|
+
} finally {
|
|
73
|
+
this.enviando = false;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
persist: {
|
|
78
|
+
storage: piniaPluginPersistedstate.sessionStorage()
|
|
79
|
+
}
|
|
80
|
+
});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { traduzirPagamentos } from "godeep-types/translate";
|
|
2
|
+
import { defineStore } from "pinia";
|
|
3
|
+
export const storePagamentos = defineStore("pagamentos", {
|
|
4
|
+
state: () => ({
|
|
5
|
+
pagamentos: [],
|
|
6
|
+
carregando: false
|
|
7
|
+
}),
|
|
8
|
+
getters: {
|
|
9
|
+
recuperarPagamentos: (state) => state.pagamentos,
|
|
10
|
+
pagamentosCarregando: (state) => state.carregando
|
|
11
|
+
},
|
|
12
|
+
actions: {
|
|
13
|
+
async resetarPagamentos() {
|
|
14
|
+
this.pagamentos = [];
|
|
15
|
+
this.carregando = false;
|
|
16
|
+
},
|
|
17
|
+
async buscarPagamentos() {
|
|
18
|
+
try {
|
|
19
|
+
this.carregando = true;
|
|
20
|
+
const response = await $fetch(
|
|
21
|
+
"/api/front-api/pagamentos"
|
|
22
|
+
);
|
|
23
|
+
const pagamentosTraduzidos = traduzirPagamentos(response);
|
|
24
|
+
this.pagamentos = pagamentosTraduzidos.dados ?? [];
|
|
25
|
+
this.carregando = false;
|
|
26
|
+
} catch {
|
|
27
|
+
this.pagamentos = [];
|
|
28
|
+
this.carregando = false;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
persist: {
|
|
33
|
+
storage: piniaPluginPersistedstate.sessionStorage()
|
|
34
|
+
}
|
|
35
|
+
});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { traduzirPagina } from "godeep-types/translate";
|
|
2
|
+
import { defineStore } from "pinia";
|
|
3
|
+
export const storePaginas = defineStore("paginas", {
|
|
4
|
+
state: () => ({
|
|
5
|
+
pagina: {},
|
|
6
|
+
carregando: false
|
|
7
|
+
}),
|
|
8
|
+
getters: {
|
|
9
|
+
recuperarPagina: (state) => state.pagina,
|
|
10
|
+
paginasCarregando: (state) => state.carregando
|
|
11
|
+
},
|
|
12
|
+
actions: {
|
|
13
|
+
async resetarPagina() {
|
|
14
|
+
this.pagina = {};
|
|
15
|
+
this.carregando = false;
|
|
16
|
+
},
|
|
17
|
+
async buscarPaginas(slug) {
|
|
18
|
+
try {
|
|
19
|
+
this.carregando = true;
|
|
20
|
+
const response = await $fetch(
|
|
21
|
+
`/api/front-api/paginas?slug=${slug}`
|
|
22
|
+
);
|
|
23
|
+
const paginaTraduzida = traduzirPagina(response);
|
|
24
|
+
this.pagina = paginaTraduzida ?? {};
|
|
25
|
+
this.carregando = false;
|
|
26
|
+
} catch {
|
|
27
|
+
this.pagina = {};
|
|
28
|
+
this.carregando = false;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
persist: {
|
|
33
|
+
storage: piniaPluginPersistedstate.sessionStorage()
|
|
34
|
+
}
|
|
35
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { StorefrontPedidosResponse } from 'godeep-types/types';
|
|
2
|
+
export declare const storePedidos: import("pinia").StoreDefinition<"pedidos", {
|
|
3
|
+
pedidos: StorefrontPedidosResponse["pedidos"];
|
|
4
|
+
paginador: StorefrontPedidosResponse["paginador"];
|
|
5
|
+
carregando: boolean;
|
|
6
|
+
erro: string;
|
|
7
|
+
}, {}, {}>;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { defineStore } from "pinia";
|
|
2
|
+
import { alerta } from "../utils/alerta.js";
|
|
3
|
+
import { traduzirPedidos } from "godeep-types/translate";
|
|
4
|
+
export const storePedidos = defineStore("pedidos", {
|
|
5
|
+
state: () => ({
|
|
6
|
+
pedidos: [],
|
|
7
|
+
paginador: void 0,
|
|
8
|
+
carregando: false,
|
|
9
|
+
erro: ""
|
|
10
|
+
}),
|
|
11
|
+
getters: {
|
|
12
|
+
recuperarPedidos: (state) => state.pedidos,
|
|
13
|
+
recuperarPaginador: (state) => state.paginador,
|
|
14
|
+
pedidosCarregando: (state) => state.carregando,
|
|
15
|
+
pedidosErro: (state) => state.erro
|
|
16
|
+
},
|
|
17
|
+
actions: {
|
|
18
|
+
resetarPedidos() {
|
|
19
|
+
this.pedidos = [];
|
|
20
|
+
this.paginador = void 0;
|
|
21
|
+
this.carregando = false;
|
|
22
|
+
this.erro = "";
|
|
23
|
+
},
|
|
24
|
+
async buscarPedidos(token) {
|
|
25
|
+
this.carregando = true;
|
|
26
|
+
this.erro = "";
|
|
27
|
+
try {
|
|
28
|
+
if (!token) throw new Error("Token de autentica\xE7\xE3o n\xE3o encontrado");
|
|
29
|
+
const resposta = await $fetch(
|
|
30
|
+
"/api/front-api/pedidos",
|
|
31
|
+
{
|
|
32
|
+
method: "GET",
|
|
33
|
+
headers: { "X-ACCESS-TOKEN": token }
|
|
34
|
+
}
|
|
35
|
+
);
|
|
36
|
+
const traduzido = traduzirPedidos(resposta);
|
|
37
|
+
this.pedidos = traduzido.pedidos;
|
|
38
|
+
this.paginador = traduzido.paginador;
|
|
39
|
+
return { sucesso: true, pedidos: this.pedidos };
|
|
40
|
+
} catch (error) {
|
|
41
|
+
this.pedidos = [];
|
|
42
|
+
this.paginador = void 0;
|
|
43
|
+
this.erro = "N\xE3o foi poss\xEDvel carregar seus pedidos.";
|
|
44
|
+
alerta.adicionar({
|
|
45
|
+
titulo: "Erro ao carregar pedidos",
|
|
46
|
+
descricao: this.erro,
|
|
47
|
+
cor: "error",
|
|
48
|
+
variantes: ["dashed", "soft"]
|
|
49
|
+
});
|
|
50
|
+
return { sucesso: false, erro: error };
|
|
51
|
+
} finally {
|
|
52
|
+
this.carregando = false;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
persist: {
|
|
57
|
+
storage: piniaPluginPersistedstate.sessionStorage()
|
|
58
|
+
}
|
|
59
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { StorefrontProduto, StorefrontProdutosRelacionados, StorefrontMetodoPagamento } from 'godeep-types/types';
|
|
2
|
+
export declare const storeProduto: import("pinia").StoreDefinition<"produto", {
|
|
3
|
+
produto: StorefrontProduto;
|
|
4
|
+
produtos: StorefrontProduto[];
|
|
5
|
+
relacionados: StorefrontProdutosRelacionados | null;
|
|
6
|
+
metodosPagamento: StorefrontMetodoPagamento[];
|
|
7
|
+
metodosErro: string;
|
|
8
|
+
carregando: boolean;
|
|
9
|
+
}, {}, {}>;
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import {
|
|
2
|
+
traduzirProduto,
|
|
3
|
+
traduzirAviseme,
|
|
4
|
+
traduzirProdutosRelacionados,
|
|
5
|
+
traduzirMetodosPagamento
|
|
6
|
+
} from "godeep-types/translate";
|
|
7
|
+
import { defineStore } from "pinia";
|
|
8
|
+
import { alerta } from "../utils/alerta.js";
|
|
9
|
+
export const storeProduto = defineStore("produto", {
|
|
10
|
+
state: () => ({
|
|
11
|
+
produto: {},
|
|
12
|
+
produtos: [],
|
|
13
|
+
relacionados: null,
|
|
14
|
+
metodosPagamento: [],
|
|
15
|
+
metodosErro: "",
|
|
16
|
+
carregando: false
|
|
17
|
+
}),
|
|
18
|
+
getters: {
|
|
19
|
+
recuperarProduto: (state) => state.produto,
|
|
20
|
+
recuperarTodosProdutos: (state) => state.produtos,
|
|
21
|
+
produtoCarregando: (state) => state.carregando,
|
|
22
|
+
todosProdutosCarregando: (state) => state.carregando,
|
|
23
|
+
recuperarRelacionados: (state) => state.relacionados,
|
|
24
|
+
recuperarMetodosPagamento: (state) => state.metodosPagamento,
|
|
25
|
+
recuperarMetodosErro: (state) => state.metodosErro
|
|
26
|
+
},
|
|
27
|
+
actions: {
|
|
28
|
+
async resetarProduto() {
|
|
29
|
+
this.produto = {};
|
|
30
|
+
this.produtos = [];
|
|
31
|
+
this.relacionados = null;
|
|
32
|
+
this.metodosPagamento = [];
|
|
33
|
+
this.metodosErro = "";
|
|
34
|
+
this.carregando = false;
|
|
35
|
+
},
|
|
36
|
+
async buscarProduto(slug) {
|
|
37
|
+
try {
|
|
38
|
+
this.carregando = true;
|
|
39
|
+
const response = await $fetch(
|
|
40
|
+
`/api/front-api/produtos/${slug}`
|
|
41
|
+
);
|
|
42
|
+
const produtoTraduzido = traduzirProduto(response);
|
|
43
|
+
this.produto = produtoTraduzido ?? {};
|
|
44
|
+
this.carregando = false;
|
|
45
|
+
} catch {
|
|
46
|
+
this.produto = {};
|
|
47
|
+
this.carregando = false;
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
async listarTodosProdutos() {
|
|
51
|
+
try {
|
|
52
|
+
this.carregando = true;
|
|
53
|
+
const response = await $fetch("/api/front-api/produtos");
|
|
54
|
+
const produtosTraduzidos = response.map(
|
|
55
|
+
(produto) => traduzirProduto(produto)
|
|
56
|
+
);
|
|
57
|
+
this.produtos = produtosTraduzidos ?? [];
|
|
58
|
+
this.carregando = false;
|
|
59
|
+
} catch {
|
|
60
|
+
this.produtos = [];
|
|
61
|
+
this.carregando = false;
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
async avisemeQuandoChegar(idProduto, email, nome) {
|
|
65
|
+
try {
|
|
66
|
+
this.carregando = true;
|
|
67
|
+
const response = await $fetch("/api/front-api/aviseme", {
|
|
68
|
+
method: "POST",
|
|
69
|
+
body: {
|
|
70
|
+
idProduto,
|
|
71
|
+
email,
|
|
72
|
+
nome
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
this.carregando = false;
|
|
76
|
+
return traduzirAviseme(response);
|
|
77
|
+
} catch {
|
|
78
|
+
this.carregando = false;
|
|
79
|
+
alerta.adicionar({
|
|
80
|
+
titulo: "Erro",
|
|
81
|
+
descricao: "Erro ao avisar quando chegar",
|
|
82
|
+
cor: "error",
|
|
83
|
+
variantes: ["dashed", "soft"]
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
async buscarProdutosRelacionados(idProduto) {
|
|
88
|
+
if (!idProduto || idProduto === 0) {
|
|
89
|
+
this.relacionados = null;
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
try {
|
|
93
|
+
this.carregando = true;
|
|
94
|
+
const resposta = await $fetch(
|
|
95
|
+
`/api/front-api/produtosRelacionados/${idProduto}`
|
|
96
|
+
);
|
|
97
|
+
this.relacionados = traduzirProdutosRelacionados(resposta);
|
|
98
|
+
} catch {
|
|
99
|
+
this.relacionados = null;
|
|
100
|
+
} finally {
|
|
101
|
+
this.carregando = false;
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
async buscarMetodosPagamento(idProduto, quantidade, cep) {
|
|
105
|
+
if (!idProduto || idProduto === 0) {
|
|
106
|
+
this.metodosPagamento = [];
|
|
107
|
+
this.metodosErro = "Produto inv\xE1lido";
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
try {
|
|
111
|
+
this.carregando = true;
|
|
112
|
+
this.metodosErro = "";
|
|
113
|
+
this.metodosPagamento = [];
|
|
114
|
+
const cepLimpo = cep?.replace(/\D/g, "");
|
|
115
|
+
const body = {
|
|
116
|
+
id: idProduto,
|
|
117
|
+
quantidade
|
|
118
|
+
};
|
|
119
|
+
if (cepLimpo && cepLimpo.length === 8) {
|
|
120
|
+
body.cep = cepLimpo;
|
|
121
|
+
}
|
|
122
|
+
const resposta = await $fetch(
|
|
123
|
+
"/api/front-api/payment-methods/product",
|
|
124
|
+
{
|
|
125
|
+
method: "POST",
|
|
126
|
+
body
|
|
127
|
+
}
|
|
128
|
+
);
|
|
129
|
+
this.metodosPagamento = traduzirMetodosPagamento(resposta);
|
|
130
|
+
} catch (error) {
|
|
131
|
+
this.metodosPagamento = [];
|
|
132
|
+
this.metodosErro = error?.data?.message ?? error?.message ?? "Erro ao buscar m\xE9todos de pagamento";
|
|
133
|
+
} finally {
|
|
134
|
+
this.carregando = false;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
persist: {
|
|
139
|
+
storage: piniaPluginPersistedstate.sessionStorage()
|
|
140
|
+
}
|
|
141
|
+
});
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { traduzirRedesSociais } from "godeep-types/translate";
|
|
2
|
+
import { defineStore } from "pinia";
|
|
3
|
+
export const storeRedesSociais = defineStore("redes-sociais", {
|
|
4
|
+
state: () => ({
|
|
5
|
+
redes: [],
|
|
6
|
+
carregando: false
|
|
7
|
+
}),
|
|
8
|
+
getters: {
|
|
9
|
+
recuperarRedesSociais: (state) => state.redes,
|
|
10
|
+
redesSociaisCarregando: (state) => state.carregando,
|
|
11
|
+
temRedesSociais: (state) => state.redes.length > 0
|
|
12
|
+
},
|
|
13
|
+
actions: {
|
|
14
|
+
resetarRedesSociais() {
|
|
15
|
+
this.redes = [];
|
|
16
|
+
this.carregando = false;
|
|
17
|
+
},
|
|
18
|
+
async buscarRedesSociais() {
|
|
19
|
+
try {
|
|
20
|
+
this.carregando = true;
|
|
21
|
+
const resposta = await $fetch(
|
|
22
|
+
"/api/front-api/redessociais",
|
|
23
|
+
{
|
|
24
|
+
method: "GET"
|
|
25
|
+
}
|
|
26
|
+
);
|
|
27
|
+
this.redes = traduzirRedesSociais(resposta);
|
|
28
|
+
} catch {
|
|
29
|
+
this.redes = [];
|
|
30
|
+
} finally {
|
|
31
|
+
this.carregando = false;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
persist: {
|
|
36
|
+
storage: piniaPluginPersistedstate.sessionStorage()
|
|
37
|
+
}
|
|
38
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { StorefrontVitrineListagem } from 'godeep-types/types';
|
|
2
|
+
type FiltrosSelecionados = Record<string, string[]>;
|
|
3
|
+
export declare const storeVitrine: import("pinia").StoreDefinition<"vitrine", {
|
|
4
|
+
vitrine: StorefrontVitrineListagem;
|
|
5
|
+
vitrinesCache: Record<string, StorefrontVitrineListagem>;
|
|
6
|
+
carregando: boolean;
|
|
7
|
+
paginaAtual: number;
|
|
8
|
+
ordenacao: string;
|
|
9
|
+
filtrosAtivos: FiltrosSelecionados;
|
|
10
|
+
slugBase: string;
|
|
11
|
+
subvitrineAtiva: string;
|
|
12
|
+
}, {}, {}>;
|
|
13
|
+
export {};
|