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.
Files changed (65) hide show
  1. package/README.md +158 -0
  2. package/dist/module.d.mts +8 -0
  3. package/dist/module.json +9 -0
  4. package/dist/module.mjs +28 -0
  5. package/dist/runtime/composables/useHeader.d.ts +2 -0
  6. package/dist/runtime/composables/useHeader.js +33 -0
  7. package/dist/runtime/plugin.d.ts +2 -0
  8. package/dist/runtime/plugin.js +3 -0
  9. package/dist/runtime/server/api/[...slug].d.ts +2 -0
  10. package/dist/runtime/server/api/[...slug].js +66 -0
  11. package/dist/runtime/server/routes/robots.d.ts +2 -0
  12. package/dist/runtime/server/routes/robots.js +37 -0
  13. package/dist/runtime/server/routes/robots.txt.d.ts +2 -0
  14. package/dist/runtime/server/routes/robots.txt.js +37 -0
  15. package/dist/runtime/server/tsconfig.json +3 -0
  16. package/dist/runtime/stores/.vscode/settings.json +3 -0
  17. package/dist/runtime/stores/avaliacoes.d.ts +53 -0
  18. package/dist/runtime/stores/avaliacoes.js +63 -0
  19. package/dist/runtime/stores/banner.d.ts +6 -0
  20. package/dist/runtime/stores/banner.js +88 -0
  21. package/dist/runtime/stores/busca.d.ts +8 -0
  22. package/dist/runtime/stores/busca.js +51 -0
  23. package/dist/runtime/stores/cadastro.d.ts +6 -0
  24. package/dist/runtime/stores/cadastro.js +117 -0
  25. package/dist/runtime/stores/carrinho.d.ts +8 -0
  26. package/dist/runtime/stores/carrinho.js +219 -0
  27. package/dist/runtime/stores/categoria.d.ts +10 -0
  28. package/dist/runtime/stores/categoria.js +137 -0
  29. package/dist/runtime/stores/configuracoes.d.ts +16 -0
  30. package/dist/runtime/stores/configuracoes.js +85 -0
  31. package/dist/runtime/stores/dados-cadastrais.d.ts +7 -0
  32. package/dist/runtime/stores/dados-cadastrais.js +89 -0
  33. package/dist/runtime/stores/enderecos.d.ts +7 -0
  34. package/dist/runtime/stores/enderecos.js +217 -0
  35. package/dist/runtime/stores/favoritos.d.ts +7 -0
  36. package/dist/runtime/stores/favoritos.js +120 -0
  37. package/dist/runtime/stores/filtros.d.ts +9 -0
  38. package/dist/runtime/stores/filtros.js +63 -0
  39. package/dist/runtime/stores/home.d.ts +5 -0
  40. package/dist/runtime/stores/home.js +59 -0
  41. package/dist/runtime/stores/login.d.ts +13 -0
  42. package/dist/runtime/stores/login.js +195 -0
  43. package/dist/runtime/stores/menus.d.ts +5 -0
  44. package/dist/runtime/stores/menus.js +35 -0
  45. package/dist/runtime/stores/newsletter.d.ts +6 -0
  46. package/dist/runtime/stores/newsletter.js +80 -0
  47. package/dist/runtime/stores/pagamentos.d.ts +5 -0
  48. package/dist/runtime/stores/pagamentos.js +35 -0
  49. package/dist/runtime/stores/paginas.d.ts +5 -0
  50. package/dist/runtime/stores/paginas.js +35 -0
  51. package/dist/runtime/stores/pedidos.d.ts +7 -0
  52. package/dist/runtime/stores/pedidos.js +59 -0
  53. package/dist/runtime/stores/produto.d.ts +9 -0
  54. package/dist/runtime/stores/produto.js +141 -0
  55. package/dist/runtime/stores/redes-sociais.d.ts +5 -0
  56. package/dist/runtime/stores/redes-sociais.js +38 -0
  57. package/dist/runtime/stores/vitrine.d.ts +13 -0
  58. package/dist/runtime/stores/vitrine.js +192 -0
  59. package/dist/runtime/types.d.ts +7 -0
  60. package/dist/runtime/utils/alerta.d.ts +10 -0
  61. package/dist/runtime/utils/alerta.js +7 -0
  62. package/dist/runtime/utils/erros.d.ts +15 -0
  63. package/dist/runtime/utils/erros.js +20 -0
  64. package/dist/types.d.mts +3 -0
  65. package/package.json +73 -0
