Skip to content

Commit 301a766

Browse files
committed
works on REDLINE-17
1 parent 004122b commit 301a766

File tree

5 files changed

+42
-3
lines changed

5 files changed

+42
-3
lines changed

service-node-koa/app/routes/movimentacao.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export const movimentacaoRouter = new Router();
1212
movimentacaoRouter.get("/:usuario_id/movimentacao", async ctx => {
1313
const { usuario_id } = ctx.request.params;
1414
const { q = "", limit = 50, offset = 0, conta_id } = ctx.request.query;
15-
if (conta_id) ctx.body = await listMovimentacaoByConta({ usuario_id, q, limit, offset });
15+
if (conta_id) ctx.body = await listMovimentacaoByConta({ conta_id, q, limit, offset });
1616
else ctx.body = await listMovimentacaoByUsuario({ usuario_id, q, limit, offset });
1717
});
1818

web-app-vue/src/services/api.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,8 @@ export const insertCategoria = async ({ id, categoria }) =>
5656

5757
export const delCategoria = async ({ id, categoria }) =>
5858
await del({ uri: `/${id}/categoria/${categoria.id}` })
59+
60+
export const lisTiposMovimentacao = async () => await get({ uri: '/tipo_movimentacao' })
61+
62+
export const listMovimentacoes = async ({ id, q = '', limit = 50, offset = 0 }) =>
63+
await get({ uri: `/${id}/movimentacao?q=${q}&limit=${limit}&offset=${offset}` })

web-app-vue/src/services/redLine.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ export const getRedLine = () => {
1515
},
1616
tiposConta: [],
1717
contas: [],
18-
categorias: []
18+
categorias: [],
19+
movimentacoes: [],
20+
tiposMovimentacao: []
1921
};
2022
} else {
2123
redLine = JSON.parse(lastState);

web-app-vue/src/stores/contaStore.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ export const useContaStore = defineStore('conta-store', () => {
1919

2020
const sincronizarContas = async () => {
2121
const redLine = getRedLine()
22-
const contas = await listContas({ id: uState.userData.id })
22+
const { id } = uState.userData
23+
const contas = await listContas({ id })
2324
const tiposConta = await listTiposConta()
2425
store.contas = contas
2526
store.tiposConta = tiposConta
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { defineStore } from 'pinia'
2+
import { useUserStore } from '@/stores/userStore'
3+
import { reactive } from 'vue'
4+
import { getRedLine, setRedLine } from '@/services/redLine'
5+
import { lisTiposMovimentacao } from "@/services/api";
6+
7+
export const useMovimentacaoStore = defineStore('movimentacao-store', () => {
8+
const uState = useUserStore()
9+
10+
function initStore() {
11+
const redLine = getRedLine()
12+
return reactive({
13+
tiposMovimentacao: redLine.tiposMovimentacao || [],
14+
movimentacoes: redLine?.movimentacoes || []
15+
})
16+
}
17+
18+
const store = initStore()
19+
20+
const sincronizarMovimentacoes = async () => {
21+
const redLine = getRedLine()
22+
store.tiposMovimentacao = await lisTiposMovimentacao()
23+
setRedLine({
24+
...redLine,
25+
tiposMovimentacao: store.tiposMovimentacao,
26+
movimentacoes: store.movimentacoes
27+
})
28+
}
29+
30+
return { store, sincronizarMovimentacoes }
31+
})

0 commit comments

Comments
 (0)