Skip to content

Commit d52985c

Browse files
committed
works on RED-21
1 parent f52e356 commit d52985c

File tree

4 files changed

+60
-7
lines changed

4 files changed

+60
-7
lines changed
Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,23 @@
11
<template>
2-
<p>detalhe </p>
2+
3+
<v-chip
4+
v-if="!edit"
5+
rounded
6+
variant="outlined"
7+
color="green-accent-2"
8+
class="ma-2"
9+
size="x-large"
10+
:append-icon="props.recorrencia?.id ? 'mdi-playlist-edit' : 'mdi-playlist-plus'"
11+
@click="edit = !edit"
12+
>
13+
{{ props.recorrencia?.descricao || "Nova recorrência" }}
14+
</v-chip>
315
</template>
4-
<script setup></script>
16+
<script setup>
17+
import {ref} from "vue";
18+
19+
const props = defineProps(['recorrencia'])
20+
const emit = defineEmits(['onSave', 'onCancel', 'onDel'])
21+
22+
const edit = ref(false)
23+
</script>

web-app-vue/src/components/recorrencia/list-recorrencia.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@
99
<script setup>
1010
import {useRecorrenciaStore} from "@/stores/recorrenciaStore";
1111
import DetalheRecorrencia from "@/components/recorrencia/detalhe-recorrencia.vue";
12-
import {computed} from "vue";
12+
import {computed, onMounted} from "vue";
1313
1414
const recorrenciaStore = useRecorrenciaStore()
1515
1616
const recorrencias = computed(() => {
1717
return recorrenciaStore.store.recorrencias || []
1818
})
1919
20+
onMounted(async () => await recorrenciaStore.sincronizarRecorrencia())
21+
2022
</script>

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,3 +168,15 @@ export const listRecorrencias = async ({ id, q, limit, offset }) =>
168168
}
169169
})
170170
})
171+
172+
export const insertRecorrencia = async ({ id, recorrencia }) =>
173+
await post({ uri: `/${id}/recorrencia`, payload: recorrencia })
174+
175+
export const findRecorrencia = async ({ id, recorrencia_id }) =>
176+
await get({ uri: `/${id}/recorrencia/${recorrencia_id}` })
177+
178+
export const updateRecorrencia = async ({ id, recorrencia }) =>
179+
await put({ uri: `/${id}/recorrencia/${recorrencia.id}`, payload: recorrencia })
180+
181+
export const delRecorrencia = async ({ id, recorrencia_id }) =>
182+
await del({ uri: `/${id}/recorrencia/${recorrencia_id}` })

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

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@ import { defineStore } from 'pinia'
22
import { reactive } from 'vue'
33
import { useUserStore } from '@/stores/userStore'
44
import { getRedLine } from '@/services/redLine'
5+
import {
6+
delRecorrencia,
7+
insertRecorrencia,
8+
listRecorrencias,
9+
updateRecorrencia
10+
} from '@/services/api'
511

612
export const useRecorrenciaStore = defineStore('recorrencia-store', () => {
713
const uState = useUserStore()
@@ -15,12 +21,26 @@ export const useRecorrenciaStore = defineStore('recorrencia-store', () => {
1521
}
1622
})
1723

18-
const sincronizarRecorrencia = () => {
24+
const sincronizarRecorrencia = async () => {
25+
console.log("aqui")
1926
const { id } = uState.userData
20-
const { q, limit, offset } = store.filtroPlanejamentos
27+
const { q, limit, offset } = store.filtroRecorrencias
28+
store.recorrencias = await listRecorrencias({ id, q, limit, offset })
29+
}
30+
const salvarRecorrencia = async (recorrencia) => {
31+
const { id } = uState.userData
32+
if (recorrencia.id) {
33+
await updateRecorrencia({ id, recorrencia })
34+
} else {
35+
await insertRecorrencia({ id, recorrencia })
36+
}
37+
await sincronizarRecorrencia()
38+
}
39+
const excluirRecorrencia = async (recorrencia_id) => {
40+
const { id } = uState.userData
41+
await delRecorrencia({ id, recorrencia_id })
42+
await sincronizarRecorrencia()
2143
}
22-
const salvarRecorrencia = () => {}
23-
const excluirRecorrencia = () => {}
2444

2545
return { store, sincronizarRecorrencia, salvarRecorrencia, excluirRecorrencia }
2646
})

0 commit comments

Comments
 (0)