Compare commits
5 Commits
Mobile-Enh
...
DIscussion
| Author | SHA1 | Date | |
|---|---|---|---|
| 33679542d7 | |||
| e8b30f6947 | |||
| 7c090c647e | |||
| 5483e42bb4 | |||
| 5cdbf72328 |
53
api/migrations/20260222232949-discussion-posts.js
Normal file
53
api/migrations/20260222232949-discussion-posts.js
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
var dbm;
|
||||||
|
var type;
|
||||||
|
var seed;
|
||||||
|
var fs = require('fs');
|
||||||
|
var path = require('path');
|
||||||
|
var Promise;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* We receive the dbmigrate dependency from dbmigrate initially.
|
||||||
|
* This enables us to not have to rely on NODE_PATH.
|
||||||
|
*/
|
||||||
|
exports.setup = function(options, seedLink) {
|
||||||
|
dbm = options.dbmigrate;
|
||||||
|
type = dbm.dataType;
|
||||||
|
seed = seedLink;
|
||||||
|
Promise = options.Promise;
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.up = function(db) {
|
||||||
|
var filePath = path.join(__dirname, 'sqls', '20260222232949-discussion-posts-up.sql');
|
||||||
|
return new Promise( function( resolve, reject ) {
|
||||||
|
fs.readFile(filePath, {encoding: 'utf-8'}, function(err,data){
|
||||||
|
if (err) return reject(err);
|
||||||
|
console.log('received data: ' + data);
|
||||||
|
|
||||||
|
resolve(data);
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.then(function(data) {
|
||||||
|
return db.runSql(data);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.down = function(db) {
|
||||||
|
var filePath = path.join(__dirname, 'sqls', '20260222232949-discussion-posts-down.sql');
|
||||||
|
return new Promise( function( resolve, reject ) {
|
||||||
|
fs.readFile(filePath, {encoding: 'utf-8'}, function(err,data){
|
||||||
|
if (err) return reject(err);
|
||||||
|
console.log('received data: ' + data);
|
||||||
|
|
||||||
|
resolve(data);
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.then(function(data) {
|
||||||
|
return db.runSql(data);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
exports._meta = {
|
||||||
|
"version": 1
|
||||||
|
};
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
/* Replace with your SQL commands */
|
||||||
|
DROP TABLE discussion_posts;
|
||||||
|
DROP TABLE discussion_comments;
|
||||||
34
api/migrations/sqls/20260222232949-discussion-posts-up.sql
Normal file
34
api/migrations/sqls/20260222232949-discussion-posts-up.sql
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
/* Replace with your SQL commands */
|
||||||
|
CREATE TABLE discussion_posts (
|
||||||
|
id INT PRIMARY KEY AUTO_INCREMENT,
|
||||||
|
type VARCHAR(50) NOT NULL,
|
||||||
|
poster_id INT NOT NULL,
|
||||||
|
title VARCHAR(100) NOT NULL,
|
||||||
|
content JSON NOT NULL,
|
||||||
|
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||||
|
is_deleted BOOLEAN DEFAULT FALSE,
|
||||||
|
is_locked BOOLEAN DEFAULT FALSE,
|
||||||
|
is_open BOOLEAN GENERATED ALWAYS AS (
|
||||||
|
NOT is_deleted
|
||||||
|
AND NOT is_locked
|
||||||
|
) STORED,
|
||||||
|
FOREIGN KEY (poster_id) REFERENCES members(id) ON DELETE CASCADE
|
||||||
|
);
|
||||||
|
CREATE TABLE discussion_comments (
|
||||||
|
id INT PRIMARY KEY AUTO_INCREMENT,
|
||||||
|
post_id INT NOT NULL,
|
||||||
|
poster_id INT NOT NULL,
|
||||||
|
content TEXT NOT NULL,
|
||||||
|
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||||
|
is_deleted BOOLEAN DEFAULT FALSE,
|
||||||
|
FOREIGN KEY (post_id) REFERENCES discussion_posts(id) ON DELETE CASCADE,
|
||||||
|
FOREIGN KEY (poster_id) REFERENCES members(id) ON DELETE CASCADE
|
||||||
|
);
|
||||||
|
CREATE INDEX idx_discussion_posts_title ON discussion_posts(title);
|
||||||
|
CREATE INDEX idx_discussion_posts_type ON discussion_posts(type);
|
||||||
|
CREATE INDEX idx_discussion_posts_poster_id ON discussion_posts(poster_id);
|
||||||
|
CREATE INDEX idx_discussion_comments_post_id ON discussion_comments(post_id);
|
||||||
|
CREATE INDEX idx_discussion_comments_poster_id ON discussion_comments(poster_id);
|
||||||
|
CREATE INDEX idx_discussion_posts_is_open ON discussion_posts(is_open);
|
||||||
@@ -103,7 +103,9 @@ import { roles, memberRoles } from './routes/roles';
|
|||||||
import { courseRouter, eventRouter } from './routes/course';
|
import { courseRouter, eventRouter } from './routes/course';
|
||||||
import { calendarRouter } from './routes/calendar';
|
import { calendarRouter } from './routes/calendar';
|
||||||
import { docsRouter } from './routes/docs';
|
import { docsRouter } from './routes/docs';
|
||||||
import { memberUnits, units } from './routes/units';
|
import { units } from './routes/units';
|
||||||
|
import { modRequestRouter } from './routes/modRequest'
|
||||||
|
import { discussionRouter } from './routes/discussion';
|
||||||
|
|
||||||
app.use('/application', applicationRouter);
|
app.use('/application', applicationRouter);
|
||||||
app.use('/ranks', ranks);
|
app.use('/ranks', ranks);
|
||||||
@@ -118,8 +120,9 @@ app.use('/course', courseRouter)
|
|||||||
app.use('/courseEvent', eventRouter)
|
app.use('/courseEvent', eventRouter)
|
||||||
app.use('/calendar', calendarRouter)
|
app.use('/calendar', calendarRouter)
|
||||||
app.use('/units', units)
|
app.use('/units', units)
|
||||||
app.use('/memberUnits', memberUnits);
|
|
||||||
app.use('/docs', docsRouter)
|
app.use('/docs', docsRouter)
|
||||||
|
app.use('/mod-request', modRequestRouter)
|
||||||
|
app.use('/discussions', discussionRouter)
|
||||||
app.use('/', authRouter)
|
app.use('/', authRouter)
|
||||||
|
|
||||||
app.get('/ping', (req, res) => {
|
app.get('/ping', (req, res) => {
|
||||||
|
|||||||
@@ -396,11 +396,11 @@ VALUES(?, ?, ?, 1);`
|
|||||||
INNER JOIN members AS member ON member.id = app.poster_id
|
INNER JOIN members AS member ON member.id = app.poster_id
|
||||||
WHERE app.id = ?; `;
|
WHERE app.id = ?; `;
|
||||||
const comment = await conn.query(getSQL, [result.insertId])
|
const comment = await conn.query(getSQL, [result.insertId])
|
||||||
audit.record('application', 'comment_added', { actorId: user.id, targetId: appID }, { commentId: Number(result.insertId) });
|
audit.record('application', 'comment_added', { actorId: user.id, targetId: appID }, { commentId: result.insertId });
|
||||||
logger.info('app', "Admin application comment posted", {
|
logger.info('app', "Admin application comment posted", {
|
||||||
application: appID,
|
application: appID,
|
||||||
poster: user.id,
|
poster: user.id,
|
||||||
comment: Number(result.insertId),
|
comment: result.insertId,
|
||||||
})
|
})
|
||||||
|
|
||||||
res.status(201).json(comment[0]);
|
res.status(201).json(comment[0]);
|
||||||
|
|||||||
49
api/src/routes/discussion.ts
Normal file
49
api/src/routes/discussion.ts
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
const express = require('express');
|
||||||
|
const router = express.Router();
|
||||||
|
|
||||||
|
import { Request, Response } from 'express';
|
||||||
|
import { requireLogin, requireMemberState, requireRole } from '../middleware/auth';
|
||||||
|
import { logger } from '../services/logging/logger';
|
||||||
|
import { audit } from '../services/logging/auditLog';
|
||||||
|
import { MemberState } from '@app/shared/types/member';
|
||||||
|
import { createDiscussion, getAllDiscussions, getDiscussionById, getPostComments, postComment } from '../services/db/discussionService';
|
||||||
|
import { ModRequest } from '@app/shared/schemas/modRequest';
|
||||||
|
import { DiscussionComment } from '@app/shared/types/discussion';
|
||||||
|
|
||||||
|
router.use(requireLogin);
|
||||||
|
router.use(requireMemberState(MemberState.Member));
|
||||||
|
|
||||||
|
router.post('/comment', async (req: Request, res: Response) => {
|
||||||
|
try {
|
||||||
|
let comment = req.body as DiscussionComment;
|
||||||
|
|
||||||
|
if (!comment.content || comment.content.trim() === '') {
|
||||||
|
return res.status(400).json({ error: 'Comment content cannot be empty' });
|
||||||
|
}
|
||||||
|
|
||||||
|
let rowID = await postComment(comment, req.user.id);
|
||||||
|
audit.discussion('comment_posted', { actorId: req.user.id, targetId: rowID }, { parent: comment.post_id })
|
||||||
|
res.sendStatus(201);
|
||||||
|
} catch (error) {
|
||||||
|
logger.error('app', "Failed to post comments", error);
|
||||||
|
res.sendStatus(500);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
router.get('/:postId/comments', async (req: Request, res: Response) => {
|
||||||
|
try {
|
||||||
|
const postId = parseInt(req.params.postId);
|
||||||
|
const comments = await getPostComments(postId);
|
||||||
|
res.json(comments);
|
||||||
|
} catch (error) {
|
||||||
|
logger.error('app', "Failed to fetch comments", error);
|
||||||
|
res.sendStatus(500);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
router.delete('/comment/:id', async (req: Request, res: Response) => {
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
export const discussionRouter = router;
|
||||||
@@ -6,8 +6,8 @@ import pool from '../db';
|
|||||||
import { requireLogin, requireMemberState, requireRole } from '../middleware/auth';
|
import { requireLogin, requireMemberState, requireRole } from '../middleware/auth';
|
||||||
import { getUserActiveLOA } from '../services/db/loaService';
|
import { getUserActiveLOA } from '../services/db/loaService';
|
||||||
import { getAllMembersLite, getMemberSettings, getMembersFull, getMembersLite, getUserData, getUserState, setUserSettings, getFilteredMembers, setUserState, getLastNonSuspendedState } from '../services/db/memberService';
|
import { getAllMembersLite, getMemberSettings, getMembersFull, getMembersLite, getUserData, getUserState, setUserSettings, getFilteredMembers, setUserState, getLastNonSuspendedState } from '../services/db/memberService';
|
||||||
import { getUserRoles, stripUserRoles } from '../services/db/rolesService';
|
import { getUserRoles } from '../services/db/rolesService';
|
||||||
import { memberSettings, MemberState, myData, UserCacheBustResult } from '@app/shared/types/member';
|
import { memberSettings, MemberState, myData } from '@app/shared/types/member';
|
||||||
import { Discharge } from '@app/shared/schemas/dischargeSchema';
|
import { Discharge } from '@app/shared/schemas/dischargeSchema';
|
||||||
|
|
||||||
import { Performance } from 'perf_hooks';
|
import { Performance } from 'perf_hooks';
|
||||||
@@ -211,32 +211,6 @@ router.post('/full/bulk', async (req: Request, res: Response) => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
router.post('/cache/user/bust', [requireLogin, requireMemberState(MemberState.Member), requireRole('dev')], async (req: Request, res: Response) => {
|
|
||||||
try {
|
|
||||||
const clearedEntries = memberCache.Clear();
|
|
||||||
const payload: UserCacheBustResult = {
|
|
||||||
success: true,
|
|
||||||
clearedEntries,
|
|
||||||
bustedAt: new Date().toISOString(),
|
|
||||||
};
|
|
||||||
|
|
||||||
logger.info('app', 'User cache manually busted', {
|
|
||||||
actor: req.user.id,
|
|
||||||
clearedEntries,
|
|
||||||
});
|
|
||||||
|
|
||||||
return res.status(200).json(payload);
|
|
||||||
} catch (error) {
|
|
||||||
logger.error('app', 'Failed to bust user cache', {
|
|
||||||
caller: req.user?.id,
|
|
||||||
error: error instanceof Error ? error.message : String(error),
|
|
||||||
stack: error instanceof Error ? error.stack : undefined,
|
|
||||||
});
|
|
||||||
|
|
||||||
return res.status(500).json({ error: 'Failed to bust user cache' });
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
router.get('/:id', [requireLogin], async (req, res) => {
|
router.get('/:id', [requireLogin], async (req, res) => {
|
||||||
const userId = req.params.id;
|
const userId = req.params.id;
|
||||||
|
|
||||||
@@ -275,7 +249,6 @@ router.post('/discharge', [requireLogin, requireMemberState(MemberState.Member),
|
|||||||
|
|
||||||
var data: Discharge = req.body;
|
var data: Discharge = req.body;
|
||||||
setUserState(data.userID, MemberState.Discharged, "Member Discharged", author, con, data.reason);
|
setUserState(data.userID, MemberState.Discharged, "Member Discharged", author, con, data.reason);
|
||||||
stripUserRoles(data.userID, con);
|
|
||||||
cancelLatestRank(data.userID, con);
|
cancelLatestRank(data.userID, con);
|
||||||
cancelLatestUnit(data.userID, con);
|
cancelLatestUnit(data.userID, con);
|
||||||
con.commit();
|
con.commit();
|
||||||
|
|||||||
65
api/src/routes/modRequest.ts
Normal file
65
api/src/routes/modRequest.ts
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
const express = require('express');
|
||||||
|
const router = express.Router();
|
||||||
|
|
||||||
|
import { Request, Response } from 'express';
|
||||||
|
import { requireLogin, requireMemberState, requireRole } from '../middleware/auth';
|
||||||
|
import { logger } from '../services/logging/logger';
|
||||||
|
import { audit } from '../services/logging/auditLog';
|
||||||
|
import { MemberState } from '@app/shared/types/member';
|
||||||
|
import { createDiscussion, getAllDiscussions, getDiscussionById } from '../services/db/discussionService';
|
||||||
|
import { ModRequest } from '@app/shared/schemas/modRequest';
|
||||||
|
|
||||||
|
router.use(requireLogin);
|
||||||
|
router.use(requireMemberState(MemberState.Member));
|
||||||
|
|
||||||
|
router.get('/', async (req: Request, res: Response) => {
|
||||||
|
try {
|
||||||
|
const page = parseInt(req.query.page as string) || 1;
|
||||||
|
const pageSize = parseInt(req.query.pageSize as string) || 10;
|
||||||
|
const search = parseInt(req.query.search as string) || null;
|
||||||
|
|
||||||
|
const result = await getAllDiscussions<ModRequest>('mod_request', page, pageSize);
|
||||||
|
|
||||||
|
return res.json(result);
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error fetching mod requests:', error);
|
||||||
|
res.status(500).json({ error: 'Internal Server Error' });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// GET a single mod request by ID
|
||||||
|
router.get('/:id', async (req: Request, res: Response) => {
|
||||||
|
try {
|
||||||
|
const id = parseInt(req.params.id, 10);
|
||||||
|
if (isNaN(id)) {
|
||||||
|
return res.status(400).json({ error: 'Invalid ID' });
|
||||||
|
}
|
||||||
|
|
||||||
|
const discussion = await getDiscussionById<ModRequest>(id);
|
||||||
|
if (!discussion) {
|
||||||
|
return res.status(404).json({ error: 'Mod request not found' });
|
||||||
|
}
|
||||||
|
|
||||||
|
return res.json(discussion);
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error fetching mod request by id:', error);
|
||||||
|
res.status(500).json({ error: 'Internal Server Error' });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
router.post('/', async (req: Request, res: Response) => {
|
||||||
|
try {
|
||||||
|
let author = req.user.id;
|
||||||
|
let data = req.body as ModRequest;
|
||||||
|
|
||||||
|
let postID = await createDiscussion<ModRequest>('mod_request', author, data.mod_title, data);
|
||||||
|
logger.info('app', 'Mod request posted', {});
|
||||||
|
audit.discussion('created', { actorId: author, targetId: postID }, { type: "mod_request" });
|
||||||
|
return res.status(200).send(postID);
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error posting a mod request:', error);
|
||||||
|
res.status(500).json({ error: 'Internal Server Error' });
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
export const modRequestRouter = router;
|
||||||
@@ -1,17 +1,10 @@
|
|||||||
import express = require('express');
|
import express = require('express');
|
||||||
const unitsRouter = express.Router();
|
const unitsRouter = express.Router();
|
||||||
const memberUnitsRouter = express.Router();
|
|
||||||
|
|
||||||
import { Request, Response } from 'express';
|
|
||||||
|
|
||||||
import pool from '../db';
|
import pool from '../db';
|
||||||
import { requireLogin, requireMemberState, requireRole } from '../middleware/auth';
|
import { requireLogin } from '../middleware/auth';
|
||||||
import { logger } from '../services/logging/logger';
|
import { logger } from '../services/logging/logger';
|
||||||
import { Unit } from '@app/shared/types/units';
|
import { Unit } from '@app/shared/types/units';
|
||||||
import { MemberState } from '@app/shared/types/member';
|
|
||||||
import { assignNewUnit } from '../services/db/unitService';
|
|
||||||
import { audit } from '../services/logging/auditLog';
|
|
||||||
import { forceInsertMemberRank, insertMemberRank } from '../services/db/rankService';
|
|
||||||
|
|
||||||
unitsRouter.use(requireLogin);
|
unitsRouter.use(requireLogin);
|
||||||
|
|
||||||
@@ -33,41 +26,4 @@ unitsRouter.get('/', async (req, res) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
memberUnitsRouter.post('/admin', [requireMemberState(MemberState.Member), requireRole("17th Administrator")], async (req: Request, res: Response) => {
|
|
||||||
const memberId = Number(req.query.memberId);
|
|
||||||
const unitId = Number(req.query.unitId);
|
|
||||||
const rankId = Number(req.query.rankId);
|
|
||||||
const reason = req.query.reason as string;
|
|
||||||
|
|
||||||
try {
|
|
||||||
|
|
||||||
if (!memberId || !unitId) {
|
|
||||||
return res.status(400).json({ error: 'memberId and unitId query parameters are required' });
|
|
||||||
}
|
|
||||||
|
|
||||||
await assignNewUnit(memberId, unitId, req.user.id, req.user.id, reason);
|
|
||||||
await forceInsertMemberRank(memberId, rankId, req.user.id, req.user.id, reason);
|
|
||||||
logger.info('app', 'Member force assigned unit', {
|
|
||||||
member: memberId,
|
|
||||||
unit: unitId,
|
|
||||||
rank: rankId,
|
|
||||||
caller: req.user.id,
|
|
||||||
});
|
|
||||||
audit.member('update_unit', { actorId: req.user.id, targetId: memberId }, { unit: unitId, rank: rankId, reason: reason });
|
|
||||||
|
|
||||||
res.sendStatus(200);
|
|
||||||
} catch (error) {
|
|
||||||
logger.error('app', 'Failed to force assign unit', {
|
|
||||||
member: memberId,
|
|
||||||
unit: unitId,
|
|
||||||
caller: req.user.id,
|
|
||||||
error: error instanceof Error ? error.message : String(error),
|
|
||||||
stack: error instanceof Error ? error.stack : undefined,
|
|
||||||
})
|
|
||||||
|
|
||||||
res.sendStatus(500);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
export const units = unitsRouter;
|
export const units = unitsRouter;
|
||||||
export const memberUnits = memberUnitsRouter;
|
|
||||||
10
api/src/services/cache/cache.ts
vendored
10
api/src/services/cache/cache.ts
vendored
@@ -16,14 +16,4 @@ export class CacheService<Key, Value> {
|
|||||||
public Invalidate(key: Key): boolean {
|
public Invalidate(key: Key): boolean {
|
||||||
return this.cacheMap.delete(key);
|
return this.cacheMap.delete(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Size(): number {
|
|
||||||
return this.cacheMap.size;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Clear(): number {
|
|
||||||
const priorSize = this.cacheMap.size;
|
|
||||||
this.cacheMap.clear();
|
|
||||||
return priorSize;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
150
api/src/services/db/discussionService.ts
Normal file
150
api/src/services/db/discussionService.ts
Normal file
@@ -0,0 +1,150 @@
|
|||||||
|
import { toDateTime } from "@app/shared/utils/time";
|
||||||
|
import pool from "../../db";
|
||||||
|
import { LOARequest, LOAType } from '@app/shared/types/loa'
|
||||||
|
import { PagedData } from '@app/shared/types/pagination'
|
||||||
|
import { DiscussionPost } from '@app/shared/types/discussion';
|
||||||
|
import { DiscussionComment } from '@app/shared/types/discussion';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves all discussion posts with pagination and optional type filtering.
|
||||||
|
* @template T - The type of content stored in discussion posts
|
||||||
|
* @param {string} [type] - Optional type filter to retrieve only posts of a specific type
|
||||||
|
* @param {number} [page=1] - The page number for pagination (1-indexed)
|
||||||
|
* @param {number} [pageSize=10] - The number of posts per page
|
||||||
|
* @returns {Promise<PagedData<DiscussionPost<T>>>} A promise that resolves to paginated discussion posts with metadata
|
||||||
|
* @throws {Error} If the database query fails
|
||||||
|
*/
|
||||||
|
export async function getAllDiscussions<T>(type?: string, page = 1, pageSize = 10, search?: string): Promise<PagedData<DiscussionPost<T>>> {
|
||||||
|
const offset = (page - 1) * pageSize;
|
||||||
|
const params: any[] = [];
|
||||||
|
|
||||||
|
// Base query parts
|
||||||
|
let whereClause = "WHERE is_deleted = FALSE";
|
||||||
|
if (type) {
|
||||||
|
whereClause += " AND type = ?";
|
||||||
|
params.push(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
const sql = `
|
||||||
|
SELECT
|
||||||
|
p.*,
|
||||||
|
m.name as poster_name
|
||||||
|
FROM discussion_posts AS p
|
||||||
|
LEFT JOIN members m ON p.poster_id = m.id
|
||||||
|
${whereClause}
|
||||||
|
ORDER BY
|
||||||
|
p.is_open DESC, -- Show active/unlocked threads first
|
||||||
|
p.created_at DESC -- Then show newest first
|
||||||
|
LIMIT ? OFFSET ?;
|
||||||
|
`;
|
||||||
|
|
||||||
|
// Add pagination params to the end
|
||||||
|
params.push(pageSize, offset);
|
||||||
|
|
||||||
|
// Execute queries
|
||||||
|
const posts: DiscussionPost<T>[] = await pool.query(sql, params) as DiscussionPost<T>[];
|
||||||
|
|
||||||
|
// Get count for the specific types
|
||||||
|
const countSql = `SELECT COUNT(*) as count FROM discussion_posts ${whereClause}`;
|
||||||
|
const countResult = await pool.query(countSql, type ? [type] : []);
|
||||||
|
const totalCount = Number(countResult[0].count);
|
||||||
|
|
||||||
|
const totalPages = Math.ceil(totalCount / pageSize);
|
||||||
|
|
||||||
|
return {
|
||||||
|
data: posts,
|
||||||
|
pagination: {
|
||||||
|
page,
|
||||||
|
pageSize,
|
||||||
|
total: totalCount,
|
||||||
|
totalPages
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new discussion post.
|
||||||
|
* @template T - The type of content for the discussion post
|
||||||
|
* @param {string} type - The type/category of the discussion post
|
||||||
|
* @param {number} authorID - The ID of the member creating the post
|
||||||
|
* @param {postTitle} string - The title of the discussion post
|
||||||
|
* @param {T} data - The content data to be stored in the post
|
||||||
|
* @returns {Promise<Number>} A promise that resolves to the ID of the newly created post
|
||||||
|
* @throws {Error} If the database insertion fails
|
||||||
|
*/
|
||||||
|
export async function createDiscussion<T>(type: string, authorID: number, postTitle: string, data: T): Promise<number> {
|
||||||
|
const sql = `
|
||||||
|
INSERT INTO discussion_posts (type, poster_id, title, content)
|
||||||
|
VALUES (?, ?, ?, ?)
|
||||||
|
`;
|
||||||
|
|
||||||
|
console.log(data);
|
||||||
|
const result = await pool.query(sql, [
|
||||||
|
type,
|
||||||
|
authorID,
|
||||||
|
postTitle,
|
||||||
|
JSON.stringify(data)
|
||||||
|
]);
|
||||||
|
|
||||||
|
console.log(result);
|
||||||
|
return Number(result.insertId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve a single discussion post by its ID.
|
||||||
|
* @template T - type of the content stored in the post (e.g. ModRequest)
|
||||||
|
* @param {number} id - The id of the discussion post to fetch
|
||||||
|
* @returns {Promise<DiscussionPost<T> | null>} The discussion post or null if not found
|
||||||
|
*/
|
||||||
|
export async function getDiscussionById<T>(id: number): Promise<DiscussionPost<T> | null> {
|
||||||
|
// Get the post
|
||||||
|
const postSql = `
|
||||||
|
SELECT
|
||||||
|
p.*,
|
||||||
|
m.name as poster_name
|
||||||
|
FROM discussion_posts AS p
|
||||||
|
LEFT JOIN members m ON p.poster_id = m.id
|
||||||
|
WHERE p.id = ?
|
||||||
|
LIMIT 1;
|
||||||
|
`;
|
||||||
|
const postResults = (await pool.query(postSql, [id])) as DiscussionPost<T>[];
|
||||||
|
if (postResults.length === 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
const post = postResults[0];
|
||||||
|
|
||||||
|
// Get comments for the post
|
||||||
|
const commentSql = `
|
||||||
|
SELECT
|
||||||
|
c.*
|
||||||
|
FROM discussion_comments AS c
|
||||||
|
WHERE c.post_id = ?
|
||||||
|
AND c.is_deleted = FALSE
|
||||||
|
ORDER BY c.created_at ASC;
|
||||||
|
`;
|
||||||
|
const comments = (await pool.query(commentSql, [id])) as DiscussionComment[];
|
||||||
|
|
||||||
|
// Attach comments to post
|
||||||
|
post.comments = comments;
|
||||||
|
|
||||||
|
return post;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getPostComments(postID: number): Promise<DiscussionComment[]> {
|
||||||
|
let comments = await pool.query("SELECT * FROM discussion_comments WHERE post_id = ?", [postID]);
|
||||||
|
return comments;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function postComment(commentData: DiscussionComment, poster: number) {
|
||||||
|
const sql = `
|
||||||
|
INSERT INTO discussion_comments (post_id, poster_id, content) VALUES (?, ?, ?);
|
||||||
|
`;
|
||||||
|
|
||||||
|
const result = await pool.query(sql, [commentData.post_id, poster, commentData.content]);
|
||||||
|
|
||||||
|
if (!result.affectedRows || result.affectedRows !== 1) {
|
||||||
|
throw new Error('Failed to insert comment: expected 1 row to be inserted');
|
||||||
|
}
|
||||||
|
|
||||||
|
return Number(result.insertId);
|
||||||
|
}
|
||||||
@@ -23,8 +23,7 @@ export async function getFilteredMembers(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (search) {
|
if (search) {
|
||||||
whereClauses.push(`(v.member_name LIKE ? OR v.displayName LIKE ?)`);
|
whereClauses.push(`v.member_name LIKE ?`);
|
||||||
params.push(`%${search}%`);
|
|
||||||
params.push(`%${search}%`);
|
params.push(`%${search}%`);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -220,10 +219,7 @@ export async function getMembersFull(ids: number[]): Promise<MemberCardDetails[]
|
|||||||
loa_until: row.loa_until ? new Date(row.loa_until) : undefined,
|
loa_until: row.loa_until ? new Date(row.loa_until) : undefined,
|
||||||
};
|
};
|
||||||
// roles comes as array of strings; parse each one
|
// roles comes as array of strings; parse each one
|
||||||
const roles: Role[] =
|
const roles: Role[] = row.roles;
|
||||||
typeof row.roles === "string"
|
|
||||||
? JSON.parse(row.roles)
|
|
||||||
: row.roles;
|
|
||||||
|
|
||||||
return { member, roles };
|
return { member, roles };
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -36,16 +36,6 @@ export async function insertMemberRank(member_id: number, rank_id: number, date?
|
|||||||
await pool.query(sql, params);
|
await pool.query(sql, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function forceInsertMemberRank(member_id: number, rank_id: number, authorized: number, creator: number, reason: string) {
|
|
||||||
const sql = `CALL sp_update_member_rank(?, ?, ?, ?, ?, NOW())`;
|
|
||||||
|
|
||||||
const result = await pool.query(sql, [member_id, rank_id, authorized, creator, reason]);
|
|
||||||
|
|
||||||
if (!result || result.affectedRows === 0) {
|
|
||||||
throw new Error("Failed to update member rank");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
export async function batchInsertMemberRank(promos: BatchPromotionMember[], author: number, approver: number) {
|
export async function batchInsertMemberRank(promos: BatchPromotionMember[], author: number, approver: number) {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ import pool from '../../db';
|
|||||||
import { Role, RoleSummary } from '@app/shared/types/roles'
|
import { Role, RoleSummary } from '@app/shared/types/roles'
|
||||||
import { logger } from '../logging/logger';
|
import { logger } from '../logging/logger';
|
||||||
import { memberCache } from '../../routes/auth';
|
import { memberCache } from '../../routes/auth';
|
||||||
import * as mariadb from 'mariadb';
|
|
||||||
|
|
||||||
export async function assignUserGroup(userID: number, roleID: number) {
|
export async function assignUserGroup(userID: number, roleID: number) {
|
||||||
try {
|
try {
|
||||||
@@ -63,16 +62,4 @@ export async function getUsersWithRole(roleId: number): Promise<MemberLight[]> {
|
|||||||
)
|
)
|
||||||
|
|
||||||
return out as MemberLight[]
|
return out as MemberLight[]
|
||||||
}
|
|
||||||
|
|
||||||
export async function stripUserRoles(userID: number, con: mariadb.Pool | mariadb.Connection = pool) {
|
|
||||||
try {
|
|
||||||
const out = await con.query(`DELETE FROM members_roles WHERE member_id = ?;`, [userID]);
|
|
||||||
return { success: true, affectedRows: out.affectedRows };
|
|
||||||
} catch (error) {
|
|
||||||
logger.error('app', 'Failed to strip user roles', error);
|
|
||||||
throw error;
|
|
||||||
} finally {
|
|
||||||
memberCache.Invalidate(userID);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -10,13 +10,4 @@ export async function cancelLatestUnit(userID: number, con: mariadb.Pool | maria
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
export async function assignNewUnit(memberID: number, unitID: number, authorizedID: number, creatorID: number, reason: string) {
|
|
||||||
let sql = `CALL sp_update_member_unit(?, ?, ?, ?, ?, NOW())`;
|
|
||||||
|
|
||||||
const result = await pool.query(sql, [memberID, unitID, authorizedID, creatorID, reason]);
|
|
||||||
if (!result || result.affectedRows === 0) {
|
|
||||||
throw new Error('Record was not updated');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
import pool from "../../db";
|
import pool from "../../db";
|
||||||
import { logger } from "./logger";
|
import { logger } from "./logger";
|
||||||
|
|
||||||
export type AuditArea = 'member' | 'calendar' | 'roles' | 'auth' | 'leave_of_absence' | 'application' | 'course';
|
export type AuditArea = 'member' | 'calendar' | 'roles' | 'auth' | 'leave_of_absence' | 'application' | 'course' | 'discussion';
|
||||||
|
|
||||||
export interface AuditContext {
|
export interface AuditContext {
|
||||||
actorId: number; // The person doing the action (created_by)
|
actorId: number; // The person doing the action (created_by)
|
||||||
@@ -32,8 +32,8 @@ class AuditLogger {
|
|||||||
logger.error('audit', `AUDIT_FAILURE: Failed to log ${actionType}`, { error: err });
|
logger.error('audit', `AUDIT_FAILURE: Failed to log ${actionType}`, { error: err });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
member(action: 'update_rank'| 'update_unit' | 'suspension_added' | 'suspension_removed' | 'discharged', context: AuditContext, data: any = {}) {
|
member(action: 'update_rank' | 'suspension_added' | 'suspension_removed' | 'discharged', context: AuditContext, data: any = {}) {
|
||||||
return this.record('member', action, context, data);
|
return this.record('member', action, context, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -56,6 +56,10 @@ class AuditLogger {
|
|||||||
course(action: 'report_created' | 'report_edited', context: AuditContext, data: any = {}) {
|
course(action: 'report_created' | 'report_edited', context: AuditContext, data: any = {}) {
|
||||||
return this.record('course', action, context, data);
|
return this.record('course', action, context, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
discussion(action: 'created' | 'comment_posted', context: AuditContext, data: any = {}) {
|
||||||
|
return this.record('discussion', action, context, data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const audit = new AuditLogger();
|
export const audit = new AuditLogger();
|
||||||
24
shared/schemas/modRequest.ts
Normal file
24
shared/schemas/modRequest.ts
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
import { z } from 'zod';
|
||||||
|
|
||||||
|
export const ModRequestSchema = z.object({
|
||||||
|
// Basic Info
|
||||||
|
mod_title: z.string().min(1),
|
||||||
|
description: z.string().min(1),
|
||||||
|
mod_link: z.string().min(1),
|
||||||
|
|
||||||
|
// Consolidated Testing
|
||||||
|
confirmed_tested: z.boolean().refine(val => val === true, {
|
||||||
|
message: "You must confirm that you have tested this mod before submitting"
|
||||||
|
}),
|
||||||
|
|
||||||
|
// Vetting
|
||||||
|
reason: z.string().min(1),
|
||||||
|
|
||||||
|
// Compatibility & Technical
|
||||||
|
detrimental_effects: z.string().min(1),
|
||||||
|
keybind_conflicts: z.string(),
|
||||||
|
|
||||||
|
special_considerations: z.string().optional()
|
||||||
|
});
|
||||||
|
|
||||||
|
export type ModRequest = z.infer<typeof ModRequestSchema>;
|
||||||
24
shared/types/discussion.ts
Normal file
24
shared/types/discussion.ts
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
export interface DiscussionPost<T = any> {
|
||||||
|
id: number;
|
||||||
|
type: string;
|
||||||
|
poster_id: number;
|
||||||
|
poster_name?: string;
|
||||||
|
title: string;
|
||||||
|
content: T;
|
||||||
|
created_at: Date;
|
||||||
|
updated_at: Date;
|
||||||
|
is_deleted: boolean;
|
||||||
|
is_locked: boolean;
|
||||||
|
is_open: boolean;
|
||||||
|
comments?: DiscussionComment[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface DiscussionComment {
|
||||||
|
id?: number;
|
||||||
|
post_id: number;
|
||||||
|
poster_id?: number;
|
||||||
|
content: string;
|
||||||
|
created_at?: Date;
|
||||||
|
updated_at?: Date;
|
||||||
|
is_deleted?: boolean;
|
||||||
|
}
|
||||||
@@ -50,10 +50,4 @@ export interface myData {
|
|||||||
LOAs: LOARequest[];
|
LOAs: LOARequest[];
|
||||||
roles: Role[];
|
roles: Role[];
|
||||||
state: MemberState;
|
state: MemberState;
|
||||||
}
|
|
||||||
|
|
||||||
export interface UserCacheBustResult {
|
|
||||||
success: boolean;
|
|
||||||
clearedEntries: number;
|
|
||||||
bustedAt: string;
|
|
||||||
}
|
}
|
||||||
@@ -6,11 +6,8 @@
|
|||||||
import AlertDescription from './components/ui/alert/AlertDescription.vue';
|
import AlertDescription from './components/ui/alert/AlertDescription.vue';
|
||||||
import Navbar from './components/Navigation/Navbar.vue';
|
import Navbar from './components/Navigation/Navbar.vue';
|
||||||
import { cancelLOA } from './api/loa';
|
import { cancelLOA } from './api/loa';
|
||||||
import { onBeforeUnmount, onMounted, ref } from 'vue';
|
|
||||||
|
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
const headerRef = ref<HTMLDivElement | null>(null);
|
|
||||||
let resizeObserver: ResizeObserver | null = null;
|
|
||||||
|
|
||||||
function formatDate(dateStr) {
|
function formatDate(dateStr) {
|
||||||
if (!dateStr) return "";
|
if (!dateStr) return "";
|
||||||
@@ -25,27 +22,6 @@
|
|||||||
const environment = import.meta.env.VITE_ENVIRONMENT;
|
const environment = import.meta.env.VITE_ENVIRONMENT;
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
const version = import.meta.env.VITE_APPLICATION_VERSION;
|
const version = import.meta.env.VITE_APPLICATION_VERSION;
|
||||||
|
|
||||||
function updateHeaderHeight() {
|
|
||||||
if (!headerRef.value) return;
|
|
||||||
const height = headerRef.value.offsetHeight;
|
|
||||||
document.documentElement.style.setProperty('--app-header-height', `${height}px`);
|
|
||||||
}
|
|
||||||
|
|
||||||
onMounted(() => {
|
|
||||||
updateHeaderHeight();
|
|
||||||
|
|
||||||
// Gracefully skip observer setup for environments that do not support ResizeObserver.
|
|
||||||
if (typeof ResizeObserver === 'undefined' || !headerRef.value) return;
|
|
||||||
|
|
||||||
resizeObserver = new ResizeObserver(updateHeaderHeight);
|
|
||||||
resizeObserver.observe(headerRef.value);
|
|
||||||
});
|
|
||||||
|
|
||||||
onBeforeUnmount(() => {
|
|
||||||
resizeObserver?.disconnect();
|
|
||||||
});
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -53,7 +29,7 @@
|
|||||||
background-size: contain;
|
background-size: contain;
|
||||||
background-attachment: fixed;
|
background-attachment: fixed;
|
||||||
background-position: center;">
|
background-position: center;">
|
||||||
<div class="sticky top-0 bg-background z-50" ref="headerRef">
|
<div class="sticky top-0 bg-background z-50">
|
||||||
<Navbar class="flex"></Navbar>
|
<Navbar class="flex"></Navbar>
|
||||||
<Alert v-if="environment == 'dev'" class="m-2 mx-auto max-w-5xl" variant="info">
|
<Alert v-if="environment == 'dev'" class="m-2 mx-auto max-w-5xl" variant="info">
|
||||||
<AlertDescription class="flex flex-row items-center text-wrap gap-5 mx-auto">
|
<AlertDescription class="flex flex-row items-center text-wrap gap-5 mx-auto">
|
||||||
|
|||||||
36
ui/src/api/discussion.ts
Normal file
36
ui/src/api/discussion.ts
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
import { DiscussionComment } from "@shared/types/discussion";
|
||||||
|
|
||||||
|
//@ts-expect-error
|
||||||
|
const addr = import.meta.env.VITE_APIHOST;
|
||||||
|
|
||||||
|
export async function postComment(comment: DiscussionComment) {
|
||||||
|
const res = await fetch(`${addr}/discussions/comment`, {
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
},
|
||||||
|
body: JSON.stringify(comment),
|
||||||
|
credentials: 'include',
|
||||||
|
});
|
||||||
|
|
||||||
|
if (res.ok) {
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
throw new Error("Failed to submit LOA");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getPostComments(postId: number): Promise<DiscussionComment[]> {
|
||||||
|
const res = await fetch(`${addr}/discussions/${postId}/comments`, {
|
||||||
|
method: "GET",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
},
|
||||||
|
credentials: 'include',
|
||||||
|
});
|
||||||
|
if (!res.ok) {
|
||||||
|
throw new Error("Failed to fetch comments");
|
||||||
|
}
|
||||||
|
return res.json();
|
||||||
|
}
|
||||||
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Discharge } from "@shared/schemas/dischargeSchema";
|
import { Discharge } from "@shared/schemas/dischargeSchema";
|
||||||
import { memberSettings, Member, MemberLight, MemberCardDetails, PaginatedMembers, MemberState, UserCacheBustResult } from "@shared/types/member";
|
import { memberSettings, Member, MemberLight, MemberCardDetails, PaginatedMembers, MemberState } from "@shared/types/member";
|
||||||
|
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
const addr = import.meta.env.VITE_APIHOST;
|
const addr = import.meta.env.VITE_APIHOST;
|
||||||
@@ -157,17 +157,4 @@ export async function unsuspendMember(memberID: number): Promise<boolean> {
|
|||||||
throw new Error("Failed to discharge member");
|
throw new Error("Failed to discharge member");
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
|
|
||||||
export async function bustUserCache(): Promise<UserCacheBustResult> {
|
|
||||||
const response = await fetch(`${addr}/members/cache/user/bust`, {
|
|
||||||
credentials: 'include',
|
|
||||||
method: 'POST',
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!response.ok) {
|
|
||||||
throw new Error('Failed to bust user cache');
|
|
||||||
}
|
|
||||||
|
|
||||||
return response.json();
|
|
||||||
}
|
}
|
||||||
72
ui/src/api/modRequests.ts
Normal file
72
ui/src/api/modRequests.ts
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
import { ModRequest } from "@shared/schemas/modRequest";
|
||||||
|
import { DiscussionPost } from "@shared/types/discussion";
|
||||||
|
import { PagedData } from "@shared/types/pagination";
|
||||||
|
|
||||||
|
//@ts-expect-error
|
||||||
|
const addr = import.meta.env.VITE_APIHOST;
|
||||||
|
|
||||||
|
export async function getModRequests(page?: number, pageSize?: number): Promise<PagedData<DiscussionPost<ModRequest>>> {
|
||||||
|
const params = new URLSearchParams();
|
||||||
|
|
||||||
|
if (page !== undefined) {
|
||||||
|
params.set("page", page.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pageSize !== undefined) {
|
||||||
|
params.set("pageSize", pageSize.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
return fetch(`${addr}/mod-request?${params}`, {
|
||||||
|
method: "GET",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
},
|
||||||
|
credentials: 'include',
|
||||||
|
}).then((res) => {
|
||||||
|
if (res.ok) {
|
||||||
|
return res.json();
|
||||||
|
} else {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Posts a new mod request to the server
|
||||||
|
* @param data Form data
|
||||||
|
* @returns Numerical ID of the new post
|
||||||
|
*/
|
||||||
|
export async function postModRequest(data: ModRequest): Promise<Number> {
|
||||||
|
return fetch(`${addr}/mod-request`, {
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
},
|
||||||
|
credentials: 'include',
|
||||||
|
body: JSON.stringify(data)
|
||||||
|
}).then((res) => {
|
||||||
|
if (res.ok) {
|
||||||
|
return res.text().then((id) => Number(id));
|
||||||
|
} else {
|
||||||
|
throw new Error("Failed to post mod request");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve a single mod request by its discussion post ID
|
||||||
|
* @param id numeric post id
|
||||||
|
*/
|
||||||
|
export async function getModRequest(id: number): Promise<DiscussionPost<ModRequest>> {
|
||||||
|
const res = await fetch(`${addr}/mod-request/${id}`, {
|
||||||
|
method: 'GET',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
},
|
||||||
|
credentials: 'include',
|
||||||
|
});
|
||||||
|
if (!res.ok) {
|
||||||
|
throw new Error(`Failed to fetch mod request ${id}`);
|
||||||
|
}
|
||||||
|
return res.json();
|
||||||
|
}
|
||||||
@@ -12,15 +12,4 @@ export async function getUnits(): Promise<Unit[]> {
|
|||||||
throw new Error("Failed to fetch units");
|
throw new Error("Failed to fetch units");
|
||||||
}
|
}
|
||||||
return response.json();
|
return response.json();
|
||||||
}
|
|
||||||
|
|
||||||
export async function adminAssignUnit(member: number, unit: number, rank: number, reason: string) {
|
|
||||||
const response = await fetch(`${addr}/memberUnits/admin?memberId=${member}&unitId=${unit}&rankId=${rank}&reason=${encodeURIComponent(reason)}`, {
|
|
||||||
method: 'POST',
|
|
||||||
credentials: 'include'
|
|
||||||
});
|
|
||||||
if (!response.ok) {
|
|
||||||
throw new Error("Failed to assign unit");
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { RouterLink, useRouter } from 'vue-router';
|
import { RouterLink } from 'vue-router';
|
||||||
import Separator from '../ui/separator/Separator.vue';
|
import Separator from '../ui/separator/Separator.vue';
|
||||||
import { Popover, PopoverContent, PopoverTrigger } from '../ui/popover';
|
import { Popover, PopoverContent, PopoverTrigger } from '../ui/popover';
|
||||||
import {
|
import {
|
||||||
@@ -18,11 +18,10 @@
|
|||||||
import NavigationMenuContent from '../ui/navigation-menu/NavigationMenuContent.vue';
|
import NavigationMenuContent from '../ui/navigation-menu/NavigationMenuContent.vue';
|
||||||
import { navigationMenuTriggerStyle } from '../ui/navigation-menu/'
|
import { navigationMenuTriggerStyle } from '../ui/navigation-menu/'
|
||||||
import { useAuth } from '@/composables/useAuth';
|
import { useAuth } from '@/composables/useAuth';
|
||||||
import { ArrowUpRight, ChevronDown, ChevronUp, CircleArrowOutUpRight, LogIn, LogOut, Menu, Settings, X } from 'lucide-vue-next';
|
import { ArrowUpRight, CircleArrowOutUpRight } from 'lucide-vue-next';
|
||||||
import DropdownMenuGroup from '../ui/dropdown-menu/DropdownMenuGroup.vue';
|
import DropdownMenuGroup from '../ui/dropdown-menu/DropdownMenuGroup.vue';
|
||||||
import DropdownMenuSeparator from '../ui/dropdown-menu/DropdownMenuSeparator.vue';
|
import DropdownMenuSeparator from '../ui/dropdown-menu/DropdownMenuSeparator.vue';
|
||||||
import { MemberState } from '@shared/types/member';
|
import { MemberState } from '@shared/types/member';
|
||||||
import { computed, onBeforeUnmount, ref, watch } from 'vue';
|
|
||||||
|
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
const auth = useAuth();
|
const auth = useAuth();
|
||||||
@@ -42,173 +41,11 @@
|
|||||||
(document.activeElement as HTMLElement)?.blur();
|
(document.activeElement as HTMLElement)?.blur();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
type NavItem = {
|
|
||||||
title: string;
|
|
||||||
to?: string;
|
|
||||||
href?: string;
|
|
||||||
status?: 'member' | 'guest';
|
|
||||||
isExternal?: boolean;
|
|
||||||
roles?: string[];
|
|
||||||
items?: NavItem[];
|
|
||||||
};
|
|
||||||
|
|
||||||
const navConfig: NavItem[] = [
|
|
||||||
{
|
|
||||||
title: 'Calendar',
|
|
||||||
to: '/calendar',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: 'Documents',
|
|
||||||
href: 'https://docs.iceberg-gaming.com',
|
|
||||||
status: 'member',
|
|
||||||
isExternal: true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: 'Forms',
|
|
||||||
status: 'member',
|
|
||||||
items: [
|
|
||||||
{ title: 'Leave of Absence', to: '/loa' },
|
|
||||||
{ title: 'Training Report', to: '/trainingReport' },
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: 'Administration',
|
|
||||||
status: 'member',
|
|
||||||
roles: ['17th Administrator', '17th HQ', '17th Command', 'Recruiter'],
|
|
||||||
items: [
|
|
||||||
{
|
|
||||||
title: 'Leave of Absence',
|
|
||||||
to: '/administration/loa',
|
|
||||||
roles: ['17th Administrator', '17th HQ', '17th Command']
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: 'Promotions',
|
|
||||||
to: '/administration/rankChange',
|
|
||||||
roles: ['17th Administrator', '17th HQ', '17th Command']
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: 'Recruitment',
|
|
||||||
to: '/administration/applications',
|
|
||||||
roles: ['Recruiter']
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: 'Member Management',
|
|
||||||
to: '/administration/members',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: 'Role Management',
|
|
||||||
to: '/administration/roles',
|
|
||||||
roles: ['17th Administrator']
|
|
||||||
},
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: 'Developer',
|
|
||||||
to: '/developer',
|
|
||||||
roles: ['Dev']
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: 'Join',
|
|
||||||
to: '/join',
|
|
||||||
status: 'guest',
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
const filteredNav = computed(() => {
|
|
||||||
return navConfig.flatMap(item => {
|
|
||||||
const filtered: NavItem[] = [];
|
|
||||||
|
|
||||||
// 1. Check Login Requirements
|
|
||||||
const isLoggedIn = userStore.isLoggedIn;
|
|
||||||
|
|
||||||
// 2. Determine visibility based on status
|
|
||||||
let shouldShow = false;
|
|
||||||
|
|
||||||
if (!item.status) {
|
|
||||||
// Public items - always show
|
|
||||||
shouldShow = true;
|
|
||||||
} else if (item.status === 'guest') {
|
|
||||||
// Show if NOT logged in OR logged in as guest (but NOT a member)
|
|
||||||
shouldShow = !isLoggedIn || auth.accountStatus.value === MemberState.Guest;
|
|
||||||
} else if (item.status === 'member') {
|
|
||||||
// Show ONLY if logged in as member
|
|
||||||
shouldShow = isLoggedIn && auth.accountStatus.value === MemberState.Member;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 3. Check Role Requirements (if status check passed)
|
|
||||||
if (shouldShow && item.roles) {
|
|
||||||
shouldShow = auth.hasAnyRole(item.roles);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (shouldShow) {
|
|
||||||
if (item.items) {
|
|
||||||
const filteredItems = item.items.filter(subItem =>
|
|
||||||
!subItem.roles || auth.hasAnyRole(subItem.roles)
|
|
||||||
);
|
|
||||||
filtered.push({ ...item, items: filteredItems });
|
|
||||||
} else {
|
|
||||||
filtered.push(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return filtered;
|
|
||||||
});
|
|
||||||
})
|
|
||||||
|
|
||||||
const isMobileMenuOpen = ref(false);
|
|
||||||
const expandedMenu = ref(null);
|
|
||||||
|
|
||||||
const router = useRouter();
|
|
||||||
|
|
||||||
function openMobileMenu() {
|
|
||||||
expandedMenu.value = null;
|
|
||||||
isMobileMenuOpen.value = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
function closeMobileMenu() {
|
|
||||||
isMobileMenuOpen.value = false;
|
|
||||||
expandedMenu.value = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
function mobileNavigateTo(to: string) {
|
|
||||||
closeMobileMenu();
|
|
||||||
router.push(to);
|
|
||||||
}
|
|
||||||
|
|
||||||
function lockDocumentScroll() {
|
|
||||||
document.documentElement.style.overflow = 'hidden';
|
|
||||||
document.documentElement.style.overscrollBehavior = 'none';
|
|
||||||
document.body.style.overflow = 'hidden';
|
|
||||||
document.body.style.overscrollBehavior = 'none';
|
|
||||||
document.body.style.touchAction = 'none';
|
|
||||||
}
|
|
||||||
|
|
||||||
function unlockDocumentScroll() {
|
|
||||||
document.documentElement.style.overflow = '';
|
|
||||||
document.documentElement.style.overscrollBehavior = '';
|
|
||||||
document.body.style.overflow = '';
|
|
||||||
document.body.style.overscrollBehavior = '';
|
|
||||||
document.body.style.touchAction = '';
|
|
||||||
}
|
|
||||||
|
|
||||||
watch(isMobileMenuOpen, (isOpen) => {
|
|
||||||
if (isOpen) {
|
|
||||||
lockDocumentScroll();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
unlockDocumentScroll();
|
|
||||||
});
|
|
||||||
|
|
||||||
onBeforeUnmount(() => {
|
|
||||||
unlockDocumentScroll();
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="w-full border-b">
|
<div class="w-full border-b">
|
||||||
<div class="hidden lg:flex max-w-screen-3xl w-full mx-auto items-center justify-between pr-10 pl-7">
|
<div class="max-w-screen-3xl w-full mx-auto flex items-center justify-between pr-10 pl-7">
|
||||||
<!-- left side -->
|
<!-- left side -->
|
||||||
<div class="flex items-center gap-7">
|
<div class="flex items-center gap-7">
|
||||||
<RouterLink to="/">
|
<RouterLink to="/">
|
||||||
@@ -265,6 +102,19 @@
|
|||||||
</NavigationMenuContent>
|
</NavigationMenuContent>
|
||||||
</NavigationMenuItem>
|
</NavigationMenuItem>
|
||||||
|
|
||||||
|
<!-- Discussions (Dropdown) -->
|
||||||
|
<NavigationMenuItem class="bg-none !focus:bg-none !active:bg-none">
|
||||||
|
<NavigationMenuTrigger>Discussions</NavigationMenuTrigger>
|
||||||
|
<NavigationMenuContent
|
||||||
|
class="grid gap-1 p-2 text-left [&_a]:w-full [&_a]:block [&_a]:whitespace-nowrap *:bg-transparent">
|
||||||
|
<NavigationMenuLink as-child :class="navigationMenuTriggerStyle()">
|
||||||
|
<RouterLink to="/discussions/mod-requests" @click="blurAfter">
|
||||||
|
Mod Requests
|
||||||
|
</RouterLink>
|
||||||
|
</NavigationMenuLink>
|
||||||
|
</NavigationMenuContent>
|
||||||
|
</NavigationMenuItem>
|
||||||
|
|
||||||
<!-- Administration (Dropdown) -->
|
<!-- Administration (Dropdown) -->
|
||||||
<NavigationMenuItem
|
<NavigationMenuItem
|
||||||
v-if="auth.hasAnyRole(['17th Administrator', '17th HQ', '17th Command', 'Recruiter'])">
|
v-if="auth.hasAnyRole(['17th Administrator', '17th HQ', '17th Command', 'Recruiter'])">
|
||||||
@@ -317,12 +167,6 @@
|
|||||||
</NavigationMenuLink>
|
</NavigationMenuLink>
|
||||||
</NavigationMenuContent>
|
</NavigationMenuContent>
|
||||||
</NavigationMenuItem>
|
</NavigationMenuItem>
|
||||||
|
|
||||||
<NavigationMenuItem v-if="auth.hasRole('Dev')">
|
|
||||||
<NavigationMenuLink as-child :class="navigationMenuTriggerStyle()">
|
|
||||||
<RouterLink to="/developer" @click="blurAfter">Developer</RouterLink>
|
|
||||||
</NavigationMenuLink>
|
|
||||||
</NavigationMenuItem>
|
|
||||||
</NavigationMenuList>
|
</NavigationMenuList>
|
||||||
</NavigationMenu>
|
</NavigationMenu>
|
||||||
</div>
|
</div>
|
||||||
@@ -366,119 +210,6 @@
|
|||||||
<a v-else :href="APIHOST + '/login'">Login</a>
|
<a v-else :href="APIHOST + '/login'">Login</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<!-- <Separator></Separator> -->
|
||||||
<!-- mobile navigation -->
|
|
||||||
<div class="flex flex-col lg:hidden w-full">
|
|
||||||
<div class="flex items-center justify-between w-full p-2">
|
|
||||||
<!-- <RouterLink to="/">
|
|
||||||
<img src="/17RBN_Logo.png" class="w-10 h-10 object-contain"></img>
|
|
||||||
</RouterLink> -->
|
|
||||||
<button @click="mobileNavigateTo('/')">
|
|
||||||
<img src="/17RBN_Logo.png" class="w-10 h-10 object-contain"></img>
|
|
||||||
</button>
|
|
||||||
|
|
||||||
<Button v-if="!isMobileMenuOpen" variant="ghost" size="icon" @click="openMobileMenu()">
|
|
||||||
<Menu class="size-7" />
|
|
||||||
</Button>
|
|
||||||
<Button v-else variant="ghost" size="icon" @click="closeMobileMenu()">
|
|
||||||
<X class="size-7" />
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
<div v-if="isMobileMenuOpen" class="fixed inset-0 z-[70] flex flex-col overflow-hidden bg-background"
|
|
||||||
:style="{ paddingBottom: 'env(safe-area-inset-bottom)' }">
|
|
||||||
<div class="flex items-center justify-between w-full border-b bg-background p-2">
|
|
||||||
<button @click="mobileNavigateTo('/')">
|
|
||||||
<img src="/17RBN_Logo.png" class="w-10 h-10 object-contain"></img>
|
|
||||||
</button>
|
|
||||||
<Button variant="ghost" size="icon" @click="closeMobileMenu()">
|
|
||||||
<X class="size-7" />
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="flex-1 overflow-y-auto overscroll-contain px-2 py-3 space-y-0.5">
|
|
||||||
<div v-for="navItem in filteredNav" :key="navItem.title" class="group">
|
|
||||||
|
|
||||||
<template v-if="!navItem.items">
|
|
||||||
<a v-if="navItem.isExternal" :href="navItem.href" target="_blank"
|
|
||||||
class="flex items-center justify-between w-full px-4 py-2.5 text-base font-medium rounded-md hover:bg-accent active:bg-accent transition-colors">
|
|
||||||
<span class="flex items-center gap-2">
|
|
||||||
{{ navItem.title }}
|
|
||||||
<ArrowUpRight class="h-3.5 w-3.5 opacity-50" />
|
|
||||||
</span>
|
|
||||||
</a>
|
|
||||||
<button v-else @click="mobileNavigateTo(navItem.to)"
|
|
||||||
class="w-full text-left px-4 py-2.5 text-base font-medium rounded-md hover:bg-accent active:bg-accent transition-colors">
|
|
||||||
{{ navItem.title }}
|
|
||||||
</button>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<div v-else class="space-y-0.5">
|
|
||||||
<button @click="expandedMenu = expandedMenu === navItem.title ? null : navItem.title"
|
|
||||||
class="flex items-center justify-between w-full px-4 py-2.5 text-base font-medium rounded-md transition-colors"
|
|
||||||
:class="expandedMenu === navItem.title ? 'bg-accent/50 text-primary' : 'hover:bg-accent'">
|
|
||||||
{{ navItem.title }}
|
|
||||||
<ChevronDown class="h-4 w-4 transition-transform duration-200"
|
|
||||||
:class="expandedMenu === navItem.title ? 'rotate-180' : ''" />
|
|
||||||
</button>
|
|
||||||
|
|
||||||
<div v-if="expandedMenu === navItem.title"
|
|
||||||
class="ml-4 mr-2 border-l border-border space-y-0.5">
|
|
||||||
<button v-for="subNavItem in navItem.items" :key="subNavItem.title"
|
|
||||||
@click="mobileNavigateTo(subNavItem.to)"
|
|
||||||
class="w-full text-left px-6 py-2 text-sm text-muted-foreground hover:text-foreground active:text-primary transition-colors">
|
|
||||||
{{ subNavItem.title }}
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="p-3 border-t bg-background mt-auto" :style="{ paddingBottom: 'max(0.75rem, env(safe-area-inset-bottom))' }">
|
|
||||||
<div v-if="userStore.isLoggedIn" class="space-y-3">
|
|
||||||
<div class="flex items-center justify-between px-2">
|
|
||||||
<div class="flex gap-3">
|
|
||||||
<!-- <div
|
|
||||||
class="size-8 rounded-full bg-primary/10 flex items-center justify-center text-xs font-bold text-primary">
|
|
||||||
{{ userStore.displayName?.charAt(0) }}
|
|
||||||
</div> -->
|
|
||||||
<div class="flex flex-col leading-tight">
|
|
||||||
<span class="text-sm font-semibold">
|
|
||||||
{{ userStore.displayName || userStore.user.member.member_name }}
|
|
||||||
</span>
|
|
||||||
<span v-if="userStore.displayName"
|
|
||||||
class="text-[10px] uppercase tracking-wider text-muted-foreground">
|
|
||||||
{{ userStore.user.member.member_name }}
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="flex items-center gap-3">
|
|
||||||
<Button variant="ghost" size="icon" @click="mobileNavigateTo('/profile')">
|
|
||||||
<Settings class="size-6"></Settings>
|
|
||||||
</Button>
|
|
||||||
<Button variant="ghost" size="icon" @click="logout()">
|
|
||||||
<LogOut class="size-6 text-destructive"></LogOut>
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="flex gap-2">
|
|
||||||
<!-- <Button variant="outline" size="xs" class="flex-1 h-8 text-xs"
|
|
||||||
@click="mobileNavigateTo('/profile')">Profile</Button> -->
|
|
||||||
<Button variant="secondary" size="xs" class="flex-1 h-8 text-xs"
|
|
||||||
@click="mobileNavigateTo('/join')">My
|
|
||||||
Application</Button>
|
|
||||||
<Button variant="secondary" size="xs" class="flex-1 h-8 text-xs"
|
|
||||||
@click="mobileNavigateTo('/applications')">Application History</Button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<a v-else :href="APIHOST + '/login'" class="block">
|
|
||||||
<Button class="w-full text-sm h-10">
|
|
||||||
<LogIn></LogIn> Login
|
|
||||||
</Button>
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
42
ui/src/components/discussion/CommentForm.vue
Normal file
42
ui/src/components/discussion/CommentForm.vue
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { ref } from 'vue';
|
||||||
|
import Textarea from '../ui/textarea/Textarea.vue';
|
||||||
|
import Button from '../ui/button/Button.vue';
|
||||||
|
import { postComment } from '@/api/discussion';
|
||||||
|
import { DiscussionComment } from '@shared/types/discussion';
|
||||||
|
|
||||||
|
const props = defineProps<{
|
||||||
|
parentId: number,
|
||||||
|
}>();
|
||||||
|
|
||||||
|
const emit = defineEmits(['commentPosted']);
|
||||||
|
const commentText = ref('');
|
||||||
|
const error = ref('');
|
||||||
|
|
||||||
|
async function submitComment(e: Event) {
|
||||||
|
e.preventDefault();
|
||||||
|
error.value = '';
|
||||||
|
if (!commentText.value.trim()) {
|
||||||
|
error.value = 'Comment cannot be empty';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let newComment: DiscussionComment = { post_id: props.parentId, content: commentText.value.trim() };
|
||||||
|
await postComment(newComment);
|
||||||
|
emit('commentPosted');
|
||||||
|
commentText.value = '';
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<form @submit="submitComment">
|
||||||
|
<div class="mb-2">
|
||||||
|
<label class="block font-medium mb-1">Add a comment</label>
|
||||||
|
<Textarea rows="3" class="bg-neutral-800 resize-none w-full" v-model="commentText"
|
||||||
|
placeholder="Add a comment…" />
|
||||||
|
<div class="h-4 text-red-500 text-sm mt-1" v-if="error">{{ error }}</div>
|
||||||
|
</div>
|
||||||
|
<div class="mt-2 flex justify-end">
|
||||||
|
<Button type="submit" :disabled="!commentText.trim()">Post Comment</Button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</template>
|
||||||
40
ui/src/components/discussion/CommentThread.vue
Normal file
40
ui/src/components/discussion/CommentThread.vue
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
|
||||||
|
import { DiscussionComment } from '@shared/types/discussion';
|
||||||
|
import DiscussionCommentView from './DiscussionCommentView.vue';
|
||||||
|
import CommentForm from './CommentForm.vue';
|
||||||
|
import { ref } from 'process';
|
||||||
|
import { getPostComments } from '@/api/discussion';
|
||||||
|
|
||||||
|
const props = defineProps<{
|
||||||
|
parentId: number,
|
||||||
|
comments: DiscussionComment[]
|
||||||
|
}>()
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
(e: 'commentsUpdated', comments: DiscussionComment[]): void
|
||||||
|
}>()
|
||||||
|
|
||||||
|
async function onCommentPosted() {
|
||||||
|
const res = await getPostComments(props.parentId);
|
||||||
|
console.log(res);
|
||||||
|
// tell parent to update state
|
||||||
|
emit('commentsUpdated', res);
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="mt-10 *:my-5">
|
||||||
|
<h3 class="text-xl font-semibold">Discussion</h3>
|
||||||
|
<div class="comment-thread">
|
||||||
|
<div class="comments-list flex flex-col gap-5">
|
||||||
|
<div v-for="comment in comments" :key="comment.id" class="comment">
|
||||||
|
<DiscussionCommentView :comment="comment"></DiscussionCommentView>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<CommentForm :parent-id="props.parentId" @commentPosted="onCommentPosted" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
26
ui/src/components/discussion/DiscussionCommentView.vue
Normal file
26
ui/src/components/discussion/DiscussionCommentView.vue
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { DiscussionComment } from '@shared/types/discussion';
|
||||||
|
import MemberCard from '../members/MemberCard.vue';
|
||||||
|
|
||||||
|
const props = defineProps<{
|
||||||
|
comment: DiscussionComment;
|
||||||
|
}>();
|
||||||
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="rounded-md border border-neutral-800 p-3 space-y-5">
|
||||||
|
<!-- Comment header -->
|
||||||
|
<div class="flex justify-between">
|
||||||
|
<MemberCard :member-id="comment.poster_id"></MemberCard>
|
||||||
|
<p class="text-muted-foreground">{{ new Date(comment.created_at).toLocaleString("EN-us", {
|
||||||
|
year: "numeric",
|
||||||
|
month: "long",
|
||||||
|
day: "numeric",
|
||||||
|
hour: "2-digit",
|
||||||
|
minute: "2-digit"
|
||||||
|
}) }}</p>
|
||||||
|
</div>
|
||||||
|
<p>{{ comment.content }}</p>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
@@ -169,16 +169,16 @@ const filteredMembers = computed(() => {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="mx-auto flex w-full max-w-5xl flex-col gap-4 lg:flex-row-reverse lg:gap-6">
|
<div class="flex flex-row-reverse gap-6 mx-auto w-full" :class="!adminMode ? 'max-w-5xl' : 'max-w-5xl'">
|
||||||
<div v-if="!adminMode" class="order-2 flex flex-1 flex-col rounded-md border p-4 lg:order-1">
|
<div v-if="!adminMode" class="flex-1 flex flex-col space-x-4 rounded-md border p-4">
|
||||||
<p class="scroll-m-20 text-2xl font-semibold tracking-tight">LOA Policy</p>
|
<p class="scroll-m-20 text-2xl font-semibold tracking-tight">LOA Policy</p>
|
||||||
<div ref="policyRef" class="bookstack-container">
|
<div ref="policyRef" class="bookstack-container">
|
||||||
<!-- LOA policy gets loaded here -->
|
<!-- LOA policy gets loaded here -->
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="order-1 flex flex-1 flex-col gap-5 lg:order-2">
|
<div class="flex-1 flex flex-col gap-5">
|
||||||
<form v-if="!formSubmitted" @submit="onSubmit" class="flex flex-col gap-2">
|
<form v-if="!formSubmitted" @submit="onSubmit" class="flex flex-col gap-2">
|
||||||
<div class="grid w-full grid-cols-1 gap-4 sm:grid-cols-2 sm:gap-5">
|
<div class="flex w-full gap-5">
|
||||||
<VeeField v-slot="{ field, errors }" name="member_id">
|
<VeeField v-slot="{ field, errors }" name="member_id">
|
||||||
<Field>
|
<Field>
|
||||||
<FieldContent>
|
<FieldContent>
|
||||||
@@ -237,13 +237,13 @@ const filteredMembers = computed(() => {
|
|||||||
</Field>
|
</Field>
|
||||||
</VeeField>
|
</VeeField>
|
||||||
</div>
|
</div>
|
||||||
<div class="grid grid-cols-1 gap-4 sm:grid-cols-2 sm:gap-5">
|
<div class="flex gap-5">
|
||||||
<VeeField v-slot="{ field, errors }" name="start_date">
|
<VeeField v-slot="{ field, errors }" name="start_date">
|
||||||
<Field class="w-full">
|
<Field>
|
||||||
<FieldContent>
|
<FieldContent>
|
||||||
<FieldLabel>Start Date</FieldLabel>
|
<FieldLabel>Start Date</FieldLabel>
|
||||||
<Popover>
|
<Popover>
|
||||||
<div class="group relative flex w-full items-center">
|
<div class="relative inline-flex items-center group">
|
||||||
<PopoverTrigger as-child>
|
<PopoverTrigger as-child>
|
||||||
<Button :disabled="!values.type" variant="outline" :class="cn(
|
<Button :disabled="!values.type" variant="outline" :class="cn(
|
||||||
'w-full justify-start text-left font-normal',
|
'w-full justify-start text-left font-normal',
|
||||||
@@ -259,7 +259,7 @@ const filteredMembers = computed(() => {
|
|||||||
text-popover-foreground shadow-md border border-border
|
text-popover-foreground shadow-md border border-border
|
||||||
opacity-0 translate-y-1
|
opacity-0 translate-y-1
|
||||||
group-hover:opacity-100 group-hover:translate-y-0
|
group-hover:opacity-100 group-hover:translate-y-0
|
||||||
transition-all duration-150">
|
transition-opacity transition-transform duration-150">
|
||||||
Select an LOA type first
|
Select an LOA type first
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -277,11 +277,11 @@ const filteredMembers = computed(() => {
|
|||||||
</Field>
|
</Field>
|
||||||
</VeeField>
|
</VeeField>
|
||||||
<VeeField v-slot="{ field, errors }" name="end_date">
|
<VeeField v-slot="{ field, errors }" name="end_date">
|
||||||
<Field class="w-full">
|
<Field>
|
||||||
<FieldContent>
|
<FieldContent>
|
||||||
<FieldLabel>End Date</FieldLabel>
|
<FieldLabel>End Date</FieldLabel>
|
||||||
<Popover>
|
<Popover>
|
||||||
<div class="group relative flex w-full items-center">
|
<div class="relative inline-flex items-center group">
|
||||||
<PopoverTrigger as-child>
|
<PopoverTrigger as-child>
|
||||||
<Button :disabled="!values.type" variant="outline" :class="cn(
|
<Button :disabled="!values.type" variant="outline" :class="cn(
|
||||||
'w-full justify-start text-left font-normal',
|
'w-full justify-start text-left font-normal',
|
||||||
@@ -297,7 +297,7 @@ const filteredMembers = computed(() => {
|
|||||||
text-popover-foreground shadow-md border border-border
|
text-popover-foreground shadow-md border border-border
|
||||||
opacity-0 translate-y-1
|
opacity-0 translate-y-1
|
||||||
group-hover:opacity-100 group-hover:translate-y-0
|
group-hover:opacity-100 group-hover:translate-y-0
|
||||||
transition-all duration-150">
|
transition-opacity transition-transform duration-150">
|
||||||
Select an LOA type first
|
Select an LOA type first
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -330,8 +330,8 @@ const filteredMembers = computed(() => {
|
|||||||
</Field>
|
</Field>
|
||||||
</VeeField>
|
</VeeField>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex justify-stretch sm:justify-end">
|
<div class="flex justify-end">
|
||||||
<Button type="submit" :disabled="submitting" class="w-full sm:w-35">
|
<Button type="submit" :disabled="submitting" class="w-35">
|
||||||
<span class="flex items-center gap-2" v-if="submitting">
|
<span class="flex items-center gap-2" v-if="submitting">
|
||||||
<Spinner></Spinner> Submitting…
|
<Spinner></Spinner> Submitting…
|
||||||
</span>
|
</span>
|
||||||
@@ -352,7 +352,7 @@ const filteredMembers = computed(() => {
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
||||||
<div class="mt-4 flex flex-col gap-3 sm:flex-row">
|
<div class="flex gap-3 mt-4">
|
||||||
<Button variant="secondary" @click="formSubmitted = false">
|
<Button variant="secondary" @click="formSubmitted = false">
|
||||||
Submit another request
|
Submit another request
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
@@ -141,125 +141,29 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<Dialog :open="isExtending" @update:open="(val) => isExtending = val">
|
<Dialog :open="isExtending" @update:open="(val) => isExtending = val">
|
||||||
<DialogContent class="w-[95vw] max-w-[95vw] p-4 sm:max-w-fit sm:p-6">
|
<DialogContent>
|
||||||
<DialogHeader class="gap-1 pr-12 text-left">
|
<DialogHeader>
|
||||||
<DialogTitle class="text-base leading-tight sm:text-lg">Extend Leave of Absence</DialogTitle>
|
<DialogTitle>Extend {{ targetLOA.name }}'s Leave of Absence </DialogTitle>
|
||||||
<DialogDescription class="truncate text-xs text-muted-foreground sm:text-sm">
|
|
||||||
{{ targetLOA?.name }}
|
|
||||||
</DialogDescription>
|
|
||||||
</DialogHeader>
|
</DialogHeader>
|
||||||
<div class="flex flex-col gap-4 sm:flex-row sm:items-start sm:gap-5">
|
<div class="flex gap-5">
|
||||||
<Calendar v-model="extendTo"
|
<Calendar v-model="extendTo" class="rounded-md border shadow-sm w-min" layout="month-and-year"
|
||||||
class="mx-auto w-min rounded-md border shadow-sm sm:mx-0"
|
|
||||||
layout="month-and-year"
|
|
||||||
:min-value="toCalendarDate(targetEnd)"
|
:min-value="toCalendarDate(targetEnd)"
|
||||||
:max-value="props.adminMode ? toCalendarDate(targetEnd).add({ years: 1 }) : toCalendarDate(targetEnd).add({ months: 1 })" />
|
:max-value="props.adminMode ? toCalendarDate(targetEnd).add({ years: 1 }) : toCalendarDate(targetEnd).add({ months: 1 })" />
|
||||||
<div class="flex w-full flex-col gap-2 sm:gap-3">
|
<div class="flex flex-col w-full gap-3 px-2">
|
||||||
<p class="text-sm font-medium text-muted-foreground">Quick Options</p>
|
<p>Quick Options</p>
|
||||||
<Button class="w-full" variant="outline" @click="extendTo = toCalendarDate(targetEnd).add({ days: 7 })">1
|
<Button variant="outline" @click="extendTo = toCalendarDate(targetEnd).add({ days: 7 })">1
|
||||||
Week</Button>
|
Week</Button>
|
||||||
<Button class="w-full" variant="outline" @click="extendTo = toCalendarDate(targetEnd).add({ months: 1 })">1
|
<Button variant="outline" @click="extendTo = toCalendarDate(targetEnd).add({ months: 1 })">1
|
||||||
Month</Button>
|
Month</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex flex-row justify-end gap-2 pt-2 sm:gap-4 sm:pt-0">
|
<div class="flex justify-end gap-4">
|
||||||
<Button class="flex-1 sm:flex-none" variant="outline" @click="isExtending = false">Cancel</Button>
|
<Button variant="outline" @click="isExtending = false">Cancel</Button>
|
||||||
<Button class="flex-1 sm:flex-none" @click="commitExtend">Extend</Button>
|
<Button @click="commitExtend">Extend</Button>
|
||||||
</div>
|
</div>
|
||||||
</DialogContent>
|
</DialogContent>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
<div class="max-w-7xl w-full mx-auto">
|
<div class="max-w-7xl w-full mx-auto">
|
||||||
<div class="space-y-3 md:hidden">
|
|
||||||
<template v-for="post in LOAList" :key="`mobile-${post.id}`">
|
|
||||||
<div class="rounded-lg border bg-card p-2.5 shadow-sm">
|
|
||||||
<div class="grid grid-cols-[minmax(0,1fr)_auto] items-center gap-2">
|
|
||||||
<div class="min-w-0 overflow-hidden">
|
|
||||||
<div class="max-w-[70vw] overflow-hidden whitespace-nowrap">
|
|
||||||
<MemberCard :member-id="post.member_id"></MemberCard>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<Badge v-if="loaStatus(post) === 'Upcoming'" class="shrink-0 bg-blue-400">Upcoming</Badge>
|
|
||||||
<Badge v-else-if="loaStatus(post) === 'Active'" class="shrink-0 bg-green-500">Active</Badge>
|
|
||||||
<Badge v-else-if="loaStatus(post) === 'Extended'" class="shrink-0 bg-green-500">Extended</Badge>
|
|
||||||
<Badge v-else-if="loaStatus(post) === 'Overdue'" class="shrink-0 bg-yellow-400">Overdue</Badge>
|
|
||||||
<Badge v-else class="shrink-0 bg-gray-400">Ended</Badge>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="mt-1 grid grid-cols-2 gap-x-4 gap-y-1">
|
|
||||||
<div>
|
|
||||||
<p class="text-[11px] uppercase tracking-wide text-muted-foreground/90">Start</p>
|
|
||||||
<p class="text-sm font-semibold text-foreground">{{ formatDate(post.start_date) }}</p>
|
|
||||||
</div>
|
|
||||||
<div class="text-right">
|
|
||||||
<p class="text-[11px] uppercase tracking-wide text-muted-foreground/90">End</p>
|
|
||||||
<p class="text-sm font-semibold text-foreground">{{ post.extended_till ? formatDate(post.extended_till) : formatDate(post.end_date) }}</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="mt-1 flex items-center justify-end gap-1">
|
|
||||||
<Button variant="ghost" class="h-8 px-2 text-xs text-muted-foreground" @click="expanded = expanded === post.id ? null : post.id">
|
|
||||||
<span class="mr-1">Details</span>
|
|
||||||
<ChevronUp v-if="expanded === post.id" class="size-4" />
|
|
||||||
<ChevronDown v-else class="size-4" />
|
|
||||||
</Button>
|
|
||||||
|
|
||||||
<DropdownMenu>
|
|
||||||
<DropdownMenuTrigger class="cursor-pointer">
|
|
||||||
<Button variant="ghost" size="icon" class="size-8 text-muted-foreground">
|
|
||||||
<Ellipsis class="size-5"></Ellipsis>
|
|
||||||
</Button>
|
|
||||||
</DropdownMenuTrigger>
|
|
||||||
<DropdownMenuContent>
|
|
||||||
<DropdownMenuItem v-if="!post.closed"
|
|
||||||
:disabled="post.extended_till !== null && !props.adminMode"
|
|
||||||
@click="isExtending = true; targetLOA = post">
|
|
||||||
{{ (post.extended_till !== null && !props.adminMode) ? 'Extend (Already Extended)' : 'Extend' }}
|
|
||||||
</DropdownMenuItem>
|
|
||||||
<DropdownMenuItem v-if="!post.closed" :variant="'destructive'"
|
|
||||||
@click="cancelAndReload(post.id)">{{ loaStatus(post) === 'Upcoming' ?
|
|
||||||
'Cancel' :
|
|
||||||
'End' }}
|
|
||||||
</DropdownMenuItem>
|
|
||||||
<p v-if="post.closed || (!props.adminMode && post.closed)"
|
|
||||||
class="p-2 text-center text-sm">
|
|
||||||
No actions
|
|
||||||
</p>
|
|
||||||
</DropdownMenuContent>
|
|
||||||
</DropdownMenu>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div v-if="expanded === post.id" class="mt-2 space-y-2.5 border-t pt-2 text-sm">
|
|
||||||
<div class="space-y-1.5">
|
|
||||||
<div class="flex items-center justify-between gap-3">
|
|
||||||
<span class="text-muted-foreground/90">Type</span>
|
|
||||||
<span class="text-right font-semibold text-foreground">{{ post.type_name }}</span>
|
|
||||||
</div>
|
|
||||||
<div class="flex items-center justify-between gap-3">
|
|
||||||
<span class="text-muted-foreground/90">Posted on</span>
|
|
||||||
<span class="text-right font-semibold text-foreground">{{ formatDate(post.filed_date) }}</span>
|
|
||||||
</div>
|
|
||||||
<div class="flex items-center justify-between gap-3">
|
|
||||||
<span class="text-muted-foreground/90">Original end</span>
|
|
||||||
<span class="text-right font-semibold text-foreground">{{ formatDate(post.end_date) }}</span>
|
|
||||||
</div>
|
|
||||||
<div class="flex items-center justify-between gap-3">
|
|
||||||
<span class="text-muted-foreground/90">Extended to</span>
|
|
||||||
<span class="text-right font-semibold text-foreground">{{ post.extended_till ? formatDate(post.extended_till) : 'N/A' }}</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<h4 class="text-[11px] font-semibold uppercase tracking-wide text-muted-foreground/90">Reason</h4>
|
|
||||||
<p class="mt-1 whitespace-pre-wrap text-sm leading-relaxed text-foreground/90">
|
|
||||||
{{ post.reason || 'No reason provided.' }}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="hidden overflow-x-auto md:block">
|
|
||||||
<Table>
|
<Table>
|
||||||
<TableHeader>
|
<TableHeader>
|
||||||
<TableRow>
|
<TableRow>
|
||||||
@@ -338,7 +242,7 @@
|
|||||||
<div class="w-full p-4 mb-6 space-y-4">
|
<div class="w-full p-4 mb-6 space-y-4">
|
||||||
|
|
||||||
<!-- Dates -->
|
<!-- Dates -->
|
||||||
<div class="grid grid-cols-1 gap-4 text-sm lg:grid-cols-3">
|
<div class="grid grid-cols-3 gap-4 text-sm">
|
||||||
<div>
|
<div>
|
||||||
<p class="text-muted-foreground">Start</p>
|
<p class="text-muted-foreground">Start</p>
|
||||||
<p class="font-medium">
|
<p class="font-medium">
|
||||||
@@ -362,12 +266,16 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Reason -->
|
<!-- Reason -->
|
||||||
<div class="space-y-2 border-t pt-3">
|
<div class="space-y-2">
|
||||||
<h4 class="text-sm font-semibold text-foreground">
|
<div class="flex items-center gap-2">
|
||||||
Reason
|
<h4 class="text-sm font-semibold text-foreground">
|
||||||
</h4>
|
Reason
|
||||||
|
</h4>
|
||||||
|
<Separator class="flex-1" />
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="text-sm leading-relaxed whitespace-pre-wrap text-muted-foreground">
|
<div
|
||||||
|
class="rounded-lg border bg-muted/40 px-4 py-3 text-sm leading-relaxed whitespace-pre-wrap text-muted-foreground">
|
||||||
{{ post.reason || 'No reason provided.' }}
|
{{ post.reason || 'No reason provided.' }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -379,9 +287,8 @@
|
|||||||
</template>
|
</template>
|
||||||
</TableBody>
|
</TableBody>
|
||||||
</Table>
|
</Table>
|
||||||
</div>
|
<div class="mt-5 flex justify-between">
|
||||||
<div class="mt-5 flex flex-col gap-3 md:flex-row md:items-center md:justify-between">
|
<div></div>
|
||||||
<div class="hidden md:block"></div>
|
|
||||||
<Pagination v-slot="{ page }" :items-per-page="pageData?.pageSize || 10" :total="pageData?.total || 10"
|
<Pagination v-slot="{ page }" :items-per-page="pageData?.pageSize || 10" :total="pageData?.total || 10"
|
||||||
:default-page="2" :page="pageNum" @update:page="setPage">
|
:default-page="2" :page="pageNum" @update:page="setPage">
|
||||||
<PaginationContent v-slot="{ items }">
|
<PaginationContent v-slot="{ items }">
|
||||||
@@ -396,7 +303,7 @@
|
|||||||
<PaginationNext />
|
<PaginationNext />
|
||||||
</PaginationContent>
|
</PaginationContent>
|
||||||
</Pagination>
|
</Pagination>
|
||||||
<div class="flex items-center justify-end gap-3 text-sm">
|
<div class="flex items-center gap-3 text-sm">
|
||||||
<p class="text-muted-foreground text-nowrap">Per page:</p>
|
<p class="text-muted-foreground text-nowrap">Per page:</p>
|
||||||
|
|
||||||
<button v-for="size in pageSizeOptions" :key="size" @click="setPageSize(size)"
|
<button v-for="size in pageSizeOptions" :key="size" @click="setPageSize(size)"
|
||||||
|
|||||||
@@ -26,10 +26,7 @@ const props = defineProps<{
|
|||||||
member: Member | null
|
member: Member | null
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const emit = defineEmits<{
|
const emit = defineEmits(['update:open', 'discharged'])
|
||||||
'update:open': [value: boolean]
|
|
||||||
'discharged': [value: { data: Discharge }]
|
|
||||||
}>()
|
|
||||||
|
|
||||||
const formSchema = toTypedSchema(dischargeSchema);
|
const formSchema = toTypedSchema(dischargeSchema);
|
||||||
|
|
||||||
|
|||||||
@@ -1,250 +0,0 @@
|
|||||||
<script setup lang="ts">
|
|
||||||
import { computed, ref, watch } from 'vue'
|
|
||||||
|
|
||||||
import { adminAssignUnit, getUnits } from '@/api/units'
|
|
||||||
import { getAllRanks } from '@/api/rank'
|
|
||||||
import { Button } from '@/components/ui/button'
|
|
||||||
import {
|
|
||||||
Dialog,
|
|
||||||
DialogContent,
|
|
||||||
DialogDescription,
|
|
||||||
DialogFooter,
|
|
||||||
DialogHeader,
|
|
||||||
DialogTitle,
|
|
||||||
} from '@/components/ui/dialog'
|
|
||||||
import { Field, FieldError, FieldLabel } from '@/components/ui/field'
|
|
||||||
import { Input } from '@/components/ui/input'
|
|
||||||
import {
|
|
||||||
Select,
|
|
||||||
SelectContent,
|
|
||||||
SelectItem,
|
|
||||||
SelectTrigger,
|
|
||||||
SelectValue,
|
|
||||||
} from '@/components/ui/select'
|
|
||||||
import MemberCard from './MemberCard.vue'
|
|
||||||
import type { Member } from '@shared/types/member'
|
|
||||||
import type { Rank } from '@shared/types/rank'
|
|
||||||
import type { Unit } from '@shared/types/units'
|
|
||||||
|
|
||||||
const props = defineProps<{
|
|
||||||
open: boolean
|
|
||||||
member: Member | null
|
|
||||||
}>()
|
|
||||||
|
|
||||||
const emit = defineEmits<{
|
|
||||||
'update:open': [value: boolean]
|
|
||||||
transferred: [value: { memberId: number; unitId: number; rankId: number; reason: string }]
|
|
||||||
}>()
|
|
||||||
|
|
||||||
const units = ref<Unit[]>([])
|
|
||||||
const ranks = ref<Rank[]>([])
|
|
||||||
const loadingUnits = ref(false)
|
|
||||||
const loadingRanks = ref(false)
|
|
||||||
const submitting = ref(false)
|
|
||||||
const formError = ref('')
|
|
||||||
|
|
||||||
const selectedUnitId = ref('')
|
|
||||||
const selectedRankId = ref('')
|
|
||||||
const selectedReason = ref('transfer_request')
|
|
||||||
const customReason = ref('')
|
|
||||||
|
|
||||||
const reasonOptions = [
|
|
||||||
{ label: 'Transfer Request', value: 'transfer_request' },
|
|
||||||
{ label: 'Leadership Vote', value: 'leadership_vote' },
|
|
||||||
{ label: 'Appointment', value: 'appointment' },
|
|
||||||
{ label: 'Step Down', value: 'step_down' },
|
|
||||||
{ label: 'Custom', value: 'custom' },
|
|
||||||
]
|
|
||||||
|
|
||||||
const resolvedReason = computed(() => {
|
|
||||||
if (selectedReason.value === 'custom') {
|
|
||||||
return customReason.value.trim()
|
|
||||||
}
|
|
||||||
return selectedReason.value
|
|
||||||
})
|
|
||||||
|
|
||||||
const canSubmit = computed(() => {
|
|
||||||
return !!props.member && !!selectedUnitId.value && !!selectedRankId.value && !!resolvedReason.value
|
|
||||||
})
|
|
||||||
|
|
||||||
function resolveDefaultRankId(member: Member | null): string {
|
|
||||||
if (!member || !member.rank) {
|
|
||||||
return ''
|
|
||||||
}
|
|
||||||
|
|
||||||
const normalizedMemberRank = member.rank.trim().toLowerCase()
|
|
||||||
const matchedRank = ranks.value.find((rank) => {
|
|
||||||
return rank.name.trim().toLowerCase() === normalizedMemberRank
|
|
||||||
|| rank.short_name.trim().toLowerCase() === normalizedMemberRank
|
|
||||||
})
|
|
||||||
|
|
||||||
return matchedRank ? String(matchedRank.id) : ''
|
|
||||||
}
|
|
||||||
|
|
||||||
function resetForm() {
|
|
||||||
selectedUnitId.value = ''
|
|
||||||
selectedRankId.value = ''
|
|
||||||
selectedReason.value = 'transfer_request'
|
|
||||||
customReason.value = ''
|
|
||||||
formError.value = ''
|
|
||||||
}
|
|
||||||
|
|
||||||
async function loadUnits() {
|
|
||||||
loadingUnits.value = true
|
|
||||||
formError.value = ''
|
|
||||||
try {
|
|
||||||
units.value = await getUnits()
|
|
||||||
} catch {
|
|
||||||
formError.value = 'Failed to load units. Please try again.'
|
|
||||||
} finally {
|
|
||||||
loadingUnits.value = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function loadRanks() {
|
|
||||||
loadingRanks.value = true
|
|
||||||
formError.value = ''
|
|
||||||
try {
|
|
||||||
ranks.value = await getAllRanks()
|
|
||||||
selectedRankId.value = resolveDefaultRankId(props.member)
|
|
||||||
} catch {
|
|
||||||
formError.value = 'Failed to load ranks. Please try again.'
|
|
||||||
} finally {
|
|
||||||
loadingRanks.value = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
watch(
|
|
||||||
() => props.open,
|
|
||||||
(isOpen) => {
|
|
||||||
if (isOpen) {
|
|
||||||
resetForm()
|
|
||||||
loadUnits()
|
|
||||||
loadRanks()
|
|
||||||
}
|
|
||||||
},
|
|
||||||
)
|
|
||||||
|
|
||||||
async function onSubmit() {
|
|
||||||
if (!props.member) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!selectedUnitId.value) {
|
|
||||||
formError.value = 'Please select a target unit.'
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!selectedRankId.value) {
|
|
||||||
formError.value = 'Please select a target rank.'
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!resolvedReason.value) {
|
|
||||||
formError.value = 'Please select a reason or enter a custom reason.'
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
submitting.value = true
|
|
||||||
formError.value = ''
|
|
||||||
try {
|
|
||||||
const unitId = Number(selectedUnitId.value)
|
|
||||||
const rankId = Number(selectedRankId.value)
|
|
||||||
await adminAssignUnit(props.member.member_id, unitId, rankId, resolvedReason.value)
|
|
||||||
|
|
||||||
emit('transferred', {
|
|
||||||
memberId: props.member.member_id,
|
|
||||||
unitId,
|
|
||||||
rankId,
|
|
||||||
reason: resolvedReason.value,
|
|
||||||
})
|
|
||||||
emit('update:open', false)
|
|
||||||
} catch {
|
|
||||||
formError.value = 'Failed to transfer member. Please try again.'
|
|
||||||
} finally {
|
|
||||||
submitting.value = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<Dialog :open="open" @update:open="emit('update:open', $event)">
|
|
||||||
<DialogContent class="sm:max-w-[425px]">
|
|
||||||
<DialogHeader>
|
|
||||||
<DialogTitle>Transfer Member</DialogTitle>
|
|
||||||
<DialogDescription>
|
|
||||||
Select a new unit assignment for
|
|
||||||
<MemberCard v-if="member" :member-id="member.member_id" />
|
|
||||||
</DialogDescription>
|
|
||||||
</DialogHeader>
|
|
||||||
|
|
||||||
<form id="transferForm" @submit.prevent="onSubmit" class="space-y-4 py-2">
|
|
||||||
<Field>
|
|
||||||
<FieldLabel>Target Unit</FieldLabel>
|
|
||||||
<Select v-model="selectedUnitId" :disabled="loadingUnits || submitting">
|
|
||||||
<SelectTrigger>
|
|
||||||
<SelectValue placeholder="Select unit" />
|
|
||||||
</SelectTrigger>
|
|
||||||
<SelectContent>
|
|
||||||
<SelectItem v-for="unit in units" :key="unit.id" :value="String(unit.id)">
|
|
||||||
{{ unit.name }}
|
|
||||||
</SelectItem>
|
|
||||||
</SelectContent>
|
|
||||||
</Select>
|
|
||||||
</Field>
|
|
||||||
|
|
||||||
<Field>
|
|
||||||
<FieldLabel>Target Rank</FieldLabel>
|
|
||||||
<Select v-model="selectedRankId" :disabled="loadingRanks || submitting">
|
|
||||||
<SelectTrigger>
|
|
||||||
<SelectValue placeholder="Select rank" />
|
|
||||||
</SelectTrigger>
|
|
||||||
<SelectContent>
|
|
||||||
<SelectItem v-for="rank in ranks" :key="rank.id" :value="String(rank.id)">
|
|
||||||
{{ rank.name }}
|
|
||||||
</SelectItem>
|
|
||||||
</SelectContent>
|
|
||||||
</Select>
|
|
||||||
</Field>
|
|
||||||
|
|
||||||
<Field>
|
|
||||||
<FieldLabel>Reason</FieldLabel>
|
|
||||||
<Select v-model="selectedReason" :disabled="submitting">
|
|
||||||
<SelectTrigger>
|
|
||||||
<SelectValue placeholder="Select reason" />
|
|
||||||
</SelectTrigger>
|
|
||||||
<SelectContent>
|
|
||||||
<SelectItem
|
|
||||||
v-for="reason in reasonOptions"
|
|
||||||
:key="reason.value"
|
|
||||||
:value="reason.value"
|
|
||||||
>
|
|
||||||
{{ reason.label }}
|
|
||||||
</SelectItem>
|
|
||||||
</SelectContent>
|
|
||||||
</Select>
|
|
||||||
</Field>
|
|
||||||
|
|
||||||
<Field v-if="selectedReason === 'custom'">
|
|
||||||
<FieldLabel>Custom Reason</FieldLabel>
|
|
||||||
<Input
|
|
||||||
v-model="customReason"
|
|
||||||
:disabled="submitting"
|
|
||||||
placeholder="Enter custom transfer reason"
|
|
||||||
/>
|
|
||||||
</Field>
|
|
||||||
|
|
||||||
<FieldError v-if="formError" :errors="[formError]" />
|
|
||||||
</form>
|
|
||||||
|
|
||||||
<DialogFooter class="gap-2">
|
|
||||||
<Button variant="ghost" @click="emit('update:open', false)">
|
|
||||||
Cancel
|
|
||||||
</Button>
|
|
||||||
<Button type="submit" form="transferForm" :disabled="!canSubmit || loadingUnits || loadingRanks || submitting">
|
|
||||||
{{ submitting ? 'Transferring...' : 'Transfer Member' }}
|
|
||||||
</Button>
|
|
||||||
</DialogFooter>
|
|
||||||
</DialogContent>
|
|
||||||
</Dialog>
|
|
||||||
</template>
|
|
||||||
241
ui/src/components/modRequests/ModRequestForm.vue
Normal file
241
ui/src/components/modRequests/ModRequestForm.vue
Normal file
@@ -0,0 +1,241 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { ModRequestSchema } from '@shared/schemas/modRequest'
|
||||||
|
import { useForm, Field as VeeField } from 'vee-validate'
|
||||||
|
import { toTypedSchema } from '@vee-validate/zod'
|
||||||
|
import { ref } from 'vue'
|
||||||
|
import Button from '@/components/ui/button/Button.vue'
|
||||||
|
import Field from '@/components/ui/field/Field.vue'
|
||||||
|
import FieldLabel from '@/components/ui/field/FieldLabel.vue'
|
||||||
|
import FieldError from '@/components/ui/field/FieldError.vue'
|
||||||
|
import FieldDescription from '@/components/ui/field/FieldDescription.vue'
|
||||||
|
import Input from '@/components/ui/input/Input.vue'
|
||||||
|
import Textarea from '@/components/ui/textarea/Textarea.vue'
|
||||||
|
import Checkbox from '@/components/ui/checkbox/Checkbox.vue'
|
||||||
|
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card'
|
||||||
|
import { Separator } from '@/components/ui/separator'
|
||||||
|
import { X } from 'lucide-vue-next'
|
||||||
|
import { postModRequest } from '@/api/modRequests'
|
||||||
|
|
||||||
|
const { handleSubmit, resetForm, errors } = useForm({
|
||||||
|
validationSchema: toTypedSchema(ModRequestSchema),
|
||||||
|
validateOnMount: false,
|
||||||
|
initialValues: {
|
||||||
|
mod_title: '',
|
||||||
|
description: '',
|
||||||
|
mod_link: '',
|
||||||
|
confirmed_tested: false,
|
||||||
|
reason: '',
|
||||||
|
detrimental_effects: '',
|
||||||
|
keybind_conflicts: '',
|
||||||
|
special_considerations: '',
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
const submitting = ref(false)
|
||||||
|
const emit = defineEmits(['submit', 'close'])
|
||||||
|
|
||||||
|
const submitForm = handleSubmit(async (values) => {
|
||||||
|
if (submitting.value) return
|
||||||
|
submitting.value = true
|
||||||
|
try {
|
||||||
|
await postModRequest(values);
|
||||||
|
emit('submit', values)
|
||||||
|
} catch (err) {
|
||||||
|
console.error('Error submitting mod request:', err)
|
||||||
|
} finally {
|
||||||
|
submitting.value = false
|
||||||
|
}
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<Card class="border-0 shadow-sm">
|
||||||
|
<CardHeader>
|
||||||
|
<div class="flex items-start justify-between">
|
||||||
|
<div class="flex-1">
|
||||||
|
<CardTitle>New Mod Request</CardTitle>
|
||||||
|
<CardDescription>Share details about the mod you'd like to see added to our server</CardDescription>
|
||||||
|
</div>
|
||||||
|
<Button type="button" variant="ghost" @click="emit('close')"
|
||||||
|
class="text-muted-foreground hover:text-foreground -mt-1 -mr-2">
|
||||||
|
Back to posts <X></X>
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</CardHeader>
|
||||||
|
|
||||||
|
<Separator class="mb-0" />
|
||||||
|
|
||||||
|
<CardContent>
|
||||||
|
<form @submit.prevent="submitForm" class="space-y-8">
|
||||||
|
<!-- SECTION: Basic Mod Information -->
|
||||||
|
<div class="space-y-5">
|
||||||
|
<div class="space-y-1">
|
||||||
|
<h3 class="font-semibold text-sm text-foreground">Mod Information</h3>
|
||||||
|
<p class="text-xs text-muted-foreground">Core details about the mod</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="space-y-5">
|
||||||
|
<!-- Title -->
|
||||||
|
<VeeField name="mod_title" v-slot="{ field, errors: e }">
|
||||||
|
<Field :data-invalid="!!e.length">
|
||||||
|
<FieldLabel class="text-sm font-medium">Mod Title</FieldLabel>
|
||||||
|
<Input v-bind="field" placeholder="Name of the mod" rows="4" class="resize-none mt-2" />
|
||||||
|
<div class="h-4">
|
||||||
|
<FieldError v-if="e.length" :errors="e" />
|
||||||
|
</div>
|
||||||
|
</Field>
|
||||||
|
</VeeField>
|
||||||
|
|
||||||
|
<!-- Description -->
|
||||||
|
<VeeField name="description" v-slot="{ field, errors: e }">
|
||||||
|
<Field :data-invalid="!!e.length">
|
||||||
|
<FieldLabel class="text-sm font-medium">What is this mod?</FieldLabel>
|
||||||
|
<FieldDescription class="text-xs">Brief overview of the mod and its main functionality
|
||||||
|
</FieldDescription>
|
||||||
|
<Textarea v-bind="field" placeholder="Describe what this mod does..." rows="4"
|
||||||
|
class="resize-none mt-2" />
|
||||||
|
<div class="h-4">
|
||||||
|
<FieldError v-if="e.length" :errors="e" />
|
||||||
|
</div>
|
||||||
|
</Field>
|
||||||
|
</VeeField>
|
||||||
|
|
||||||
|
<!-- Mod Link -->
|
||||||
|
<VeeField name="mod_link" v-slot="{ field, errors: e }">
|
||||||
|
<Field :data-invalid="!!e.length">
|
||||||
|
<FieldLabel class="text-sm font-medium">Mod Link</FieldLabel>
|
||||||
|
<FieldDescription class="text-xs">Where can this mod be found?</FieldDescription>
|
||||||
|
<Input v-bind="field" placeholder="https://..." class="mt-2" />
|
||||||
|
<div class="h-4">
|
||||||
|
<FieldError v-if="e.length" :errors="e" />
|
||||||
|
</div>
|
||||||
|
</Field>
|
||||||
|
</VeeField>
|
||||||
|
|
||||||
|
<!-- Reason -->
|
||||||
|
<VeeField name="reason" v-slot="{ field, errors: e }">
|
||||||
|
<Field :data-invalid="!!e.length">
|
||||||
|
<FieldLabel class="text-sm font-medium">Why add this mod?</FieldLabel>
|
||||||
|
<FieldDescription class="text-xs">What benefits does this mod bring to our community and
|
||||||
|
why should we consider it?
|
||||||
|
</FieldDescription>
|
||||||
|
<Textarea v-bind="field" placeholder="Share your thoughts..." rows="3"
|
||||||
|
class="resize-none mt-2" />
|
||||||
|
<div class="h-4">
|
||||||
|
<FieldError v-if="e.length" :errors="e" />
|
||||||
|
</div>
|
||||||
|
</Field>
|
||||||
|
</VeeField>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<Separator />
|
||||||
|
|
||||||
|
<!-- SECTION: Testing & Verification -->
|
||||||
|
<div class="space-y-5">
|
||||||
|
<div class="space-y-1">
|
||||||
|
<h3 class="font-semibold text-sm text-foreground">Testing & Verification</h3>
|
||||||
|
<p class="text-xs text-muted-foreground">Your experience with this mod</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="space-y-5">
|
||||||
|
<!-- Confirmed Tested -->
|
||||||
|
<VeeField name="confirmed_tested" v-slot="{ field, errors: e }">
|
||||||
|
<Field :data-invalid="!!e.length">
|
||||||
|
<div class="flex items-center gap-3 p-3 rounded-md bg-muted/30 border border-border/50">
|
||||||
|
<Checkbox :model-value="field.value" @update:model-value="field.onChange"
|
||||||
|
class="hover:cursor-pointer" />
|
||||||
|
<div class="flex-1">
|
||||||
|
<FieldLabel class="font-medium text-md cursor-pointer">Testing & Stability
|
||||||
|
Confirmation
|
||||||
|
</FieldLabel>
|
||||||
|
<FieldDescription class="text-sm">I confirm that I have personally tested this
|
||||||
|
mod and to the best of my ability have verified that it functions as
|
||||||
|
described without
|
||||||
|
causing game-breaking bugs,
|
||||||
|
critical stability issues, or unintended performance degradation.
|
||||||
|
</FieldDescription>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="h-4">
|
||||||
|
<FieldError v-if="e.length" :errors="e" />
|
||||||
|
</div>
|
||||||
|
</Field>
|
||||||
|
</VeeField>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<Separator />
|
||||||
|
|
||||||
|
<!-- SECTION: Compatibility -->
|
||||||
|
<div class="space-y-5">
|
||||||
|
<div class="space-y-1">
|
||||||
|
<h3 class="font-semibold text-sm text-foreground">Compatibility & Conflicts</h3>
|
||||||
|
<p class="text-xs text-muted-foreground">How does it work with our current setup?</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="space-y-5">
|
||||||
|
<!-- Detrimental Effects -->
|
||||||
|
<VeeField name="detrimental_effects" v-slot="{ field, errors: e }">
|
||||||
|
<Field :data-invalid="!!e.length">
|
||||||
|
<FieldLabel class="text-sm font-medium">Potential Issues</FieldLabel>
|
||||||
|
<FieldDescription class="text-xs">Any negative impacts or concerns you noticed (Keybind
|
||||||
|
conflicts sould be noted in the dedicated section)?
|
||||||
|
</FieldDescription>
|
||||||
|
<Textarea v-bind="field" placeholder="List any issues... (leave blank if none)" rows="3"
|
||||||
|
class="resize-none mt-2" />
|
||||||
|
<div class="h-4">
|
||||||
|
<FieldError v-if="e.length" :errors="e" />
|
||||||
|
</div>
|
||||||
|
</Field>
|
||||||
|
</VeeField>
|
||||||
|
|
||||||
|
<!-- Keybind Conflicts -->
|
||||||
|
<VeeField name="keybind_conflicts" v-slot="{ field, errors: e }">
|
||||||
|
<Field :data-invalid="!!e.length">
|
||||||
|
<FieldLabel class="text-sm font-medium">Keybind Conflicts</FieldLabel>
|
||||||
|
<FieldDescription class="text-xs">Identify any controls that conflict with the existing
|
||||||
|
modpack along with resolutions for those conflicts.
|
||||||
|
</FieldDescription>
|
||||||
|
<Textarea v-bind="field"
|
||||||
|
placeholder='List specific conflicts and resolutions here, or type "None" if there are no conflicts.'
|
||||||
|
rows="3" class="resize-none mt-2" />
|
||||||
|
<div class="h-4">
|
||||||
|
<FieldError v-if="e.length" :errors="e" />
|
||||||
|
</div>
|
||||||
|
</Field>
|
||||||
|
</VeeField>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<Separator />
|
||||||
|
|
||||||
|
<!-- SECTION: Additional Notes -->
|
||||||
|
<div class="space-y-5">
|
||||||
|
<div class="space-y-5">
|
||||||
|
<!-- Special Considerations -->
|
||||||
|
<VeeField name="special_considerations" v-slot="{ field, errors: e }">
|
||||||
|
<Field :data-invalid="!!e.length">
|
||||||
|
<FieldLabel class="text-sm font-medium">Additional Information</FieldLabel>
|
||||||
|
<FieldDescription class="text-xs">Anything else we should know?</FieldDescription>
|
||||||
|
<Textarea v-bind="field" placeholder="Add any other important notes... (optional)"
|
||||||
|
rows="4" class="resize-none mt-2" />
|
||||||
|
<div class="h-4">
|
||||||
|
<FieldError v-if="e.length" :errors="e" />
|
||||||
|
</div>
|
||||||
|
</Field>
|
||||||
|
</VeeField>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Action Buttons -->
|
||||||
|
<div class="flex gap-2 justify-end pt-4">
|
||||||
|
<Button type="button" variant="outline" @click="resetForm">Clear</Button>
|
||||||
|
<Button type="submit" :disabled="submitting">
|
||||||
|
{{ submitting ? 'Submitting...' : 'Submit Request' }}
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</CardContent>
|
||||||
|
</Card>
|
||||||
|
</template>
|
||||||
125
ui/src/components/modRequests/ModRequestList.vue
Normal file
125
ui/src/components/modRequests/ModRequestList.vue
Normal file
@@ -0,0 +1,125 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { ref, onMounted } from 'vue';
|
||||||
|
import type { DiscussionPost } from '@shared/types/discussion';
|
||||||
|
import type { ModRequest } from '@shared/schemas/modRequest';
|
||||||
|
import type { PagedData, pagination } from '@shared/types/pagination';
|
||||||
|
import {
|
||||||
|
Table,
|
||||||
|
TableBody,
|
||||||
|
TableCell,
|
||||||
|
TableHead,
|
||||||
|
TableHeader,
|
||||||
|
TableRow,
|
||||||
|
} from '@/components/ui/table';
|
||||||
|
import Badge from '@/components/ui/badge/Badge.vue';
|
||||||
|
import { getModRequests } from '@/api/modRequests';
|
||||||
|
import Pagination from '../ui/pagination/Pagination.vue';
|
||||||
|
import PaginationContent from '../ui/pagination/PaginationContent.vue';
|
||||||
|
import PaginationPrevious from '../ui/pagination/PaginationPrevious.vue';
|
||||||
|
import PaginationItem from '../ui/pagination/PaginationItem.vue';
|
||||||
|
import PaginationEllipsis from '../ui/pagination/PaginationEllipsis.vue';
|
||||||
|
import PaginationNext from '../ui/pagination/PaginationNext.vue';
|
||||||
|
import { Lock } from 'lucide-vue-next';
|
||||||
|
|
||||||
|
const requests = ref<DiscussionPost<ModRequest>[]>([]);
|
||||||
|
const loading = ref(true);
|
||||||
|
|
||||||
|
async function loadRequests() {
|
||||||
|
loading.value = true;
|
||||||
|
try {
|
||||||
|
const response = await getModRequests(pageNum.value, pageSize.value);
|
||||||
|
|
||||||
|
requests.value = response.data;
|
||||||
|
pageData.value = response.pagination;
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Failed to load requests:", error);
|
||||||
|
} finally {
|
||||||
|
loading.value = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
loadRequests();
|
||||||
|
});
|
||||||
|
|
||||||
|
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;
|
||||||
|
loadRequests();
|
||||||
|
}
|
||||||
|
|
||||||
|
function setPage(pagenum: number) {
|
||||||
|
pageNum.value = pagenum;
|
||||||
|
loadRequests();
|
||||||
|
}
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="mod-request-list">
|
||||||
|
<Table v-if="!loading">
|
||||||
|
<TableHeader>
|
||||||
|
<TableRow>
|
||||||
|
<TableHead class="w-1/2">Title</TableHead>
|
||||||
|
<TableHead class="w-1/4">Creator</TableHead>
|
||||||
|
<TableHead class="w-1/4">Date</TableHead>
|
||||||
|
<TableHead class="w-1/5 text-right">Status</TableHead>
|
||||||
|
</TableRow>
|
||||||
|
</TableHeader>
|
||||||
|
<TableBody>
|
||||||
|
<TableRow v-for="post in requests" :key="post.id"
|
||||||
|
class="hover:bg-muted/50 cursor-pointer transition-colors"
|
||||||
|
@click="$router.push(`/discussions/mod-requests/${post.id}`)">
|
||||||
|
<TableCell class="font-medium">{{ post.title }}</TableCell>
|
||||||
|
<TableCell>{{ post.poster_name }}</TableCell>
|
||||||
|
<TableCell class="text-muted-foreground">{{ new Date(post.created_at).toLocaleDateString() }}
|
||||||
|
</TableCell>
|
||||||
|
<TableCell class="text-right">
|
||||||
|
<Badge :variant="post.is_open ? 'secondary' : 'outline'">
|
||||||
|
{{ post.is_open ? 'Open' : 'Locked' }}
|
||||||
|
<Lock v-if="!post.is_open" />
|
||||||
|
</Badge>
|
||||||
|
</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
</TableBody>
|
||||||
|
</Table>
|
||||||
|
<div v-else class="flex items-center justify-center py-12">
|
||||||
|
<p class="text-muted-foreground">Loading requests...</p>
|
||||||
|
</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>
|
||||||
|
</template>
|
||||||
106
ui/src/components/modRequests/ViewModRequest.vue
Normal file
106
ui/src/components/modRequests/ViewModRequest.vue
Normal file
@@ -0,0 +1,106 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { ref, onMounted } from 'vue';
|
||||||
|
import { useRoute, useRouter } from 'vue-router';
|
||||||
|
import type { DiscussionPost } from '@shared/types/discussion';
|
||||||
|
import type { ModRequest } from '@shared/schemas/modRequest';
|
||||||
|
import { getModRequest } from '@/api/modRequests';
|
||||||
|
import Button from '@/components/ui/button/Button.vue';
|
||||||
|
import Badge from '@/components/ui/badge/Badge.vue';
|
||||||
|
import CommentThread from '../discussion/CommentThread.vue';
|
||||||
|
|
||||||
|
const route = useRoute();
|
||||||
|
const router = useRouter();
|
||||||
|
|
||||||
|
const post = ref<DiscussionPost<ModRequest> | null>(null);
|
||||||
|
const loading = ref(true);
|
||||||
|
const error = ref<string | null>(null);
|
||||||
|
|
||||||
|
async function loadPost() {
|
||||||
|
loading.value = true;
|
||||||
|
error.value = null;
|
||||||
|
try {
|
||||||
|
const id = Number(route.params.id);
|
||||||
|
if (isNaN(id)) {
|
||||||
|
error.value = 'Invalid request ID';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
post.value = await getModRequest(id);
|
||||||
|
} catch (err: any) {
|
||||||
|
console.error('Failed to fetch mod request', err);
|
||||||
|
error.value = 'Failed to load mod request';
|
||||||
|
} finally {
|
||||||
|
loading.value = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
loadPost();
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="max-w-[80rem] mt-5 mx-auto px-2 lg:px-20 w-full">
|
||||||
|
<div class="mb-8 flex items-center justify-between">
|
||||||
|
<div>
|
||||||
|
<h1 class="scroll-m-20 text-3xl font-semibold tracking-tight mb-2">Mod Request: {{ post?.title }}</h1>
|
||||||
|
<p class="text-muted-foreground" v-if="post">
|
||||||
|
Requested by {{ post.poster_name || 'Unknown' }} on {{ new
|
||||||
|
Date(post.created_at).toLocaleDateString() }}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<Button variant="outline" @click="router.push('/discussions/mod-requests')">
|
||||||
|
Back to posts
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div v-if="loading" class="flex items-center justify-center py-12">
|
||||||
|
<p class="text-muted-foreground">Loading...</p>
|
||||||
|
</div>
|
||||||
|
<div v-else-if="error" class="text-red-500">{{ error }}</div>
|
||||||
|
<div v-else-if="post" class="space-y-6">
|
||||||
|
<div class="flex items-center gap-3">
|
||||||
|
<Badge :variant="post.is_open ? 'secondary' : 'outline'">
|
||||||
|
{{ post.is_open ? 'Open' : 'Locked' }}
|
||||||
|
</Badge>
|
||||||
|
</div>
|
||||||
|
<div class="border rounded-lg p-6 bg-muted/50">
|
||||||
|
<h2 class="text-2xl font-semibold mb-2">{{ post.content.mod_title }}</h2>
|
||||||
|
<p class="text-sm text-muted-foreground mb-4"><a :href="post.content.mod_link" target="_blank"
|
||||||
|
class="text-primary underline">{{ post.content.mod_link }}</a></p>
|
||||||
|
<div class="space-y-4">
|
||||||
|
<div>
|
||||||
|
<h3 class="font-medium">Description</h3>
|
||||||
|
<p>{{ post.content.description }}</p>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<h3 class="font-medium">Reason</h3>
|
||||||
|
<p>{{ post.content.reason }}</p>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<h3 class="font-medium">Tested?</h3>
|
||||||
|
<p>{{ post.content.confirmed_tested ? 'Yes' : 'No' }}</p>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<h3 class="font-medium">Detrimental Effects</h3>
|
||||||
|
<p>{{ post.content.detrimental_effects }}</p>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<h3 class="font-medium">Keybind Conflicts</h3>
|
||||||
|
<p>{{ post.content.keybind_conflicts || 'None' }}</p>
|
||||||
|
</div>
|
||||||
|
<div v-if="post.content.special_considerations">
|
||||||
|
<h3 class="font-medium">Additional Notes</h3>
|
||||||
|
<p>{{ post.content.special_considerations }}</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- discussion placeholder -->
|
||||||
|
<CommentThread :parent-id="post.id" :comments="post.comments" @comments-updated="post.comments = $event" />
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div v-else>
|
||||||
|
<p class="text-muted-foreground">Unable to locate this mod request.</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
@@ -135,7 +135,11 @@ function setAllToday() {
|
|||||||
<div class="w-xl">
|
<div class="w-xl">
|
||||||
<form v-if="!formSubmitted" id="trainingForm" @submit.prevent="submitForm"
|
<form v-if="!formSubmitted" id="trainingForm" @submit.prevent="submitForm"
|
||||||
class="w-full min-w-0 flex flex-col gap-4">
|
class="w-full min-w-0 flex flex-col gap-4">
|
||||||
|
<div>
|
||||||
|
<FieldLegend class="scroll-m-20 text-2xl font-semibold tracking-tight">
|
||||||
|
Promotion Form
|
||||||
|
</FieldLegend>
|
||||||
|
</div>
|
||||||
<VeeFieldArray name="promotions" v-slot="{ fields, push, remove }">
|
<VeeFieldArray name="promotions" v-slot="{ fields, push, remove }">
|
||||||
<FieldSet class="w-full min-w-0">
|
<FieldSet class="w-full min-w-0">
|
||||||
<div class="flex flex-col gap-2">
|
<div class="flex flex-col gap-2">
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ const forwarded = useForwardPropsEmits(delegatedProps, emits);
|
|||||||
<slot />
|
<slot />
|
||||||
|
|
||||||
<DialogClose
|
<DialogClose
|
||||||
class="ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-3.5 right-3.5 inline-flex h-9 w-9 items-center justify-center rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none sm:top-4 sm:right-4 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-5"
|
class="ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4"
|
||||||
>
|
>
|
||||||
<X />
|
<X />
|
||||||
<span class="sr-only">Close</span>
|
<span class="sr-only">Close</span>
|
||||||
|
|||||||
@@ -227,9 +227,6 @@ onMounted(() => {
|
|||||||
/* Ensure the calendar fills the container properly */
|
/* Ensure the calendar fills the container properly */
|
||||||
:global(.fc) {
|
:global(.fc) {
|
||||||
height: 100% !important;
|
height: 100% !important;
|
||||||
--fc-page-bg-color: transparent;
|
|
||||||
--fc-neutral-bg-color: color-mix(in srgb, var(--color-foreground) 8%, transparent);
|
|
||||||
--fc-neutral-text-color: var(--color-muted-foreground);
|
|
||||||
--fc-border-color: var(--color-border);
|
--fc-border-color: var(--color-border);
|
||||||
--fc-button-bg-color: transparent;
|
--fc-button-bg-color: transparent;
|
||||||
--fc-button-border-color: var(--color-border);
|
--fc-button-border-color: var(--color-border);
|
||||||
@@ -302,7 +299,6 @@ onMounted(() => {
|
|||||||
:global(.fc .fc-scrollgrid td),
|
:global(.fc .fc-scrollgrid td),
|
||||||
:global(.fc .fc-scrollgrid th) {
|
:global(.fc .fc-scrollgrid th) {
|
||||||
border-color: var(--color-border);
|
border-color: var(--color-border);
|
||||||
background: var(--fc-page-bg-color);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------- Built-in toolbar (if you keep it) ---------- */
|
/* ---------- Built-in toolbar (if you keep it) ---------- */
|
||||||
@@ -350,7 +346,9 @@ onMounted(() => {
|
|||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
:global(#app > div > div.flex-1.min-h-0 > div > div > div > div.fc.fc-media-screen.fc-direction-ltr.fc-theme-standard > div.fc-view-harness.fc-view-harness-passive > div > table > thead > tr > th) {
|
||||||
|
background-color: transparent;
|
||||||
|
}
|
||||||
:global(.fc .fc-daygrid-day-top) {
|
:global(.fc .fc-daygrid-day-top) {
|
||||||
padding: 8px 8px 0 8px;
|
padding: 8px 8px 0 8px;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,52 +0,0 @@
|
|||||||
<script setup lang="ts">
|
|
||||||
import Button from '@/components/ui/button/Button.vue';
|
|
||||||
import { bustUserCache } from '@/api/member';
|
|
||||||
import type { UserCacheBustResult } from '@shared/types/member';
|
|
||||||
import { ref } from 'vue';
|
|
||||||
|
|
||||||
const loading = ref(false);
|
|
||||||
const result = ref<UserCacheBustResult | null>(null);
|
|
||||||
const error = ref<string | null>(null);
|
|
||||||
|
|
||||||
async function onBustUserCache() {
|
|
||||||
loading.value = true;
|
|
||||||
error.value = null;
|
|
||||||
|
|
||||||
try {
|
|
||||||
result.value = await bustUserCache();
|
|
||||||
} catch (err) {
|
|
||||||
result.value = null;
|
|
||||||
error.value = err instanceof Error ? err.message : 'Failed to bust user cache';
|
|
||||||
} finally {
|
|
||||||
loading.value = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<div class="max-w-3xl mx-auto pt-10 px-4">
|
|
||||||
<h1 class="scroll-m-20 text-2xl font-semibold tracking-tight">Developer Tools</h1>
|
|
||||||
<p class="mt-2 text-sm text-muted-foreground">
|
|
||||||
Use this page to recover from stale in-memory authentication data after manual database changes.
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<div class="mt-6 rounded-lg border p-5 bg-card">
|
|
||||||
<p class="font-medium">Server User Cache</p>
|
|
||||||
<p class="text-sm text-muted-foreground mt-1">
|
|
||||||
This clears the API server's cached user session data so the next request reloads from the database.
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<div class="mt-4 flex items-center gap-3">
|
|
||||||
<Button :disabled="loading" @click="onBustUserCache">
|
|
||||||
{{ loading ? 'Busting Cache...' : 'Bust User Cache' }}
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<p v-if="result" class="mt-4 text-sm text-green-700">
|
|
||||||
Cache busted successfully. Cleared {{ result.clearedEntries }} entr{{ result.clearedEntries === 1 ? 'y' : 'ies' }} at
|
|
||||||
{{ new Date(result.bustedAt).toLocaleString() }}.
|
|
||||||
</p>
|
|
||||||
<p v-if="error" class="mt-4 text-sm text-red-700">{{ error }}</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
@@ -19,20 +19,17 @@ const showLOADialog = ref(false);
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<Dialog v-model:open="showLOADialog" v-on:update:open="showLOADialog = false">
|
<Dialog v-model:open="showLOADialog" v-on:update:open="showLOADialog = false">
|
||||||
<DialogContent class="w-[95vw] max-w-[95vw] max-h-[90dvh] overflow-y-auto p-4 sm:max-w-fit sm:p-6">
|
<DialogContent class="sm:max-w-fit">
|
||||||
<DialogHeader>
|
<DialogHeader>
|
||||||
<DialogTitle>Post LOA</DialogTitle>
|
<DialogTitle>Post LOA</DialogTitle>
|
||||||
<DialogDescription>
|
<DialogDescription>
|
||||||
Post an LOA on behalf of a member.
|
Post an LOA on behalf of a member.
|
||||||
</DialogDescription>
|
</DialogDescription>
|
||||||
</DialogHeader>
|
</DialogHeader>
|
||||||
<LoaForm :admin-mode="true"></LoaForm>
|
<LoaForm :admin-mode="true" class="my-3"></LoaForm>
|
||||||
<DialogFooter>
|
|
||||||
<Button variant="outline" @click="showLOADialog = false">Cancel</Button>
|
|
||||||
</DialogFooter>
|
|
||||||
</DialogContent>
|
</DialogContent>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
<div class="mx-auto max-w-5xl px-3 pt-10 sm:px-4 lg:px-0">
|
<div class="max-w-5xl mx-auto pt-10">
|
||||||
<div class="flex justify-between mb-4">
|
<div class="flex justify-between mb-4">
|
||||||
<h1 class="scroll-m-20 text-2xl font-semibold tracking-tight">LOA Log</h1>
|
<h1 class="scroll-m-20 text-2xl font-semibold tracking-tight">LOA Log</h1>
|
||||||
<div>
|
<div>
|
||||||
|
|||||||
32
ui/src/pages/ModRequest.vue
Normal file
32
ui/src/pages/ModRequest.vue
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { ref } from 'vue';
|
||||||
|
import Button from '@/components/ui/button/Button.vue';
|
||||||
|
import ModRequestForm from '@/components/modRequests/ModRequestForm.vue';
|
||||||
|
import ModRequestList from '@/components/modRequests/ModRequestList.vue';
|
||||||
|
|
||||||
|
const showForm = ref(false);
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="max-w-[80rem] mt-5 mx-auto px-2 lg:px-20 w-full">
|
||||||
|
<!-- Header - always visible -->
|
||||||
|
<div class="mb-8">
|
||||||
|
<h1 class="scroll-m-20 text-3xl font-semibold tracking-tight mb-2">Mod Requests</h1>
|
||||||
|
<p class="text-muted-foreground">Submit and manage mod requests for the community</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- List View -->
|
||||||
|
<template v-if="!showForm">
|
||||||
|
<Button @click="showForm = true" class="mb-6">
|
||||||
|
New Request
|
||||||
|
</Button>
|
||||||
|
<ModRequestList></ModRequestList>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<!-- Form View -->
|
||||||
|
<template v-else>
|
||||||
|
<ModRequestForm class="mb-8" @close="showForm = false" @submit="(id) => $router.push(`/discussions/mod-requests/${id}`)"></ModRequestForm>
|
||||||
|
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
@@ -1,48 +1,29 @@
|
|||||||
<script setup>
|
|
||||||
import { ref } from 'vue'
|
|
||||||
import { Plus, PlusIcon, X } from 'lucide-vue-next'
|
|
||||||
import PromotionForm from '@/components/promotions/promotionForm.vue'
|
|
||||||
import PromotionList from '@/components/promotions/promotionList.vue'
|
|
||||||
import DialogContent from '@/components/ui/dialog/DialogContent.vue'
|
|
||||||
import Dialog from '@/components/ui/dialog/Dialog.vue'
|
|
||||||
import DialogTrigger from '@/components/ui/dialog/DialogTrigger.vue'
|
|
||||||
import DialogHeader from '@/components/ui/dialog/DialogHeader.vue'
|
|
||||||
import DialogTitle from '@/components/ui/dialog/DialogTitle.vue'
|
|
||||||
import Button from '@/components/ui/button/Button.vue'
|
|
||||||
|
|
||||||
const isFormOpen = ref(false)
|
|
||||||
const listRef = ref(null)
|
|
||||||
|
|
||||||
const isMobileFormOpen = ref(false);
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="mx-auto mt-6 lg:mt-10 px-4 lg:px-8">
|
<div class="mx-auto mt-6 lg:mt-10 px-4 lg:px-8">
|
||||||
|
|
||||||
<div class="flex flex-col items-center justify-between mb-6 lg:hidden">
|
<div class="flex items-center justify-between mb-6 lg:hidden">
|
||||||
<div v-if="isMobileFormOpen">
|
<h1 class="text-2xl font-semibold tracking-tight">Promotion History</h1>
|
||||||
<div class="mb-4 flex justify-between items-center">
|
|
||||||
<p class="scroll-m-20 text-2xl font-semibold tracking-tight">
|
<Dialog v-model:open="isFormOpen">
|
||||||
Promotion Form
|
<DialogTrigger as-child>
|
||||||
</p>
|
<Button size="sm" class="gap-2">
|
||||||
<Button variant="ghost" size="icon" @click="isMobileFormOpen = false">
|
<Plus class="size-4" />
|
||||||
<X v-if="isMobileFormOpen" class="size-6"></X>
|
Promote
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</DialogTrigger>
|
||||||
<PromotionForm @submitted="listRef?.refresh" />
|
<DialogContent class="w-full h-full max-w-none m-0 rounded-none flex flex-col">
|
||||||
</div>
|
<DialogHeader class="flex-row items-center justify-between border-b pb-4">
|
||||||
<div v-else>
|
<DialogTitle>New Promotion</DialogTitle>
|
||||||
<div class="flex justify-between w-full">
|
</DialogHeader>
|
||||||
<h1 class="text-2xl font-semibold tracking-tight">Promotion History</h1>
|
|
||||||
<Button @click="isMobileFormOpen = true">
|
<div class="flex-1 overflow-y-auto pt-6">
|
||||||
<PlusIcon />Submit
|
<PromotionForm @submitted="handleMobileSubmit" />
|
||||||
</Button>
|
</div>
|
||||||
</div>
|
</DialogContent>
|
||||||
<PromotionList></PromotionList>
|
</Dialog>
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="hidden lg:flex flex-row lg:max-h-[70vh] gap-8">
|
<div class="flex flex-col lg:flex-row lg:max-h-[70vh] gap-8">
|
||||||
<div class="flex-1 lg:border-r lg:pr-8 w-full lg:min-w-2xl">
|
<div class="flex-1 lg:border-r lg:pr-8 w-full lg:min-w-2xl">
|
||||||
<p class="hidden lg:block scroll-m-20 text-2xl font-semibold tracking-tight mb-3">
|
<p class="hidden lg:block scroll-m-20 text-2xl font-semibold tracking-tight mb-3">
|
||||||
Promotion History
|
Promotion History
|
||||||
@@ -60,4 +41,25 @@ const isMobileFormOpen = ref(false);
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import { ref } from 'vue'
|
||||||
|
import { Plus } from 'lucide-vue-next'
|
||||||
|
import PromotionForm from '@/components/promotions/promotionForm.vue'
|
||||||
|
import PromotionList from '@/components/promotions/promotionList.vue'
|
||||||
|
import DialogContent from '@/components/ui/dialog/DialogContent.vue'
|
||||||
|
import Dialog from '@/components/ui/dialog/Dialog.vue'
|
||||||
|
import DialogTrigger from '@/components/ui/dialog/DialogTrigger.vue'
|
||||||
|
import DialogHeader from '@/components/ui/dialog/DialogHeader.vue'
|
||||||
|
import DialogTitle from '@/components/ui/dialog/DialogTitle.vue'
|
||||||
|
import Button from '@/components/ui/button/Button.vue'
|
||||||
|
|
||||||
|
const isFormOpen = ref(false)
|
||||||
|
const listRef = ref(null)
|
||||||
|
|
||||||
|
const handleMobileSubmit = () => {
|
||||||
|
isFormOpen.value = false // Close the "Whole page" modal
|
||||||
|
listRef.value?.refresh() // Refresh the list behind it
|
||||||
|
}
|
||||||
|
</script>
|
||||||
@@ -11,7 +11,7 @@ const mode = ref<'submit' | 'view'>('submit')
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="mx-auto mt-4 mb-10 flex w-full max-w-5xl flex-col px-3 sm:px-4 lg:px-0">
|
<div class="max-w-5xl mx-auto flex w-full flex-col mt-4 mb-10">
|
||||||
<div class="mb-8">
|
<div class="mb-8">
|
||||||
<p class="scroll-m-20 text-2xl font-semibold tracking-tight">Leave of Absence</p>
|
<p class="scroll-m-20 text-2xl font-semibold tracking-tight">Leave of Absence</p>
|
||||||
<div class="pt-3">
|
<div class="pt-3">
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { getTrainingReport, getTrainingReports } from '@/api/trainingReport';
|
import { getTrainingReport, getTrainingReports } from '@/api/trainingReport';
|
||||||
import { CourseAttendee, CourseEventDetails, CourseEventSummary } from '@shared/types/course';
|
import { CourseAttendee, CourseEventDetails, CourseEventSummary } from '@shared/types/course';
|
||||||
import { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue';
|
import { computed, onMounted, ref, watch } from 'vue';
|
||||||
import {
|
import {
|
||||||
Table,
|
Table,
|
||||||
TableBody,
|
TableBody,
|
||||||
@@ -10,7 +10,7 @@ import {
|
|||||||
TableHeader,
|
TableHeader,
|
||||||
TableRow,
|
TableRow,
|
||||||
} from '@/components/ui/table'
|
} from '@/components/ui/table'
|
||||||
import { ArrowUpDown, ChevronDown, ChevronLeft, ChevronUp, Funnel, Link, Plus, Search, X } from 'lucide-vue-next';
|
import { ArrowUpDown, ChevronDown, ChevronUp, Funnel, Link, Plus, Search, X } from 'lucide-vue-next';
|
||||||
import Button from '@/components/ui/button/Button.vue';
|
import Button from '@/components/ui/button/Button.vue';
|
||||||
import TrainingReportForm from '@/components/trainingReport/trainingReportForm.vue';
|
import TrainingReportForm from '@/components/trainingReport/trainingReportForm.vue';
|
||||||
import Checkbox from '@/components/ui/checkbox/Checkbox.vue';
|
import Checkbox from '@/components/ui/checkbox/Checkbox.vue';
|
||||||
@@ -49,21 +49,6 @@ const sidePanel = computed<sidePanelState>(() => {
|
|||||||
return sidePanelState.closed;
|
return sidePanelState.closed;
|
||||||
})
|
})
|
||||||
|
|
||||||
const isMobile = ref(false);
|
|
||||||
const mobilePanel = ref<sidePanelState>(sidePanelState.closed);
|
|
||||||
let mobileMediaQuery: MediaQueryList | null = null;
|
|
||||||
|
|
||||||
function syncMobileMode() {
|
|
||||||
isMobile.value = mobileMediaQuery?.matches ?? window.innerWidth < 1024;
|
|
||||||
if (!isMobile.value) {
|
|
||||||
mobilePanel.value = sidePanelState.closed;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const effectivePanel = computed<sidePanelState>(() => {
|
|
||||||
return isMobile.value ? mobilePanel.value : sidePanel.value;
|
|
||||||
})
|
|
||||||
|
|
||||||
watch(() => route.params.id, async (newID) => {
|
watch(() => route.params.id, async (newID) => {
|
||||||
if (!newID) {
|
if (!newID) {
|
||||||
focusedTrainingReport.value = null;
|
focusedTrainingReport.value = null;
|
||||||
@@ -97,41 +82,6 @@ async function closeTrainingReport() {
|
|||||||
focusedTrainingReport.value = null;
|
focusedTrainingReport.value = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function openTrainingReport(id: number) {
|
|
||||||
if (isMobile.value) {
|
|
||||||
focusedTrainingReport.value = null;
|
|
||||||
TRLoaded.value = false;
|
|
||||||
expanded.value = null;
|
|
||||||
mobilePanel.value = sidePanelState.view;
|
|
||||||
await viewTrainingReport(id);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
router.push(`/trainingReport/${id}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
function openCreatePanel() {
|
|
||||||
if (isMobile.value) {
|
|
||||||
mobilePanel.value = sidePanelState.create;
|
|
||||||
focusedTrainingReport.value = null;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
router.push('/trainingReport/new');
|
|
||||||
}
|
|
||||||
|
|
||||||
async function closePanel() {
|
|
||||||
if (isMobile.value) {
|
|
||||||
mobilePanel.value = sidePanelState.closed;
|
|
||||||
focusedTrainingReport.value = null;
|
|
||||||
TRLoaded.value = false;
|
|
||||||
expanded.value = null;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
await closeTrainingReport();
|
|
||||||
}
|
|
||||||
|
|
||||||
const sortMode = ref<string>("descending");
|
const sortMode = ref<string>("descending");
|
||||||
const searchString = ref<string>("");
|
const searchString = ref<string>("");
|
||||||
let debounceTimer: ReturnType<typeof setTimeout> | null = null;
|
let debounceTimer: ReturnType<typeof setTimeout> | null = null;
|
||||||
@@ -155,20 +105,12 @@ async function loadTrainingReports() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
mobileMediaQuery = window.matchMedia('(max-width: 1023px)');
|
|
||||||
syncMobileMode();
|
|
||||||
mobileMediaQuery.addEventListener('change', syncMobileMode);
|
|
||||||
|
|
||||||
await loadTrainingReports();
|
await loadTrainingReports();
|
||||||
if (route.params.id)
|
if (route.params.id)
|
||||||
viewTrainingReport(Number(route.params.id))
|
viewTrainingReport(Number(route.params.id))
|
||||||
loaded.value = true;
|
loaded.value = true;
|
||||||
})
|
})
|
||||||
|
|
||||||
onBeforeUnmount(() => {
|
|
||||||
mobileMediaQuery?.removeEventListener('change', syncMobileMode);
|
|
||||||
})
|
|
||||||
|
|
||||||
const TRLoaded = ref(false);
|
const TRLoaded = ref(false);
|
||||||
|
|
||||||
const pageNum = ref<number>(1);
|
const pageNum = ref<number>(1);
|
||||||
@@ -177,16 +119,6 @@ const pageData = ref<pagination>();
|
|||||||
const pageSize = ref<number>(15)
|
const pageSize = ref<number>(15)
|
||||||
const pageSizeOptions = [10, 15, 30]
|
const pageSizeOptions = [10, 15, 30]
|
||||||
|
|
||||||
function formatDate(date: Date | string): string {
|
|
||||||
if (!date) return '';
|
|
||||||
const dateObj = typeof date === 'string' ? new Date(date) : date;
|
|
||||||
return dateObj.toLocaleDateString('en-US', {
|
|
||||||
year: 'numeric',
|
|
||||||
month: 'short',
|
|
||||||
day: 'numeric',
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function setPageSize(size: number) {
|
function setPageSize(size: number) {
|
||||||
pageSize.value = size
|
pageSize.value = size
|
||||||
pageNum.value = 1;
|
pageNum.value = 1;
|
||||||
@@ -202,22 +134,21 @@ const expanded = ref<number>(null);
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="mx-auto mt-5 flex w-full max-w-[100rem] flex-col px-3 sm:px-4 lg:flex-row lg:px-8 xl:px-20">
|
<div class="px-20 mx-auto max-w-[100rem] w-full flex mt-5">
|
||||||
<!-- training report list -->
|
<!-- training report list -->
|
||||||
<div v-show="!isMobile || effectivePanel === sidePanelState.closed" class="my-3 px-0 lg:px-4"
|
<div class="px-4 my-3" :class="sidePanel == sidePanelState.closed ? 'w-full' : 'w-2/5'">
|
||||||
:class="effectivePanel == sidePanelState.closed ? 'w-full' : 'w-full lg:flex-[0_0_26rem] xl:flex-[0_0_30rem]'">
|
|
||||||
<div class="flex justify-between mb-4">
|
<div class="flex justify-between mb-4">
|
||||||
<p class="scroll-m-20 text-2xl font-semibold tracking-tight">Training Reports</p>
|
<p class="scroll-m-20 text-2xl font-semibold tracking-tight">Training Reports</p>
|
||||||
<Button @click="openCreatePanel()">
|
<Button @click="router.push('/trainingReport/new')">
|
||||||
<Plus></Plus> New Training Report
|
<Plus></Plus> New Training Report
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
<!-- search/filter -->
|
<!-- search/filter -->
|
||||||
<div class="flex flex-col gap-3 sm:flex-row sm:items-end sm:justify-between">
|
<div class="flex justify-between">
|
||||||
<!-- <Search></Search>
|
<!-- <Search></Search>
|
||||||
<Funnel></Funnel> -->
|
<Funnel></Funnel> -->
|
||||||
<div></div>
|
<div></div>
|
||||||
<div class="flex flex-col gap-3 sm:flex-row sm:gap-5">
|
<div class="flex flex-row gap-5">
|
||||||
<div>
|
<div>
|
||||||
<label class="text-muted-foreground">Search</label>
|
<label class="text-muted-foreground">Search</label>
|
||||||
<Input v-model="searchString" placeholder="Search..."></Input>
|
<Input v-model="searchString" placeholder="Search..."></Input>
|
||||||
@@ -241,24 +172,7 @@ const expanded = ref<number>(null);
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="mt-5">
|
<div class="overflow-y-auto max-h-[70vh] mt-5 scrollbar-themed">
|
||||||
<div class="space-y-2 md:hidden">
|
|
||||||
<button v-for="report in trainingReports" :key="`mobile-report-${report.event_id}`"
|
|
||||||
class="w-full rounded-lg border bg-card px-3 py-2 text-left transition-colors hover:bg-muted/40"
|
|
||||||
@click="openTrainingReport(report.event_id)">
|
|
||||||
<p class="font-semibold text-foreground">
|
|
||||||
{{ report.course_name.length > 35 ? report.course_shortname : report.course_name }}
|
|
||||||
</p>
|
|
||||||
<p class="mt-1 text-sm text-muted-foreground">{{ formatDate(report.date) }}</p>
|
|
||||||
<div class="mt-2 flex items-center gap-2 text-xs text-muted-foreground">
|
|
||||||
<span class="font-medium">Posted by:</span>
|
|
||||||
<MemberCard v-if="report.created_by" :member-id="report.created_by"></MemberCard>
|
|
||||||
<span v-else>Unknown User</span>
|
|
||||||
</div>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="hidden md:block">
|
|
||||||
<Table>
|
<Table>
|
||||||
<TableHeader class="">
|
<TableHeader class="">
|
||||||
<TableRow>
|
<TableRow>
|
||||||
@@ -273,12 +187,12 @@ const expanded = ref<number>(null);
|
|||||||
</TableHeader>
|
</TableHeader>
|
||||||
<TableBody v-if="loaded">
|
<TableBody v-if="loaded">
|
||||||
<TableRow class="cursor-pointer" v-for="report in trainingReports" :key="report.event_id"
|
<TableRow class="cursor-pointer" v-for="report in trainingReports" :key="report.event_id"
|
||||||
@click="openTrainingReport(report.event_id)">
|
@click="router.push(`/trainingReport/${report.event_id}`)">
|
||||||
<TableCell class="font-medium">{{ report.course_name.length > 30 ? report.course_shortname :
|
<TableCell class="font-medium">{{ report.course_name.length > 30 ? report.course_shortname :
|
||||||
report.course_name }}</TableCell>
|
report.course_name }}</TableCell>
|
||||||
<TableCell>{{ report.date.split('T')[0] }}</TableCell>
|
<TableCell>{{ report.date.split('T')[0] }}</TableCell>
|
||||||
<TableCell class="text-right">
|
<TableCell class="text-right">
|
||||||
<MemberCard v-if="report.created_by" :member-id="report.created_by"></MemberCard>
|
<MemberCard v-if="report.created_by_name" :member-id="report.created_by"></MemberCard>
|
||||||
<span v-else>Unknown User</span>
|
<span v-else>Unknown User</span>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<!-- <TableCell class="text-right">{{ report.created_by_name === null ? "Unknown User" :
|
<!-- <TableCell class="text-right">{{ report.created_by_name === null ? "Unknown User" :
|
||||||
@@ -287,11 +201,10 @@ const expanded = ref<number>(null);
|
|||||||
</TableRow>
|
</TableRow>
|
||||||
</TableBody>
|
</TableBody>
|
||||||
</Table>
|
</Table>
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="mt-5 flex flex-col gap-3 md:flex-row md:items-center md:justify-between"
|
<div class="mt-5 flex justify-between"
|
||||||
:class="effectivePanel !== sidePanelState.closed ? 'items-center' : ''">
|
:class="sidePanel !== sidePanelState.closed ? 'flex-col items-center' : 'items-center justify-between'">
|
||||||
<div class="hidden md:block"></div>
|
<div></div>
|
||||||
<Pagination v-slot="{ page }" :items-per-page="pageData?.pageSize || 10" :total="pageData?.total || 10"
|
<Pagination v-slot="{ page }" :items-per-page="pageData?.pageSize || 10" :total="pageData?.total || 10"
|
||||||
:default-page="2" :page="pageNum" @update:page="setPage">
|
:default-page="2" :page="pageNum" @update:page="setPage">
|
||||||
<PaginationContent v-slot="{ items }">
|
<PaginationContent v-slot="{ items }">
|
||||||
@@ -306,9 +219,8 @@ const expanded = ref<number>(null);
|
|||||||
<PaginationNext />
|
<PaginationNext />
|
||||||
</PaginationContent>
|
</PaginationContent>
|
||||||
</Pagination>
|
</Pagination>
|
||||||
<div class="flex flex-wrap items-center justify-end gap-2 text-sm"
|
<div class="flex items-center gap-3 text-sm" :class="sidePanel !== sidePanelState.closed ? 'mt-3' : ''">
|
||||||
:class="effectivePanel !== sidePanelState.closed ? 'w-full justify-center md:w-auto md:justify-end' : ''">
|
<p class="text-muted-foreground text-nowrap">Per page:</p>
|
||||||
<p class="text-muted-foreground">Per page:</p>
|
|
||||||
|
|
||||||
<button v-for="size in pageSizeOptions" :key="size" @click="setPageSize(size)"
|
<button v-for="size in pageSizeOptions" :key="size" @click="setPageSize(size)"
|
||||||
class="px-2 py-1 rounded transition-colors" :class="{
|
class="px-2 py-1 rounded transition-colors" :class="{
|
||||||
@@ -322,125 +234,82 @@ const expanded = ref<number>(null);
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
<!-- view training report section -->
|
<!-- view training report section -->
|
||||||
<div v-if="focusedTrainingReport != null && effectivePanel == sidePanelState.view"
|
<div v-if="focusedTrainingReport != null && sidePanel == sidePanelState.view" class="pl-9 my-3 border-l w-3/5">
|
||||||
:class="isMobile ? 'fixed inset-0 z-[60] overflow-y-auto px-3 py-3' : 'my-3 mt-2 w-full min-w-0 lg:mt-0 lg:flex-1 lg:border-l lg:pl-9'"
|
|
||||||
:style="isMobile ? { top: 'var(--app-header-height, 60px)' } : {}">
|
|
||||||
<div class="flex justify-between items-center">
|
<div class="flex justify-between items-center">
|
||||||
<p class="scroll-m-20 text-2xl font-semibold tracking-tight">Training Report Details</p>
|
<p class="scroll-m-20 text-2xl font-semibold tracking-tight">Training Report Details</p>
|
||||||
<div class="flex items-center gap-2">
|
<div class="flex items-center gap-2">
|
||||||
<Button v-if="isMobile" @click="closePanel" class="cursor-pointer" variant="outline" size="sm">
|
<Button class="cursor-pointer" variant="ghost" size="icon" @click="CopyLink()">
|
||||||
<ChevronLeft class="size-4"></ChevronLeft> Back
|
|
||||||
</Button>
|
|
||||||
<Button v-else class="cursor-pointer" variant="ghost" size="icon" @click="CopyLink()">
|
|
||||||
<Link class="size-4" />
|
<Link class="size-4" />
|
||||||
</Button>
|
</Button>
|
||||||
<Button v-if="!isMobile" @click="closePanel" class="cursor-pointer" variant="ghost" size="icon">
|
<Button @click="closeTrainingReport" class="cursor-pointer" variant="ghost" size="icon">
|
||||||
<X class="size-6"></X>
|
<X class="size-6"></X>
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="TRLoaded" :class="isMobile ? 'my-3 pb-8' : 'my-5 max-h-[70vh] overflow-y-auto overflow-x-hidden scrollbar-themed'">
|
<div v-if="TRLoaded" class="max-h-[70vh] overflow-auto scrollbar-themed my-5">
|
||||||
<div class="flex flex-col mb-5 border rounded-lg bg-muted/70 p-2 py-3 px-4">
|
<div class="flex flex-col mb-5 border rounded-lg bg-muted/70 p-2 py-3 px-4">
|
||||||
<p class="scroll-m-20 text-xl font-semibold tracking-tight">{{ focusedTrainingReport.course_name }}
|
<p class="scroll-m-20 text-xl font-semibold tracking-tight">{{ focusedTrainingReport.course_name }}
|
||||||
</p>
|
</p>
|
||||||
<div class="mt-2 flex flex-col gap-2 text-sm sm:flex-row sm:items-center sm:gap-10">
|
<div class="flex gap-10 items-center">
|
||||||
<p class="text-muted-foreground">{{ formatDate(focusedTrainingReport.event_date) }}</p>
|
<p class="text-muted-foreground">{{ focusedTrainingReport.event_date.split('T')[0] }}</p>
|
||||||
<div class="flex gap-2 items-center">Created by:
|
<p class="flex gap-2 items-center">Created by:
|
||||||
<MemberCard v-if="focusedTrainingReport.created_by"
|
<MemberCard v-if="focusedTrainingReport.created_by"
|
||||||
:member-id="focusedTrainingReport.created_by" />
|
:member-id="focusedTrainingReport.created_by" />
|
||||||
<span v-else>Unknown User</span>
|
<p v-else>{{ focusedTrainingReport.created_by_name === null ? "Unknown User" :
|
||||||
</div>
|
focusedTrainingReport.created_by_name
|
||||||
|
}}</p>
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex flex-col gap-8 ">
|
<div class="flex flex-col gap-8 ">
|
||||||
<!-- Trainers -->
|
<!-- Trainers -->
|
||||||
<div>
|
<div>
|
||||||
<label class="scroll-m-20 text-xl font-semibold tracking-tight">Trainers</label>
|
<label class="scroll-m-20 text-xl font-semibold tracking-tight">Trainers</label>
|
||||||
<div class="mt-3 space-y-2 md:hidden">
|
<div
|
||||||
<article v-for="person in focusedTrainingTrainers" :key="person.attendee_id ?? person.attendee_name"
|
class="grid grid-cols-[1fr_1fr_2fr_3rem] py-2 text-sm font-medium text-muted-foreground border-b">
|
||||||
class="rounded-xl border bg-card p-3 shadow-sm" :class="expanded === person.attendee_id && 'ring-1 ring-primary/30'">
|
<span>Name</span>
|
||||||
<div class="flex items-start justify-between gap-2">
|
<span class="">Role</span>
|
||||||
<div class="min-w-0">
|
<span class="text-right">Remarks</span>
|
||||||
<MemberCard v-if="person.attendee_id" :member-id="person.attendee_id"
|
<span></span>
|
||||||
class="max-w-full whitespace-nowrap overflow-hidden text-ellipsis"></MemberCard>
|
</div>
|
||||||
<p v-else class="font-medium whitespace-nowrap overflow-hidden text-ellipsis">{{ person.attendee_name }}</p>
|
<div v-for="person in focusedTrainingTrainers" class=" items-center border-b last:border-none"
|
||||||
</div>
|
:class="expanded === person.attendee_id && 'bg-muted/20'">
|
||||||
<Button @click.stop="expanded === person.attendee_id ? expanded = null : expanded = person.attendee_id"
|
<div class="grid grid-cols-[1fr_1fr_2fr_3rem] items-center py-2">
|
||||||
variant="ghost" size="icon" class="shrink-0">
|
<div>
|
||||||
<ChevronDown v-if="expanded !== person.attendee_id" class="size-5" />
|
<MemberCard v-if="person.attendee_id" :member-id="person.attendee_id"
|
||||||
<ChevronUp v-else class="size-5" />
|
class="justify-self-start"></MemberCard>
|
||||||
|
<p v-else>{{ person.attendee_name }}</p>
|
||||||
|
</div>
|
||||||
|
<p class="">{{ person.role.name }}</p>
|
||||||
|
<p class="text-right px-2 truncate"
|
||||||
|
:class="person.remarks == '' ? 'text-muted-foreground' : ''">
|
||||||
|
{{ person.remarks == "" ?
|
||||||
|
'--'
|
||||||
|
: person.remarks }}</p>
|
||||||
|
<div class="w-min mx-auto">
|
||||||
|
<Button v-if="expanded === person.attendee_id" @click.stop="expanded = null"
|
||||||
|
variant="ghost" size="icon">
|
||||||
|
<ChevronUp class="size-6" />
|
||||||
|
</Button>
|
||||||
|
<Button v-else @click.stop="expanded = person.attendee_id" variant="ghost"
|
||||||
|
size="icon">
|
||||||
|
<ChevronDown class="size-6" />
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
<div class="mt-3 grid grid-cols-1 gap-2 text-xs">
|
</div>
|
||||||
<div class="rounded-lg bg-muted px-3 py-2">
|
<div class="col-span-full" v-if="expanded === person.attendee_id">
|
||||||
<p class="text-muted-foreground">Role</p>
|
<div class="px-6 pb-5 pt-2 space-y-2">
|
||||||
<p class="font-medium text-foreground">{{ person.role.name }}</p>
|
<p class="text-sm font-medium text-foreground">
|
||||||
</div>
|
Remarks
|
||||||
<div class="rounded-lg bg-muted px-3 py-2">
|
</p>
|
||||||
<p class="text-muted-foreground">Remarks</p>
|
|
||||||
<p class="font-medium text-foreground truncate">{{ person.remarks || '--' }}</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div v-if="expanded === person.attendee_id" class="mt-3 rounded-lg border bg-background px-3 py-2">
|
|
||||||
<p class="text-sm font-medium text-foreground">Full Remarks</p>
|
|
||||||
<p v-if="person.remarks"
|
<p v-if="person.remarks"
|
||||||
class="mt-1 text-sm text-muted-foreground leading-relaxed whitespace-pre-wrap max-h-72 overflow-y-auto">
|
class="text-sm text-muted-foreground leading-relaxed whitespace-pre-wrap max-h-72 overflow-y-auto">
|
||||||
{{ person.remarks }}
|
{{ person.remarks }}
|
||||||
</p>
|
</p>
|
||||||
<p v-else class="mt-1 text-sm text-muted-foreground italic">
|
<p v-else class="text-sm text-muted-foreground italic">
|
||||||
None provided
|
None provided
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</article>
|
|
||||||
</div>
|
|
||||||
<div class="mt-2 hidden md:block">
|
|
||||||
<div
|
|
||||||
class="grid grid-cols-[minmax(0,1.6fr)_minmax(0,1fr)_minmax(0,1.4fr)_2.5rem] py-2 text-sm font-medium text-muted-foreground border-b gap-x-2">
|
|
||||||
<span>Name</span>
|
|
||||||
<span>Role</span>
|
|
||||||
<span class="text-right">Remarks</span>
|
|
||||||
<span></span>
|
|
||||||
</div>
|
|
||||||
<div v-for="person in focusedTrainingTrainers" :key="person.attendee_id ?? person.attendee_name"
|
|
||||||
class="items-center border-b last:border-none"
|
|
||||||
:class="expanded === person.attendee_id && 'bg-muted/20'">
|
|
||||||
<div class="grid grid-cols-[minmax(0,1.6fr)_minmax(0,1fr)_minmax(0,1.4fr)_2.5rem] items-center py-2 gap-x-2">
|
|
||||||
<div class="min-w-0">
|
|
||||||
<MemberCard v-if="person.attendee_id" :member-id="person.attendee_id"
|
|
||||||
class="justify-self-start max-w-full whitespace-nowrap overflow-hidden text-ellipsis"></MemberCard>
|
|
||||||
<p v-else class="whitespace-nowrap overflow-hidden text-ellipsis">{{ person.attendee_name }}</p>
|
|
||||||
</div>
|
|
||||||
<p class="truncate">{{ person.role.name }}</p>
|
|
||||||
<p class="text-right px-2 truncate"
|
|
||||||
:class="person.remarks == '' ? 'text-muted-foreground' : ''">
|
|
||||||
{{ person.remarks == "" ?
|
|
||||||
'--'
|
|
||||||
: person.remarks }}</p>
|
|
||||||
<div class="w-min mx-auto">
|
|
||||||
<Button v-if="expanded === person.attendee_id" @click.stop="expanded = null"
|
|
||||||
variant="ghost" size="icon">
|
|
||||||
<ChevronUp class="size-6" />
|
|
||||||
</Button>
|
|
||||||
<Button v-else @click.stop="expanded = person.attendee_id" variant="ghost"
|
|
||||||
size="icon">
|
|
||||||
<ChevronDown class="size-6" />
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="col-span-full" v-if="expanded === person.attendee_id">
|
|
||||||
<div class="px-6 pb-5 pt-2 space-y-2">
|
|
||||||
<p class="text-sm font-medium text-foreground">
|
|
||||||
Remarks
|
|
||||||
</p>
|
|
||||||
<p v-if="person.remarks"
|
|
||||||
class="text-sm text-muted-foreground leading-relaxed whitespace-pre-wrap max-h-72 overflow-y-auto">
|
|
||||||
{{ person.remarks }}
|
|
||||||
</p>
|
|
||||||
<p v-else class="text-sm text-muted-foreground italic">
|
|
||||||
None provided
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -448,110 +317,63 @@ const expanded = ref<number>(null);
|
|||||||
<div>
|
<div>
|
||||||
<div class="flex flex-col">
|
<div class="flex flex-col">
|
||||||
<label class="scroll-m-20 text-xl font-semibold tracking-tight">Trainees</label>
|
<label class="scroll-m-20 text-xl font-semibold tracking-tight">Trainees</label>
|
||||||
<div class="mt-3 space-y-2 md:hidden">
|
<div
|
||||||
<article v-for="person in focusedTrainingTrainees" :key="person.attendee_id ?? person.attendee_name"
|
class="grid grid-cols-[1fr_5rem_5rem_2fr_3rem] py-2 text-sm font-medium text-muted-foreground border-b px-2">
|
||||||
class="rounded-xl border bg-card p-3 shadow-sm" :class="expanded === person.attendee_id && 'ring-1 ring-primary/30'">
|
<span>Name</span>
|
||||||
<div class="flex items-start justify-between gap-2">
|
<span class="text-center">Bookwork</span>
|
||||||
<div class="min-w-0">
|
<span class="text-center">Qual</span>
|
||||||
<MemberCard v-if="person.attendee_id" :member-id="person.attendee_id"
|
<span class="text-right">Remarks</span>
|
||||||
class="max-w-full whitespace-nowrap overflow-hidden text-ellipsis"></MemberCard>
|
<span class="w-15"></span>
|
||||||
<p v-else class="font-medium whitespace-nowrap overflow-hidden text-ellipsis">{{ person.attendee_name }}</p>
|
|
||||||
</div>
|
|
||||||
<Button @click.stop="expanded === person.attendee_id ? expanded = null : expanded = person.attendee_id"
|
|
||||||
variant="ghost" size="icon" class="shrink-0">
|
|
||||||
<ChevronDown v-if="expanded !== person.attendee_id" class="size-5" />
|
|
||||||
<ChevronUp v-else class="size-5" />
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
<div class="mt-3 grid grid-cols-2 gap-2 text-xs">
|
|
||||||
<div class="rounded-lg bg-muted px-3 py-2 text-center">
|
|
||||||
<p class="text-muted-foreground">Bookwork</p>
|
|
||||||
<p class="font-semibold text-foreground">{{ !focusedTrainingReport.course.hasBookwork ? 'N/A' : (person.passed_bookwork ? 'Pass' : 'Fail') }}</p>
|
|
||||||
</div>
|
|
||||||
<div class="rounded-lg bg-muted px-3 py-2 text-center">
|
|
||||||
<p class="text-muted-foreground">Qual</p>
|
|
||||||
<p class="font-semibold text-foreground">{{ !focusedTrainingReport.course.hasQual ? 'N/A' : (person.passed_qual ? 'Pass' : 'Fail') }}</p>
|
|
||||||
</div>
|
|
||||||
<div class="col-span-2 rounded-lg bg-muted px-3 py-2">
|
|
||||||
<p class="text-muted-foreground">Remarks</p>
|
|
||||||
<p class="font-medium text-foreground truncate">{{ person.remarks || '--' }}</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div v-if="expanded === person.attendee_id" class="mt-3 rounded-lg border bg-background px-3 py-2">
|
|
||||||
<p class="text-sm font-medium text-foreground">Full Remarks</p>
|
|
||||||
<p v-if="person.remarks"
|
|
||||||
class="mt-1 text-sm text-muted-foreground leading-relaxed whitespace-pre-wrap max-h-72 overflow-y-auto">
|
|
||||||
{{ person.remarks }}
|
|
||||||
</p>
|
|
||||||
<p v-else class="mt-1 text-sm text-muted-foreground italic">
|
|
||||||
None provided
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</article>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="hidden md:block">
|
</div>
|
||||||
<div
|
<div v-for="person in focusedTrainingTrainees" class="border-b last:border-none"
|
||||||
class="grid grid-cols-[minmax(0,1.6fr)_4.25rem_4.25rem_minmax(0,1.4fr)_2.5rem] py-2 text-sm font-medium text-muted-foreground border-b px-2 gap-x-2">
|
:class="expanded === person.attendee_id && 'bg-muted/20'">
|
||||||
<span>Name</span>
|
<div class="grid grid-cols-[1fr_5rem_5rem_2fr_3rem] py-2 items-center mx-2">
|
||||||
<span class="text-center">Bookwork</span>
|
<div>
|
||||||
<span class="text-center">Qual</span>
|
<MemberCard v-if="person.attendee_id" :member-id="person.attendee_id"
|
||||||
<span class="text-right">Remarks</span>
|
class="justify-self-start"></MemberCard>
|
||||||
<span class="w-15"></span>
|
<p v-else>{{ person.attendee_name }}</p>
|
||||||
</div>
|
</div>
|
||||||
<div v-for="person in focusedTrainingTrainees" :key="person.attendee_id ?? person.attendee_name" class="border-b last:border-none"
|
<Tooltip :open="!focusedTrainingReport.course.hasBookwork" class="mx-auto"
|
||||||
:class="expanded === person.attendee_id && 'bg-muted/20'">
|
message="This course does not have bookwork">
|
||||||
<div class="grid grid-cols-[minmax(0,1.6fr)_4.25rem_4.25rem_minmax(0,1.4fr)_2.5rem] py-2 items-center px-2 gap-x-2">
|
<Checkbox :disabled="!focusedTrainingReport.course.hasBookwork"
|
||||||
<div class="min-w-0">
|
:model-value="person.passed_bookwork" class="pointer-events-none">
|
||||||
<MemberCard v-if="person.attendee_id" :member-id="person.attendee_id"
|
</Checkbox>
|
||||||
class="justify-self-start max-w-full whitespace-nowrap overflow-hidden text-ellipsis"></MemberCard>
|
</Tooltip>
|
||||||
<p v-else class="whitespace-nowrap overflow-hidden text-ellipsis">{{ person.attendee_name }}</p>
|
<Tooltip :open="!focusedTrainingReport.course.hasQual" class="mx-auto"
|
||||||
</div>
|
message="This course does not have a qualification">
|
||||||
<div class="flex justify-center">
|
<Checkbox :disabled="!focusedTrainingReport.course.hasQual"
|
||||||
<Tooltip :open="!focusedTrainingReport.course.hasBookwork"
|
:model-value="person.passed_qual" class="pointer-events-none ml-1">
|
||||||
message="This course does not have bookwork">
|
</Checkbox>
|
||||||
<Checkbox :disabled="!focusedTrainingReport.course.hasBookwork"
|
</Tooltip>
|
||||||
:model-value="person.passed_bookwork" class="pointer-events-none">
|
<p class="text-right truncate"
|
||||||
</Checkbox>
|
:class="person.remarks == '' ? 'text-muted-foreground' : ''">
|
||||||
</Tooltip>
|
{{ person.remarks == "" ?
|
||||||
</div>
|
'--'
|
||||||
<div class="flex justify-center">
|
: person.remarks }}</p>
|
||||||
<Tooltip :open="!focusedTrainingReport.course.hasQual"
|
<div class="w-min mx-auto">
|
||||||
message="This course does not have a qualification">
|
<Button v-if="expanded === person.attendee_id" @click.stop="expanded = null"
|
||||||
<Checkbox :disabled="!focusedTrainingReport.course.hasQual"
|
variant="ghost" size="icon">
|
||||||
:model-value="person.passed_qual" class="pointer-events-none">
|
<ChevronUp class="size-6" />
|
||||||
</Checkbox>
|
</Button>
|
||||||
</Tooltip>
|
<Button v-else @click.stop="expanded = person.attendee_id" variant="ghost"
|
||||||
</div>
|
size="icon">
|
||||||
<p class="text-right truncate"
|
<ChevronDown class="size-6" />
|
||||||
:class="person.remarks == '' ? 'text-muted-foreground' : ''">
|
</Button>
|
||||||
{{ person.remarks == "" ?
|
</div>
|
||||||
'--'
|
</div>
|
||||||
: person.remarks }}</p>
|
<div class="col-span-full" v-if="expanded === person.attendee_id">
|
||||||
<div class="w-min mx-auto">
|
<div class="px-6 pb-5 pt-2 space-y-2">
|
||||||
<Button v-if="expanded === person.attendee_id" @click.stop="expanded = null"
|
<p class="text-sm font-medium text-foreground">
|
||||||
variant="ghost" size="icon">
|
Remarks
|
||||||
<ChevronUp class="size-6" />
|
</p>
|
||||||
</Button>
|
<p v-if="person.remarks"
|
||||||
<Button v-else @click.stop="expanded = person.attendee_id" variant="ghost"
|
class="text-sm text-muted-foreground leading-relaxed whitespace-pre-wrap max-h-72 overflow-y-auto">
|
||||||
size="icon">
|
{{ person.remarks }}
|
||||||
<ChevronDown class="size-6" />
|
</p>
|
||||||
</Button>
|
<p v-else class="text-sm text-muted-foreground italic">
|
||||||
</div>
|
None provided
|
||||||
</div>
|
</p>
|
||||||
<div class="col-span-full" v-if="expanded === person.attendee_id">
|
|
||||||
<div class="px-6 pb-5 pt-2 space-y-2">
|
|
||||||
<p class="text-sm font-medium text-foreground">
|
|
||||||
Remarks
|
|
||||||
</p>
|
|
||||||
<p v-if="person.remarks"
|
|
||||||
class="text-sm text-muted-foreground leading-relaxed whitespace-pre-wrap max-h-72 overflow-y-auto">
|
|
||||||
{{ person.remarks }}
|
|
||||||
</p>
|
|
||||||
<p v-else class="text-sm text-muted-foreground italic">
|
|
||||||
None provided
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -563,108 +385,60 @@ const expanded = ref<number>(null);
|
|||||||
No Shows
|
No Shows
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
<div class="mt-3 space-y-2 md:hidden">
|
<div
|
||||||
<article v-for="person in focusedNoShows" :key="person.attendee_id ?? person.attendee_name"
|
class="grid grid-cols-[1fr_5rem_5rem_2fr_3rem] py-2 text-sm font-medium text-muted-foreground border-b">
|
||||||
class="rounded-xl border bg-card p-3 shadow-sm" :class="expanded === person.attendee_id && 'ring-1 ring-primary/30'">
|
<span>Name</span>
|
||||||
<div class="flex items-start justify-between gap-2">
|
<span></span>
|
||||||
<div class="min-w-0">
|
<span></span>
|
||||||
<MemberCard v-if="person.attendee_id" :member-id="person.attendee_id"
|
<span class="text-right">Remarks</span>
|
||||||
class="max-w-full whitespace-nowrap overflow-hidden text-ellipsis" />
|
<span></span>
|
||||||
<p v-else class="font-medium whitespace-nowrap overflow-hidden text-ellipsis">{{ person.attendee_name }}</p>
|
|
||||||
</div>
|
|
||||||
<Button variant="ghost" size="icon" class="shrink-0" @click.stop="expanded === person.attendee_id
|
|
||||||
? expanded = null
|
|
||||||
: expanded = person.attendee_id">
|
|
||||||
<ChevronDown v-if="expanded !== person.attendee_id" class="size-5" />
|
|
||||||
<ChevronUp v-else class="size-5" />
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
<div class="mt-3 grid grid-cols-2 gap-2 text-xs">
|
|
||||||
<div class="rounded-lg bg-muted px-3 py-2 text-center">
|
|
||||||
<p class="text-muted-foreground">Bookwork</p>
|
|
||||||
<p class="font-semibold text-foreground">N/A</p>
|
|
||||||
</div>
|
|
||||||
<div class="rounded-lg bg-muted px-3 py-2 text-center">
|
|
||||||
<p class="text-muted-foreground">Qual</p>
|
|
||||||
<p class="font-semibold text-foreground">N/A</p>
|
|
||||||
</div>
|
|
||||||
<div class="col-span-2 rounded-lg bg-muted px-3 py-2">
|
|
||||||
<p class="text-muted-foreground">Remarks</p>
|
|
||||||
<p class="font-medium text-foreground truncate">{{ person.remarks || '--' }}</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div v-if="expanded === person.attendee_id" class="mt-3 rounded-lg border bg-background px-3 py-2">
|
|
||||||
<p class="text-sm font-medium text-foreground">
|
|
||||||
Full Remarks
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<p v-if="person.remarks"
|
|
||||||
class="mt-1 text-sm text-muted-foreground leading-relaxed whitespace-pre-wrap max-h-72 overflow-y-auto">
|
|
||||||
{{ person.remarks }}
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<p v-else class="mt-1 text-sm text-muted-foreground italic">
|
|
||||||
None provided
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</article>
|
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="hidden md:block">
|
<div v-for="person in focusedNoShows" :key="person.attendee_id ?? person.attendee_name"
|
||||||
<div
|
class="border-b last:border-none transition-colors"
|
||||||
class="grid grid-cols-[minmax(0,1.6fr)_4.25rem_4.25rem_minmax(0,1.4fr)_2.5rem] py-2 text-sm font-medium text-muted-foreground border-b gap-x-2">
|
:class="expanded === person.attendee_id && 'bg-muted/20'">
|
||||||
<span>Name</span>
|
<!-- Row -->
|
||||||
<span class="text-center">Bookwork</span>
|
<div class="grid grid-cols-[1fr_5rem_5rem_2fr_3rem] py-2 items-center">
|
||||||
<span class="text-center">Qual</span>
|
<!-- Name -->
|
||||||
<span class="text-right">Remarks</span>
|
<div>
|
||||||
<span></span>
|
<MemberCard v-if="person.attendee_id" :member-id="person.attendee_id" />
|
||||||
|
<p v-else>{{ person.attendee_name }}</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div v-for="person in focusedNoShows" :key="person.attendee_id ?? person.attendee_name"
|
<div></div>
|
||||||
class="border-b last:border-none transition-colors"
|
<div></div>
|
||||||
:class="expanded === person.attendee_id && 'bg-muted/20'">
|
|
||||||
<div class="grid grid-cols-[minmax(0,1.6fr)_4.25rem_4.25rem_minmax(0,1.4fr)_2.5rem] py-2 items-center gap-x-2">
|
|
||||||
<div class="min-w-0">
|
|
||||||
<MemberCard v-if="person.attendee_id" :member-id="person.attendee_id"
|
|
||||||
class="max-w-full whitespace-nowrap overflow-hidden text-ellipsis" />
|
|
||||||
<p v-else class="whitespace-nowrap overflow-hidden text-ellipsis">{{ person.attendee_name }}</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<p class="text-center text-muted-foreground">-</p>
|
<p class="text-right px-2 truncate" :class="!person.remarks && 'text-muted-foreground'">
|
||||||
<p class="text-center text-muted-foreground">-</p>
|
{{ person.remarks || '--' }}
|
||||||
|
</p>
|
||||||
|
|
||||||
<p class="text-right px-2 truncate" :class="!person.remarks && 'text-muted-foreground'">
|
<Button variant="ghost" size="icon" @click.stop="expanded === person.attendee_id
|
||||||
{{ person.remarks || '--' }}
|
? expanded = null
|
||||||
</p>
|
: expanded = person.attendee_id">
|
||||||
|
<ChevronDown v-if="expanded !== person.attendee_id" class="size-5" />
|
||||||
|
<ChevronUp v-else class="size-5" />
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
|
||||||
<Button variant="ghost" size="icon" @click.stop="expanded === person.attendee_id
|
<div v-if="expanded === person.attendee_id" class="col-span-full">
|
||||||
? expanded = null
|
<div class="px-6 py-4 space-y-2">
|
||||||
: expanded = person.attendee_id">
|
<p class="text-sm font-medium text-foreground">
|
||||||
<ChevronDown v-if="expanded !== person.attendee_id" class="size-5" />
|
Remarks
|
||||||
<ChevronUp v-else class="size-5" />
|
</p>
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div v-if="expanded === person.attendee_id" class="col-span-full">
|
<p v-if="person.remarks"
|
||||||
<div class="px-6 py-4 space-y-2">
|
class="text-sm text-muted-foreground leading-relaxed whitespace-pre-wrap max-h-72 overflow-y-auto">
|
||||||
<p class="text-sm font-medium text-foreground">
|
{{ person.remarks }}
|
||||||
Remarks
|
</p>
|
||||||
</p>
|
|
||||||
|
|
||||||
<p v-if="person.remarks"
|
<p v-else class="text-sm text-muted-foreground italic">
|
||||||
class="text-sm text-muted-foreground leading-relaxed whitespace-pre-wrap max-h-72 overflow-y-auto">
|
None provided
|
||||||
{{ person.remarks }}
|
</p>
|
||||||
</p>
|
|
||||||
|
|
||||||
<p v-else class="text-sm text-muted-foreground italic">
|
|
||||||
None provided
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<label class="scroll-m-20 text-xl font-semibold tracking-tight">Remarks</label>
|
<label class="scroll-m-20 text-xl font-semibold tracking-tight">Remarks</label>
|
||||||
@@ -678,30 +452,18 @@ const expanded = ref<number>(null);
|
|||||||
<Spinner class="size-8"></Spinner>
|
<Spinner class="size-8"></Spinner>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="effectivePanel == sidePanelState.create" :class="isMobile ? 'fixed inset-0 z-[60] overflow-y-auto bg-background px-3 py-3' : 'mt-2 w-full max-w-5xl lg:mt-0 lg:w-3/5 lg:border-l lg:pl-7'"
|
<div v-if="sidePanel == sidePanelState.create" class="pl-7 border-l w-3/5 max-w-5xl">
|
||||||
:style="isMobile ? { top: 'var(--app-header-height, 60px)' } : {}">
|
|
||||||
<div class="flex justify-between items-center my-3">
|
<div class="flex justify-between items-center my-3">
|
||||||
<div class="flex gap-5 lg:pl-2">
|
<div class="flex pl-2 gap-5">
|
||||||
<p class="scroll-m-20 text-2xl font-semibold tracking-tight">New Training Report</p>
|
<p class="scroll-m-20 text-2xl font-semibold tracking-tight">New Training Report</p>
|
||||||
</div>
|
</div>
|
||||||
<Button v-if="isMobile" @click="closePanel" class="cursor-pointer" variant="outline" size="sm">
|
<Button @click="closeTrainingReport" class="cursor-pointer" variant="ghost" size="icon">
|
||||||
<ChevronLeft class="size-4"></ChevronLeft> Back
|
|
||||||
</Button>
|
|
||||||
<Button v-else @click="closePanel" class="cursor-pointer" variant="ghost" size="icon">
|
|
||||||
<X class="size-6"></X>
|
<X class="size-6"></X>
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
<div :class="isMobile ? 'mt-3 pb-8' : 'overflow-y-auto max-h-[70vh] mt-5 scrollbar-themed'">
|
<div class="overflow-y-auto max-h-[70vh] mt-5 scrollbar-themed">
|
||||||
<TrainingReportForm class="w-full lg:pl-2"
|
<TrainingReportForm class="w-full pl-2"
|
||||||
@submit="async (newID) => {
|
@submit="(newID) => { router.push(`/trainingReport/${newID}`); loadTrainingReports() }">
|
||||||
if (isMobile) {
|
|
||||||
await viewTrainingReport(newID);
|
|
||||||
mobilePanel = sidePanelState.view;
|
|
||||||
} else {
|
|
||||||
router.push(`/trainingReport/${newID}`);
|
|
||||||
}
|
|
||||||
loadTrainingReports()
|
|
||||||
}">
|
|
||||||
</TrainingReportForm>
|
</TrainingReportForm>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -32,9 +32,6 @@
|
|||||||
import Spinner from "@/components/ui/spinner/Spinner.vue";
|
import Spinner from "@/components/ui/spinner/Spinner.vue";
|
||||||
import DischargeMember from "@/components/members/DischargeMember.vue";
|
import DischargeMember from "@/components/members/DischargeMember.vue";
|
||||||
import MemberCard from "@/components/members/MemberCard.vue";
|
import MemberCard from "@/components/members/MemberCard.vue";
|
||||||
import { useMemberDirectory } from "@/stores/memberDirectory";
|
|
||||||
import { Discharge } from "@shared/schemas/dischargeSchema";
|
|
||||||
import TransferMember from "@/components/members/TransferMember.vue";
|
|
||||||
|
|
||||||
// --- State ---
|
// --- State ---
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
@@ -142,41 +139,25 @@
|
|||||||
|
|
||||||
//discharge form logic
|
//discharge form logic
|
||||||
const isDischargeOpen = ref(false)
|
const isDischargeOpen = ref(false)
|
||||||
const isTransferOpen = ref(false)
|
const targetMember = ref(null)
|
||||||
const targetMember = ref<Member | null>(null)
|
|
||||||
|
|
||||||
function openDischargeModal(member: Member) {
|
function openDischargeModal(member: Member) {
|
||||||
targetMember.value = member
|
targetMember.value = member
|
||||||
isDischargeOpen.value = true
|
isDischargeOpen.value = true
|
||||||
}
|
}
|
||||||
|
|
||||||
function openTransferModal(member: Member) {
|
|
||||||
targetMember.value = member
|
|
||||||
isTransferOpen.value = true
|
|
||||||
}
|
|
||||||
|
|
||||||
async function onSuspend(member: Member) {
|
async function onSuspend(member: Member) {
|
||||||
await suspendMember(member.member_id);
|
await suspendMember(member.member_id);
|
||||||
await fetchMembers();
|
await fetchMembers();
|
||||||
memberCache.invalidateMember(member.member_id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function onUnsuspend(member: Member) {
|
async function onUnsuspend(member: Member) {
|
||||||
await unsuspendMember(member.member_id);
|
await unsuspendMember(member.member_id);
|
||||||
await fetchMembers();
|
await fetchMembers();
|
||||||
memberCache.invalidateMember(member.member_id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const memberCache = useMemberDirectory();
|
function handleDischargeSuccess(data) {
|
||||||
|
|
||||||
function handleDischargeSuccess(value: { data: Discharge }) {
|
|
||||||
fetchMembers();
|
fetchMembers();
|
||||||
memberCache.invalidateMember(value.data.userID);
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleTransferSuccess(value: { memberId: number; unitId: number; rankId: number; reason: string }) {
|
|
||||||
fetchMembers();
|
|
||||||
memberCache.invalidateMember(value.memberId);
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -184,8 +165,6 @@
|
|||||||
<div>
|
<div>
|
||||||
<DischargeMember v-model:open="isDischargeOpen" :member="targetMember" @discharged="handleDischargeSuccess">
|
<DischargeMember v-model:open="isDischargeOpen" :member="targetMember" @discharged="handleDischargeSuccess">
|
||||||
</DischargeMember>
|
</DischargeMember>
|
||||||
<TransferMember v-model:open="isTransferOpen" :member="targetMember" @transferred="handleTransferSuccess">
|
|
||||||
</TransferMember>
|
|
||||||
<div class="mx-auto max-w-7xl w-full py-10 px-4">
|
<div class="mx-auto max-w-7xl w-full py-10 px-4">
|
||||||
<div class="flex flex-col gap-2">
|
<div class="flex flex-col gap-2">
|
||||||
<div class="flex flex-col md:flex-row md:items-center justify-between gap-4">
|
<div class="flex flex-col md:flex-row md:items-center justify-between gap-4">
|
||||||
@@ -266,8 +245,7 @@
|
|||||||
<TableCell>{{ member.rank }}</TableCell>
|
<TableCell>{{ member.rank }}</TableCell>
|
||||||
<TableCell>{{ member.unit }}</TableCell>
|
<TableCell>{{ member.unit }}</TableCell>
|
||||||
<TableCell>
|
<TableCell>
|
||||||
<Badge variant="outline" class="capitalize font-normal">{{
|
<Badge variant="outline" class="capitalize font-normal">{{ MemberState[member.member_state] }}</Badge>
|
||||||
MemberState[member.member_state] }}</Badge>
|
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell>
|
<TableCell>
|
||||||
<Badge v-if="member.loa_until" variant="secondary"
|
<Badge v-if="member.loa_until" variant="secondary"
|
||||||
@@ -284,17 +262,11 @@
|
|||||||
<!-- <DropdownMenuItem @click="navigateToMember(member.member_id)">
|
<!-- <DropdownMenuItem @click="navigateToMember(member.member_id)">
|
||||||
View Profile
|
View Profile
|
||||||
</DropdownMenuItem> -->
|
</DropdownMenuItem> -->
|
||||||
<DropdownMenuItem v-if="member.member_state === MemberState.Member"
|
<DropdownMenuItem @click="openDischargeModal(member)"
|
||||||
@click="openTransferModal(member)">
|
|
||||||
Transfer Member
|
|
||||||
</DropdownMenuItem>
|
|
||||||
<DropdownMenuItem v-if="member.member_state !== MemberState.Discharged"
|
|
||||||
@click="openDischargeModal(member)"
|
|
||||||
class="text-destructive focus:bg-destructive focus:text-destructive-foreground font-medium">
|
class="text-destructive focus:bg-destructive focus:text-destructive-foreground font-medium">
|
||||||
Discharge Member
|
Discharge Member
|
||||||
</DropdownMenuItem>
|
</DropdownMenuItem>
|
||||||
<DropdownMenuItem v-if="member.member_state !== MemberState.Suspended"
|
<DropdownMenuItem v-if="member.member_state !== MemberState.Suspended" @click="onSuspend(member)"
|
||||||
@click="onSuspend(member)"
|
|
||||||
class="text-destructive focus:bg-destructive focus:text-destructive-foreground font-medium">
|
class="text-destructive focus:bg-destructive focus:text-destructive-foreground font-medium">
|
||||||
Suspend Member
|
Suspend Member
|
||||||
</DropdownMenuItem>
|
</DropdownMenuItem>
|
||||||
|
|||||||
@@ -28,12 +28,20 @@ const router = createRouter({
|
|||||||
{ path: '/trainingReport/new', component: () => import('@/pages/TrainingReport.vue'), meta: { requiresAuth: true, memberOnly: true } },
|
{ path: '/trainingReport/new', component: () => import('@/pages/TrainingReport.vue'), meta: { requiresAuth: true, memberOnly: true } },
|
||||||
{ path: '/trainingReport/:id', component: () => import('@/pages/TrainingReport.vue'), meta: { requiresAuth: true, memberOnly: true } },
|
{ path: '/trainingReport/:id', component: () => import('@/pages/TrainingReport.vue'), meta: { requiresAuth: true, memberOnly: true } },
|
||||||
|
|
||||||
{ path: '/developer', component: () => import('@/pages/DeveloperTools.vue'), meta: { requiresAuth: true, memberOnly: true, roles: ['Dev'] } },
|
//discussion routes
|
||||||
|
{
|
||||||
|
path: '/discussions',
|
||||||
|
meta: { requiresAuth: true, memberOnly: true },
|
||||||
|
children: [
|
||||||
|
{ path: 'mod-requests', component: () => import('@/pages/ModRequest.vue') },
|
||||||
|
{ path: 'mod-requests/:id', component: () => import('@/components/modRequests/ViewModRequest.vue') },
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
// ADMIN / STAFF ROUTES
|
// ADMIN / STAFF ROUTES
|
||||||
{
|
{
|
||||||
path: '/administration',
|
path: '/administration',
|
||||||
meta: { requiresAuth: true, memberOnly: true, roles: ['17th Administrator', '17th HQ', '17th Command', '17th Recruiter'] },
|
meta: { requiresAuth: true, memberOnly: true, roles: ['17th Administrator', '17th HQ', '17th Command'] },
|
||||||
children: [
|
children: [
|
||||||
{ path: 'applications', component: () => import('@/pages/ManageApplications.vue') },
|
{ path: 'applications', component: () => import('@/pages/ManageApplications.vue') },
|
||||||
{ path: 'applications/:id', component: () => import('@/pages/ManageApplications.vue') },
|
{ path: 'applications/:id', component: () => import('@/pages/ManageApplications.vue') },
|
||||||
|
|||||||
Reference in New Issue
Block a user