Updated rank change page systems
This commit is contained in:
@@ -4,13 +4,6 @@ const router = express.Router();
|
||||
// DB pool (same as used in api/index.js)
|
||||
const pool = require('../db');
|
||||
|
||||
// Keep any in-memory structures if needed (preserved from original file)
|
||||
let applicationData = {
|
||||
app: null,
|
||||
messages: [],
|
||||
status: null,
|
||||
};
|
||||
|
||||
// POST /application
|
||||
router.post('/', async (req, res) => {
|
||||
try {
|
||||
|
||||
@@ -11,7 +11,26 @@ const pool = require('../db');
|
||||
|
||||
//insert a new latest role for a user
|
||||
ur.post('/', async (req, res) => {
|
||||
try {
|
||||
const App = req.body?.App || {};
|
||||
|
||||
// TODO: replace with current user ID
|
||||
const memberId = 1;
|
||||
|
||||
const sql = `INSERT INTO applications (member_id, app_version, app_data) VALUES (?, ?, ?);`;
|
||||
const appVersion = 1;
|
||||
|
||||
const params = [memberId, appVersion, JSON.stringify(App)]
|
||||
|
||||
console.log(params)
|
||||
|
||||
await pool.query(sql, params);
|
||||
|
||||
res.sendStatus(201);
|
||||
} catch (err) {
|
||||
console.error('Insert failed:', err);
|
||||
res.status(500).json({ error: 'Failed to save application' });
|
||||
}
|
||||
});
|
||||
|
||||
r.get('/', async (req, res) => {
|
||||
@@ -25,6 +44,6 @@ r.get('/', async (req, res) => {
|
||||
});
|
||||
|
||||
module.exports.ranks = r;
|
||||
module.exports.userRanks = ur;
|
||||
module.exports.memberRanks = ur;
|
||||
|
||||
// TODO, implement get all ranks route with SQL stirng SELECT id, name, short_name, category, sort_id FROM ranks;
|
||||
@@ -1,33 +1,39 @@
|
||||
export type Member = { id: number; name: string }
|
||||
export type Rank = { id: number; name: string }
|
||||
|
||||
// Placeholder: fetch list of members
|
||||
export async function getMembers(): Promise<Member[]> {
|
||||
// Simulate async delay
|
||||
await new Promise((r) => setTimeout(r, 150))
|
||||
return [
|
||||
{ id: 1, name: 'Alice Anderson' },
|
||||
{ id: 2, name: 'Bob Brown' },
|
||||
{ id: 3, name: 'Charlie Clark' },
|
||||
{ id: 4, name: 'Dana Diaz' },
|
||||
]
|
||||
export type Rank = {
|
||||
id: number
|
||||
name: string
|
||||
short_name: string
|
||||
sortOrder: number
|
||||
}
|
||||
|
||||
const addr = "localhost:3000"
|
||||
|
||||
|
||||
// Placeholder: fetch list of ranks
|
||||
export async function getRanks(): Promise<Rank[]> {
|
||||
await new Promise((r) => setTimeout(r, 120))
|
||||
return [
|
||||
{ id: 10, name: 'Private' },
|
||||
{ id: 20, name: 'Corporal' },
|
||||
{ id: 30, name: 'Sergeant' },
|
||||
{ id: 40, name: 'Lieutenant' },
|
||||
{ id: 50, name: 'Captain' },
|
||||
]
|
||||
const res = await fetch(`http://${addr}/ranks`)
|
||||
|
||||
if (res.ok) {
|
||||
return res.json()
|
||||
} else {
|
||||
console.error("Something went wrong approving the application")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Placeholder: submit a rank change
|
||||
export async function submitRankChange(memberId: number, rankId: number): Promise<{ ok: boolean }> {
|
||||
console.log('Stub submitRankChange', { memberId, rankId })
|
||||
await new Promise((r) => setTimeout(r, 200))
|
||||
const res = await fetch(`http://${addr}/rank`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({ memberId, rankId }),
|
||||
})
|
||||
|
||||
if (res.ok) {
|
||||
return { ok: true }
|
||||
} else {
|
||||
console.error("Failed to submit rank change")
|
||||
return { ok: false }
|
||||
}
|
||||
}
|
||||
18
ui/src/components/ui/dropdown-menu/DropdownMenuShortcut.vue
Normal file
18
ui/src/components/ui/dropdown-menu/DropdownMenuShortcut.vue
Normal file
@@ -0,0 +1,18 @@
|
||||
<script setup>
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
const props = defineProps({
|
||||
class: { type: null, required: false },
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<span
|
||||
data-slot="dropdown-menu-shortcut"
|
||||
:class="
|
||||
cn('text-muted-foreground ml-auto text-xs tracking-widest', props.class)
|
||||
"
|
||||
>
|
||||
<slot />
|
||||
</span>
|
||||
</template>
|
||||
Reference in New Issue
Block a user