From d3b8148cfa777517ed1a80affe58d2410e120952 Mon Sep 17 00:00:00 2001 From: "Gabriel R. Antunes" Date: Wed, 24 Jul 2024 15:12:17 -0400 Subject: [PATCH] refactor: use typescript props definition --- .../Appbar/SpeechBubbles/SpeechBubbles.vue | 7 +++- components/Pages/DashboardCalendar/Event.vue | 29 ++++++++++------- .../Pages/DashboardCalendar/EventList.vue | 15 +++++---- components/Pages/DashboardCalendar/Month.vue | 17 ++++++---- components/Section/Ambientes/Form/Form.vue | 23 ++++++++----- components/Section/Ambientes/Modal/Modal.vue | 16 ++++++---- components/Section/Blocos/Form/Form.vue | 23 ++++++++----- components/Section/Blocos/Modal/Modal.vue | 21 ++++++------ components/Section/Cursos/Form/Form.vue | 23 ++++++++----- components/Section/Cursos/Modal/Modal.vue | 16 ++++++---- .../Form/Geral/02-Turmas/02-Turmas.vue | 23 +++++++------ components/Section/Diarios/Grid/Grid.vue | 14 ++++++-- components/Section/Diarios/Grid/Item/Item.vue | 18 +++++++---- components/Section/Diarios/Modal/Modal.vue | 16 ++++++---- components/Section/Disciplinas/Form/Form.vue | 21 +++++++----- .../Section/Disciplinas/Modal/Modal.vue | 16 ++++++---- .../SpeechBubblesCalendar.vue | 8 ++++- .../Turmas/Form/Fields/Periodo/Bruto.vue | 16 ++++------ .../Turmas/Form/Fields/Periodo/Periodo.vue | 16 ++++------ .../Turmas/Form/Fields/Periodo/SerieTurma.vue | 16 ++++------ components/Section/Turmas/Form/Form.vue | 14 ++++---- components/Section/Turmas/Modal/Modal.vue | 16 ++++++---- components/Section/Usuarios/Form/Form.vue | 15 +++++---- .../Section/Usuarios/Form/Profile/Profile.vue | 17 ++++++---- components/Section/Usuarios/Grid/Grid.vue | 12 +++++-- .../Section/Usuarios/Modals/Form/Form.vue | 16 ++++++---- components/Sidebar/SidebarItem.vue | 15 +++++---- components/Sidebar/SidebarItemGroup.vue | 15 +++++---- components/Sidebar/SidebarItemSpacer.vue | 15 +++++---- components/UI/SearchBar/SearchBar.vue | 14 +++++--- components/UI/TextButton/TextButton.vue | 14 +++++--- components/VV/Autocomplete/Autocomplete.vue | 15 +++++---- components/VV/SelectRoles/SelectRoles.vue | 15 +++++---- components/VV/TextField.vue | 32 +++++++++---------- 34 files changed, 348 insertions(+), 231 deletions(-) diff --git a/components/Appbar/SpeechBubbles/SpeechBubbles.vue b/components/Appbar/SpeechBubbles/SpeechBubbles.vue index 9d814e2..c5ebdff 100644 --- a/components/Appbar/SpeechBubbles/SpeechBubbles.vue +++ b/components/Appbar/SpeechBubbles/SpeechBubbles.vue @@ -1,7 +1,12 @@ diff --git a/components/Pages/DashboardCalendar/EventList.vue b/components/Pages/DashboardCalendar/EventList.vue index f9aa8c9..6b82bc0 100644 --- a/components/Pages/DashboardCalendar/EventList.vue +++ b/components/Pages/DashboardCalendar/EventList.vue @@ -25,12 +25,15 @@ type EventItem = Omit & { }; // Props -const props = defineProps({ - year: Number, - steps: Array, - events: Array, - monthNum: Number, -}); + +type Props = { + year: number; + steps: Step[]; + events: Event[]; + monthNum: number; +}; + +const props = defineProps(); // Set event data let allEventItems = ref([ diff --git a/components/Pages/DashboardCalendar/Month.vue b/components/Pages/DashboardCalendar/Month.vue index ec20dff..28e1fd4 100644 --- a/components/Pages/DashboardCalendar/Month.vue +++ b/components/Pages/DashboardCalendar/Month.vue @@ -26,12 +26,15 @@ type Event = { }; // Props -const props = defineProps({ - year: Number, - toggleMonth: Boolean, - steps: Array, - events: Array, -}); + +type Props = { + year: number; + toggleMonth: boolean; + steps: Step[]; + events: Event[]; +}; + +const props = defineProps(); // Month const daysInTheWeek = ['Dom', 'Seg', 'Ter', 'Qua', 'Qui', 'Sex', 'Sáb']; @@ -244,7 +247,7 @@ onMounted(async () => { @click="toggleMonth(-1)" v-show="props.toggleMonth!" /> - +

{{ diff --git a/components/Section/Ambientes/Form/Form.vue b/components/Section/Ambientes/Form/Form.vue index 17de7c3..b2ae6b5 100644 --- a/components/Section/Ambientes/Form/Form.vue +++ b/components/Section/Ambientes/Form/Form.vue @@ -5,15 +5,18 @@ import { computed } from 'vue'; import * as yup from 'yup'; import { useApiAmbienteFindOne, useApiClient } from '~/composables'; -const props = defineProps({ - //props do modal criar e editar - editId: { - type: String, - required: false, - default: null, - }, +// + +type Props = { + editId?: string | null; +}; + +const props = withDefaults(defineProps(), { + editId: null, }); +// + const editIdRef = toRef(props, 'editId'); const $emit = defineEmits(['close']); @@ -68,12 +71,16 @@ const initialFormValues = reactive({ }); const handleDelete = async () => { + const id = editIdRef.value; + + if (!id) return; + const resposta = window.confirm( 'Você tem certeza de que deseja deletar esse ambiente?' ); if (resposta) { - await apiClient.ambientes.ambienteDeleteById({ id: editIdRef.value }); + await apiClient.ambientes.ambienteDeleteById({ id: id }); await queryClient.invalidateQueries({ queryKey: ['ambientes'] }); $emit('close'); } diff --git a/components/Section/Ambientes/Modal/Modal.vue b/components/Section/Ambientes/Modal/Modal.vue index db54ee2..3884e3f 100644 --- a/components/Section/Ambientes/Modal/Modal.vue +++ b/components/Section/Ambientes/Modal/Modal.vue @@ -1,14 +1,18 @@ diff --git a/components/Section/Diarios/Grid/Item/Item.vue b/components/Section/Diarios/Grid/Item/Item.vue index 1068fb3..b666e14 100644 --- a/components/Section/Diarios/Grid/Item/Item.vue +++ b/components/Section/Diarios/Grid/Item/Item.vue @@ -1,15 +1,21 @@ - @@ -31,7 +37,7 @@ const { diarioProfessorList } = await useApiDiariosProfessorFindAllByDiarioId({ Professores: