Compare commits
15 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 52e06c8f00 | |||
| 3b261bc18e | |||
| 9a9cbc323e | |||
| 072c82f578 | |||
| 5e06e38a0d | |||
| b8750f1e8e | |||
| 00f8d583cc | |||
| f3e35f3f6a | |||
| d7b099ac75 | |||
| 6d83a2d342 | |||
| 43763853f8 | |||
| 278690e094 | |||
| f9e5dacda8 | |||
| e0d9eeae92 | |||
| 7990c86a86 |
@@ -12,7 +12,7 @@ const pool = mariadb.createPool({
|
|||||||
connectionLimit: 5,
|
connectionLimit: 5,
|
||||||
connectTimeout: 10000, // give it more breathing room
|
connectTimeout: 10000, // give it more breathing room
|
||||||
acquireTimeout: 15000,
|
acquireTimeout: 15000,
|
||||||
database: process.env.DB_PASSWORD,
|
database: process.env.DB_DATABASE,
|
||||||
ssl: false,
|
ssl: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -115,11 +115,24 @@ router.get('/callback', (req, res, next) => {
|
|||||||
router.get('/logout', [requireLogin], function (req, res, next) {
|
router.get('/logout', [requireLogin], function (req, res, next) {
|
||||||
req.logout(function (err) {
|
req.logout(function (err) {
|
||||||
if (err) { return next(err); }
|
if (err) { return next(err); }
|
||||||
|
|
||||||
|
req.session.destroy((err) => {
|
||||||
|
if (err) { return next(err); }
|
||||||
|
|
||||||
|
res.clearCookie('connect.sid', {
|
||||||
|
path: '/',
|
||||||
|
domain: process.env.CLIENT_DOMAIN,
|
||||||
|
httpOnly: true,
|
||||||
|
sameSite: 'lax'
|
||||||
|
});
|
||||||
|
|
||||||
var params = {
|
var params = {
|
||||||
client_id: process.env.AUTH_CLIENT_ID,
|
client_id: process.env.AUTH_CLIENT_ID,
|
||||||
returnTo: process.env.CLIENT_URL
|
returnTo: process.env.CLIENT_URL
|
||||||
};
|
};
|
||||||
res.redirect(process.env.AUTH_END_SESSION_URI + '?' + querystring.stringify(params));
|
res.redirect(process.env.AUTH_END_SESSION_URI + '?' + querystring.stringify(params));
|
||||||
|
|
||||||
|
})
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { MemberState } from "@app/shared/types/member";
|
import { MemberState } from "@app/shared/types/member";
|
||||||
import { requireLogin, requireMemberState, requireRole } from "../middleware/auth";
|
import { requireLogin, requireMemberState, requireRole } from "../middleware/auth";
|
||||||
import { getAllRanks, insertMemberRank } from "../services/rankService";
|
import { batchInsertMemberRank, getAllRanks, getPromotionHistorySummary, getPromotionsOnDay, insertMemberRank } from "../services/rankService";
|
||||||
|
import { BatchPromotion, BatchPromotionMember } from '@app/shared/schemas/promotionSchema'
|
||||||
|
|
||||||
import express = require('express');
|
import express = require('express');
|
||||||
const r = express.Router();
|
const r = express.Router();
|
||||||
@@ -11,11 +12,13 @@ r.use(requireLogin)
|
|||||||
ur.use(requireLogin)
|
ur.use(requireLogin)
|
||||||
|
|
||||||
//insert a new latest rank for a user
|
//insert a new latest rank for a user
|
||||||
ur.post('/', [requireRole(["17th Command", "17th Administrator", "17th HQ"]), requireMemberState(MemberState.Member)], async (req, res) => {
|
ur.post('/', [requireRole(["17th Command", "17th Administrator", "17th HQ"]), requireMemberState(MemberState.Member)], async (req: express.Request, res: express.Response) => {
|
||||||
3
|
|
||||||
try {
|
try {
|
||||||
const change = req.body?.change;
|
const change = req.body.promotions as BatchPromotionMember[];
|
||||||
await insertMemberRank(change.member_id, change.rank_id, change.date);
|
const author = req.user.id;
|
||||||
|
if (!change) res.sendStatus(400);
|
||||||
|
|
||||||
|
await batchInsertMemberRank(change, author);
|
||||||
|
|
||||||
res.sendStatus(201);
|
res.sendStatus(201);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
@@ -24,6 +27,31 @@ ur.post('/', [requireRole(["17th Command", "17th Administrator", "17th HQ"]), re
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
ur.get('/', async (req: express.Request, res: express.Response) => {
|
||||||
|
try {
|
||||||
|
const promos = await getPromotionHistorySummary();
|
||||||
|
console.log(promos);
|
||||||
|
res.status(200).json(promos);
|
||||||
|
} catch (err) {
|
||||||
|
console.error(err);
|
||||||
|
res.status(500).json({ error: 'Internal server error' });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
ur.get('/:day', async (req: express.Request, res: express.Response) => {
|
||||||
|
try {
|
||||||
|
if (!req.params.day) res.sendStatus(400);
|
||||||
|
|
||||||
|
let day = new Date(req.params.day)
|
||||||
|
const promos = await getPromotionsOnDay(day);
|
||||||
|
console.log(promos);
|
||||||
|
res.status(200).json(promos);
|
||||||
|
} catch (err) {
|
||||||
|
console.error(err);
|
||||||
|
res.status(500).json({ error: 'Internal server error' });
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
//get all ranks
|
//get all ranks
|
||||||
r.get('/', async (req, res) => {
|
r.get('/', async (req, res) => {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -1,4 +1,8 @@
|
|||||||
|
import { BatchPromotion, BatchPromotionMember } from "@app/shared/schemas/promotionSchema";
|
||||||
|
import { PromotionDetails, PromotionSummary } from "@app/shared/types/rank"
|
||||||
import pool from "../db";
|
import pool from "../db";
|
||||||
|
import { PagedData } from "@app/shared/types/pagination";
|
||||||
|
import { toDateTime } from "@app/shared/utils/time";
|
||||||
|
|
||||||
export async function getAllRanks() {
|
export async function getAllRanks() {
|
||||||
const rows = await pool.query(
|
const rows = await pool.query(
|
||||||
@@ -30,3 +34,75 @@ export async function insertMemberRank(member_id: number, rank_id: number, date?
|
|||||||
|
|
||||||
await pool.query(sql, params);
|
await pool.query(sql, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export async function batchInsertMemberRank(promos: BatchPromotionMember[], author: number) {
|
||||||
|
try {
|
||||||
|
var con = await pool.getConnection();
|
||||||
|
console.log(promos);
|
||||||
|
promos.forEach(p => {
|
||||||
|
con.query(`CALL sp_update_member_rank(?, ?, ?, ?, ?, ?)`, [p.member_id, p.rank_id, author, author, "Rank Change", toDateTime(new Date(p.start_date))])
|
||||||
|
});
|
||||||
|
|
||||||
|
con.commit();
|
||||||
|
return
|
||||||
|
} catch (error) {
|
||||||
|
throw error; //pass it up
|
||||||
|
} finally {
|
||||||
|
con.release();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getPromotionHistorySummary(page: number = 1, pageSize: number = 15): Promise<PagedData<PromotionSummary>> {
|
||||||
|
|
||||||
|
const offset = (page - 1) * pageSize;
|
||||||
|
|
||||||
|
let sql = `SELECT
|
||||||
|
DATE(start_date) AS entry_day
|
||||||
|
FROM
|
||||||
|
members_ranks
|
||||||
|
WHERE reason = 'Rank Change'
|
||||||
|
GROUP BY
|
||||||
|
entry_day
|
||||||
|
ORDER BY
|
||||||
|
entry_day DESC
|
||||||
|
LIMIT ? OFFSET ?;`
|
||||||
|
|
||||||
|
let promoList: PromotionSummary[] = await pool.query(sql, [pageSize, offset]) as PromotionSummary[];
|
||||||
|
|
||||||
|
let loaCount = Number((await pool.query(`SELECT
|
||||||
|
COUNT(*) AS total_grouped_days_count
|
||||||
|
FROM
|
||||||
|
(
|
||||||
|
SELECT DISTINCT DATE(start_date)
|
||||||
|
FROM members_ranks
|
||||||
|
WHERE reason = 'Rank Change'
|
||||||
|
) AS grouped_days;`))[0]);
|
||||||
|
|
||||||
|
console.log(loaCount);
|
||||||
|
let pageCount = loaCount / pageSize;
|
||||||
|
|
||||||
|
let output: PagedData<PromotionSummary> = { data: promoList, pagination: { page: page, pageSize: pageSize, total: loaCount, totalPages: pageCount } }
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getPromotionsOnDay(day: Date): Promise<PromotionDetails[]> {
|
||||||
|
|
||||||
|
const dayString = toDateTime(day);
|
||||||
|
|
||||||
|
// SQL query to fetch all records from members_unit for the specified day
|
||||||
|
let sql = `
|
||||||
|
SELECT
|
||||||
|
mr.member_id,
|
||||||
|
mr.created_by_id,
|
||||||
|
r.short_name
|
||||||
|
FROM members_ranks AS mr
|
||||||
|
LEFT JOIN ranks AS r ON r.id = mr.rank_id
|
||||||
|
WHERE DATE(mr.start_date) = ? && mr.reason = 'Rank Change'
|
||||||
|
ORDER BY mr.start_date ASC;
|
||||||
|
`;
|
||||||
|
|
||||||
|
let batchPromotion = await pool.query(sql, [dayString]) as PromotionDetails[];
|
||||||
|
|
||||||
|
return batchPromotion;
|
||||||
|
}
|
||||||
32
shared/schemas/promotionSchema.ts
Normal file
32
shared/schemas/promotionSchema.ts
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
import { z } from "zod";
|
||||||
|
|
||||||
|
export const batchPromotionMemberSchema = z.object({
|
||||||
|
member_id: z.number({ invalid_type_error: "Must select a member" }).int().positive(),
|
||||||
|
rank_id: z.number({ invalid_type_error: "Must select a rank" }).int().positive(),
|
||||||
|
start_date: z.string().refine((val) => !isNaN(Date.parse(val)), {
|
||||||
|
message: "Must be a valid date",
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
|
||||||
|
export const batchPromotionSchema = z.object({
|
||||||
|
promotions: z.array(batchPromotionMemberSchema, { message: "At least one promotion is required" }).nonempty({ message: "At least one promotion is required" }),
|
||||||
|
|
||||||
|
})
|
||||||
|
.superRefine((data, ctx) => {
|
||||||
|
// optional: check for duplicate member_ids
|
||||||
|
const memberCounts = new Map<number, number>();
|
||||||
|
data.promotions.forEach((p, index) => {
|
||||||
|
memberCounts.set(p.member_id, (memberCounts.get(p.member_id) ?? 0) + 1);
|
||||||
|
if (memberCounts.get(p.member_id)! > 1) {
|
||||||
|
ctx.addIssue({
|
||||||
|
code: z.ZodIssueCode.custom,
|
||||||
|
path: ["promotions", index, "member_id"],
|
||||||
|
message: "Duplicate member in batch is not allowed",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
export type BatchPromotion = z.infer<typeof batchPromotionSchema>;
|
||||||
|
export type BatchPromotionMember = z.infer<typeof batchPromotionMemberSchema>;
|
||||||
17
shared/types/rank.ts
Normal file
17
shared/types/rank.ts
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
export type Rank = {
|
||||||
|
id: number
|
||||||
|
name: string
|
||||||
|
short_name: string
|
||||||
|
category: string
|
||||||
|
sortOrder: number
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface PromotionSummary {
|
||||||
|
entry_day: Date;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface PromotionDetails {
|
||||||
|
member_id: number;
|
||||||
|
short_name: string;
|
||||||
|
created_by_id: number;
|
||||||
|
}
|
||||||
@@ -1,38 +1,74 @@
|
|||||||
export type Rank = {
|
import { BatchPromotion, BatchPromotionMember } from '@shared/schemas/promotionSchema';
|
||||||
id: number
|
import { PagedData } from '@shared/types/pagination';
|
||||||
name: string
|
import { PromotionDetails, PromotionSummary, Rank } from '@shared/types/rank'
|
||||||
short_name: string
|
|
||||||
sortOrder: number
|
|
||||||
}
|
|
||||||
|
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
const addr = import.meta.env.VITE_APIHOST;
|
const addr = import.meta.env.VITE_APIHOST;
|
||||||
|
|
||||||
export async function getRanks(): Promise<Rank[]> {
|
export async function getAllRanks(): Promise<Rank[]> {
|
||||||
const res = await fetch(`${addr}/ranks`)
|
const res = await fetch(`${addr}/ranks`, {
|
||||||
|
credentials: 'include'
|
||||||
|
})
|
||||||
|
|
||||||
if (res.ok) {
|
if (res.ok) {
|
||||||
return res.json()
|
return res.json()
|
||||||
} else {
|
} else {
|
||||||
console.error("Something went wrong approving the application")
|
console.error("Something went wrong approving the application")
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Placeholder: submit a rank change
|
export async function submitRankChange(promo: BatchPromotion) {
|
||||||
export async function submitRankChange(member_id: number, rank_id: number, date: string): Promise<{ ok: boolean }> {
|
|
||||||
const res = await fetch(`${addr}/memberRanks`, {
|
const res = await fetch(`${addr}/memberRanks`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
},
|
},
|
||||||
body: JSON.stringify({ change: { member_id, rank_id, date } }),
|
credentials: 'include',
|
||||||
|
body: JSON.stringify(promo),
|
||||||
})
|
})
|
||||||
|
|
||||||
if (res.ok) {
|
if (res.ok) {
|
||||||
return { ok: true }
|
return
|
||||||
} else {
|
} else {
|
||||||
console.error("Failed to submit rank change")
|
throw new Error("Failed to submit rank change: Server error");
|
||||||
return { ok: false }
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getPromoHistory(page?: number, pageSize?: number): Promise<PagedData<PromotionSummary>> {
|
||||||
|
const params = new URLSearchParams();
|
||||||
|
|
||||||
|
if (page !== undefined) {
|
||||||
|
params.set("page", page.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pageSize !== undefined) {
|
||||||
|
params.set("pageSize", pageSize.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
return fetch(`${addr}/memberRanks?${params}`, {
|
||||||
|
method: "GET",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
},
|
||||||
|
credentials: 'include',
|
||||||
|
}).then((res) => {
|
||||||
|
if (res.ok) {
|
||||||
|
return res.json();
|
||||||
|
} else {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getPromotionsOnDay(day: Date): Promise<PromotionDetails[]> {
|
||||||
|
console.log(day.toISOString());
|
||||||
|
const res = await fetch(`${addr}/memberRanks/${day.toISOString()}`, {
|
||||||
|
credentials: 'include',
|
||||||
|
})
|
||||||
|
|
||||||
|
if (res.ok) {
|
||||||
|
return await res.json();
|
||||||
|
} else {
|
||||||
|
throw new Error("Failed to submit rank change: Server error");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
269
ui/src/components/promotions/promotionForm.vue
Normal file
269
ui/src/components/promotions/promotionForm.vue
Normal file
@@ -0,0 +1,269 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { batchPromotionSchema } from '@shared/schemas/promotionSchema';
|
||||||
|
import { useForm, Field as VeeField, FieldArray as VeeFieldArray } from 'vee-validate';
|
||||||
|
import { toTypedSchema } from '@vee-validate/zod';
|
||||||
|
import FieldSet from '../ui/field/FieldSet.vue';
|
||||||
|
import FieldLegend from '../ui/field/FieldLegend.vue';
|
||||||
|
import FieldDescription from '../ui/field/FieldDescription.vue';
|
||||||
|
import FieldGroup from '../ui/field/FieldGroup.vue';
|
||||||
|
import Combobox from '../ui/combobox/Combobox.vue';
|
||||||
|
import ComboboxAnchor from '../ui/combobox/ComboboxAnchor.vue';
|
||||||
|
import ComboboxInput from '../ui/combobox/ComboboxInput.vue';
|
||||||
|
import ComboboxList from '../ui/combobox/ComboboxList.vue';
|
||||||
|
import ComboboxEmpty from '../ui/combobox/ComboboxEmpty.vue';
|
||||||
|
import ComboboxGroup from '../ui/combobox/ComboboxGroup.vue';
|
||||||
|
import ComboboxItem from '../ui/combobox/ComboboxItem.vue';
|
||||||
|
import ComboboxItemIndicator from '../ui/combobox/ComboboxItemIndicator.vue';
|
||||||
|
import { computed, onMounted, ref } from 'vue';
|
||||||
|
import { MemberLight } from '@shared/types/member';
|
||||||
|
import { Check, Plus, X } from 'lucide-vue-next';
|
||||||
|
import Button from '../ui/button/Button.vue';
|
||||||
|
import FieldError from '../ui/field/FieldError.vue';
|
||||||
|
import { getAllLightMembers } from '@/api/member';
|
||||||
|
import { Rank } from '@shared/types/rank';
|
||||||
|
import { getAllRanks, submitRankChange } from '@/api/rank';
|
||||||
|
import { error } from 'console';
|
||||||
|
import Input from '../ui/input/Input.vue';
|
||||||
|
import Field from '../ui/field/Field.vue';
|
||||||
|
|
||||||
|
const { handleSubmit, errors, values, resetForm, setFieldValue } = useForm({
|
||||||
|
validationSchema: toTypedSchema(batchPromotionSchema),
|
||||||
|
validateOnMount: false,
|
||||||
|
})
|
||||||
|
|
||||||
|
const submitForm = handleSubmit(
|
||||||
|
async (vals) => {
|
||||||
|
try {
|
||||||
|
let output = vals;
|
||||||
|
output.promotions.map(p => p.start_date = new Date(p.start_date).toISOString())
|
||||||
|
await submitRankChange(output);
|
||||||
|
formSubmitted.value = true;
|
||||||
|
} catch (error) {
|
||||||
|
submitError.value = error;
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
const submitError = ref<string>(null);
|
||||||
|
const formSubmitted = ref(false);
|
||||||
|
|
||||||
|
const allmembers = ref<MemberLight[]>([]);
|
||||||
|
const allRanks = ref<Rank[]>([]);
|
||||||
|
|
||||||
|
const memberById = computed(() => {
|
||||||
|
const map = new Map<number, MemberLight>();
|
||||||
|
for (const m of allmembers.value) {
|
||||||
|
map.set(m.id, m);
|
||||||
|
}
|
||||||
|
return map;
|
||||||
|
});
|
||||||
|
|
||||||
|
const rankById = computed(() => {
|
||||||
|
const map = new Map<number, Rank>();
|
||||||
|
for (const r of allRanks.value) {
|
||||||
|
map.set(r.id, r);
|
||||||
|
}
|
||||||
|
return map;
|
||||||
|
});
|
||||||
|
|
||||||
|
const memberSearch = ref('');
|
||||||
|
const rankSearch = ref('');
|
||||||
|
|
||||||
|
const filteredMembers = computed(() => {
|
||||||
|
const q = memberSearch?.value?.toLowerCase() ?? ""
|
||||||
|
const results: MemberLight[] = []
|
||||||
|
|
||||||
|
for (const m of allmembers.value ?? []) {
|
||||||
|
if (!q || (m.displayName || m.username).toLowerCase().includes(q)) {
|
||||||
|
results.push(m)
|
||||||
|
if (results.length >= 50) break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return results
|
||||||
|
})
|
||||||
|
|
||||||
|
const filteredRanks = computed(() =>
|
||||||
|
filterRanks(rankSearch.value)
|
||||||
|
);
|
||||||
|
|
||||||
|
function filterRanks(query: string): Rank[] {
|
||||||
|
if (!query) return allRanks.value;
|
||||||
|
|
||||||
|
const q = query.toLowerCase();
|
||||||
|
return allRanks.value.filter(r =>
|
||||||
|
r.name.toLowerCase().includes(q) ||
|
||||||
|
r.short_name.toLowerCase().includes(q)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(async () => {
|
||||||
|
allmembers.value = await getAllLightMembers()
|
||||||
|
allRanks.value = await getAllRanks();
|
||||||
|
})
|
||||||
|
|
||||||
|
function setAllToday() {
|
||||||
|
const today = () => {
|
||||||
|
const d = new Date()
|
||||||
|
const year = d.getFullYear()
|
||||||
|
const month = String(d.getMonth() + 1).padStart(2, '0')
|
||||||
|
const day = String(d.getDate()).padStart(2, '0')
|
||||||
|
|
||||||
|
return `${year}-${month}-${day}`
|
||||||
|
}
|
||||||
|
|
||||||
|
values.promotions?.forEach((_, index) => {
|
||||||
|
// @ts-ignore
|
||||||
|
setFieldValue(`promotions[${index}].start_date`, today())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="w-xl">
|
||||||
|
<form v-if="!formSubmitted" id="trainingForm" @submit.prevent="submitForm"
|
||||||
|
class="w-full min-w-0 flex flex-col gap-6">
|
||||||
|
<VeeFieldArray name="promotions" v-slot="{ fields, push, remove }">
|
||||||
|
<FieldSet class="w-full min-w-0">
|
||||||
|
<div class="flex flex-col gap-2">
|
||||||
|
<div>
|
||||||
|
<FieldLegend class="scroll-m-20 text-2xl font-semibold tracking-tight">
|
||||||
|
Promotion Form
|
||||||
|
</FieldLegend>
|
||||||
|
<div class="h-6">
|
||||||
|
<p v-if="errors.promotions && typeof errors.promotions === 'string'"
|
||||||
|
class="text-sm text-red-500">
|
||||||
|
{{ errors.promotions }}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!-- TABLE SHELL -->
|
||||||
|
<div class="">
|
||||||
|
<FieldGroup class="">
|
||||||
|
<!-- HEADER -->
|
||||||
|
<div class="grid grid-cols-[200px_200px_150px_1fr_auto]
|
||||||
|
gap-3 px-1 -mb-4
|
||||||
|
text-sm font-medium text-muted-foreground">
|
||||||
|
<div>Member</div>
|
||||||
|
<div>Rank</div>
|
||||||
|
<div class="flex justify-between">
|
||||||
|
<p>Date</p><button @click.prevent.stop="setAllToday"
|
||||||
|
class="cursor-pointer border-1 rounded-full px-3 hover:bg-secondary hover:border-accent">Today</button>
|
||||||
|
</div>
|
||||||
|
<div></div>
|
||||||
|
<div></div>
|
||||||
|
</div>
|
||||||
|
<!-- BODY -->
|
||||||
|
<div class="flex flex-col gap-2">
|
||||||
|
<div v-for="(row, index) in fields" :key="row.key" class="grid grid-cols-[200px_200px_150px_1fr_auto]
|
||||||
|
gap-3 items-start">
|
||||||
|
<!-- Member -->
|
||||||
|
<VeeField :name="`promotions[${index}].member_id`" v-slot="{ field, errors }">
|
||||||
|
<div class="flex flex-col min-w-0">
|
||||||
|
<Combobox :model-value="field.value"
|
||||||
|
@update:model-value="field.onChange" :ignore-filter="true">
|
||||||
|
<ComboboxAnchor>
|
||||||
|
<ComboboxInput class="w-full pl-3" placeholder="Search members…"
|
||||||
|
:display-value="id =>
|
||||||
|
memberById.get(id)?.displayName ||
|
||||||
|
memberById.get(id)?.username
|
||||||
|
" @input="memberSearch = $event.target.value" />
|
||||||
|
</ComboboxAnchor>
|
||||||
|
<ComboboxList>
|
||||||
|
<ComboboxEmpty>No results</ComboboxEmpty>
|
||||||
|
<ComboboxGroup>
|
||||||
|
<div
|
||||||
|
class="max-h-80 overflow-y-auto min-w-[12rem] scrollbar-themed">
|
||||||
|
<ComboboxItem v-for="member in filteredMembers"
|
||||||
|
:key="member.id" :value="member.id">
|
||||||
|
{{ member.displayName || member.username }}
|
||||||
|
<ComboboxItemIndicator>
|
||||||
|
<Check />
|
||||||
|
</ComboboxItemIndicator>
|
||||||
|
</ComboboxItem>
|
||||||
|
</div>
|
||||||
|
</ComboboxGroup>
|
||||||
|
</ComboboxList>
|
||||||
|
</Combobox>
|
||||||
|
<div class="h-5">
|
||||||
|
<FieldError v-if="errors.length" :errors="errors" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</VeeField>
|
||||||
|
<!-- Rank -->
|
||||||
|
<VeeField :name="`promotions[${index}].rank_id`" v-slot="{ field, errors }">
|
||||||
|
<div class="flex flex-col min-w-0">
|
||||||
|
<Combobox :model-value="field.value"
|
||||||
|
@update:model-value="field.onChange" :ignore-filter="true">
|
||||||
|
<ComboboxAnchor>
|
||||||
|
<ComboboxInput class="w-full pl-3" placeholder="Select rank…"
|
||||||
|
:display-value="id => rankById.get(id)?.name"
|
||||||
|
@input="rankSearch = $event.target.value" />
|
||||||
|
</ComboboxAnchor>
|
||||||
|
<ComboboxList>
|
||||||
|
<ComboboxEmpty>No results</ComboboxEmpty>
|
||||||
|
<ComboboxGroup>
|
||||||
|
<div
|
||||||
|
class="max-h-80 overflow-y-auto min-w-[12rem] scrollbar-themed">
|
||||||
|
<ComboboxItem v-for="rank in filteredRanks"
|
||||||
|
:key="rank.id" :value="rank.id">
|
||||||
|
{{ rank.name }}
|
||||||
|
<ComboboxItemIndicator>
|
||||||
|
<Check />
|
||||||
|
</ComboboxItemIndicator>
|
||||||
|
</ComboboxItem>
|
||||||
|
</div>
|
||||||
|
</ComboboxGroup>
|
||||||
|
</ComboboxList>
|
||||||
|
</Combobox>
|
||||||
|
<div class="h-5">
|
||||||
|
<FieldError v-if="errors.length" :errors="errors" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</VeeField>
|
||||||
|
<!-- Date -->
|
||||||
|
<VeeField :name="`promotions[${index}].start_date`" v-slot="{ field, errors }">
|
||||||
|
<Field>
|
||||||
|
<div>
|
||||||
|
<Input type="date" v-bind="field" />
|
||||||
|
<div class="h-5">
|
||||||
|
<FieldError v-if="errors.length" :errors="errors" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Field>
|
||||||
|
</VeeField>
|
||||||
|
<!-- Remove -->
|
||||||
|
<div class="flex justify-end">
|
||||||
|
<Button type="button" variant="ghost" size="icon" @click="remove(index)">
|
||||||
|
<X />
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</FieldGroup>
|
||||||
|
</div>
|
||||||
|
<Button type="button" @click="push({})" class="w-full" variant="outline">
|
||||||
|
<Plus /> Member
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</FieldSet>
|
||||||
|
</VeeFieldArray>
|
||||||
|
<div class="flex justify-end items-center gap-5">
|
||||||
|
<p v-if="submitError" class="text-destructive">{{ submitError }}</p>
|
||||||
|
<Button type="submit">Submit</Button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
<div v-else>
|
||||||
|
<div class="flex flex-col max-w-sm justify-center gap-4 py-24 mx-auto">
|
||||||
|
<div class="text-left">
|
||||||
|
<h2 class="text-2xl font-semibold mb-2">Successfully Submitted</h2>
|
||||||
|
<p class="text-muted-foreground">Your promotions have been recorded.</p>
|
||||||
|
</div>
|
||||||
|
<Button @click="() => { formSubmitted = false; resetForm(); }" variant="secondary">
|
||||||
|
Submit Another
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
151
ui/src/components/promotions/promotionList.vue
Normal file
151
ui/src/components/promotions/promotionList.vue
Normal file
@@ -0,0 +1,151 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { pagination } from '@shared/types/pagination';
|
||||||
|
import { PromotionSummary } from '@shared/types/rank';
|
||||||
|
import { onMounted, ref } from 'vue';
|
||||||
|
import {
|
||||||
|
Pagination,
|
||||||
|
PaginationContent,
|
||||||
|
PaginationEllipsis,
|
||||||
|
PaginationItem,
|
||||||
|
PaginationNext,
|
||||||
|
PaginationPrevious,
|
||||||
|
} from '@/components/ui/pagination'
|
||||||
|
import {
|
||||||
|
Table,
|
||||||
|
TableBody,
|
||||||
|
TableCaption,
|
||||||
|
TableCell,
|
||||||
|
TableHead,
|
||||||
|
TableHeader,
|
||||||
|
TableRow,
|
||||||
|
} from "@/components/ui/table"
|
||||||
|
import { ChevronDown, ChevronUp } from 'lucide-vue-next';
|
||||||
|
import Button from '../ui/button/Button.vue';
|
||||||
|
import { getPromoHistory } from '@/api/rank';
|
||||||
|
import Spinner from '../ui/spinner/Spinner.vue';
|
||||||
|
import PromotionListDay from './promotionListDay.vue';
|
||||||
|
|
||||||
|
|
||||||
|
const loading = ref(true);
|
||||||
|
const batchList = ref<PromotionSummary[]>();
|
||||||
|
|
||||||
|
onMounted(async () => {
|
||||||
|
await loadHistory();
|
||||||
|
loading.value = false;
|
||||||
|
})
|
||||||
|
|
||||||
|
async function loadHistory() {
|
||||||
|
let d = await getPromoHistory(pageNum.value, pageSize.value);
|
||||||
|
batchList.value = d.data;
|
||||||
|
pageData.value = d.pagination;
|
||||||
|
}
|
||||||
|
|
||||||
|
const expanded = ref<number | null>(null);
|
||||||
|
const hoverID = ref<number | null>(null);
|
||||||
|
|
||||||
|
const pageNum = ref<number>(1);
|
||||||
|
const pageData = ref<pagination>();
|
||||||
|
|
||||||
|
const pageSize = ref<number>(15)
|
||||||
|
const pageSizeOptions = [10, 15, 30]
|
||||||
|
|
||||||
|
function setPageSize(size: number) {
|
||||||
|
pageSize.value = size
|
||||||
|
pageNum.value = 1;
|
||||||
|
loadHistory();
|
||||||
|
}
|
||||||
|
|
||||||
|
function setPage(pagenum: number) {
|
||||||
|
pageNum.value = pagenum;
|
||||||
|
loadHistory();
|
||||||
|
}
|
||||||
|
|
||||||
|
function formatDate(date: Date): string {
|
||||||
|
if (!date) return "";
|
||||||
|
date = typeof date === 'string' ? new Date(date) : date;
|
||||||
|
return date.toLocaleDateString("en-US", {
|
||||||
|
year: "numeric",
|
||||||
|
month: "short",
|
||||||
|
day: "numeric",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
<template>
|
||||||
|
<div class="flex flex-col max-w-7xl w-full">
|
||||||
|
<p class="scroll-m-20 text-2xl font-semibold tracking-tight mb-3">
|
||||||
|
Promotion History
|
||||||
|
</p>
|
||||||
|
<div class="w-full mx-auto">
|
||||||
|
<Table>
|
||||||
|
<TableHeader>
|
||||||
|
<TableRow>
|
||||||
|
<TableHead>Date</TableHead>
|
||||||
|
<TableHead></TableHead>
|
||||||
|
</TableRow>
|
||||||
|
</TableHeader>
|
||||||
|
<TableBody>
|
||||||
|
<template v-for="(batch, index) in batchList" :key="index">
|
||||||
|
<TableRow class="hover:bg-muted/50 cursor-pointer" @click="expanded = index"
|
||||||
|
@mouseenter="hoverID = index" @mouseleave="hoverID = null" :class="{
|
||||||
|
'border-b-0': expanded === index,
|
||||||
|
'bg-muted/50': hoverID === index
|
||||||
|
}">
|
||||||
|
<TableCell class="font-medium">
|
||||||
|
{{ formatDate(new Date(batch.entry_day)) }}
|
||||||
|
</TableCell>
|
||||||
|
<TableCell class="text-right">
|
||||||
|
<Button v-if="expanded === index" @click.stop="expanded = null" size="icon"
|
||||||
|
variant="ghost">
|
||||||
|
<ChevronUp class="size-6" />
|
||||||
|
</Button>
|
||||||
|
<Button v-else @click.stop="expanded = index" size="icon" variant="ghost">
|
||||||
|
<ChevronDown class="size-6" />
|
||||||
|
</Button>
|
||||||
|
</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
<TableRow v-if="expanded === index" @mouseenter="hoverID = index" @mouseleave="hoverID = null"
|
||||||
|
:class="{ 'bg-muted/50 border-t-0': hoverID === index }">
|
||||||
|
<TableCell :colspan="8" class="p-0">
|
||||||
|
<div class="w-full p-2 mb-6 space-y-3">
|
||||||
|
<PromotionListDay :date="new Date(batch.entry_day)"></PromotionListDay>
|
||||||
|
</div>
|
||||||
|
</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
|
||||||
|
</template>
|
||||||
|
</TableBody>
|
||||||
|
</Table>
|
||||||
|
<div v-if="loading" class="w-full flex mx-auto justify-center my-15">
|
||||||
|
<Spinner class="size-7"></Spinner>
|
||||||
|
</div>
|
||||||
|
<div class="mt-5 flex justify-between">
|
||||||
|
<div></div>
|
||||||
|
<Pagination v-slot="{ page }" :items-per-page="pageData?.pageSize || 10" :total="pageData?.total || 10"
|
||||||
|
:default-page="2" :page="pageNum" @update:page="setPage">
|
||||||
|
<PaginationContent v-slot="{ items }">
|
||||||
|
<PaginationPrevious />
|
||||||
|
<template v-for="(item, index) in items" :key="index">
|
||||||
|
<PaginationItem v-if="item.type === 'page'" :value="item.value"
|
||||||
|
:is-active="item.value === page">
|
||||||
|
{{ item.value }}
|
||||||
|
</PaginationItem>
|
||||||
|
</template>
|
||||||
|
<PaginationEllipsis :index="4" />
|
||||||
|
<PaginationNext />
|
||||||
|
</PaginationContent>
|
||||||
|
</Pagination>
|
||||||
|
<div class="flex items-center gap-3 text-sm">
|
||||||
|
<p class="text-muted-foreground text-nowrap">Per page:</p>
|
||||||
|
|
||||||
|
<button v-for="size in pageSizeOptions" :key="size" @click="setPageSize(size)"
|
||||||
|
class="px-2 py-1 rounded transition-colors" :class="{
|
||||||
|
'bg-muted font-semibold': pageSize === size,
|
||||||
|
'hover:bg-muted/50': pageSize !== size
|
||||||
|
}">
|
||||||
|
{{ size }}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
52
ui/src/components/promotions/promotionListDay.vue
Normal file
52
ui/src/components/promotions/promotionListDay.vue
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { getPromotionsOnDay } from '@/api/rank';
|
||||||
|
import { onMounted, ref } from 'vue';
|
||||||
|
import MemberCard from '../members/MemberCard.vue';
|
||||||
|
import Spinner from '../ui/spinner/Spinner.vue';
|
||||||
|
import { PromotionDetails } from '@shared/types/rank';
|
||||||
|
|
||||||
|
|
||||||
|
const props = defineProps<{
|
||||||
|
date: Date
|
||||||
|
}>()
|
||||||
|
|
||||||
|
const promoList = ref<PromotionDetails[]>();
|
||||||
|
const loading = ref(true);
|
||||||
|
|
||||||
|
onMounted(async () => {
|
||||||
|
promoList.value = await getPromotionsOnDay(props.date);
|
||||||
|
loading.value = false;
|
||||||
|
})
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="overflow-x-auto">
|
||||||
|
<table v-if="!loading" class="min-w-full text-left border-collapse">
|
||||||
|
<thead>
|
||||||
|
<tr class="border-b-2 border-gray-200 bg-white/10">
|
||||||
|
<th class="px-4 py-3 text-sm font-semibold">Member</th>
|
||||||
|
<th class="px-4 py-3 text-sm font-semibold">Rank</th>
|
||||||
|
<th class="px-4 py-3 text-sm font-semibold text-right">Approved By</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
|
||||||
|
<tbody>
|
||||||
|
<tr v-for="p in promoList" :key="p.member_id" class="border-b transition-colors">
|
||||||
|
<td class="px-2 py-2">
|
||||||
|
<MemberCard :member-id="p.member_id" />
|
||||||
|
</td>
|
||||||
|
<td class="px-4 py-2 text-sm">
|
||||||
|
{{ p.short_name }}
|
||||||
|
</td>
|
||||||
|
<td class="px-2 py-2 text-sm text-right">
|
||||||
|
<MemberCard :member-id="p.created_by_id" />
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<div v-else class="overflow-hidden mx-auto flex w-full">
|
||||||
|
<Spinner class="size-7"></Spinner>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
26
ui/src/pages/Banned.vue
Normal file
26
ui/src/pages/Banned.vue
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
<template>
|
||||||
|
<div class="w-full max-w-2xl flex flex-col gap-8 justify-center mx-auto">
|
||||||
|
<h1 class="text-3xl sm:text-4xl font-bold text-left">
|
||||||
|
Access Restricted
|
||||||
|
</h1>
|
||||||
|
<div class="space-y-4 text-muted-foreground text-left leading-relaxed">
|
||||||
|
<p>
|
||||||
|
Your access to the <strong>17th Ranger Battalion</strong> has been
|
||||||
|
<strong>revoked</strong> due to a violation of our community standards
|
||||||
|
or policies.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
If you believe this action was taken in error or would like to better
|
||||||
|
understand the reason for this decision, you may
|
||||||
|
<strong>reach out to our administrative staff on Discord</strong>
|
||||||
|
to request clarification or discuss a potential appeal.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
Regards,<br />
|
||||||
|
<span class="text-foreground font-medium">
|
||||||
|
The 17th Ranger Battalion Administration Team
|
||||||
|
</span>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
@@ -1,115 +1,24 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { Check, Search } from "lucide-vue-next"
|
import PromotionForm from "@/components/promotions/promotionForm.vue";
|
||||||
import { Combobox, ComboboxAnchor, ComboboxEmpty, ComboboxGroup, ComboboxInput, ComboboxItem, ComboboxItemIndicator, ComboboxList } from "@/components/ui/combobox"
|
import PromotionList from "@/components/promotions/promotionList.vue";
|
||||||
import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover"
|
|
||||||
import { getRanks, Rank, submitRankChange } from "@/api/rank"
|
|
||||||
import { onMounted, ref } from "vue";
|
|
||||||
import { Member, getMembers } from "@/api/member";
|
|
||||||
import { cn } from "@/lib/utils"
|
|
||||||
import { CalendarIcon } from "lucide-vue-next"
|
|
||||||
|
|
||||||
import {
|
|
||||||
DateFormatter,
|
|
||||||
|
|
||||||
DateValue,
|
|
||||||
|
|
||||||
getLocalTimeZone,
|
|
||||||
today,
|
|
||||||
} from "@internationalized/date"
|
|
||||||
|
|
||||||
import Button from "@/components/ui/button/Button.vue";
|
|
||||||
import Calendar from "@/components/ui/calendar/Calendar.vue";
|
|
||||||
|
|
||||||
const members = ref<Member[]>([])
|
|
||||||
const ranks = ref<Rank[]>([])
|
|
||||||
const date = ref<DateValue>(today(getLocalTimeZone()))
|
|
||||||
|
|
||||||
|
|
||||||
const currentMember = ref<Member | null>(null);
|
|
||||||
const currentRank = ref<Rank | null>(null);
|
|
||||||
onMounted(async () => {
|
|
||||||
members.value = await getMembers();
|
|
||||||
ranks.value = await getRanks();
|
|
||||||
});
|
|
||||||
|
|
||||||
const df = new DateFormatter("en-US", {
|
|
||||||
dateStyle: "long",
|
|
||||||
})
|
|
||||||
|
|
||||||
function submit() {
|
|
||||||
submitRankChange(currentMember.value.member_id, currentRank.value?.id, date.value.toString())
|
|
||||||
.then(() => {
|
|
||||||
alert("Rank change submitted!");
|
|
||||||
currentMember.value = null;
|
|
||||||
currentRank.value = null;
|
|
||||||
date.value = today(getLocalTimeZone());
|
|
||||||
})
|
|
||||||
.catch((err) => {
|
|
||||||
console.error(err);
|
|
||||||
alert("Failed to submit rank change.");
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="flex max-w-5xl justify-center gap-5 mx-auto mt-10">
|
<div class="mx-auto mt-10 max-w-7xl px-8">
|
||||||
<Combobox v-model="currentMember">
|
<div class="flex max-h-[70vh] gap-8">
|
||||||
<ComboboxAnchor class="w-[300px]">
|
|
||||||
<ComboboxInput placeholder="Search members..." class="w-full pl-9"
|
|
||||||
:display-value="(v) => v ? v.member_name : ''" />
|
|
||||||
</ComboboxAnchor>
|
|
||||||
<ComboboxList class="w-[300px]">
|
|
||||||
<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>
|
|
||||||
|
|
||||||
<!-- Rank Combobox -->
|
<!-- LEFT COLUMN -->
|
||||||
<Combobox v-model="currentRank">
|
<div class="flex-1 border-r pr-8">
|
||||||
<ComboboxAnchor class="w-[300px]">
|
<PromotionList></PromotionList>
|
||||||
<ComboboxInput placeholder="Search ranks..." class="w-full pl-9"
|
</div>
|
||||||
:display-value="(v) => v ? v.short_name : ''" />
|
|
||||||
</ComboboxAnchor>
|
<!-- RIGHT COLUMN -->
|
||||||
<ComboboxList class="w-[300px]">
|
<div class="flex-1 flex justify-center pl-8">
|
||||||
<ComboboxEmpty class="text-muted-foreground">No results</ComboboxEmpty>
|
<div class="w-full max-w-3xl">
|
||||||
<ComboboxGroup>
|
<PromotionForm />
|
||||||
<template v-for="rank in ranks" :key="rank.id">
|
</div>
|
||||||
<ComboboxItem :value="rank"
|
</div>
|
||||||
class="data-[highlighted]:bg-accent data-[highlighted]:text-accent-foreground relative cursor-pointer select-none px-2 py-1.5">
|
|
||||||
{{ rank.short_name }}
|
</div>
|
||||||
<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-[280px] justify-start text-left font-normal',
|
|
||||||
!date && 'text-muted-foreground',
|
|
||||||
)">
|
|
||||||
<CalendarIcon class="mr-2 h-4 w-4" />
|
|
||||||
{{ date ? df.format(date.toDate(getLocalTimeZone())) : "Pick a date" }}
|
|
||||||
</Button>
|
|
||||||
</PopoverTrigger>
|
|
||||||
<PopoverContent class="w-auto p-0">
|
|
||||||
<Calendar v-model="date" initial-focus />
|
|
||||||
</PopoverContent>
|
|
||||||
</Popover>
|
|
||||||
<Button @click="submit">Submit</Button>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -19,6 +19,8 @@ const router = createRouter({
|
|||||||
{ path: '/profile', component: () => import('@/pages/MyProfile.vue'), meta: { requiresAuth: true } },
|
{ path: '/profile', component: () => import('@/pages/MyProfile.vue'), meta: { requiresAuth: true } },
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{ path: '/calendar', component: () => import('@/pages/Calendar.vue') },
|
{ path: '/calendar', component: () => import('@/pages/Calendar.vue') },
|
||||||
{ path: '/calendar/event/:id', component: () => import('@/pages/Calendar.vue') },
|
{ path: '/calendar/event/:id', component: () => import('@/pages/Calendar.vue') },
|
||||||
|
|
||||||
@@ -45,7 +47,10 @@ const router = createRouter({
|
|||||||
},
|
},
|
||||||
|
|
||||||
// UNAUTHORIZED PAGE
|
// UNAUTHORIZED PAGE
|
||||||
{ path: '/unauthorized', component: () => import('@/pages/Unauthorized.vue') }
|
{ path: '/unauthorized', component: () => import('@/pages/Unauthorized.vue') },
|
||||||
|
|
||||||
|
{ path: '/restricted', component: () => import('@/pages/Banned.vue'), meta: { requiresAuth: true } },
|
||||||
|
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -68,6 +73,10 @@ router.beforeEach(async (to) => {
|
|||||||
return false // Prevent Vue Router from continuing
|
return false // Prevent Vue Router from continuing
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// banned state
|
||||||
|
if (user.state === 'banned' && to.path !== '/restricted') {
|
||||||
|
return '/restricted';
|
||||||
|
}
|
||||||
|
|
||||||
// Must be a member
|
// Must be a member
|
||||||
if (to.meta.memberOnly && user.state !== 'member') {
|
if (to.meta.memberOnly && user.state !== 'member') {
|
||||||
|
|||||||
Reference in New Issue
Block a user