|
|
@@ -78,10 +78,17 @@
|
|
|
</template>
|
|
|
</DefaultInput>
|
|
|
|
|
|
- <!-- Instrutor -->
|
|
|
- <DefaultInput
|
|
|
+ <!-- Instrutor (Neurotrainer da unidade) -->
|
|
|
+ <DefaultSelect
|
|
|
v-model="form.instructor"
|
|
|
- label="Nome do Instrutor"
|
|
|
+ label="Neurotrainer"
|
|
|
+ :options="instructorOptions"
|
|
|
+ option-value="name"
|
|
|
+ option-label="name"
|
|
|
+ emit-value
|
|
|
+ map-options
|
|
|
+ clearable
|
|
|
+ :loading="loadingInstructors"
|
|
|
class="col-6"
|
|
|
/>
|
|
|
|
|
|
@@ -130,6 +137,7 @@ import DefaultInputDatePicker from "src/components/defaults/DefaultInputDatePick
|
|
|
|
|
|
import { createClass, updateClass } from "src/api/class";
|
|
|
import { getUnitPackages } from "src/api/package";
|
|
|
+import { getUsersByUnit } from "src/api/user";
|
|
|
|
|
|
defineEmits([...useDialogPluginComponent.emits]);
|
|
|
|
|
|
@@ -148,6 +156,8 @@ const formRef = ref(null);
|
|
|
const saving = ref(false);
|
|
|
const loadingPackages = ref(false);
|
|
|
const packageOptions = ref([]);
|
|
|
+const loadingInstructors = ref(false);
|
|
|
+const instructorOptions = ref([]);
|
|
|
|
|
|
const toDisplay = (isoDate) =>
|
|
|
isoDate ? isoDate.split("-").reverse().join("/") : null;
|
|
|
@@ -174,6 +184,20 @@ const loadPackages = async () => {
|
|
|
}
|
|
|
};
|
|
|
|
|
|
+const loadInstructors = async () => {
|
|
|
+ loadingInstructors.value = true;
|
|
|
+ try {
|
|
|
+ const users = await getUsersByUnit();
|
|
|
+ instructorOptions.value = (users ?? []).filter(
|
|
|
+ (u) => u.user_type === "NEUROTRAINER",
|
|
|
+ );
|
|
|
+ } catch (e) {
|
|
|
+ console.error("Erro ao carregar neurotrainers:", e);
|
|
|
+ } finally {
|
|
|
+ loadingInstructors.value = false;
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
const onSubmit = async () => {
|
|
|
const valid = await formRef.value.validate();
|
|
|
if (!valid) return;
|
|
|
@@ -203,5 +227,8 @@ const onSubmit = async () => {
|
|
|
}
|
|
|
};
|
|
|
|
|
|
-onMounted(loadPackages);
|
|
|
+onMounted(() => {
|
|
|
+ loadPackages();
|
|
|
+ loadInstructors();
|
|
|
+});
|
|
|
</script>
|