diff --git a/ui/.env.example b/ui/.env.example index becdf99..57810b0 100644 --- a/ui/.env.example +++ b/ui/.env.example @@ -1,5 +1,6 @@ # SITE SETTINGS VITE_APIHOST= +VITE_DOCHOST= # https://bookstack.whatever.com/api VITE_ENVIRONMENT= # dev / prod # Glitchtip diff --git a/ui/src/api/loa.ts b/ui/src/api/loa.ts index 93168cb..f21f7d7 100644 --- a/ui/src/api/loa.ts +++ b/ui/src/api/loa.ts @@ -87,4 +87,22 @@ export async function getLoaTypes(): Promise { } else { return null; } +}; + +export async function getLoaPolicy(): Promise { + //@ts-ignore + const res = await fetch(`${import.meta.env.VITE_DOCHOST}/api/pages/42`, { + method: "GET", + credentials: 'include', + }); + if (res.ok) { + const out = res.json(); + console.log(out); + if (!out) { + return null; + } + return out; + } else { + return null; + } } \ No newline at end of file diff --git a/ui/src/components/loa/loaForm.vue b/ui/src/components/loa/loaForm.vue index cc7f050..09f7a49 100644 --- a/ui/src/components/loa/loaForm.vue +++ b/ui/src/components/loa/loaForm.vue @@ -17,11 +17,10 @@ import type { Ref } from "vue" import Popover from "@/components/ui/popover/Popover.vue"; import PopoverTrigger from "@/components/ui/popover/PopoverTrigger.vue"; import PopoverContent from "@/components/ui/popover/PopoverContent.vue"; -import { RangeCalendar } from "@/components/ui/range-calendar" import { cn } from "@/lib/utils"; import { CalendarIcon } from "lucide-vue-next" import Textarea from "@/components/ui/textarea/Textarea.vue"; -import { getLoaTypes, submitLOA } from "@/api/loa"; // <-- import the submit function +import { getLoaPolicy, getLoaTypes, submitLOA } from "@/api/loa"; // <-- import the submit function import { LOARequest, LOAType } from "@shared/types/loa"; import { useForm, Field as VeeField } from "vee-validate"; import { @@ -41,6 +40,7 @@ import FieldError from "../ui/field/FieldError.vue"; const members = ref([]) const loaTypes = ref(); +const policyString = ref(null); const currentMember = ref(null); @@ -63,7 +63,6 @@ const df = new Intl.DateTimeFormat('en-US', { import { loaSchema } from '@shared/schemas/loaSchema' import { toTypedSchema } from "@vee-validate/zod"; import Calendar from "../ui/calendar/Calendar.vue"; -import { el } from "@fullcalendar/core/internal-common"; const { handleSubmit, values, resetForm } = useForm({ validationSchema: toTypedSchema(loaSchema), @@ -81,11 +80,15 @@ onMounted(async () => { if (props.member) { currentMember.value = props.member; } + if (!props.adminMode) { + policyString.value = await getLoaPolicy(); + } members.value = await getMembers(); loaTypes.value = await getLoaTypes(); console.log(currentMember.value); resetForm({ values: { member_id: currentMember.value?.member_id } }); }); + const defaultPlaceholder = today(getLocalTimeZone()) const minEndDate = computed(() => {