hooked up new LOA creation system
This commit is contained in:
@@ -11,6 +11,7 @@ router.post("/", async (req: Request, res: Response) => {
|
||||
let LOARequest = req.body as LOARequest;
|
||||
LOARequest.member_id = req.user.id;
|
||||
LOARequest.created_by = req.user.id;
|
||||
LOARequest.filed_date = new Date();
|
||||
|
||||
console.log(LOARequest);
|
||||
|
||||
@@ -27,6 +28,7 @@ router.post("/", async (req: Request, res: Response) => {
|
||||
router.post("/admin", async (req: Request, res: Response) => {
|
||||
let LOARequest = req.body as LOARequest;
|
||||
LOARequest.created_by = req.user.id;
|
||||
LOARequest.filed_date = new Date();
|
||||
|
||||
console.log(LOARequest);
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { toDateTime } from "@app/shared/utils/time";
|
||||
import pool from "../db";
|
||||
import { LOARequest, LOAType } from '@app/shared/types/loa'
|
||||
|
||||
@@ -24,6 +25,6 @@ export async function createNewLOA(data: LOARequest) {
|
||||
const sql = `INSERT INTO leave_of_absences
|
||||
(member_id, filed_date, start_date, end_date, type_id, reason)
|
||||
VALUES (?, ?, ?, ?, ?, ?)`;
|
||||
await pool.query(sql, [data.member_id, data.filed_date, data.start_date, data.end_date, data.type_id, data.reason])
|
||||
await pool.query(sql, [data.member_id, toDateTime(data.filed_date), toDateTime(data.start_date), toDateTime(data.end_date), data.type_id, data.reason])
|
||||
return;
|
||||
}
|
||||
@@ -1,10 +1,10 @@
|
||||
export interface LOARequest {
|
||||
id?: number;
|
||||
member_id?: number;
|
||||
filed_date?: string; // ISO 8601 string
|
||||
start_date: string; // ISO 8601 string
|
||||
end_date: string; // ISO 8601 string
|
||||
extended_till?: string;
|
||||
filed_date?: Date; // ISO 8601 string
|
||||
start_date: Date; // ISO 8601 string
|
||||
end_date: Date; // ISO 8601 string
|
||||
extended_till?: Date;
|
||||
type_id?: number;
|
||||
reason?: string;
|
||||
expired?: boolean;
|
||||
|
||||
@@ -20,7 +20,7 @@ import PopoverContent from "@/components/ui/popover/PopoverContent.vue";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { CalendarIcon } from "lucide-vue-next"
|
||||
import Textarea from "@/components/ui/textarea/Textarea.vue";
|
||||
import { getLoaPolicy, getLoaTypes, submitLOA } from "@/api/loa"; // <-- import the submit function
|
||||
import { adminSubmitLOA, 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 {
|
||||
@@ -68,8 +68,20 @@ const { handleSubmit, values, resetForm } = useForm({
|
||||
validationSchema: toTypedSchema(loaSchema),
|
||||
})
|
||||
|
||||
const onSubmit = handleSubmit((values) => {
|
||||
const onSubmit = handleSubmit(async (values) => {
|
||||
console.log(values);
|
||||
const out: LOARequest = {
|
||||
member_id: values.member_id,
|
||||
start_date: values.start_date,
|
||||
end_date: values.end_date,
|
||||
type_id: values.type.id,
|
||||
reason: values.reason
|
||||
};
|
||||
if (props.adminMode) {
|
||||
await adminSubmitLOA(out);
|
||||
} else {
|
||||
await submitLOA(out);
|
||||
}
|
||||
})
|
||||
|
||||
onMounted(async () => {
|
||||
|
||||
@@ -28,18 +28,6 @@ const showLOADialog = ref(false);
|
||||
<LoaForm :admin-mode="true" class="my-3"></LoaForm>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
<!-- <Dialog v-model:open="showLOADialog" v-on:update:open="showLOADialog = false">
|
||||
<DialogContent class="max-w-full">
|
||||
<DialogHeader>
|
||||
<DialogTitle>Are you absolutely sure?</DialogTitle>
|
||||
<DialogDescription>
|
||||
This action cannot be undone. This will permanently delete your account
|
||||
and remove your data from our servers.
|
||||
</DialogDescription>
|
||||
</DialogHeader>
|
||||
</DialogContent>
|
||||
</Dialog> -->
|
||||
|
||||
<div class="max-w-5xl mx-auto pt-10">
|
||||
<div class="flex justify-end mb-4">
|
||||
<Button @click="showLOADialog = true">Post LOA</Button>
|
||||
|
||||
Reference in New Issue
Block a user