Compare commits
20 Commits
Onboarding
...
LOA-Upgrad
| Author | SHA1 | Date | |
|---|---|---|---|
| 7ab06b6a4c | |||
| 9d217aafaf | |||
| 87c472e98e | |||
| dcb4720129 | |||
| 8cdbb99d6f | |||
| 2821bc62c4 | |||
| dd472a5283 | |||
| 92c0d657ea | |||
| 62defe5b6d | |||
| 468fd30514 | |||
| 1f52a2c4f7 | |||
| dccdaddd20 | |||
| 1a80bfc543 | |||
| 2185ffc746 | |||
| c04a2b06cb | |||
| 98138f51f4 | |||
| 5a7b3ba2ab | |||
| 2de6b18135 | |||
| aedcbd9492 | |||
| f985e0234c |
@@ -1,6 +1,8 @@
|
||||
name: Continuous Deployment
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
Deploy:
|
||||
@@ -8,7 +10,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
volumes:
|
||||
- /var/www/html/milsim-site-v4:/var/www/html/milsim-site-v4:rw
|
||||
- /var/www/html/milsim-site-v4:/var/www/html/milsim-site-v4:z
|
||||
steps:
|
||||
- name: Setup Local Environment
|
||||
run: |
|
||||
@@ -17,7 +19,9 @@ jobs:
|
||||
|
||||
- name: Verify Node Environment
|
||||
run: |
|
||||
which npm
|
||||
npm -v
|
||||
which node
|
||||
node -v
|
||||
|
||||
- name: Checkout
|
||||
@@ -39,24 +43,31 @@ jobs:
|
||||
|
||||
- name: Update Application Code
|
||||
run: |
|
||||
sudo -u nginx bash -c "cd /var/www/html/milsim-site-v4 && git reset --hard && git pull origin main"
|
||||
cd /var/www/html/milsim-site-v4
|
||||
sudo -u nginx git reset --hard
|
||||
sudo -u nginx git pull origin main
|
||||
|
||||
- name: Update Shared Dependencies
|
||||
run: |
|
||||
sudo -u nginx bash -c "cd /var/www/html/milsim-site-v4/shared && npm install"
|
||||
cd /var/www/html/milsim-site-v4/shared
|
||||
sudo -u nginx -E npm install
|
||||
|
||||
- name: Update UI Dependencies
|
||||
run: |
|
||||
sudo -u nginx bash -c "cd /var/www/html/milsim-site-v4/ui && npm install"
|
||||
cd /var/www/html/milsim-site-v4/ui
|
||||
sudo -u nginx -E npm install
|
||||
|
||||
- name: Update API Dependencies
|
||||
run: |
|
||||
sudo -u nginx bash -c "cd /var/www/html/milsim-site-v4/api && npm install"
|
||||
cd /var/www/html/milsim-site-v4/api
|
||||
sudo -u nginx -E npm install
|
||||
|
||||
- name: Build UI
|
||||
run: |
|
||||
sudo -u nginx bash -c "cd /var/www/html/milsim-site-v4/ui && npm run build"
|
||||
cd /var/www/html/milsim-site-v4/ui
|
||||
sudo -u nginx -E npm run build
|
||||
|
||||
- name: Build API
|
||||
run: |
|
||||
sudo -u nginx bash -c "cd /var/www/html/milsim-site-v4/api && npm run build"
|
||||
cd /var/www/html/milsim-site-v4/api
|
||||
sudo -u nginx -E npm run build
|
||||
|
||||
@@ -20,8 +20,8 @@ const port = process.env.SERVER_PORT;
|
||||
|
||||
//glitchtip setup
|
||||
const sentry = require('@sentry/node');
|
||||
if (!process.env.DISABLE_GLITCHTIP) {
|
||||
console.log("Glitchtip disabled AAAAAA")
|
||||
if (process.env.DISABLE_GLITCHTIP) {
|
||||
console.log("Glitchtip disabled")
|
||||
} else {
|
||||
let dsn = process.env.GLITCHTIP_DSN;
|
||||
sentry.init({ dsn: dsn });
|
||||
|
||||
@@ -1,56 +0,0 @@
|
||||
const express = require('express');
|
||||
const router = express.Router();
|
||||
|
||||
import pool from '../db';
|
||||
|
||||
//post a new LOA
|
||||
router.post("/", async (req, res) => {
|
||||
const { member_id, filed_date, start_date, end_date, reason } = req.body;
|
||||
|
||||
if (!member_id || !filed_date || !start_date || !end_date) {
|
||||
return res.status(400).json({ error: "Missing required fields" });
|
||||
}
|
||||
|
||||
try {
|
||||
const result = await pool.query(
|
||||
`INSERT INTO leave_of_absences
|
||||
(member_id, filed_date, start_date, end_date, reason)
|
||||
VALUES (?, ?, ?, ?, ?)`,
|
||||
[member_id, filed_date, start_date, end_date, reason]
|
||||
);
|
||||
res.sendStatus(201);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
res.status(500).send('Something went wrong', error);
|
||||
}
|
||||
});
|
||||
|
||||
//get my current LOA
|
||||
router.get("/me", async (req, res) => {
|
||||
//TODO: implement current user getter
|
||||
const user = 89;
|
||||
|
||||
try {
|
||||
const result = await pool.query("SELECT * FROM leave_of_absences WHERE member_id = ?", [user])
|
||||
res.status(200).json(result)
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
res.status(500).send(error);
|
||||
}
|
||||
})
|
||||
|
||||
router.get('/all', async (req, res) => {
|
||||
try {
|
||||
const result = await pool.query(
|
||||
`SELECT loa.*, members.name
|
||||
FROM leave_of_absences AS loa
|
||||
INNER JOIN members ON loa.member_id = members.id;
|
||||
`);
|
||||
res.status(200).json(result)
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
res.status(500).send(error);
|
||||
}
|
||||
})
|
||||
|
||||
module.exports = router;
|
||||
76
api/src/routes/loa.ts
Normal file
76
api/src/routes/loa.ts
Normal file
@@ -0,0 +1,76 @@
|
||||
const express = require('express');
|
||||
const router = express.Router();
|
||||
|
||||
import { Request, Response } from 'express';
|
||||
import pool from '../db';
|
||||
import { createNewLOA, getAllLOA, getLoaTypes, getUserLOA } from '../services/loaService';
|
||||
import { LOARequest } from '@app/shared/types/loa';
|
||||
|
||||
//member posts LOA
|
||||
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);
|
||||
|
||||
try {
|
||||
await createNewLOA(LOARequest);
|
||||
res.sendStatus(201);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
res.status(500).send(error);
|
||||
}
|
||||
});
|
||||
|
||||
//admin posts LOA
|
||||
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);
|
||||
|
||||
try {
|
||||
await createNewLOA(LOARequest);
|
||||
res.sendStatus(201);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
res.status(500).send(error);
|
||||
}
|
||||
});
|
||||
|
||||
//get my current LOA
|
||||
router.get("/me", async (req: Request, res: Response) => {
|
||||
const user = req.user.id;
|
||||
try {
|
||||
const result = await getUserLOA(user);
|
||||
res.status(200).json(result)
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
res.status(500).send(error);
|
||||
}
|
||||
})
|
||||
|
||||
router.get('/all', async (req, res) => {
|
||||
try {
|
||||
const result = await getAllLOA();
|
||||
res.status(200).json(result)
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
res.status(500).send(error);
|
||||
}
|
||||
})
|
||||
|
||||
router.get('/types', async (req: Request, res: Response) => {
|
||||
try {
|
||||
let out = await getLoaTypes();
|
||||
res.status(200).json(out);
|
||||
} catch (error) {
|
||||
res.status(500).json(error);
|
||||
console.error(error);
|
||||
}
|
||||
})
|
||||
|
||||
module.exports = router;
|
||||
30
api/src/services/loaService.ts
Normal file
30
api/src/services/loaService.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import { toDateTime } from "@app/shared/utils/time";
|
||||
import pool from "../db";
|
||||
import { LOARequest, LOAType } from '@app/shared/types/loa'
|
||||
|
||||
export async function getLoaTypes(): Promise<LOAType[]> {
|
||||
return await pool.query('SELECT * FROM leave_of_absences_types;');
|
||||
}
|
||||
|
||||
export async function getAllLOA(): Promise<LOARequest[]> {
|
||||
let res: LOARequest[] = await pool.query(
|
||||
`SELECT loa.*, members.name, t.name AS type_name
|
||||
FROM leave_of_absences AS loa
|
||||
LEFT JOIN members ON loa.member_id = members.id
|
||||
LEFT JOIN leave_of_absences_types AS t ON loa.type_id = t.id;
|
||||
`) as LOARequest[];
|
||||
return res;
|
||||
}
|
||||
|
||||
export async function getUserLOA(userId: number): Promise<LOARequest[]> {
|
||||
const result: LOARequest[] = await pool.query("SELECT * FROM leave_of_absences WHERE member_id = ?", [userId])
|
||||
return result;
|
||||
}
|
||||
|
||||
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, toDateTime(data.filed_date), toDateTime(data.start_date), toDateTime(data.end_date), data.type_id, data.reason])
|
||||
return;
|
||||
}
|
||||
51
shared/schemas/loaSchema.ts
Normal file
51
shared/schemas/loaSchema.ts
Normal file
@@ -0,0 +1,51 @@
|
||||
import * as z from "zod";
|
||||
import { LOAType } from "../types/loa";
|
||||
|
||||
export const loaTypeSchema = z.object({
|
||||
id: z.number(),
|
||||
name: z.string(),
|
||||
max_length_days: z.number(),
|
||||
});
|
||||
|
||||
export const loaSchema = z.object({
|
||||
member_id: z.number(),
|
||||
start_date: z.date(),
|
||||
end_date: z.date(),
|
||||
type: loaTypeSchema,
|
||||
reason: z.string(),
|
||||
})
|
||||
.superRefine((data, ctx) => {
|
||||
const { start_date, end_date, type } = data;
|
||||
|
||||
const today = new Date();
|
||||
today.setHours(0, 0, 0, 0);
|
||||
|
||||
if (start_date < today) {
|
||||
ctx.addIssue({
|
||||
code: z.ZodIssueCode.custom,
|
||||
path: ["start_date"],
|
||||
message: "Start date cannot be in the past.",
|
||||
});
|
||||
}
|
||||
|
||||
// 1. end > start
|
||||
if (end_date <= start_date) {
|
||||
ctx.addIssue({
|
||||
code: z.ZodIssueCode.custom,
|
||||
path: ["end_date"],
|
||||
message: "End date must be after start date.",
|
||||
});
|
||||
}
|
||||
|
||||
// 2. calculate max
|
||||
const maxEnd = new Date(start_date);
|
||||
maxEnd.setDate(maxEnd.getDate() + type.max_length_days);
|
||||
|
||||
if (end_date > maxEnd) {
|
||||
ctx.addIssue({
|
||||
code: z.ZodIssueCode.custom,
|
||||
path: ["end_date"],
|
||||
message: `This LOA type allows a maximum of ${type.max_length_days} days.`,
|
||||
});
|
||||
}
|
||||
});
|
||||
24
shared/types/loa.ts
Normal file
24
shared/types/loa.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
export interface LOARequest {
|
||||
id?: number;
|
||||
member_id?: number;
|
||||
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;
|
||||
closed?: boolean;
|
||||
closed_by?: number;
|
||||
created_by?: number;
|
||||
|
||||
name?: string; //member name
|
||||
type_name?: string;
|
||||
};
|
||||
|
||||
export interface LOAType {
|
||||
id: number;
|
||||
name: string;
|
||||
max_length_days: number;
|
||||
extendable: boolean;
|
||||
}
|
||||
@@ -1,5 +1,8 @@
|
||||
export function toDateTime(date: Date): string {
|
||||
console.log(date);
|
||||
if (typeof date === 'string') {
|
||||
date = new Date(date);
|
||||
}
|
||||
// This produces a CST-local time because server runs in CST
|
||||
const year = date.getFullYear();
|
||||
const month = (date.getMonth() + 1).toString().padStart(2, "0");
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
# SITE SETTINGS
|
||||
VITE_APIHOST=
|
||||
VITE_DOCHOST= # https://bookstack.whatever.com/api
|
||||
VITE_ENVIRONMENT= # dev / prod
|
||||
|
||||
# Glitchtip
|
||||
|
||||
@@ -22,18 +22,20 @@ const environment = import.meta.env.VITE_ENVIRONMENT;
|
||||
|
||||
<template>
|
||||
<div class="flex flex-col min-h-screen">
|
||||
<Navbar class="flex"></Navbar>
|
||||
<Alert v-if="environment == 'dev'" class="m-2 mx-auto w-5xl" variant="info">
|
||||
<AlertDescription class="flex flex-row items-center text-nowrap gap-5 mx-auto">
|
||||
<p>This is a development build of the application. Some features will be unavailable or unstable.</p>
|
||||
</AlertDescription>
|
||||
</Alert>
|
||||
<Alert v-if="userStore.user?.loa?.[0]" class="m-2 mx-auto w-5xl" variant="info">
|
||||
<AlertDescription class="flex flex-row items-center text-nowrap gap-5 mx-auto">
|
||||
<p>You are on LOA until <strong>{{ formatDate(userStore.user?.loa?.[0].end_date) }}</strong></p>
|
||||
<Button variant="secondary">End LOA</Button>
|
||||
</AlertDescription>
|
||||
</Alert>
|
||||
<div class="sticky top-0 bg-background z-50">
|
||||
<Navbar class="flex"></Navbar>
|
||||
<Alert v-if="environment == 'dev'" class="m-2 mx-auto w-5xl" variant="info">
|
||||
<AlertDescription class="flex flex-row items-center text-nowrap gap-5 mx-auto">
|
||||
<p>This is a development build of the application. Some features will be unavailable or unstable.</p>
|
||||
</AlertDescription>
|
||||
</Alert>
|
||||
<Alert v-if="userStore.user?.loa?.[0]" class="m-2 mx-auto w-5xl" variant="info">
|
||||
<AlertDescription class="flex flex-row items-center text-nowrap gap-5 mx-auto">
|
||||
<p>You are on LOA until <strong>{{ formatDate(userStore.user?.loa?.[0].end_date) }}</strong></p>
|
||||
<Button variant="secondary">End LOA</Button>
|
||||
</AlertDescription>
|
||||
</Alert>
|
||||
</div>
|
||||
|
||||
<RouterView class="flex-1 min-h-0"></RouterView>
|
||||
</div>
|
||||
|
||||
@@ -1,12 +1,4 @@
|
||||
export type LOARequest = {
|
||||
id?: number;
|
||||
name?: string;
|
||||
member_id: number;
|
||||
filed_date: string; // ISO 8601 string
|
||||
start_date: string; // ISO 8601 string
|
||||
end_date: string; // ISO 8601 string
|
||||
reason?: string;
|
||||
};
|
||||
import { LOARequest, LOAType } from '@shared/types/loa'
|
||||
// @ts-ignore
|
||||
const addr = import.meta.env.VITE_APIHOST;
|
||||
|
||||
@@ -17,6 +9,7 @@ export async function submitLOA(request: LOARequest): Promise<{ id?: number; err
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify(request),
|
||||
credentials: 'include',
|
||||
});
|
||||
|
||||
if (res.ok) {
|
||||
@@ -26,6 +19,24 @@ export async function submitLOA(request: LOARequest): Promise<{ id?: number; err
|
||||
}
|
||||
}
|
||||
|
||||
export async function adminSubmitLOA(request: LOARequest): Promise<{ id?: number; error?: string }> {
|
||||
const res = await fetch(`${addr}/loa/admin`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify(request),
|
||||
credentials: 'include',
|
||||
});
|
||||
|
||||
if (res.ok) {
|
||||
return res.json();
|
||||
} else {
|
||||
return { error: "Failed to submit LOA" };
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export async function getMyLOA(): Promise<LOARequest | null> {
|
||||
const res = await fetch(`${addr}/loa/me`, {
|
||||
method: "GET",
|
||||
@@ -60,3 +71,38 @@ export function getAllLOAs(): Promise<LOARequest[]> {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export async function getLoaTypes(): Promise<LOAType[]> {
|
||||
const res = await fetch(`${addr}/loa/types`, {
|
||||
method: "GET",
|
||||
credentials: 'include',
|
||||
});
|
||||
|
||||
if (res.ok) {
|
||||
const out = res.json();
|
||||
if (!out) {
|
||||
return null;
|
||||
}
|
||||
return out;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
export async function getLoaPolicy(): Promise<string> {
|
||||
//@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;
|
||||
}
|
||||
}
|
||||
@@ -1,26 +1,47 @@
|
||||
<script setup lang="ts">
|
||||
import { Check, Search } from "lucide-vue-next"
|
||||
import { Combobox, ComboboxAnchor, ComboboxEmpty, ComboboxGroup, ComboboxInput, ComboboxItem, ComboboxItemIndicator, ComboboxList } from "@/components/ui/combobox"
|
||||
import { onMounted, ref } from "vue";
|
||||
import { ComboboxAnchor, ComboboxEmpty, ComboboxGroup, ComboboxInput, ComboboxItem, ComboboxItemIndicator, ComboboxList } from "@/components/ui/combobox"
|
||||
import { computed, onMounted, ref, watch } from "vue";
|
||||
import { Member, getMembers } from "@/api/member";
|
||||
import Button from "@/components/ui/button/Button.vue";
|
||||
import {
|
||||
CalendarDate,
|
||||
DateFormatter,
|
||||
fromDate,
|
||||
getLocalTimeZone,
|
||||
parseDate,
|
||||
today,
|
||||
} from "@internationalized/date"
|
||||
import type { DateRange } from "reka-ui"
|
||||
import type { DateRange, DateValue } from "reka-ui"
|
||||
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 { LOARequest, 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 {
|
||||
Field,
|
||||
FieldContent,
|
||||
FieldDescription,
|
||||
FieldGroup,
|
||||
FieldLabel,
|
||||
} from '@/components/ui/field'
|
||||
import Combobox from "../ui/combobox/Combobox.vue";
|
||||
import Select from "../ui/select/Select.vue";
|
||||
import SelectTrigger from "../ui/select/SelectTrigger.vue";
|
||||
import SelectValue from "../ui/select/SelectValue.vue";
|
||||
import SelectContent from "../ui/select/SelectContent.vue";
|
||||
import SelectItem from "../ui/select/SelectItem.vue";
|
||||
import FieldError from "../ui/field/FieldError.vue";
|
||||
|
||||
const members = ref<Member[]>([])
|
||||
const loaTypes = ref<LOAType[]>();
|
||||
const policyString = ref<string | null>(null);
|
||||
|
||||
const currentMember = ref<Member | null>(null);
|
||||
|
||||
const props = withDefaults(defineProps<{
|
||||
@@ -31,73 +52,73 @@ const props = withDefaults(defineProps<{
|
||||
member: null,
|
||||
});
|
||||
|
||||
const df = new Intl.DateTimeFormat('en-US', {
|
||||
year: 'numeric',
|
||||
month: 'long',
|
||||
day: 'numeric'
|
||||
});
|
||||
|
||||
const df = new DateFormatter("en-US", {
|
||||
dateStyle: "medium",
|
||||
|
||||
//form stuff
|
||||
import { loaSchema } from '@shared/schemas/loaSchema'
|
||||
import { toTypedSchema } from "@vee-validate/zod";
|
||||
import Calendar from "../ui/calendar/Calendar.vue";
|
||||
|
||||
const { handleSubmit, values, resetForm } = useForm({
|
||||
validationSchema: toTypedSchema(loaSchema),
|
||||
})
|
||||
|
||||
const value = ref({
|
||||
// start: new CalendarDate(2022, 1, 20),
|
||||
// end: new CalendarDate(2022, 1, 20).add({ days: 20 }),
|
||||
}) as Ref<DateRange>
|
||||
|
||||
const reason = ref(""); // <-- reason for LOA
|
||||
const submitting = ref(false);
|
||||
const submitError = ref<string | null>(null);
|
||||
const submitSuccess = ref(false);
|
||||
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 () => {
|
||||
if (props.member) {
|
||||
currentMember.value = props.member;
|
||||
}
|
||||
if (props.adminMode) {
|
||||
members.value = await getMembers();
|
||||
try {
|
||||
if (!props.adminMode) {
|
||||
policyString.value = await getLoaPolicy();
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
|
||||
members.value = await getMembers();
|
||||
loaTypes.value = await getLoaTypes();
|
||||
resetForm({ values: { member_id: currentMember.value?.member_id } });
|
||||
});
|
||||
|
||||
// Submit handler
|
||||
async function handleSubmit() {
|
||||
submitError.value = null;
|
||||
submitSuccess.value = false;
|
||||
submitting.value = true;
|
||||
const defaultPlaceholder = today(getLocalTimeZone())
|
||||
|
||||
// Use currentMember if adminMode, otherwise use your own member id (stubbed as 89 here)
|
||||
const member_id = currentMember.value?.member_id ?? 89;
|
||||
|
||||
// Format dates as ISO strings
|
||||
const filed_date = toMariaDBDatetime(new Date());
|
||||
const start_date = toMariaDBDatetime(value.value.start?.toDate(getLocalTimeZone()));
|
||||
const end_date = toMariaDBDatetime(value.value.end?.toDate(getLocalTimeZone()));
|
||||
|
||||
if (!member_id || !filed_date || !start_date || !end_date) {
|
||||
submitError.value = "Missing required fields";
|
||||
submitting.value = false;
|
||||
return;
|
||||
}
|
||||
|
||||
const req: LOARequest = {
|
||||
filed_date,
|
||||
start_date,
|
||||
end_date,
|
||||
reason: reason.value,
|
||||
member_id
|
||||
};
|
||||
|
||||
const result = await submitLOA(req);
|
||||
submitting.value = false;
|
||||
|
||||
if (result.id) {
|
||||
submitSuccess.value = true;
|
||||
reason.value = "";
|
||||
const minEndDate = computed(() => {
|
||||
if (values.start_date) {
|
||||
return new CalendarDate(values.start_date.getFullYear(), values.start_date.getMonth() + 1, values.start_date.getDate())
|
||||
} else {
|
||||
submitError.value = result.error || "Failed to submit LOA";
|
||||
return null;
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
function toMariaDBDatetime(date: Date): string {
|
||||
return date.toISOString().slice(0, 19).replace('T', ' ');
|
||||
}
|
||||
const maxEndDate = computed(() => {
|
||||
if (values.type && values.start_date) {
|
||||
let endDateObj = new Date(values.start_date.getTime() + values.type.max_length_days * 24 * 60 * 60 * 1000);
|
||||
return new CalendarDate(endDateObj.getFullYear(), endDateObj.getMonth() + 1, endDateObj.getDate())
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -113,60 +134,141 @@ function toMariaDBDatetime(date: Date): string {
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex-1 flex flex-col gap-5">
|
||||
<div class="flex w-full gap-5 ">
|
||||
<Combobox class="w-1/2" v-model="currentMember" :disabled="!adminMode">
|
||||
<ComboboxAnchor class="w-full">
|
||||
<ComboboxInput placeholder="Search members..." class="w-full pl-9"
|
||||
:display-value="(v) => v ? v.member_name : ''" />
|
||||
</ComboboxAnchor>
|
||||
<ComboboxList class="w-full">
|
||||
<ComboboxEmpty class="text-muted-foreground">No results</ComboboxEmpty>
|
||||
<ComboboxGroup>
|
||||
<template v-for="member in members" :key="member.member_id">
|
||||
<ComboboxItem :value="member"
|
||||
class="data-[highlighted]:bg-accent data-[highlighted]:text-accent-foreground relative cursor-pointer select-none px-2 py-1.5">
|
||||
{{ member.member_name }}
|
||||
<ComboboxItemIndicator class="absolute left-2 inline-flex items-center">
|
||||
<Check class="h-4 w-4" />
|
||||
</ComboboxItemIndicator>
|
||||
</ComboboxItem>
|
||||
</template>
|
||||
</ComboboxGroup>
|
||||
</ComboboxList>
|
||||
</Combobox>
|
||||
<Popover>
|
||||
<PopoverTrigger as-child>
|
||||
<Button variant="outline" :class="cn(
|
||||
'w-1/2 justify-start text-left font-normal',
|
||||
!value && 'text-muted-foreground',
|
||||
)">
|
||||
<CalendarIcon class="mr-2 h-4 w-4" />
|
||||
<template v-if="value.start">
|
||||
<template v-if="value.end">
|
||||
{{ df.format(value.start.toDate(getLocalTimeZone())) }} - {{
|
||||
df.format(value.end.toDate(getLocalTimeZone())) }}
|
||||
</template>
|
||||
<template v-else>
|
||||
{{ df.format(value.start.toDate(getLocalTimeZone())) }}
|
||||
</template>
|
||||
</template>
|
||||
<template v-else>
|
||||
Pick a date
|
||||
</template>
|
||||
</Button>
|
||||
</PopoverTrigger>
|
||||
<PopoverContent class="w-auto p-0">
|
||||
<RangeCalendar v-model="value" initial-focus :number-of-months="2"
|
||||
@update:start-value="(startDate) => value.start = startDate" />
|
||||
</PopoverContent>
|
||||
</Popover>
|
||||
</div>
|
||||
<Textarea v-model="reason" placeholder="Reason for LOA" class="w-full resize-none" />
|
||||
<div class="flex justify-end">
|
||||
<Button :onClick="handleSubmit" :disabled="submitting" class="w-min">Submit</Button>
|
||||
</div>
|
||||
<div v-if="submitError" class="text-red-500 text-sm mt-2">{{ submitError }}</div>
|
||||
<div v-if="submitSuccess" class="text-green-500 text-sm mt-2">LOA submitted successfully!</div>
|
||||
<form @submit="onSubmit" class="flex flex-col gap-2">
|
||||
<div class="flex w-full gap-5">
|
||||
<VeeField v-slot="{ field, errors }" name="member_id">
|
||||
<Field>
|
||||
<FieldContent>
|
||||
<FieldLabel>Member</FieldLabel>
|
||||
<Combobox :model-value="field.value" @update:model-value="field.onChange"
|
||||
:disabled="!adminMode">
|
||||
<ComboboxAnchor class="w-full">
|
||||
<ComboboxInput placeholder="Search members..." class="w-full pl-3"
|
||||
:display-value="(id) => {
|
||||
const m = members.find(mem => mem.member_id === id)
|
||||
return m ? m.member_name : ''
|
||||
}" />
|
||||
</ComboboxAnchor>
|
||||
<ComboboxList class="*:w-64">
|
||||
<ComboboxEmpty class="text-muted-foreground w-full">No results</ComboboxEmpty>
|
||||
<ComboboxGroup>
|
||||
<template v-for="member in members" :key="member.member_id">
|
||||
<ComboboxItem :value="member.member_id"
|
||||
class="data-[highlighted]:bg-accent data-[highlighted]:text-accent-foreground relative cursor-pointer select-none px-2 py-1.5 w-full">
|
||||
{{ member.member_name }}
|
||||
<ComboboxItemIndicator
|
||||
class="absolute left-2 inline-flex items-center">
|
||||
<Check class="h-4 w-4" />
|
||||
</ComboboxItemIndicator>
|
||||
</ComboboxItem>
|
||||
</template>
|
||||
</ComboboxGroup>
|
||||
</ComboboxList>
|
||||
</Combobox>
|
||||
<div class="h-4">
|
||||
<FieldError v-if="errors.length" :errors="errors"></FieldError>
|
||||
</div>
|
||||
</FieldContent>
|
||||
</Field>
|
||||
</VeeField>
|
||||
<VeeField v-slot="{ field, errors }" name="type">
|
||||
<Field class="w-full">
|
||||
<FieldContent>
|
||||
<FieldLabel>Type</FieldLabel>
|
||||
<Select :model-value="field.value" @update:model-value="field.onChange">
|
||||
<SelectTrigger class="w-full">
|
||||
<SelectValue></SelectValue>
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem v-for="type in loaTypes" :value="type">
|
||||
{{ type.name }}
|
||||
</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
<div class="h-4">
|
||||
<FieldError v-if="errors.length" :errors="errors"></FieldError>
|
||||
</div>
|
||||
</FieldContent>
|
||||
</Field>
|
||||
</VeeField>
|
||||
</div>
|
||||
<div class="flex gap-5">
|
||||
<VeeField v-slot="{ field, errors }" name="start_date">
|
||||
<Field>
|
||||
<FieldContent>
|
||||
<FieldLabel>Start Date</FieldLabel>
|
||||
<Popover>
|
||||
<PopoverTrigger as-child>
|
||||
<Button variant="outline" :class="cn(
|
||||
'w-[280px] justify-start text-left font-normal',
|
||||
!field.value && 'text-muted-foreground',
|
||||
)">
|
||||
<CalendarIcon class="mr-2 h-4 w-4" />
|
||||
{{ field.value ? df.format(field.value) : "Pick a date" }}
|
||||
</Button>
|
||||
</PopoverTrigger>
|
||||
<PopoverContent class="w-auto p-0">
|
||||
<Calendar
|
||||
:model-value="field.value
|
||||
? new CalendarDate(field.value.getFullYear(), field.value.getMonth() + 1, field.value.getDate()) : null"
|
||||
@update:model-value="(val: CalendarDate) => field.onChange(val.toDate(getLocalTimeZone()))"
|
||||
layout="month-and-year" :min-value="today(getLocalTimeZone())" />
|
||||
</PopoverContent>
|
||||
</Popover>
|
||||
<div class="h-4">
|
||||
<FieldError v-if="errors.length" :errors="errors"></FieldError>
|
||||
</div>
|
||||
</FieldContent>
|
||||
</Field>
|
||||
</VeeField>
|
||||
<VeeField v-slot="{ field, errors }" name="end_date">
|
||||
<Field>
|
||||
<FieldContent>
|
||||
<FieldLabel>End Date</FieldLabel>
|
||||
<Popover>
|
||||
<PopoverTrigger as-child>
|
||||
<Button variant="outline" :class="cn(
|
||||
'w-[280px] justify-start text-left font-normal',
|
||||
!field.value && 'text-muted-foreground',
|
||||
)">
|
||||
<CalendarIcon class="mr-2 h-4 w-4" />
|
||||
{{ field.value ? df.format(field.value) : "Pick a date" }}
|
||||
</Button>
|
||||
</PopoverTrigger>
|
||||
<PopoverContent class="w-auto p-0">
|
||||
<Calendar
|
||||
:model-value="field.value ? new CalendarDate(field.value.getFullYear(), field.value.getMonth() + 1, field.value.getDate()) : null"
|
||||
@update:model-value="(val: CalendarDate) => field.onChange(val.toDate(getLocalTimeZone()))"
|
||||
:default-placeholder="defaultPlaceholder" :min-value="minEndDate"
|
||||
:max-value="maxEndDate" layout="month-and-year">
|
||||
</Calendar>
|
||||
</PopoverContent>
|
||||
</Popover>
|
||||
<div class="h-4">
|
||||
<FieldError v-if="errors.length" :errors="errors"></FieldError>
|
||||
</div>
|
||||
</FieldContent>
|
||||
</Field>
|
||||
</VeeField>
|
||||
</div>
|
||||
<div>
|
||||
<VeeField v-slot="{ field, errors }" name="reason">
|
||||
<Field>
|
||||
<FieldContent>
|
||||
<FieldLabel>Reason</FieldLabel>
|
||||
<Textarea :model-value="field.value" @update:model-value="field.onChange"
|
||||
placeholder="Reason for LOA" class="resize-none h-28"></Textarea>
|
||||
<div class="h-4">
|
||||
<FieldError v-if="errors.length" :errors="errors"></FieldError>
|
||||
</div>
|
||||
</FieldContent>
|
||||
</Field>
|
||||
</VeeField>
|
||||
</div>
|
||||
<div class="flex justify-end">
|
||||
<Button type="submit">Submit</Button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -1,7 +1,14 @@
|
||||
<script setup>
|
||||
import { reactiveOmit } from "@vueuse/core";
|
||||
import { CalendarRoot, useForwardPropsEmits } from "reka-ui";
|
||||
import { getLocalTimeZone, today } from "@internationalized/date";
|
||||
import { createReusableTemplate, reactiveOmit, useVModel } from "@vueuse/core";
|
||||
import { CalendarRoot, useDateFormatter, useForwardPropsEmits } from "reka-ui";
|
||||
import { createYear, createYearRange, toDate } from "reka-ui/date";
|
||||
import { computed, toRaw } from "vue";
|
||||
import { cn } from "@/lib/utils";
|
||||
import {
|
||||
NativeSelect,
|
||||
NativeSelectOption,
|
||||
} from '@/components/ui/native-select';
|
||||
import {
|
||||
CalendarCell,
|
||||
CalendarCellTrigger,
|
||||
@@ -38,34 +45,165 @@ const props = defineProps({
|
||||
dir: { type: String, required: false },
|
||||
nextPage: { type: Function, required: false },
|
||||
prevPage: { type: Function, required: false },
|
||||
modelValue: { type: null, required: false },
|
||||
modelValue: { type: null, required: false, default: undefined },
|
||||
multiple: { type: Boolean, required: false },
|
||||
disableDaysOutsideCurrentView: { type: Boolean, required: false },
|
||||
asChild: { type: Boolean, required: false },
|
||||
as: { type: [String, Object, Function], required: false },
|
||||
as: { type: null, required: false },
|
||||
class: { type: null, required: false },
|
||||
layout: { type: null, required: false, default: undefined },
|
||||
yearRange: { type: Array, required: false },
|
||||
});
|
||||
const emits = defineEmits(["update:modelValue", "update:placeholder"]);
|
||||
|
||||
const delegatedProps = reactiveOmit(props, "class");
|
||||
const delegatedProps = reactiveOmit(props, "class", "layout", "placeholder");
|
||||
|
||||
const placeholder = useVModel(props, "placeholder", emits, {
|
||||
passive: true,
|
||||
defaultValue: props.defaultPlaceholder ?? today(getLocalTimeZone()),
|
||||
});
|
||||
|
||||
const formatter = useDateFormatter(props.locale ?? "en");
|
||||
|
||||
const yearRange = computed(() => {
|
||||
return (
|
||||
props.yearRange ??
|
||||
createYearRange({
|
||||
start:
|
||||
props?.minValue ??
|
||||
(
|
||||
toRaw(props.placeholder) ??
|
||||
props.defaultPlaceholder ??
|
||||
today(getLocalTimeZone())
|
||||
).cycle("year", -100),
|
||||
|
||||
end:
|
||||
props?.maxValue ??
|
||||
(
|
||||
toRaw(props.placeholder) ??
|
||||
props.defaultPlaceholder ??
|
||||
today(getLocalTimeZone())
|
||||
).cycle("year", 10),
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
const [DefineMonthTemplate, ReuseMonthTemplate] = createReusableTemplate();
|
||||
const [DefineYearTemplate, ReuseYearTemplate] = createReusableTemplate();
|
||||
|
||||
const forwarded = useForwardPropsEmits(delegatedProps, emits);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<DefineMonthTemplate v-slot="{ date }">
|
||||
<div class="**:data-[slot=native-select-icon]:right-1">
|
||||
<div class="relative">
|
||||
<div
|
||||
class="absolute inset-0 flex h-full items-center text-sm pl-2 pointer-events-none"
|
||||
>
|
||||
{{ formatter.custom(toDate(date), { month: "short" }) }}
|
||||
</div>
|
||||
<NativeSelect
|
||||
class="text-xs h-8 pr-6 pl-2 text-transparent relative"
|
||||
@change="
|
||||
(e) => {
|
||||
placeholder = placeholder.set({
|
||||
month: Number(e?.target?.value),
|
||||
});
|
||||
}
|
||||
"
|
||||
>
|
||||
<NativeSelectOption
|
||||
v-for="month in createYear({ dateObj: date })"
|
||||
:key="month.toString()"
|
||||
:value="month.month"
|
||||
:selected="date.month === month.month"
|
||||
>
|
||||
{{ formatter.custom(toDate(month), { month: "short" }) }}
|
||||
</NativeSelectOption>
|
||||
</NativeSelect>
|
||||
</div>
|
||||
</div>
|
||||
</DefineMonthTemplate>
|
||||
|
||||
<DefineYearTemplate v-slot="{ date }">
|
||||
<div class="**:data-[slot=native-select-icon]:right-1">
|
||||
<div class="relative">
|
||||
<div
|
||||
class="absolute inset-0 flex h-full items-center text-sm pl-2 pointer-events-none"
|
||||
>
|
||||
{{ formatter.custom(toDate(date), { year: "numeric" }) }}
|
||||
</div>
|
||||
<NativeSelect
|
||||
class="text-xs h-8 pr-6 pl-2 text-transparent relative"
|
||||
@change="
|
||||
(e) => {
|
||||
placeholder = placeholder.set({
|
||||
year: Number(e?.target?.value),
|
||||
});
|
||||
}
|
||||
"
|
||||
>
|
||||
<NativeSelectOption
|
||||
v-for="year in yearRange"
|
||||
:key="year.toString()"
|
||||
:value="year.year"
|
||||
:selected="date.year === year.year"
|
||||
>
|
||||
{{ formatter.custom(toDate(year), { year: "numeric" }) }}
|
||||
</NativeSelectOption>
|
||||
</NativeSelect>
|
||||
</div>
|
||||
</div>
|
||||
</DefineYearTemplate>
|
||||
|
||||
<CalendarRoot
|
||||
v-slot="{ grid, weekDays }"
|
||||
v-slot="{ grid, weekDays, date }"
|
||||
v-bind="forwarded"
|
||||
v-model:placeholder="placeholder"
|
||||
data-slot="calendar"
|
||||
:class="cn('p-3', props.class)"
|
||||
v-bind="forwarded"
|
||||
>
|
||||
<CalendarHeader>
|
||||
<CalendarHeading />
|
||||
<CalendarHeader class="pt-0">
|
||||
<nav
|
||||
class="flex items-center gap-1 absolute top-0 inset-x-0 justify-between"
|
||||
>
|
||||
<CalendarPrevButton>
|
||||
<slot name="calendar-prev-icon" />
|
||||
</CalendarPrevButton>
|
||||
<CalendarNextButton>
|
||||
<slot name="calendar-next-icon" />
|
||||
</CalendarNextButton>
|
||||
</nav>
|
||||
|
||||
<div class="flex items-center gap-1">
|
||||
<CalendarPrevButton />
|
||||
<CalendarNextButton />
|
||||
</div>
|
||||
<slot
|
||||
name="calendar-heading"
|
||||
:date="date"
|
||||
:month="ReuseMonthTemplate"
|
||||
:year="ReuseYearTemplate"
|
||||
>
|
||||
<template v-if="layout === 'month-and-year'">
|
||||
<div class="flex items-center justify-center gap-1">
|
||||
<ReuseMonthTemplate :date="date" />
|
||||
<ReuseYearTemplate :date="date" />
|
||||
</div>
|
||||
</template>
|
||||
<template v-else-if="layout === 'month-only'">
|
||||
<div class="flex items-center justify-center gap-1">
|
||||
<ReuseMonthTemplate :date="date" />
|
||||
{{ formatter.custom(toDate(date), { year: "numeric" }) }}
|
||||
</div>
|
||||
</template>
|
||||
<template v-else-if="layout === 'year-only'">
|
||||
<div class="flex items-center justify-center gap-1">
|
||||
{{ formatter.custom(toDate(date), { month: "short" }) }}
|
||||
<ReuseYearTemplate :date="date" />
|
||||
</div>
|
||||
</template>
|
||||
<template v-else>
|
||||
<CalendarHeading />
|
||||
</template>
|
||||
</slot>
|
||||
</CalendarHeader>
|
||||
|
||||
<div class="flex flex-col gap-y-4 mt-4 sm:flex-row sm:gap-x-4 sm:gap-y-0">
|
||||
|
||||
@@ -6,7 +6,7 @@ import { cn } from "@/lib/utils";
|
||||
const props = defineProps({
|
||||
date: { type: null, required: true },
|
||||
asChild: { type: Boolean, required: false },
|
||||
as: { type: [String, Object, Function], required: false },
|
||||
as: { type: null, required: false },
|
||||
class: { type: null, required: false },
|
||||
});
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ const props = defineProps({
|
||||
day: { type: null, required: true },
|
||||
month: { type: null, required: true },
|
||||
asChild: { type: Boolean, required: false },
|
||||
as: { type: [String, Object, Function], required: false, default: "button" },
|
||||
as: { type: null, required: false, default: "button" },
|
||||
class: { type: null, required: false },
|
||||
});
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import { cn } from "@/lib/utils";
|
||||
|
||||
const props = defineProps({
|
||||
asChild: { type: Boolean, required: false },
|
||||
as: { type: [String, Object, Function], required: false },
|
||||
as: { type: null, required: false },
|
||||
class: { type: null, required: false },
|
||||
});
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ import { CalendarGridBody } from "reka-ui";
|
||||
|
||||
const props = defineProps({
|
||||
asChild: { type: Boolean, required: false },
|
||||
as: { type: [String, Object, Function], required: false },
|
||||
as: { type: null, required: false },
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ import { CalendarGridHead } from "reka-ui";
|
||||
|
||||
const props = defineProps({
|
||||
asChild: { type: Boolean, required: false },
|
||||
as: { type: [String, Object, Function], required: false },
|
||||
as: { type: null, required: false },
|
||||
class: { type: null, required: false },
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -5,7 +5,7 @@ import { cn } from "@/lib/utils";
|
||||
|
||||
const props = defineProps({
|
||||
asChild: { type: Boolean, required: false },
|
||||
as: { type: [String, Object, Function], required: false },
|
||||
as: { type: null, required: false },
|
||||
class: { type: null, required: false },
|
||||
});
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import { cn } from "@/lib/utils";
|
||||
|
||||
const props = defineProps({
|
||||
asChild: { type: Boolean, required: false },
|
||||
as: { type: [String, Object, Function], required: false },
|
||||
as: { type: null, required: false },
|
||||
class: { type: null, required: false },
|
||||
});
|
||||
|
||||
@@ -19,7 +19,7 @@ const forwardedProps = useForwardProps(delegatedProps);
|
||||
data-slot="calendar-head-cell"
|
||||
:class="
|
||||
cn(
|
||||
'text-muted-foreground rounded-md w-8 font-normal text-[0.8rem]',
|
||||
'text-muted-foreground rounded-md flex-1 font-normal text-[0.8rem]',
|
||||
props.class,
|
||||
)
|
||||
"
|
||||
|
||||
@@ -5,7 +5,7 @@ import { cn } from "@/lib/utils";
|
||||
|
||||
const props = defineProps({
|
||||
asChild: { type: Boolean, required: false },
|
||||
as: { type: [String, Object, Function], required: false },
|
||||
as: { type: null, required: false },
|
||||
class: { type: null, required: false },
|
||||
});
|
||||
|
||||
@@ -18,7 +18,10 @@ const forwardedProps = useForwardProps(delegatedProps);
|
||||
<CalendarHeader
|
||||
data-slot="calendar-header"
|
||||
:class="
|
||||
cn('flex justify-center pt-1 relative items-center w-full', props.class)
|
||||
cn(
|
||||
'flex justify-center pt-1 relative items-center w-full px-8',
|
||||
props.class,
|
||||
)
|
||||
"
|
||||
v-bind="forwardedProps"
|
||||
>
|
||||
|
||||
@@ -5,7 +5,7 @@ import { cn } from "@/lib/utils";
|
||||
|
||||
const props = defineProps({
|
||||
asChild: { type: Boolean, required: false },
|
||||
as: { type: [String, Object, Function], required: false },
|
||||
as: { type: null, required: false },
|
||||
class: { type: null, required: false },
|
||||
});
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import { buttonVariants } from '@/components/ui/button';
|
||||
const props = defineProps({
|
||||
nextPage: { type: Function, required: false },
|
||||
asChild: { type: Boolean, required: false },
|
||||
as: { type: [String, Object, Function], required: false },
|
||||
as: { type: null, required: false },
|
||||
class: { type: null, required: false },
|
||||
});
|
||||
|
||||
@@ -23,7 +23,6 @@ const forwardedProps = useForwardProps(delegatedProps);
|
||||
:class="
|
||||
cn(
|
||||
buttonVariants({ variant: 'outline' }),
|
||||
'absolute right-1',
|
||||
'size-7 bg-transparent p-0 opacity-50 hover:opacity-100',
|
||||
props.class,
|
||||
)
|
||||
|
||||
@@ -8,7 +8,7 @@ import { buttonVariants } from '@/components/ui/button';
|
||||
const props = defineProps({
|
||||
prevPage: { type: Function, required: false },
|
||||
asChild: { type: Boolean, required: false },
|
||||
as: { type: [String, Object, Function], required: false },
|
||||
as: { type: null, required: false },
|
||||
class: { type: null, required: false },
|
||||
});
|
||||
|
||||
@@ -23,7 +23,6 @@ const forwardedProps = useForwardProps(delegatedProps);
|
||||
:class="
|
||||
cn(
|
||||
buttonVariants({ variant: 'outline' }),
|
||||
'absolute left-1',
|
||||
'size-7 bg-transparent p-0 opacity-50 hover:opacity-100',
|
||||
props.class,
|
||||
)
|
||||
|
||||
51
ui/src/components/ui/native-select/NativeSelect.vue
Normal file
51
ui/src/components/ui/native-select/NativeSelect.vue
Normal file
@@ -0,0 +1,51 @@
|
||||
<script setup>
|
||||
import { reactiveOmit, useVModel } from "@vueuse/core";
|
||||
import { ChevronDownIcon } from "lucide-vue-next";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
defineOptions({
|
||||
inheritAttrs: false,
|
||||
});
|
||||
|
||||
const props = defineProps({
|
||||
modelValue: { type: null, required: false },
|
||||
class: { type: null, required: false },
|
||||
});
|
||||
|
||||
const emit = defineEmits(["update:modelValue"]);
|
||||
|
||||
const modelValue = useVModel(props, "modelValue", emit, {
|
||||
passive: true,
|
||||
defaultValue: "",
|
||||
});
|
||||
|
||||
const delegatedProps = reactiveOmit(props, "class");
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
class="group/native-select relative w-fit has-[select:disabled]:opacity-50"
|
||||
data-slot="native-select-wrapper"
|
||||
>
|
||||
<select
|
||||
v-bind="{ ...$attrs, ...delegatedProps }"
|
||||
v-model="modelValue"
|
||||
data-slot="native-select"
|
||||
:class="
|
||||
cn(
|
||||
'border-input placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 dark:hover:bg-input/50 h-9 w-full min-w-0 appearance-none rounded-md border bg-transparent px-3 py-2 pr-9 text-sm shadow-xs transition-[color,box-shadow] outline-none disabled:pointer-events-none disabled:cursor-not-allowed',
|
||||
'focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]',
|
||||
'aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive',
|
||||
props.class,
|
||||
)
|
||||
"
|
||||
>
|
||||
<slot />
|
||||
</select>
|
||||
<ChevronDownIcon
|
||||
class="text-muted-foreground pointer-events-none absolute top-1/2 right-3.5 size-4 -translate-y-1/2 opacity-50 select-none"
|
||||
aria-hidden="true"
|
||||
data-slot="native-select-icon"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
19
ui/src/components/ui/native-select/NativeSelectOptGroup.vue
Normal file
19
ui/src/components/ui/native-select/NativeSelectOptGroup.vue
Normal file
@@ -0,0 +1,19 @@
|
||||
<!-- @fallthroughAttributes true -->
|
||||
<!-- @strictTemplates true -->
|
||||
|
||||
<script setup>
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
const props = defineProps({
|
||||
class: { type: null, required: false },
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<optgroup
|
||||
data-slot="native-select-optgroup"
|
||||
:class="cn('bg-popover text-popover-foreground', props.class)"
|
||||
>
|
||||
<slot />
|
||||
</optgroup>
|
||||
</template>
|
||||
19
ui/src/components/ui/native-select/NativeSelectOption.vue
Normal file
19
ui/src/components/ui/native-select/NativeSelectOption.vue
Normal file
@@ -0,0 +1,19 @@
|
||||
<!-- @fallthroughAttributes true -->
|
||||
<!-- @strictTemplates true -->
|
||||
|
||||
<script setup>
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
const props = defineProps({
|
||||
class: { type: null, required: false },
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<option
|
||||
data-slot="native-select-option"
|
||||
:class="cn('bg-popover text-popover-foreground', props.class)"
|
||||
>
|
||||
<slot />
|
||||
</option>
|
||||
</template>
|
||||
3
ui/src/components/ui/native-select/index.js
Normal file
3
ui/src/components/ui/native-select/index.js
Normal file
@@ -0,0 +1,3 @@
|
||||
export { default as NativeSelect } from "./NativeSelect.vue";
|
||||
export { default as NativeSelectOptGroup } from "./NativeSelectOptGroup.vue";
|
||||
export { default as NativeSelectOption } from "./NativeSelectOption.vue";
|
||||
@@ -20,7 +20,7 @@ const app = createApp(App)
|
||||
app.use(createPinia())
|
||||
app.use(router)
|
||||
|
||||
if (!!import.meta.env.VITE_DISABLE_GLITCHTIP) {
|
||||
if (!import.meta.env.VITE_DISABLE_GLITCHTIP) {
|
||||
let dsn = import.meta.env.VITE_GLITCHTIP_DSN;
|
||||
let environment = import.meta.env.VITE_ENVIRONMENT;
|
||||
|
||||
|
||||
@@ -116,7 +116,7 @@ const finalPanel = ref<'app' | 'message'>('message');
|
||||
</div>
|
||||
|
||||
<!-- Content -->
|
||||
<div class="mt-12 mb-20 flex w-full justify-center">
|
||||
<div class="mt-12 mb-20 flex w-full max-w-6xl justify-center">
|
||||
<div v-if="currentStep === 1" class="w-full max-w-2xl p-8">
|
||||
<h1 class="text-3xl sm:text-4xl font-bold mb-4 text-left">
|
||||
Create your account
|
||||
@@ -133,7 +133,7 @@ const finalPanel = ref<'app' | 'message'>('message');
|
||||
</div>
|
||||
<Application v-else-if="currentStep === 2" @submit="userStore.loadUser()" :mode="'create'"></Application>
|
||||
<Application v-else-if="currentStep === 3" :mode="'view-self'"></Application>
|
||||
<div v-if="currentStep === 5" class="w-full max-w-4xl p-8 pt-0">
|
||||
<div v-if="currentStep === 5" class="w-full p-8 pt-0">
|
||||
<div class="mb-5">
|
||||
<div class="flex w-min *:px-10 pt-2 border-b *:w-full *:text-center *:pb-1 *:cursor-pointer">
|
||||
<label :class="finalPanel === 'message' ? 'border-b-3 border-foreground' : 'mb-[2px]'"
|
||||
|
||||
@@ -18,21 +18,16 @@ const showLOADialog = ref(false);
|
||||
|
||||
<template>
|
||||
<Dialog v-model:open="showLOADialog" v-on:update:open="showLOADialog = false">
|
||||
<DialogContent>
|
||||
<DialogContent class="sm:max-w-fit">
|
||||
<DialogHeader>
|
||||
<DialogTitle>Post LOA</DialogTitle>
|
||||
<DialogDescription>
|
||||
Post an LOA on behalf of a member.
|
||||
</DialogDescription>
|
||||
</DialogHeader>
|
||||
<LoaForm :admin-mode="true" class="my-5 w-full"></LoaForm>
|
||||
<!-- <DialogFooter>
|
||||
<Button variant="secondary" @click="showLOADialog = false">Cancel</Button>
|
||||
<Button>Apply</Button>
|
||||
</DialogFooter> -->
|
||||
<LoaForm :admin-mode="true" class="my-3"></LoaForm>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
|
||||
</Dialog>
|
||||
<div class="max-w-5xl mx-auto pt-10">
|
||||
<div class="flex justify-end mb-4">
|
||||
<Button @click="showLOADialog = true">Post LOA</Button>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<div class="min-h-screen flex flex-col items-center justify-center text-center px-6">
|
||||
<div class="flex flex-col items-center justify-center text-center px-6">
|
||||
<h1 class="text-5xl font-bold mb-4">Unauthorized</h1>
|
||||
<p class="text-lg text-muted-foreground max-w-md mb-6">
|
||||
You don't have permission to access this page.
|
||||
|
||||
Reference in New Issue
Block a user