Skip to content

Commit

Permalink
RED-16 - montando endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
sombriks committed Jul 21, 2024
1 parent 6ae8871 commit b680213
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 6 deletions.
2 changes: 1 addition & 1 deletion service-node-koa/app/controllers/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ export * from "./dashboard.mjs";
export * from "./movimentacao.mjs";
export * from "./planejamento.mjs";
export * from "./recorrencia.mjs";
export * from "./user.mjs";
export * from "./usuario.mjs";
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,15 @@ export const delUsuarioRequest = async (ctx) => {
ctx.body = delUsuario(usuario.id);
}
};

export const updateUserRequest = async (ctx) => {
const { usuario_id: id } = ctx.params;
const { nome, email, senha, editToken } = ctx.request.body;
const usuario = await login({ email, senha });
if (!nome) ctx.throw(400, "Nome de usuário requerido");
if (!email) ctx.throw(400, "Email requerido");
if (!senha) ctx.throw(400, "Senha requerida");
if (!editToken) ctx.throw(400, "editToken requerido");
if (id != usuario.id) ctx.throw(400, "Usuário incorreto!");

};
3 changes: 2 additions & 1 deletion service-node-koa/app/main.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import {
updateMovimentacaoRequest,
updatePlanejamentoRequest,
updateRecorrenciaRequest,
updateUserRequest,
uploadMovimentacoesRequest,
userLoginRequest,
userSignupRequest,
Expand Down Expand Up @@ -77,7 +78,7 @@ new ApiBuilder({ router })

b.path("/:usuario_id", ifAuthenticated, (b) => {
b.del("/removeAccount", delUsuarioRequest);

b.put("/updateUser", updateUserRequest);
b.path("/categoria", (b) => {
b.get(listCategoriasRequest);
b.post(insertCategoriaRequest);
Expand Down
4 changes: 2 additions & 2 deletions web-app-vue/src/pages/dashboard/controles-dashboard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<chip-periodo v-model:inicial="inicio" v-model:final="fim"></chip-periodo>
</v-row>
<v-row>
<v-expansiuon-panels v-model="folha" variant="accordion">
<v-expansion-panels v-model="folha" variant="accordion">
<v-expansion-panel value="composicao">
<v-expansion-panel-title>Composição</v-expansion-panel-title>
<v-expansion-panel-text>
Expand Down Expand Up @@ -55,7 +55,7 @@
<saldos/>
</v-expansion-panel-text>
</v-expansion-panel>
</v-expansiuon-panels>
</v-expansion-panels>
</v-row>
</v-container>
</template>
Expand Down
4 changes: 2 additions & 2 deletions web-app-vue/src/services/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ export const createUser = async (newUser) => await post({ uri: '/signup', payloa
export const removeAccount = async ({ id, email, senha }) =>
await del({ uri: `/${id}/removeAccount?email=${email}&senha=${senha}` })

export const updateUser = async ({id = -1, updateToken, }) =>
await put()
export const updateUser = async ({id = -1, nome, email, senha, editToken, }) =>
await put({uri:`/${id}/updateUser`, payload: {nome, email, senha, editToken}})

export const listTiposConta = async () => await get({ uri: '/tipo-conta' })

Expand Down

0 comments on commit b680213

Please sign in to comment.