@@ -0,0 +1,89 @@
1
+ import { defineStore } from "pinia";
2
+ import { alerta } from "../utils/alerta.js";
3
+ import { traduzirClienteResponse, reverterCliente } from "godeep-types/translate";
4
+ export const storeDadosCadastrais = defineStore("dados-cadastrais", {
5
+ state: () => ({
6
+ dados: null,
7
+ tipoPessoa: "PF",
8
+ carregando: false,
9
+ salvando: false
10
+ }),
11
+ getters: {
12
+ recuperarDados: (state) => state.dados,
13
+ dadosCarregando: (state) => state.carregando,
14
+ dadosSalvando: (state) => state.salvando
15
+ },
16
+ actions: {
17
+ resetarDados() {
18
+ this.dados = null;
19
+ this.carregando = false;
20
+ this.salvando = false;
21
+ },
22
+ async buscarDadosCadastrais(token, tipoCliente) {
23
+ this.carregando = true;
24
+ try {
25
+ if (!token) throw new Error("Token de autentica\xE7\xE3o n\xE3o encontrado");
26
+ const resposta = await $fetch(
27
+ "/api/front-api/clientes",
28
+ {
29
+ method: "GET",
30
+ headers: { "X-ACCESS-TOKEN": token }
31
+ }
32
+ );
33
+ if (!resposta?.dados)
34
+ throw new Error("Dados do cliente n\xE3o encontrados");
35
+ const tipoPessoa = resposta.dados.tipoPessoa || tipoCliente || "PF";
36
+ this.dados = traduzirClienteResponse(
37
+ resposta.dados,
38
+ tipoPessoa
39
+ );
40
+ this.tipoPessoa = tipoPessoa;
41
+ return { sucesso: true, dados: this.dados };
42
+ } catch (error) {
43
+ this.dados = null;
44
+ alerta.adicionar({
45
+ titulo: "Erro ao carregar dados",
46
+ descricao: "N\xE3o foi poss\xEDvel carregar seus dados cadastrais.",
47
+ cor: "error",
48
+ variantes: ["dashed", "soft"]
49
+ });
50
+ return { sucesso: false, erro: error };
51
+ } finally {
52
+ this.carregando = false;
53
+ }
54
+ },
55
+ async atualizarDadosCadastrais(token, dadosAtualizados) {
56
+ this.salvando = true;
57
+ try {
58
+ if (!token) throw new Error("Token de autentica\xE7\xE3o n\xE3o encontrado");
59
+ const tipoCliente = "cpf" in dadosAtualizados ? "PF" : "PJ";
60
+ await $fetch(`/api/front-api/clientes/${tipoCliente}`, {
61
+ method: "PUT",
62
+ headers: { "X-ACCESS-TOKEN": token },
63
+ body: reverterCliente(dadosAtualizados)
64
+ });
65
+ this.dados = dadosAtualizados;
66
+ alerta.adicionar({
67
+ titulo: "Dados atualizados!",
68
+ descricao: "Seus dados cadastrais foram atualizados com sucesso.",
69
+ cor: "success",
70
+ variantes: ["dashed", "soft"]
71
+ });
72
+ return { sucesso: true };
73
+ } catch (error) {
74
+ alerta.adicionar({
75
+ titulo: "Erro ao atualizar",
76
+ descricao: "N\xE3o foi poss\xEDvel atualizar seus dados. Verifique os campos e tente novamente.",
77
+ cor: "error",
78
+ variantes: ["dashed", "soft"]
79
+ });
80
+ return { sucesso: false, erro: error };
81
+ } finally {
82
+ this.salvando = false;
83
+ }
84
+ }
85
+ },
86
+ persist: {
87
+ storage: piniaPluginPersistedstate.sessionStorage()
88
+ }
89
+ });
@@ -0,0 +1,7 @@
1
+ import type { StorefrontEndereco } from 'godeep-types/types';
2
+ export declare const storeEnderecos: import("pinia").StoreDefinition<"enderecos", {
3
+ enderecos: StorefrontEndereco[];
4
+ endereco: StorefrontEndereco;
5
+ carregando: boolean;
6
+ salvando: boolean;
7
+ }, {}, {}>;
@@ -0,0 +1,217 @@
1
+ import { defineStore } from "pinia";
2
+ import { alerta } from "../utils/alerta.js";
3
+ import { traduzirEnderecosCliente } from "godeep-types/translate";
4
+ export const storeEnderecos = defineStore("enderecos", {
5
+ state: () => ({
6
+ enderecos: [],
7
+ endereco: {
8
+ id: "",
9
+ destinatario: "",
10
+ cep: "",
11
+ endereco: "",
12
+ logradouro: "",
13
+ numero: "",
14
+ complemento: "",
15
+ bairro: "",
16
+ estado: "",
17
+ cidade: "",
18
+ nomeEndereco: "",
19
+ tipo: ""
20
+ },
21
+ carregando: false,
22
+ salvando: false
23
+ }),
24
+ getters: {
25
+ recuperarEnderecos: (state) => state.enderecos,
26
+ recuperarEndereco: (state) => state.endereco,
27
+ enderecosCarregando: (state) => state.carregando,
28
+ enderecosSalvando: (state) => state.salvando
29
+ },
30
+ actions: {
31
+ resetarEnderecos() {
32
+ this.enderecos = [];
33
+ this.endereco = {
34
+ id: "",
35
+ destinatario: "",
36
+ cep: "",
37
+ endereco: "",
38
+ logradouro: "",
39
+ numero: "",
40
+ complemento: "",
41
+ bairro: "",
42
+ estado: "",
43
+ cidade: "",
44
+ nomeEndereco: "",
45
+ tipo: ""
46
+ };
47
+ this.carregando = false;
48
+ },
49
+ async buscarEnderecos(token) {
50
+ try {
51
+ this.carregando = true;
52
+ if (!token) throw new Error("Token de autentica\xE7\xE3o n\xE3o encontrado");
53
+ const resposta = await $fetch(
54
+ "/api/front-api/clientes/enderecos",
55
+ {
56
+ method: "GET",
57
+ headers: { "X-ACCESS-TOKEN": token }
58
+ }
59
+ );
60
+ this.enderecos = traduzirEnderecosCliente(resposta);
61
+ return { sucesso: true, enderecos: this.enderecos };
62
+ } catch (error) {
63
+ this.enderecos = [];
64
+ alerta.adicionar({
65
+ titulo: "Erro ao carregar endere\xE7os",
66
+ descricao: "N\xE3o foi poss\xEDvel carregar seus endere\xE7os.",
67
+ cor: "error",
68
+ variantes: ["dashed", "soft"]
69
+ });
70
+ return { sucesso: false, erro: error };
71
+ } finally {
72
+ this.carregando = false;
73
+ }
74
+ },
75
+ async buscarEndereco(token, id) {
76
+ try {
77
+ this.carregando = true;
78
+ if (!token) throw new Error("Token de autentica\xE7\xE3o n\xE3o encontrado");
79
+ const resposta = await $fetch(
80
+ `/api/front-api/clientes/enderecos/${id}`,
81
+ {
82
+ headers: { "X-ACCESS-TOKEN": token }
83
+ }
84
+ );
85
+ this.endereco = traduzirEnderecosCliente(
86
+ resposta
87
+ )[0];
88
+ return { sucesso: true, endereco: this.endereco };
89
+ } catch (error) {
90
+ alerta.adicionar({
91
+ titulo: "Erro ao carregar endere\xE7o",
92
+ descricao: "N\xE3o foi poss\xEDvel carregar o endere\xE7o.",
93
+ cor: "error",
94
+ variantes: ["dashed", "soft"]
95
+ });
96
+ return { sucesso: false, erro: error };
97
+ } finally {
98
+ this.carregando = false;
99
+ }
100
+ },
101
+ async cadastrarEndereco(token, endereco) {
102
+ this.carregando = true;
103
+ try {
104
+ if (!token) throw new Error("Token de autentica\xE7\xE3o n\xE3o encontrado");
105
+ await $fetch("/api/front-api/clientes/enderecos/cadastrar", {
106
+ method: "POST",
107
+ headers: { "X-ACCESS-TOKEN": token },
108
+ body: endereco
109
+ });
110
+ alerta.adicionar({
111
+ titulo: "Endere\xE7o cadastrado!",
112
+ descricao: "O endere\xE7o foi cadastrado com sucesso.",
113
+ cor: "success",
114
+ variantes: ["dashed", "soft"]
115
+ });
116
+ this.endereco = endereco;
117
+ await this.buscarEnderecos(token);
118
+ return { sucesso: true };
119
+ } catch (error) {
120
+ return { sucesso: false, erro: error };
121
+ } finally {
122
+ this.carregando = false;
123
+ }
124
+ },
125
+ async atualizarEndereco(token, id, endereco) {
126
+ try {
127
+ this.carregando = true;
128
+ if (!token) throw new Error("Token de autentica\xE7\xE3o n\xE3o encontrado");
129
+ await $fetch(`/api/front-api/clientes/enderecos/atualizar/${id}`, {
130
+ method: "PUT",
131
+ headers: { "X-ACCESS-TOKEN": token },
132
+ body: endereco
133
+ });
134
+ alerta.adicionar({
135
+ titulo: "Endere\xE7o atualizado!",
136
+ descricao: "O endere\xE7o foi atualizado com sucesso.",
137
+ cor: "success",
138
+ variantes: ["dashed", "soft"]
139
+ });
140
+ await this.buscarEnderecos(token);
141
+ return { sucesso: true };
142
+ } catch (error) {
143
+ alerta.adicionar({
144
+ titulo: "Erro ao atualizar endere\xE7o",
145
+ descricao: "N\xE3o foi poss\xEDvel atualizar o endere\xE7o. Verifique os campos e tente novamente.",
146
+ cor: "error",
147
+ variantes: ["dashed", "soft"]
148
+ });
149
+ return { sucesso: false, erro: error };
150
+ } finally {
151
+ this.carregando = false;
152
+ }
153
+ },
154
+ async deletarEndereco(token, id) {
155
+ try {
156
+ this.carregando = true;
157
+ if (!token) throw new Error("Token de autentica\xE7\xE3o n\xE3o encontrado");
158
+ await $fetch(`/api/front-api/clientes/enderecos/${id}`, {
159
+ method: "DELETE",
160
+ headers: { "X-ACCESS-TOKEN": token }
161
+ });
162
+ alerta.adicionar({
163
+ titulo: "Endere\xE7o removido!",
164
+ descricao: "O endere\xE7o foi removido com sucesso.",
165
+ cor: "success",
166
+ variantes: ["dashed", "soft"]
167
+ });
168
+ await this.buscarEnderecos(token);
169
+ return { sucesso: true };
170
+ } catch (error) {
171
+ alerta.adicionar({
172
+ titulo: "Erro ao remover endere\xE7o",
173
+ descricao: "N\xE3o foi poss\xEDvel remover o endere\xE7o.",
174
+ cor: "error",
175
+ variantes: ["dashed", "soft"]
176
+ });
177
+ return { sucesso: false, erro: error };
178
+ } finally {
179
+ this.carregando = false;
180
+ }
181
+ },
182
+ async definirComoPrincipal(token, id) {
183
+ try {
184
+ this.carregando = true;
185
+ if (!token) throw new Error("Token de autentica\xE7\xE3o n\xE3o encontrado");
186
+ const endereco = this.enderecos.find((e) => e.id === id);
187
+ if (!endereco) throw new Error("Endere\xE7o n\xE3o encontrado");
188
+ await $fetch(`/api/front-api/clientes/enderecos/atualizar/${id}`, {
189
+ method: "PUT",
190
+ headers: { "X-ACCESS-TOKEN": token },
191
+ body: { ...endereco, tipo: "Principal" }
192
+ });
193
+ alerta.adicionar({
194
+ titulo: "Endere\xE7o definido como principal!",
195
+ descricao: "O endere\xE7o foi definido como principal com sucesso.",
196
+ cor: "success",
197
+ variantes: ["dashed", "soft"]
198
+ });
199
+ await this.buscarEnderecos(token);
200
+ return { sucesso: true };
201
+ } catch (error) {
202
+ alerta.adicionar({
203
+ titulo: "Erro ao definir como principal",
204
+ descricao: "N\xE3o foi poss\xEDvel definir o endere\xE7o como principal.",
205
+ cor: "error",
206
+ variantes: ["dashed", "soft"]
207
+ });
208
+ return { sucesso: false, erro: error };
209
+ } finally {
210
+ this.carregando = false;
211
+ }
212
+ }
213
+ },
214
+ persist: {
215
+ storage: piniaPluginPersistedstate.sessionStorage()
216
+ }
217
+ });
@@ -0,0 +1,7 @@
1
+ import type { StorefrontFavoritoResponse } from 'godeep-types/types';
2
+ export declare const favoritosDefault: StorefrontFavoritoResponse;
3
+ export declare const storeFavoritos: import("pinia").StoreDefinition<"favoritos", {
4
+ listaIds: string[];
5
+ favoritos: StorefrontFavoritoResponse;
6
+ carregando: boolean;
7
+ }, {}, {}>;
@@ -0,0 +1,120 @@
1
+ import { traduzirFavoritos } from "godeep-types/translate";
2
+ import { defineStore } from "pinia";
3
+ import { storeLogin } from "./login.js";
4
+ import { alerta } from "../utils/alerta.js";
5
+ export const favoritosDefault = {
6
+ produtos: []
7
+ };
8
+ export const storeFavoritos = defineStore("favoritos", {
9
+ state: () => ({
10
+ listaIds: [],
11
+ favoritos: favoritosDefault,
12
+ carregando: false
13
+ }),
14
+ getters: {
15
+ recuperarListaIds: (state) => state.listaIds,
16
+ recuperarListaIdsCarregando: (state) => state.carregando,
17
+ produtoFavoritado: (state) => (produtoId) => state.listaIds.includes(produtoId),
18
+ produtoFavoritadoCarregando: (state) => state.carregando,
19
+ recuperarFavoritos: (state) => state.favoritos,
20
+ recuperarFavoritosCarregando: (state) => state.carregando
21
+ },
22
+ actions: {
23
+ async resetarFavoritos() {
24
+ this.listaIds = [];
25
+ this.favoritos = favoritosDefault;
26
+ this.carregando = false;
27
+ },
28
+ async verificarUsuarioLogado() {
29
+ const loginStore = storeLogin();
30
+ const token = loginStore.usuario?.token;
31
+ if (!token) {
32
+ alerta.adicionar({
33
+ titulo: "Erro",
34
+ descricao: "Usu\xE1rio n\xE3o logado",
35
+ cor: "error",
36
+ variantes: ["outline"]
37
+ });
38
+ return null;
39
+ }
40
+ return token;
41
+ },
42
+ async buscarFavoritos() {
43
+ const token = await this.verificarUsuarioLogado();
44
+ if (!token) {
45
+ return;
46
+ }
47
+ try {
48
+ this.carregando = true;
49
+ const response = await $fetch("/api/front-api/favoritos", {
50
+ method: "GET",
51
+ headers: { "X-ACCESS-TOKEN": token }
52
+ });
53
+ const favoritosTraduzidos = traduzirFavoritos(response);
54
+ this.favoritos = favoritosTraduzidos ?? favoritosDefault;
55
+ this.carregando = false;
56
+ } catch {
57
+ this.favoritos = favoritosDefault;
58
+ this.carregando = false;
59
+ }
60
+ },
61
+ async adicionarFavorito(produtoId) {
62
+ try {
63
+ const token = await this.verificarUsuarioLogado();
64
+ if (!token) {
65
+ return;
66
+ }
67
+ this.carregando = true;
68
+ await $fetch(
69
+ `/api/front-api/favoritos/${produtoId}`,
70
+ {
71
+ method: "POST",
72
+ headers: { "X-ACCESS-TOKEN": token }
73
+ }
74
+ );
75
+ if (!this.listaIds.includes(produtoId)) {
76
+ this.listaIds.push(produtoId);
77
+ }
78
+ this.carregando = false;
79
+ } catch {
80
+ this.listaIds = [];
81
+ this.carregando = false;
82
+ }
83
+ },
84
+ async removerFavorito(produtoId) {
85
+ const token = await this.verificarUsuarioLogado();
86
+ if (!token) {
87
+ return;
88
+ }
89
+ try {
90
+ const response = await $fetch(`/api/front-api/favoritos/${produtoId}`, {
91
+ method: "DELETE",
92
+ headers: { "X-ACCESS-TOKEN": token }
93
+ });
94
+ if (response.mensagens && response.mensagens.length > 0) {
95
+ alerta.adicionar({
96
+ titulo: "Produto removido dos favoritos",
97
+ descricao: response.mensagens[0],
98
+ cor: "success",
99
+ variantes: ["outline"]
100
+ });
101
+ this.listaIds = this.listaIds.filter((id) => id !== produtoId);
102
+ this.buscarFavoritos();
103
+ }
104
+ } catch {
105
+ this.listaIds = [];
106
+ this.carregando = false;
107
+ }
108
+ },
109
+ async toggleFavorito(produtoId) {
110
+ if (this.listaIds.includes(produtoId)) {
111
+ await this.removerFavorito(produtoId);
112
+ } else {
113
+ await this.adicionarFavorito(produtoId);
114
+ }
115
+ }
116
+ },
117
+ persist: {
118
+ storage: piniaPluginPersistedstate.sessionStorage()
119
+ }
120
+ });
@@ -0,0 +1,9 @@
1
+ import type { StorefrontFiltroPreco, StorefrontFiltroSecao, StorefrontSubcategoriaItem } from 'godeep-types/types';
2
+ export declare const storeFiltros: import("pinia").StoreDefinition<"filtros", {
3
+ filtros: StorefrontFiltroSecao[];
4
+ subcategorias: StorefrontSubcategoriaItem[];
5
+ faixasPreco: StorefrontFiltroPreco[];
6
+ carregando: boolean;
7
+ erro: string;
8
+ slug: string;
9
+ }, {}, {}>;
@@ -0,0 +1,63 @@
1
+ import { traduzirParametros } from "godeep-types/translate";
2
+ import { defineStore } from "pinia";
3
+ function normalizarSlug(slug) {
4
+ let valor = slug.startsWith("/") ? slug.slice(1) : slug;
5
+ valor = valor.replace(/^categorias\//, "");
6
+ return valor.startsWith("categorias/") ? valor : `categorias/${valor}`;
7
+ }
8
+ export const storeFiltros = defineStore("filtros", {
9
+ state: () => ({
10
+ filtros: [],
11
+ subcategorias: [],
12
+ faixasPreco: [],
13
+ carregando: false,
14
+ erro: "",
15
+ slug: ""
16
+ }),
17
+ getters: {
18
+ recuperarFiltros: (state) => state.filtros,
19
+ recuperarSubcategorias: (state) => state.subcategorias,
20
+ recuperarFaixasPreco: (state) => state.faixasPreco,
21
+ filtrosCarregando: (state) => state.carregando,
22
+ recuperarErro: (state) => state.erro
23
+ },
24
+ actions: {
25
+ resetarFiltros() {
26
+ this.filtros = [];
27
+ this.subcategorias = [];
28
+ this.faixasPreco = [];
29
+ this.carregando = false;
30
+ this.erro = "";
31
+ this.slug = "";
32
+ },
33
+ async buscarFiltros(slug) {
34
+ const slugNormalizado = normalizarSlug(slug);
35
+ this.slug = slugNormalizado;
36
+ try {
37
+ this.carregando = true;
38
+ const resposta = await $fetch(
39
+ "/api/front-api/parametros",
40
+ {
41
+ method: "GET",
42
+ params: { slug: slugNormalizado }
43
+ }
44
+ );
45
+ const traduzido = traduzirParametros(resposta);
46
+ this.filtros = traduzido.filtros;
47
+ this.subcategorias = traduzido.subcategorias;
48
+ this.faixasPreco = traduzido.faixasPreco;
49
+ this.erro = "";
50
+ } catch {
51
+ this.filtros = [];
52
+ this.subcategorias = [];
53
+ this.faixasPreco = [];
54
+ this.erro = "Erro ao carregar filtros";
55
+ } finally {
56
+ this.carregando = false;
57
+ }
58
+ }
59
+ },
60
+ persist: {
61
+ storage: piniaPluginPersistedstate.sessionStorage()
62
+ }
63
+ });
@@ -0,0 +1,5 @@
1
+ import type { StorefrontCmsHome } from 'godeep-types/types';
2
+ export declare const storeHome: import("pinia").StoreDefinition<"home", {
3
+ home: StorefrontCmsHome[];
4
+ carregando: boolean;
5
+ }, {}, {}>;
@@ -0,0 +1,59 @@
1
+ import { traduzirCmsHome } from "godeep-types/translate";
2
+ import { defineStore } from "pinia";
3
+ import { storeVitrine } from "./vitrine.js";
4
+ import { storeBanners } from "./banner.js";
5
+ export const storeHome = defineStore("home", {
6
+ state: () => ({
7
+ home: [],
8
+ carregando: false
9
+ }),
10
+ getters: {
11
+ recuperarHome: (state) => state.home,
12
+ homeCarregando: (state) => state.carregando
13
+ },
14
+ actions: {
15
+ async resetarHome() {
16
+ this.home = [];
17
+ this.carregando = false;
18
+ },
19
+ async buscarHome() {
20
+ try {
21
+ this.carregando = true;
22
+ const url = "/mocks/home.json";
23
+ const response = await $fetch(
24
+ url
25
+ );
26
+ const homeTraduzido = traduzirCmsHome(response);
27
+ console.log("homeTraduzido", homeTraduzido);
28
+ this.home = homeTraduzido ?? {};
29
+ const vitrineStore = storeVitrine();
30
+ const vitrines = homeTraduzido.filter((item) => item.tipoComponente === "vitrine" && item.slug);
31
+ await Promise.all(
32
+ vitrines.map((item) => {
33
+ const slug = item.slug === "mock" ? `mock-${item.idComponente}` : item.slug;
34
+ return vitrineStore.buscarVitrine(slug, true);
35
+ })
36
+ );
37
+ const bannerStore = storeBanners();
38
+ const banners = homeTraduzido.filter((item) => item.tipoComponente === "banner");
39
+ await Promise.all(
40
+ banners.map((item) => {
41
+ return bannerStore.buscarBanners(
42
+ item.posicaoComponente ?? "",
43
+ item.localizacao ?? "",
44
+ item.tipo ?? "",
45
+ item.slug ?? ""
46
+ );
47
+ })
48
+ );
49
+ this.carregando = false;
50
+ } catch {
51
+ this.home = [];
52
+ this.carregando = false;
53
+ }
54
+ }
55
+ },
56
+ persist: {
57
+ storage: piniaPluginPersistedstate.sessionStorage()
58
+ }
59
+ });
@@ -0,0 +1,13 @@
1
+ import type { StorefrontEsqueceuSenhaTokenResponse, StorefrontRedefinirSenhaResponse, StorefrontUsuario } from 'godeep-types/types';
2
+ export declare const storeLogin: import("pinia").StoreDefinition<"login", {
3
+ esqueceuSenhaToken: StorefrontEsqueceuSenhaTokenResponse;
4
+ redefinirSenhaResposta: StorefrontRedefinirSenhaResponse;
5
+ usuario: StorefrontUsuario;
6
+ carregando: boolean;
7
+ dadosLembrarMe: {
8
+ email: string;
9
+ senha: string;
10
+ } | null;
11
+ emailEnviado: boolean;
12
+ mensagemEsqueceuSenha: string;
13
+ }, {}, {}>;