first commit
This commit is contained in:
24
client/.gitignore
vendored
Executable file
24
client/.gitignore
vendored
Executable file
@@ -0,0 +1,24 @@
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
pnpm-debug.log*
|
||||
lerna-debug.log*
|
||||
|
||||
node_modules
|
||||
dist
|
||||
dist-ssr
|
||||
*.local
|
||||
|
||||
# Editor directories and files
|
||||
.vscode/*
|
||||
!.vscode/extensions.json
|
||||
.idea
|
||||
.DS_Store
|
||||
*.suo
|
||||
*.ntvs*
|
||||
*.njsproj
|
||||
*.sln
|
||||
*.sw?
|
||||
3
client/.vscode/extensions.json
vendored
Executable file
3
client/.vscode/extensions.json
vendored
Executable file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"recommendations": ["Vue.volar"]
|
||||
}
|
||||
5
client/README.md
Executable file
5
client/README.md
Executable file
@@ -0,0 +1,5 @@
|
||||
# Vue 3 + Vite
|
||||
|
||||
This template should help get you started developing with Vue 3 in Vite. The template uses Vue 3 `<script setup>` SFCs, check out the [script setup docs](https://v3.vuejs.org/api/sfc-script-setup.html#sfc-script-setup) to learn more.
|
||||
|
||||
Learn more about IDE Support for Vue in the [Vue Docs Scaling up Guide](https://vuejs.org/guide/scaling-up/tooling.html#ide-support).
|
||||
13
client/index.html
Executable file
13
client/index.html
Executable file
@@ -0,0 +1,13 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>client</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
<script type="module" src="/src/main.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
1407
client/package-lock.json
generated
Executable file
1407
client/package-lock.json
generated
Executable file
File diff suppressed because it is too large
Load Diff
20
client/package.json
Executable file
20
client/package.json
Executable file
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"name": "client",
|
||||
"private": true,
|
||||
"version": "0.0.0",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "vite build",
|
||||
"preview": "vite preview"
|
||||
},
|
||||
"dependencies": {
|
||||
"axios": "^1.6.8",
|
||||
"vue": "^3.5.13",
|
||||
"vue-router": "^4.3.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@vitejs/plugin-vue": "^6.0.6",
|
||||
"vite": "^8.0.10"
|
||||
}
|
||||
}
|
||||
1
client/public/favicon.svg
Executable file
1
client/public/favicon.svg
Executable file
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 9.3 KiB |
24
client/public/icons.svg
Executable file
24
client/public/icons.svg
Executable file
@@ -0,0 +1,24 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg">
|
||||
<symbol id="bluesky-icon" viewBox="0 0 16 17">
|
||||
<g clip-path="url(#bluesky-clip)"><path fill="#08060d" d="M7.75 7.735c-.693-1.348-2.58-3.86-4.334-5.097-1.68-1.187-2.32-.981-2.74-.79C.188 2.065.1 2.812.1 3.251s.241 3.602.398 4.13c.52 1.744 2.367 2.333 4.07 2.145-2.495.37-4.71 1.278-1.805 4.512 3.196 3.309 4.38-.71 4.987-2.746.608 2.036 1.307 5.91 4.93 2.746 2.72-2.746.747-4.143-1.747-4.512 1.702.189 3.55-.4 4.07-2.145.156-.528.397-3.691.397-4.13s-.088-1.186-.575-1.406c-.42-.19-1.06-.395-2.741.79-1.755 1.24-3.64 3.752-4.334 5.099"/></g>
|
||||
<defs><clipPath id="bluesky-clip"><path fill="#fff" d="M.1.85h15.3v15.3H.1z"/></clipPath></defs>
|
||||
</symbol>
|
||||
<symbol id="discord-icon" viewBox="0 0 20 19">
|
||||
<path fill="#08060d" d="M16.224 3.768a14.5 14.5 0 0 0-3.67-1.153c-.158.286-.343.67-.47.976a13.5 13.5 0 0 0-4.067 0c-.128-.306-.317-.69-.476-.976A14.4 14.4 0 0 0 3.868 3.77C1.546 7.28.916 10.703 1.231 14.077a14.7 14.7 0 0 0 4.5 2.306q.545-.748.965-1.587a9.5 9.5 0 0 1-1.518-.74q.191-.14.372-.293c2.927 1.369 6.107 1.369 8.999 0q.183.152.372.294-.723.437-1.52.74.418.838.963 1.588a14.6 14.6 0 0 0 4.504-2.308c.37-3.911-.63-7.302-2.644-10.309m-9.13 8.234c-.878 0-1.599-.82-1.599-1.82 0-.998.705-1.82 1.6-1.82.894 0 1.614.82 1.599 1.82.001 1-.705 1.82-1.6 1.82m5.91 0c-.878 0-1.599-.82-1.599-1.82 0-.998.705-1.82 1.6-1.82.893 0 1.614.82 1.599 1.82 0 1-.706 1.82-1.6 1.82"/>
|
||||
</symbol>
|
||||
<symbol id="documentation-icon" viewBox="0 0 21 20">
|
||||
<path fill="none" stroke="#aa3bff" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.35" d="m15.5 13.333 1.533 1.322c.645.555.967.833.967 1.178s-.322.623-.967 1.179L15.5 18.333m-3.333-5-1.534 1.322c-.644.555-.966.833-.966 1.178s.322.623.966 1.179l1.534 1.321"/>
|
||||
<path fill="none" stroke="#aa3bff" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.35" d="M17.167 10.836v-4.32c0-1.41 0-2.117-.224-2.68-.359-.906-1.118-1.621-2.08-1.96-.599-.21-1.349-.21-2.848-.21-2.623 0-3.935 0-4.983.369-1.684.591-3.013 1.842-3.641 3.428C3 6.449 3 7.684 3 10.154v2.122c0 2.558 0 3.838.706 4.726q.306.383.713.671c.76.536 1.79.64 3.581.66"/>
|
||||
<path fill="none" stroke="#aa3bff" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.35" d="M3 10a2.78 2.78 0 0 1 2.778-2.778c.555 0 1.209.097 1.748-.047.48-.129.854-.503.982-.982.145-.54.048-1.194.048-1.749a2.78 2.78 0 0 1 2.777-2.777"/>
|
||||
</symbol>
|
||||
<symbol id="github-icon" viewBox="0 0 19 19">
|
||||
<path fill="#08060d" fill-rule="evenodd" d="M9.356 1.85C5.05 1.85 1.57 5.356 1.57 9.694a7.84 7.84 0 0 0 5.324 7.44c.387.079.528-.168.528-.376 0-.182-.013-.805-.013-1.454-2.165.467-2.616-.935-2.616-.935-.349-.91-.864-1.143-.864-1.143-.71-.48.051-.48.051-.48.787.051 1.2.805 1.2.805.695 1.194 1.817.857 2.268.649.064-.507.27-.857.49-1.052-1.728-.182-3.545-.857-3.545-3.87 0-.857.31-1.558.8-2.104-.078-.195-.349-1 .077-2.078 0 0 .657-.208 2.14.805a7.5 7.5 0 0 1 1.946-.26c.657 0 1.328.092 1.946.26 1.483-1.013 2.14-.805 2.14-.805.426 1.078.155 1.883.078 2.078.502.546.799 1.247.799 2.104 0 3.013-1.818 3.675-3.558 3.87.284.247.528.714.528 1.454 0 1.052-.012 1.896-.012 2.156 0 .208.142.455.528.377a7.84 7.84 0 0 0 5.324-7.441c.013-4.338-3.48-7.844-7.773-7.844" clip-rule="evenodd"/>
|
||||
</symbol>
|
||||
<symbol id="social-icon" viewBox="0 0 20 20">
|
||||
<path fill="none" stroke="#aa3bff" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.35" d="M12.5 6.667a4.167 4.167 0 1 0-8.334 0 4.167 4.167 0 0 0 8.334 0"/>
|
||||
<path fill="none" stroke="#aa3bff" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.35" d="M2.5 16.667a5.833 5.833 0 0 1 8.75-5.053m3.837.474.513 1.035c.07.144.257.282.414.309l.93.155c.596.1.736.536.307.965l-.723.73a.64.64 0 0 0-.152.531l.207.903c.164.715-.213.991-.84.618l-.872-.52a.63.63 0 0 0-.577 0l-.872.52c-.624.373-1.003.094-.84-.618l.207-.903a.64.64 0 0 0-.152-.532l-.723-.729c-.426-.43-.289-.864.306-.964l.93-.156a.64.64 0 0 0 .412-.31l.513-1.034c.28-.562.735-.562 1.012 0"/>
|
||||
</symbol>
|
||||
<symbol id="x-icon" viewBox="0 0 19 19">
|
||||
<path fill="#08060d" fill-rule="evenodd" d="M1.893 1.98c.052.072 1.245 1.769 2.653 3.77l2.892 4.114c.183.261.333.48.333.486s-.068.089-.152.183l-.522.593-.765.867-3.597 4.087c-.375.426-.734.834-.798.905a1 1 0 0 0-.118.148c0 .01.236.017.664.017h.663l.729-.83c.4-.457.796-.906.879-.999a692 692 0 0 0 1.794-2.038c.034-.037.301-.34.594-.675l.551-.624.345-.392a7 7 0 0 1 .34-.374c.006 0 .93 1.306 2.052 2.903l2.084 2.965.045.063h2.275c1.87 0 2.273-.003 2.266-.021-.008-.02-1.098-1.572-3.894-5.547-2.013-2.862-2.28-3.246-2.273-3.266.008-.019.282-.332 2.085-2.38l2-2.274 1.567-1.782c.022-.028-.016-.03-.65-.03h-.674l-.3.342a871 871 0 0 1-1.782 2.025c-.067.075-.405.458-.75.852a100 100 0 0 1-.803.91c-.148.172-.299.344-.99 1.127-.304.343-.32.358-.345.327-.015-.019-.904-1.282-1.976-2.808L6.365 1.85H1.8zm1.782.91 8.078 11.294c.772 1.08 1.413 1.973 1.425 1.984.016.017.241.02 1.05.017l1.03-.004-2.694-3.766L7.796 5.75 5.722 2.852l-1.039-.004-1.039-.004z" clip-rule="evenodd"/>
|
||||
</symbol>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 4.9 KiB |
76
client/src/App.vue
Executable file
76
client/src/App.vue
Executable file
@@ -0,0 +1,76 @@
|
||||
<template>
|
||||
<div id="app">
|
||||
<header v-if="isLoggedIn">
|
||||
<div class="user-info">
|
||||
Logged in as: <strong>{{ role }}</strong>
|
||||
</div>
|
||||
<button @click="logout" class="logout-btn">Logout</button>
|
||||
</header>
|
||||
<main>
|
||||
<router-view />
|
||||
</main>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed } from 'vue';
|
||||
import { useRouter } from 'vue-router';
|
||||
|
||||
const router = useRouter();
|
||||
const isLoggedIn = computed(() => !!localStorage.getItem('token'));
|
||||
const role = computed(() => localStorage.getItem('role'));
|
||||
|
||||
const logout = () => {
|
||||
localStorage.removeItem('token');
|
||||
localStorage.removeItem('role');
|
||||
router.push('/');
|
||||
};
|
||||
</script>
|
||||
|
||||
<style>
|
||||
body {
|
||||
margin: 0;
|
||||
font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
|
||||
background-color: var(--bg-color);
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
#app {
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
header {
|
||||
background: var(--card-bg);
|
||||
padding: 1rem 2rem;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
|
||||
border-bottom: 1px solid var(--border-color);
|
||||
}
|
||||
|
||||
.user-info {
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
.user-info strong {
|
||||
color: var(--accent-color);
|
||||
}
|
||||
|
||||
.logout-btn {
|
||||
padding: 0.5rem 1rem;
|
||||
background: #252932;
|
||||
border: 1px solid var(--border-color);
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.logout-btn:hover {
|
||||
background: #2e323a;
|
||||
}
|
||||
|
||||
main {
|
||||
padding-top: 2rem;
|
||||
}
|
||||
</style>
|
||||
BIN
client/src/assets/hero.png
Normal file
BIN
client/src/assets/hero.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 13 KiB |
1
client/src/assets/vite.svg
Normal file
1
client/src/assets/vite.svg
Normal file
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 8.5 KiB |
1
client/src/assets/vue.svg
Normal file
1
client/src/assets/vue.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="37.07" height="36" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 198"><path fill="#41B883" d="M204.8 0H256L128 220.8L0 0h97.92L128 51.2L157.44 0h47.36Z"></path><path fill="#41B883" d="m0 0l128 220.8L256 0h-51.2L128 132.48L50.56 0H0Z"></path><path fill="#35495E" d="M50.56 0L128 133.12L204.8 0h-47.36L128 51.2L97.92 0H50.56Z"></path></svg>
|
||||
|
After Width: | Height: | Size: 496 B |
95
client/src/components/HelloWorld.vue
Normal file
95
client/src/components/HelloWorld.vue
Normal file
@@ -0,0 +1,95 @@
|
||||
<script setup>
|
||||
import { ref } from 'vue'
|
||||
import viteLogo from '../assets/vite.svg'
|
||||
import heroImg from '../assets/hero.png'
|
||||
import vueLogo from '../assets/vue.svg'
|
||||
|
||||
const count = ref(0)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section id="center">
|
||||
<div class="hero">
|
||||
<img :src="heroImg" class="base" width="170" height="179" alt="" />
|
||||
<img :src="vueLogo" class="framework" alt="Vue logo" />
|
||||
<img :src="viteLogo" class="vite" alt="Vite logo" />
|
||||
</div>
|
||||
<div>
|
||||
<h1>Get started</h1>
|
||||
<p>Edit <code>src/App.vue</code> and save to test <code>HMR</code></p>
|
||||
</div>
|
||||
<button type="button" class="counter" @click="count++">
|
||||
Count is {{ count }}
|
||||
</button>
|
||||
</section>
|
||||
|
||||
<div class="ticks"></div>
|
||||
|
||||
<section id="next-steps">
|
||||
<div id="docs">
|
||||
<svg class="icon" role="presentation" aria-hidden="true">
|
||||
<use href="/icons.svg#documentation-icon"></use>
|
||||
</svg>
|
||||
<h2>Documentation</h2>
|
||||
<p>Your questions, answered</p>
|
||||
<ul>
|
||||
<li>
|
||||
<a href="https://vite.dev/" target="_blank">
|
||||
<img class="logo" :src="viteLogo" alt="" />
|
||||
Explore Vite
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://vuejs.org/" target="_blank">
|
||||
<img class="button-icon" :src="vueLogo" alt="" />
|
||||
Learn more
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div id="social">
|
||||
<svg class="icon" role="presentation" aria-hidden="true">
|
||||
<use href="/icons.svg#social-icon"></use>
|
||||
</svg>
|
||||
<h2>Connect with us</h2>
|
||||
<p>Join the Vite community</p>
|
||||
<ul>
|
||||
<li>
|
||||
<a href="https://github.com/vitejs/vite" target="_blank">
|
||||
<svg class="button-icon" role="presentation" aria-hidden="true">
|
||||
<use href="/icons.svg#github-icon"></use>
|
||||
</svg>
|
||||
GitHub
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://chat.vite.dev/" target="_blank">
|
||||
<svg class="button-icon" role="presentation" aria-hidden="true">
|
||||
<use href="/icons.svg#discord-icon"></use>
|
||||
</svg>
|
||||
Discord
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://x.com/vite_js" target="_blank">
|
||||
<svg class="button-icon" role="presentation" aria-hidden="true">
|
||||
<use href="/icons.svg#x-icon"></use>
|
||||
</svg>
|
||||
X.com
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://bsky.app/profile/vite.dev" target="_blank">
|
||||
<svg class="button-icon" role="presentation" aria-hidden="true">
|
||||
<use href="/icons.svg#bluesky-icon"></use>
|
||||
</svg>
|
||||
Bluesky
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<div class="ticks"></div>
|
||||
<section id="spacer"></section>
|
||||
</template>
|
||||
8
client/src/main.js
Executable file
8
client/src/main.js
Executable file
@@ -0,0 +1,8 @@
|
||||
import { createApp } from 'vue';
|
||||
import './style.css';
|
||||
import App from './App.vue';
|
||||
import router from './router';
|
||||
|
||||
const app = createApp(App);
|
||||
app.use(router);
|
||||
app.mount('#app');
|
||||
72
client/src/router/index.js
Normal file
72
client/src/router/index.js
Normal file
@@ -0,0 +1,72 @@
|
||||
import { createRouter, createWebHistory } from 'vue-router';
|
||||
import BoothLogin from '../views/BoothLogin.vue';
|
||||
import VotingFlow from '../views/VotingFlow.vue';
|
||||
import AdminDashboard from '../views/AdminDashboard.vue';
|
||||
import Setup from '../views/Setup.vue';
|
||||
import { authService } from '../services/api';
|
||||
|
||||
const routes = [
|
||||
{
|
||||
path: '/setup',
|
||||
name: 'Setup',
|
||||
component: Setup
|
||||
},
|
||||
{
|
||||
path: '/',
|
||||
name: 'Login',
|
||||
component: BoothLogin
|
||||
},
|
||||
{
|
||||
path: '/vote',
|
||||
name: 'Vote',
|
||||
component: VotingFlow,
|
||||
meta: { requiresAuth: true, role: 'booth' }
|
||||
},
|
||||
{
|
||||
path: '/admin',
|
||||
name: 'Admin',
|
||||
component: AdminDashboard,
|
||||
meta: { requiresAuth: true, role: 'admin' }
|
||||
}
|
||||
];
|
||||
|
||||
const router = createRouter({
|
||||
history: createWebHistory(),
|
||||
routes
|
||||
});
|
||||
|
||||
let isConfigured = null;
|
||||
|
||||
router.beforeEach(async (to, from, next) => {
|
||||
// 1. Check if system is configured
|
||||
if (isConfigured === null) {
|
||||
try {
|
||||
const { data } = await authService.checkStatus();
|
||||
isConfigured = data.configured;
|
||||
} catch (err) {
|
||||
console.error('Failed to check configuration status');
|
||||
}
|
||||
}
|
||||
|
||||
if (!isConfigured && to.name !== 'Setup') {
|
||||
return next('/setup');
|
||||
}
|
||||
|
||||
if (isConfigured && to.name === 'Setup') {
|
||||
return next('/');
|
||||
}
|
||||
|
||||
// 2. Auth checks
|
||||
const token = localStorage.getItem('token');
|
||||
const role = localStorage.getItem('role');
|
||||
|
||||
if (to.meta.requiresAuth && !token) {
|
||||
next('/');
|
||||
} else if (to.meta.role && to.meta.role !== role) {
|
||||
next('/');
|
||||
} else {
|
||||
next();
|
||||
}
|
||||
});
|
||||
|
||||
export default router;
|
||||
36
client/src/services/api.js
Normal file
36
client/src/services/api.js
Normal file
@@ -0,0 +1,36 @@
|
||||
import axios from 'axios';
|
||||
|
||||
const API_URL = 'http://localhost:3000/api'; // Changed to localhost for testing
|
||||
|
||||
const api = axios.create({
|
||||
baseURL: API_URL,
|
||||
});
|
||||
|
||||
export const authService = {
|
||||
checkStatus: () => api.get('/auth/status'),
|
||||
setup: (data) => api.post('/auth/setup', data),
|
||||
login: (credentials) => api.post('/auth/login', credentials),
|
||||
};
|
||||
|
||||
export const positionService = {
|
||||
getAll: () => api.get('/positions'),
|
||||
create: (data) => api.post('/positions', data),
|
||||
delete: (id) => api.delete(`/positions/${id}`),
|
||||
};
|
||||
|
||||
export const candidateService = {
|
||||
getAll: () => api.get('/candidates'),
|
||||
create: (formData) => api.post('/candidates', formData, {
|
||||
headers: { 'Content-Type': 'multipart/form-data' }
|
||||
}),
|
||||
delete: (id) => api.delete(`/candidates/${id}`),
|
||||
};
|
||||
|
||||
export const voteService = {
|
||||
checkAdmission: (num) => api.get(`/vote/check/${num}`),
|
||||
castVote: (voteData) => api.post('/vote', voteData),
|
||||
getResults: () => api.get('/vote/results'),
|
||||
resetVotes: (resetData) => api.post('/vote/reset', resetData),
|
||||
};
|
||||
|
||||
export default api;
|
||||
46
client/src/style.css
Executable file
46
client/src/style.css
Executable file
@@ -0,0 +1,46 @@
|
||||
:root {
|
||||
--bg-color: #0f1115;
|
||||
--card-bg: #1a1d23;
|
||||
--accent-color: #7c3aed;
|
||||
--text-primary: #cbd5e1; /* Replaced white with light gray */
|
||||
--text-secondary: #94a3b8;
|
||||
--danger-color: #e74c3c;
|
||||
--border-color: #2e323a;
|
||||
--font-family: 'Inter', system-ui, -apple-system, sans-serif;
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
background-color: var(--bg-color);
|
||||
color: var(--text-primary);
|
||||
font-family: var(--font-family);
|
||||
-webkit-font-smoothing: antialiased;
|
||||
}
|
||||
|
||||
#app {
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
/* Global Transitions */
|
||||
* {
|
||||
transition: background-color 0.3s ease, border-color 0.3s ease;
|
||||
}
|
||||
|
||||
/* Scrollbar Style */
|
||||
::-webkit-scrollbar {
|
||||
width: 8px;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-track {
|
||||
background: var(--bg-color);
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb {
|
||||
background: var(--border-color);
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb:hover {
|
||||
background: var(--accent-color);
|
||||
}
|
||||
542
client/src/views/AdminDashboard.vue
Normal file
542
client/src/views/AdminDashboard.vue
Normal file
@@ -0,0 +1,542 @@
|
||||
<template>
|
||||
<div class="admin-page">
|
||||
<div class="admin-container">
|
||||
<header class="admin-header">
|
||||
<h1>Admin Control Panel</h1>
|
||||
<div class="header-actions">
|
||||
<button @click="fetchData" class="secondary-btn">🔄 Refresh Data</button>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<div class="dashboard-layout">
|
||||
<!-- Left: Forms -->
|
||||
<section class="config-section">
|
||||
<!-- Position Management -->
|
||||
<div class="card">
|
||||
<h3>Manage Positions</h3>
|
||||
<form @submit.prevent="addPosition" class="admin-form">
|
||||
<div class="form-group">
|
||||
<label>Position Title</label>
|
||||
<input v-model="newPosition.title" type="text" placeholder="e.g. Head Boy" required />
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Display Order</label>
|
||||
<input v-model="newPosition.display_order" type="number" placeholder="0" />
|
||||
</div>
|
||||
<button type="submit" :disabled="loading" class="primary-btn">
|
||||
Add Position
|
||||
</button>
|
||||
</form>
|
||||
<div class="positions-list">
|
||||
<div v-for="pos in positions" :key="pos.id" class="pos-tag">
|
||||
{{ pos.title }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Candidate Registration -->
|
||||
<div class="card">
|
||||
<h3>Register New Candidate</h3>
|
||||
<form @submit.prevent="addCandidate" class="admin-form">
|
||||
<div class="form-group">
|
||||
<label>Candidate Name</label>
|
||||
<input v-model="newCandidate.name" type="text" placeholder="Full Name" required />
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Select Position</label>
|
||||
<select v-model="newCandidate.position_id" required class="admin-select">
|
||||
<option disabled value="">Choose position...</option>
|
||||
<option v-for="pos in positions" :key="pos.id" :value="pos.id">
|
||||
{{ pos.title }}
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Profile Image</label>
|
||||
<div class="file-input-wrapper">
|
||||
<input type="file" @change="handleImageUpload" accept="image/*" id="candidate-img" class="hidden-input" required />
|
||||
<label for="candidate-img" class="file-label">
|
||||
<span v-if="!newCandidate.image">Choose Image...</span>
|
||||
<span v-else>{{ newCandidate.image.name }}</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<button type="submit" :disabled="loading || positions.length === 0" class="primary-btn">
|
||||
{{ loading ? 'Saving...' : 'Add Candidate' }}
|
||||
</button>
|
||||
<p v-if="positions.length === 0" class="hint">Create a position first!</p>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div class="card danger-card">
|
||||
<h3>Danger Zone</h3>
|
||||
<p>Delete all votes and reset the election system. This cannot be undone.</p>
|
||||
<button @click="showResetModal = true" class="danger-btn">Reset All Votes</button>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- Right: Results -->
|
||||
<section class="results-section">
|
||||
<div class="card">
|
||||
<h3>Live Election Results</h3>
|
||||
<div class="results-container">
|
||||
<div v-if="groupedResults.length === 0" class="empty-state">
|
||||
No data available. Register positions and candidates first.
|
||||
</div>
|
||||
|
||||
<div v-for="group in groupedResults" :key="group.position_id" class="position-group">
|
||||
<h4 class="group-title">{{ group.position_title }}</h4>
|
||||
<div v-for="candidate in group.candidates" :key="candidate.candidate_id" class="result-row">
|
||||
<div class="row-header">
|
||||
<div class="cand-details-admin">
|
||||
<span class="cand-name">{{ candidate.candidate_name }}</span>
|
||||
<button @click="deleteCandidate(candidate.candidate_id)" class="delete-btn" title="Remove Candidate">🗑️</button>
|
||||
</div>
|
||||
<span class="vote-count">{{ candidate.vote_count }} Votes</span>
|
||||
</div>
|
||||
<div class="progress-track">
|
||||
<div
|
||||
class="progress-fill"
|
||||
:style="{ width: getPercentage(candidate.vote_count, group.total) + '%' }"
|
||||
></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Reset Modal -->
|
||||
<Transition name="fade">
|
||||
<div v-if="showResetModal" class="modal-backdrop">
|
||||
<div class="modal reset-modal">
|
||||
<div class="warning-icon">⚠️</div>
|
||||
<h2>Critical Action Required</h2>
|
||||
<p>Please complete the following to confirm the full system reset.</p>
|
||||
|
||||
<div class="confirm-inputs">
|
||||
<div class="form-group">
|
||||
<label>Admin Password</label>
|
||||
<input v-model="resetConfirm.adminPassword" type="password" />
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Secondary Key (resetvotes2026)</label>
|
||||
<input v-model="resetConfirm.resetPassword" type="password" />
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Type: "I confirm to reset all votes"</label>
|
||||
<input v-model="resetConfirm.sentence" type="text" placeholder="Type sentence exactly" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal-footer">
|
||||
<button
|
||||
class="final-reset-btn"
|
||||
:disabled="!isResetFormValid"
|
||||
@click="handleReset"
|
||||
>
|
||||
PERFORM SYSTEM RESET
|
||||
</button>
|
||||
<button class="cancel-btn" @click="closeResetModal">Cancel</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Transition>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, reactive, computed, onMounted } from 'vue';
|
||||
import { candidateService, voteService, positionService } from '../services/api';
|
||||
|
||||
const results = ref([]);
|
||||
const positions = ref([]);
|
||||
const loading = ref(false);
|
||||
const showResetModal = ref(false);
|
||||
|
||||
const newPosition = reactive({ title: '', display_order: 0 });
|
||||
const newCandidate = reactive({ name: '', position_id: '', image: null });
|
||||
const resetConfirm = reactive({ adminPassword: '', resetPassword: '', sentence: '' });
|
||||
|
||||
const groupedResults = computed(() => {
|
||||
const groups = {};
|
||||
results.value.forEach(r => {
|
||||
if (!groups[r.position_id]) {
|
||||
groups[r.position_id] = {
|
||||
position_id: r.position_id,
|
||||
position_title: r.position_title,
|
||||
candidates: [],
|
||||
total: 0
|
||||
};
|
||||
}
|
||||
groups[r.position_id].candidates.push(r);
|
||||
groups[r.position_id].total += r.vote_count;
|
||||
});
|
||||
return Object.values(groups);
|
||||
});
|
||||
|
||||
const getPercentage = (count, total) => total === 0 ? 0 : (count / total) * 100;
|
||||
|
||||
const isResetFormValid = computed(() => {
|
||||
return resetConfirm.adminPassword === 'adminkcps2026' &&
|
||||
resetConfirm.resetPassword === 'resetvotes2026' &&
|
||||
resetConfirm.sentence === 'I confirm to reset all votes';
|
||||
});
|
||||
|
||||
onMounted(fetchData);
|
||||
|
||||
async function fetchData() {
|
||||
await fetchPositions();
|
||||
await fetchResults();
|
||||
}
|
||||
|
||||
async function fetchPositions() {
|
||||
try {
|
||||
const response = await positionService.getAll();
|
||||
positions.value = response.data;
|
||||
} catch (err) { console.error('Positions fetch failed'); }
|
||||
}
|
||||
|
||||
async function fetchResults() {
|
||||
try {
|
||||
const response = await voteService.getResults();
|
||||
results.value = response.data;
|
||||
} catch (err) { console.error('Results fetch failed'); }
|
||||
}
|
||||
|
||||
async function addPosition() {
|
||||
loading.value = true;
|
||||
try {
|
||||
await positionService.create(newPosition);
|
||||
newPosition.title = ''; newPosition.display_order = 0;
|
||||
await fetchPositions();
|
||||
} catch (err) { alert('Failed to add position'); }
|
||||
finally { loading.value = false; }
|
||||
}
|
||||
|
||||
function handleImageUpload(e) { newCandidate.image = e.target.files[0]; }
|
||||
|
||||
async function addCandidate() {
|
||||
loading.value = true;
|
||||
const formData = new FormData();
|
||||
formData.append('name', newCandidate.name);
|
||||
formData.append('position_id', newCandidate.position_id);
|
||||
formData.append('image', newCandidate.image);
|
||||
|
||||
try {
|
||||
await candidateService.create(formData);
|
||||
alert('Candidate Added!');
|
||||
newCandidate.name = ''; newCandidate.position_id = ''; newCandidate.image = null;
|
||||
fetchResults();
|
||||
} catch (err) { alert('Save failed'); }
|
||||
finally { loading.value = false; }
|
||||
}
|
||||
|
||||
async function deleteCandidate(id) {
|
||||
if (!confirm('Are you sure you want to delete this candidate? This will also remove all votes they received.')) return;
|
||||
try {
|
||||
await candidateService.delete(id);
|
||||
await fetchResults();
|
||||
} catch (err) {
|
||||
alert(err.response?.data?.error || 'Failed to delete candidate');
|
||||
}
|
||||
}
|
||||
|
||||
async function handleReset() {
|
||||
if (!confirm('This is the FINAL check. Continue?')) return;
|
||||
try {
|
||||
await voteService.resetVotes(resetConfirm);
|
||||
alert('System Reset Successfully.');
|
||||
closeResetModal();
|
||||
fetchResults();
|
||||
} catch (err) { alert('Reset Failed'); }
|
||||
}
|
||||
|
||||
function closeResetModal() {
|
||||
showResetModal.value = false;
|
||||
resetConfirm.adminPassword = ''; resetConfirm.resetPassword = ''; resetConfirm.sentence = '';
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.admin-page {
|
||||
min-height: 100vh;
|
||||
background-color: var(--bg-color);
|
||||
padding: 2rem;
|
||||
}
|
||||
|
||||
.admin-container {
|
||||
max-width: 1200px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.admin-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 3rem;
|
||||
}
|
||||
|
||||
.admin-header h1 {
|
||||
font-size: 2rem;
|
||||
color: var(--accent-color);
|
||||
}
|
||||
|
||||
.dashboard-layout {
|
||||
display: grid;
|
||||
grid-template-columns: 400px 1fr;
|
||||
gap: 2rem;
|
||||
}
|
||||
|
||||
.card {
|
||||
background: var(--card-bg);
|
||||
padding: 2rem;
|
||||
border-radius: 12px;
|
||||
border: 1px solid var(--border-color);
|
||||
margin-bottom: 2rem;
|
||||
}
|
||||
|
||||
h3 {
|
||||
margin-top: 0;
|
||||
margin-bottom: 1.5rem;
|
||||
font-size: 1.25rem;
|
||||
border-bottom: 1px solid var(--border-color);
|
||||
padding-bottom: 0.75rem;
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.form-group {
|
||||
margin-bottom: 1.25rem;
|
||||
}
|
||||
|
||||
label {
|
||||
display: block;
|
||||
font-size: 0.85rem;
|
||||
color: var(--text-secondary);
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
|
||||
input, .admin-select {
|
||||
width: 100%;
|
||||
background: #252932;
|
||||
border: 1px solid var(--border-color);
|
||||
padding: 0.8rem;
|
||||
border-radius: 6px;
|
||||
color: var(--text-primary);
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.admin-select {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.positions-list {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.5rem;
|
||||
margin-top: 1rem;
|
||||
}
|
||||
|
||||
.pos-tag {
|
||||
background: #252932;
|
||||
padding: 0.3rem 0.8rem;
|
||||
border-radius: 15px;
|
||||
font-size: 0.8rem;
|
||||
color: var(--text-secondary);
|
||||
border: 1px solid var(--border-color);
|
||||
}
|
||||
|
||||
.hidden-input {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.file-label {
|
||||
display: block;
|
||||
background: #252932;
|
||||
border: 1px dashed var(--border-color);
|
||||
padding: 1rem;
|
||||
text-align: center;
|
||||
border-radius: 6px;
|
||||
cursor: pointer;
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
.file-label:hover {
|
||||
border-color: var(--accent-color);
|
||||
}
|
||||
|
||||
.primary-btn {
|
||||
width: 100%;
|
||||
background: var(--accent-color);
|
||||
color: #fff;
|
||||
padding: 1rem;
|
||||
border: none;
|
||||
border-radius: 6px;
|
||||
font-weight: 700;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.secondary-btn {
|
||||
background: #252932;
|
||||
color: var(--text-primary);
|
||||
border: 1px solid var(--border-color);
|
||||
padding: 0.6rem 1.2rem;
|
||||
border-radius: 6px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.danger-card {
|
||||
border-color: rgba(231, 76, 60, 0.3);
|
||||
}
|
||||
|
||||
.danger-card h3 {
|
||||
color: var(--danger-color);
|
||||
}
|
||||
|
||||
.danger-btn {
|
||||
background: var(--danger-color);
|
||||
color: #fff;
|
||||
border: none;
|
||||
padding: 0.8rem 1.5rem;
|
||||
border-radius: 6px;
|
||||
font-weight: 700;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
/* Results */
|
||||
.position-group {
|
||||
margin-bottom: 3rem;
|
||||
}
|
||||
|
||||
.group-title {
|
||||
color: var(--accent-color);
|
||||
font-size: 1.1rem;
|
||||
margin-bottom: 1.5rem;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 1px;
|
||||
}
|
||||
|
||||
.result-row {
|
||||
margin-bottom: 1.5rem;
|
||||
}
|
||||
|
||||
.row-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 0.5rem;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.cand-details-admin {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.8rem;
|
||||
}
|
||||
|
||||
.delete-btn {
|
||||
background: none;
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
font-size: 1rem;
|
||||
padding: 0;
|
||||
opacity: 0.5;
|
||||
transition: opacity 0.2s;
|
||||
}
|
||||
|
||||
.delete-btn:hover {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.cand-name {
|
||||
font-weight: 700;
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.vote-count {
|
||||
font-weight: 800;
|
||||
color: var(--accent-color);
|
||||
}
|
||||
|
||||
.progress-track {
|
||||
height: 10px;
|
||||
background: #252932;
|
||||
border-radius: 5px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.progress-fill {
|
||||
height: 100%;
|
||||
background: var(--accent-color);
|
||||
border-radius: 5px;
|
||||
transition: width 1s ease-out;
|
||||
}
|
||||
|
||||
.hint {
|
||||
font-size: 0.8rem;
|
||||
color: var(--danger-color);
|
||||
margin-top: 0.5rem;
|
||||
}
|
||||
|
||||
/* Modal */
|
||||
.modal-backdrop {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background: rgba(0,0,0,0.9);
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
z-index: 1000;
|
||||
}
|
||||
|
||||
.modal {
|
||||
background: var(--card-bg);
|
||||
padding: 3rem;
|
||||
border-radius: 20px;
|
||||
border: 1px solid var(--border-color);
|
||||
max-width: 500px;
|
||||
width: 90%;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.warning-icon {
|
||||
font-size: 4rem;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.confirm-inputs {
|
||||
margin: 2rem 0;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.final-reset-btn {
|
||||
width: 100%;
|
||||
background: var(--danger-color);
|
||||
color: #fff;
|
||||
padding: 1rem;
|
||||
border: none;
|
||||
border-radius: 6px;
|
||||
font-weight: 800;
|
||||
margin-bottom: 1rem;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.final-reset-btn:disabled {
|
||||
opacity: 0.4;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
.cancel-btn {
|
||||
background: transparent;
|
||||
color: var(--text-secondary);
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.fade-enter-active, .fade-leave-active { transition: opacity 0.3s; }
|
||||
.fade-enter-from, .fade-leave-to { opacity: 0; }
|
||||
</style>
|
||||
203
client/src/views/BoothLogin.vue
Normal file
203
client/src/views/BoothLogin.vue
Normal file
@@ -0,0 +1,203 @@
|
||||
<template>
|
||||
<div class="login-page">
|
||||
<div class="login-card">
|
||||
<div class="logo">
|
||||
<span class="icon">🗳️</span>
|
||||
<h1>Election 2026</h1>
|
||||
</div>
|
||||
<h2>Login to KCPS</h2>
|
||||
<p class="subtitle">Please enter your credentials to access the booth or admin panel.</p>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Username</label>
|
||||
<div class="input-wrapper">
|
||||
<input v-model="username" type="text" placeholder="Enter username" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Password</label>
|
||||
<div class="input-wrapper">
|
||||
<input v-model="password" type="password" placeholder="••••••••" @keyup.enter="handleLogin" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button @click="handleLogin" :disabled="loading" class="primary-btn">
|
||||
<span v-if="!loading">Sign In</span>
|
||||
<span v-else class="loader"></span>
|
||||
</button>
|
||||
|
||||
<p v-if="error" class="error-message">{{ error }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from 'vue';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { authService } from '../services/api';
|
||||
|
||||
const username = ref('');
|
||||
const password = ref('');
|
||||
const error = ref('');
|
||||
const loading = ref(false);
|
||||
const router = useRouter();
|
||||
|
||||
const handleLogin = async () => {
|
||||
if (!username.value || !password.value) {
|
||||
error.value = 'Fields cannot be empty';
|
||||
return;
|
||||
}
|
||||
loading.value = true;
|
||||
error.value = '';
|
||||
try {
|
||||
const response = await authService.login({ username: username.value, password: password.value });
|
||||
localStorage.setItem('token', response.data.token);
|
||||
localStorage.setItem('role', response.data.role);
|
||||
if (response.data.role === 'admin') router.push('/admin');
|
||||
else router.push('/vote');
|
||||
} catch (err) {
|
||||
error.value = 'Invalid username or password';
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.login-page {
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
background-color: var(--bg-color);
|
||||
padding: 1rem;
|
||||
}
|
||||
|
||||
.login-card {
|
||||
width: 100%;
|
||||
max-width: 420px;
|
||||
background-color: var(--card-bg);
|
||||
padding: 2.5rem;
|
||||
border-radius: 12px;
|
||||
border: 1px solid var(--border-color);
|
||||
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
|
||||
}
|
||||
|
||||
.logo {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
margin-bottom: 2rem;
|
||||
}
|
||||
|
||||
.logo .icon {
|
||||
font-size: 3rem;
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
|
||||
.logo h1 {
|
||||
font-size: 1.5rem;
|
||||
font-weight: 700;
|
||||
margin: 0;
|
||||
color: var(--accent-color);
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 2px;
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-size: 1.25rem;
|
||||
font-weight: 600;
|
||||
margin-bottom: 0.5rem;
|
||||
text-align: center;
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.subtitle {
|
||||
color: var(--text-secondary);
|
||||
font-size: 0.9rem;
|
||||
text-align: center;
|
||||
margin-bottom: 2rem;
|
||||
}
|
||||
|
||||
.form-group {
|
||||
margin-bottom: 1.5rem;
|
||||
}
|
||||
|
||||
label {
|
||||
display: block;
|
||||
font-size: 0.85rem;
|
||||
font-weight: 500;
|
||||
color: var(--text-secondary);
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
|
||||
input {
|
||||
width: 100%;
|
||||
background: #252932;
|
||||
border: 1px solid var(--border-color);
|
||||
padding: 0.8rem 1rem;
|
||||
border-radius: 8px;
|
||||
color: var(--text-primary);
|
||||
font-size: 1rem;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
input:focus {
|
||||
outline: none;
|
||||
border-color: var(--accent-color);
|
||||
box-shadow: 0 0 0 2px rgba(124, 58, 237, 0.2);
|
||||
}
|
||||
|
||||
.primary-btn {
|
||||
width: 100%;
|
||||
background-color: var(--accent-color);
|
||||
color: #fff;
|
||||
padding: 1rem;
|
||||
border: none;
|
||||
border-radius: 8px;
|
||||
font-size: 1rem;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
margin-top: 1rem;
|
||||
transition: opacity 0.2s, transform 0.1s;
|
||||
}
|
||||
|
||||
.primary-btn:hover:not(:disabled) {
|
||||
opacity: 0.9;
|
||||
}
|
||||
|
||||
.primary-btn:active:not(:disabled) {
|
||||
transform: scale(0.98);
|
||||
}
|
||||
|
||||
.primary-btn:disabled {
|
||||
opacity: 0.6;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
.error-message {
|
||||
color: var(--danger-color);
|
||||
background: rgba(231, 76, 60, 0.1);
|
||||
padding: 0.8rem;
|
||||
border-radius: 6px;
|
||||
font-size: 0.85rem;
|
||||
margin-top: 1.5rem;
|
||||
text-align: center;
|
||||
border: 1px solid rgba(231, 76, 60, 0.2);
|
||||
}
|
||||
|
||||
.loader {
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
border: 3px solid rgba(255, 255, 255, 0.3);
|
||||
border-radius: 50%;
|
||||
border-top-color: #fff;
|
||||
animation: spin 1s ease-in-out infinite;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
@keyframes spin {
|
||||
to { transform: rotate(360deg); }
|
||||
}
|
||||
</style>
|
||||
38
client/src/views/Results.vue
Normal file
38
client/src/views/Results.vue
Normal file
@@ -0,0 +1,38 @@
|
||||
<template>
|
||||
<div class="results-container">
|
||||
<h1>Live Election Results</h1>
|
||||
<div v-if="results.length > 0">
|
||||
<ul>
|
||||
<li v-for="candidate in results" :key="candidate.id">
|
||||
{{ candidate.name }}: {{ candidate.votes }} votes
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div v-else>
|
||||
<p>Loading results...</p>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, onMounted } from 'vue';
|
||||
|
||||
const results = ref([]);
|
||||
|
||||
onMounted(() => {
|
||||
// TODO: Fetch results from backend
|
||||
results.value = [
|
||||
{ id: 1, name: 'Sample Candidate A', votes: 12 },
|
||||
{ id: 2, name: 'Sample Candidate B', votes: 8 }
|
||||
];
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.results-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
margin-top: 50px;
|
||||
}
|
||||
</style>
|
||||
182
client/src/views/Setup.vue
Normal file
182
client/src/views/Setup.vue
Normal file
@@ -0,0 +1,182 @@
|
||||
<template>
|
||||
<div class="setup-container">
|
||||
<div class="setup-card">
|
||||
<h1>Initial System Setup</h1>
|
||||
<p>Welcome to the Student Council Election system. Please set up the initial credentials to proceed.</p>
|
||||
|
||||
<form @submit.prevent="handleSetup">
|
||||
<div class="form-section">
|
||||
<h3>Admin Credentials</h3>
|
||||
<div class="form-group">
|
||||
<label>Admin Username</label>
|
||||
<input v-model="form.adminUser" type="text" placeholder="e.g. admin" required />
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Admin Password</label>
|
||||
<input v-model="form.adminPass" type="password" placeholder="Set a strong password" required />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-section">
|
||||
<h3>Booth Credentials</h3>
|
||||
<p class="section-desc">These credentials will be used at the voting stations.</p>
|
||||
<div class="form-group">
|
||||
<label>Booth Username</label>
|
||||
<input v-model="form.boothUser" type="text" placeholder="e.g. booth1" required />
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Booth Password</label>
|
||||
<input v-model="form.boothPass" type="password" placeholder="Set booth password" required />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="error" class="error-message">{{ error }}</div>
|
||||
|
||||
<button type="submit" :disabled="loading" class="setup-btn">
|
||||
{{ loading ? 'Configuring System...' : 'Complete Setup' }}
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from 'vue';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { authService } from '../services/api';
|
||||
|
||||
const router = useRouter();
|
||||
const loading = ref(false);
|
||||
const error = ref('');
|
||||
|
||||
const form = ref({
|
||||
adminUser: '',
|
||||
adminPass: '',
|
||||
boothUser: '',
|
||||
boothPass: ''
|
||||
});
|
||||
|
||||
const handleSetup = async () => {
|
||||
loading.value = true;
|
||||
error.value = '';
|
||||
try {
|
||||
await authService.setup(form.value);
|
||||
alert('System configured successfully! Please login with your new credentials.');
|
||||
router.push('/');
|
||||
} catch (err) {
|
||||
error.value = err.response?.data?.error || 'Setup failed. Please try again.';
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.setup-container {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
min-height: 80vh;
|
||||
padding: 2rem;
|
||||
}
|
||||
|
||||
.setup-card {
|
||||
background: white;
|
||||
padding: 2.5rem;
|
||||
border-radius: 12px;
|
||||
box-shadow: 0 10px 25px rgba(0,0,0,0.1);
|
||||
max-width: 500px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
h1 {
|
||||
margin-bottom: 0.5rem;
|
||||
color: #2c3e50;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
p {
|
||||
color: #666;
|
||||
text-align: center;
|
||||
margin-bottom: 2rem;
|
||||
}
|
||||
|
||||
.form-section {
|
||||
margin-bottom: 2rem;
|
||||
padding: 1.5rem;
|
||||
background: #f8f9fa;
|
||||
border-radius: 8px;
|
||||
border: 1px solid #e9ecef;
|
||||
}
|
||||
|
||||
h3 {
|
||||
margin-top: 0;
|
||||
margin-bottom: 1rem;
|
||||
font-size: 1.1rem;
|
||||
color: #34495e;
|
||||
}
|
||||
|
||||
.section-desc {
|
||||
font-size: 0.85rem;
|
||||
text-align: left;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.form-group {
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
label {
|
||||
display: block;
|
||||
margin-bottom: 0.4rem;
|
||||
font-weight: 500;
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
input {
|
||||
width: 100%;
|
||||
padding: 0.8rem;
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 4px;
|
||||
font-size: 1rem;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
input:focus {
|
||||
outline: none;
|
||||
border-color: #3498db;
|
||||
box-shadow: 0 0 0 2px rgba(52,152,219,0.2);
|
||||
}
|
||||
|
||||
.setup-btn {
|
||||
width: 100%;
|
||||
padding: 1rem;
|
||||
background: #3498db;
|
||||
color: white;
|
||||
border: none;
|
||||
border-radius: 6px;
|
||||
font-size: 1.1rem;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
transition: background 0.2s;
|
||||
}
|
||||
|
||||
.setup-btn:hover {
|
||||
background: #2980b9;
|
||||
}
|
||||
|
||||
.setup-btn:disabled {
|
||||
background: #bdc3c7;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
.error-message {
|
||||
color: #e74c3c;
|
||||
background: #fdeaea;
|
||||
padding: 0.8rem;
|
||||
border-radius: 4px;
|
||||
margin-bottom: 1.5rem;
|
||||
font-size: 0.9rem;
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
556
client/src/views/VotingFlow.vue
Normal file
556
client/src/views/VotingFlow.vue
Normal file
@@ -0,0 +1,556 @@
|
||||
<template>
|
||||
<div class="voting-page">
|
||||
<!-- Step 1: Admission Number -->
|
||||
<div v-if="step === 1" class="step-container admission-step">
|
||||
<div class="content-card">
|
||||
<h1>Welcome to KCPS Elections</h1>
|
||||
<p class="instruction">Enter your admission number to proceed to the ballot.</p>
|
||||
<div class="input-group">
|
||||
<input
|
||||
v-model="admissionNumber"
|
||||
type="text"
|
||||
placeholder="e.g. 2024001"
|
||||
@keyup.enter="checkAdmission"
|
||||
ref="admissionInput"
|
||||
autofocus
|
||||
/>
|
||||
<button @click="checkAdmission" :disabled="loading" class="primary-btn large">
|
||||
{{ loading ? 'Verifying...' : 'Start Voting' }}
|
||||
</button>
|
||||
</div>
|
||||
<p v-if="error" class="error-text">{{ error }}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Step 2: Full Ballot Selection -->
|
||||
<div v-else-if="step === 2" class="step-container ballot-step">
|
||||
<header class="ballot-header">
|
||||
<div class="voter-info">
|
||||
Voter Admission: <span>{{ admissionNumber }}</span>
|
||||
</div>
|
||||
<h2>Cast Your Ballot</h2>
|
||||
<button class="ghost-btn" @click="resetFlow">Cancel</button>
|
||||
</header>
|
||||
|
||||
<div class="ballot-content">
|
||||
<div v-for="pos in positions" :key="pos.id" class="position-section">
|
||||
<h3 class="pos-title">{{ pos.title }}</h3>
|
||||
<div class="candidates-grid">
|
||||
<div
|
||||
v-for="candidate in getCandidatesForPosition(pos.id)"
|
||||
:key="candidate.id"
|
||||
class="candidate-card"
|
||||
:class="{ selected: selections[pos.id] === candidate.id }"
|
||||
@click="selectCandidate(pos.id, candidate.id)"
|
||||
>
|
||||
<div class="image-box">
|
||||
<img :src="candidate.image_url ? 'http://192.168.29.200:3000' + candidate.image_url : '/placeholder.png'" :alt="candidate.name" />
|
||||
<div v-if="selections[pos.id] === candidate.id" class="selected-check">✓</div>
|
||||
</div>
|
||||
<div class="candidate-info">
|
||||
<h3>{{ candidate.name }}</h3>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<footer class="ballot-footer">
|
||||
<p v-if="!isBallotComplete" class="warning-text">
|
||||
Please select one candidate for each position to proceed.
|
||||
</p>
|
||||
<button
|
||||
@click="showConfirmModal = true"
|
||||
:disabled="!isBallotComplete"
|
||||
class="primary-btn submit-ballot-btn"
|
||||
>
|
||||
Submit Full Ballot
|
||||
</button>
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
<!-- Step 3: Success Confirmation -->
|
||||
<div v-else-if="step === 3" class="step-container success-step">
|
||||
<div class="success-card">
|
||||
<div class="check-icon">✓</div>
|
||||
<h2>Vote Recorded!</h2>
|
||||
<p>Thank you for participating in the KCPS Student Council Election.</p>
|
||||
<div class="progress-bar-container">
|
||||
<div class="progress-bar" :style="{ width: progress + '%' }"></div>
|
||||
</div>
|
||||
<p class="timer-text">Resetting for next voter in {{ Math.ceil((100 - progress)/33) }}s</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Modal -->
|
||||
<Transition name="fade">
|
||||
<div v-if="showConfirmModal" class="modal-backdrop">
|
||||
<div class="modal">
|
||||
<div class="modal-icon">🗳️</div>
|
||||
<h3>Confirm Your Selection</h3>
|
||||
<p>You have made selections for all {{ positions.length }} positions.</p>
|
||||
<div class="modal-footer">
|
||||
<button class="confirm-btn" @click="submitVote" :disabled="loading">
|
||||
{{ loading ? 'Processing...' : 'Yes, Cast Ballot' }}
|
||||
</button>
|
||||
<button class="cancel-btn" @click="showConfirmModal = false">No, Go Back</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Transition>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, onMounted, nextTick, reactive, computed } from 'vue';
|
||||
import { candidateService, voteService, positionService } from '../services/api';
|
||||
|
||||
const step = ref(1);
|
||||
const admissionNumber = ref('');
|
||||
const positions = ref([]);
|
||||
const allCandidates = ref([]);
|
||||
const selections = reactive({}); // { positionId: candidateId }
|
||||
const showConfirmModal = ref(false);
|
||||
const loading = ref(false);
|
||||
const error = ref('');
|
||||
const admissionInput = ref(null);
|
||||
const progress = ref(0);
|
||||
|
||||
const isBallotComplete = computed(() => {
|
||||
return positions.value.every(pos => !!selections[pos.id]);
|
||||
});
|
||||
|
||||
onMounted(async () => {
|
||||
fetchData();
|
||||
focusInput();
|
||||
});
|
||||
|
||||
const focusInput = () => {
|
||||
nextTick(() => {
|
||||
admissionInput.value?.focus();
|
||||
});
|
||||
};
|
||||
|
||||
const fetchData = async () => {
|
||||
try {
|
||||
const [posRes, candRes] = await Promise.all([
|
||||
positionService.getAll(),
|
||||
candidateService.getAll()
|
||||
]);
|
||||
positions.value = posRes.data;
|
||||
allCandidates.value = candRes.data;
|
||||
} catch (err) {
|
||||
console.error('Failed to fetch data');
|
||||
}
|
||||
};
|
||||
|
||||
const getCandidatesForPosition = (posId) => {
|
||||
return allCandidates.value.filter(c => c.position_id === posId);
|
||||
};
|
||||
|
||||
const selectCandidate = (posId, candId) => {
|
||||
selections[posId] = candId;
|
||||
};
|
||||
|
||||
const checkAdmission = async () => {
|
||||
if (!admissionNumber.value) {
|
||||
error.value = 'Please enter your admission number';
|
||||
return;
|
||||
}
|
||||
|
||||
const num = parseInt(admissionNumber.value);
|
||||
if (isNaN(num) || num < 5000 || num > 15000) {
|
||||
error.value = 'Invalid Admission Number. Must be between 5000 and 15000.';
|
||||
return;
|
||||
}
|
||||
|
||||
loading.value = true;
|
||||
error.value = '';
|
||||
try {
|
||||
const response = await voteService.checkAdmission(admissionNumber.value);
|
||||
if (response.data.hasVoted) {
|
||||
error.value = 'Already voted under this admission number.';
|
||||
} else {
|
||||
step.value = 2;
|
||||
}
|
||||
} catch (err) {
|
||||
error.value = err.response?.data?.error || 'Verification failed. Try again.';
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
const submitVote = async () => {
|
||||
loading.value = true;
|
||||
try {
|
||||
const candidateIds = Object.values(selections);
|
||||
await voteService.castVote({
|
||||
admissionNumber: admissionNumber.value,
|
||||
candidateIds: candidateIds
|
||||
});
|
||||
showConfirmModal.value = false;
|
||||
step.value = 3;
|
||||
startResetTimer();
|
||||
} catch (err) {
|
||||
alert('Critical Error: Failed to save ballot.');
|
||||
showConfirmModal.value = false;
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
const startResetTimer = () => {
|
||||
progress.value = 0;
|
||||
const interval = setInterval(() => {
|
||||
progress.value += 2;
|
||||
if (progress.value >= 100) {
|
||||
clearInterval(interval);
|
||||
resetFlow();
|
||||
}
|
||||
}, 60);
|
||||
};
|
||||
|
||||
const resetFlow = () => {
|
||||
step.value = 1;
|
||||
admissionNumber.value = '';
|
||||
Object.keys(selections).forEach(key => delete selections[key]);
|
||||
error.value = '';
|
||||
focusInput();
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.voting-page {
|
||||
min-height: 100vh;
|
||||
background-color: var(--bg-color);
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.step-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
padding: 2rem;
|
||||
}
|
||||
|
||||
/* Step 1 */
|
||||
.admission-step {
|
||||
justify-content: center;
|
||||
height: 80vh;
|
||||
}
|
||||
|
||||
.content-card {
|
||||
background: var(--card-bg);
|
||||
padding: 4rem;
|
||||
border-radius: 16px;
|
||||
border: 1px solid var(--border-color);
|
||||
text-align: center;
|
||||
max-width: 600px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: 2.5rem;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.instruction {
|
||||
color: var(--text-secondary);
|
||||
font-size: 1.1rem;
|
||||
margin-bottom: 3rem;
|
||||
}
|
||||
|
||||
.input-group {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1.5rem;
|
||||
}
|
||||
|
||||
input {
|
||||
background: #252932;
|
||||
border: 2px solid var(--border-color);
|
||||
padding: 1.5rem;
|
||||
border-radius: 12px;
|
||||
color: var(--text-primary);
|
||||
font-size: 1.5rem;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
input:focus {
|
||||
outline: none;
|
||||
border-color: var(--accent-color);
|
||||
}
|
||||
|
||||
.primary-btn.large {
|
||||
padding: 1.5rem;
|
||||
font-size: 1.25rem;
|
||||
font-weight: 700;
|
||||
background-color: var(--accent-color);
|
||||
border: none;
|
||||
border-radius: 12px;
|
||||
color: #fff;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.error-text {
|
||||
color: var(--danger-color);
|
||||
margin-top: 1.5rem;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
/* Step 2 */
|
||||
.ballot-step {
|
||||
max-width: 1200px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.ballot-header {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 3rem;
|
||||
padding-bottom: 1.5rem;
|
||||
border-bottom: 1px solid var(--border-color);
|
||||
}
|
||||
|
||||
.voter-info {
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
.voter-info span {
|
||||
color: var(--accent-color);
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.ballot-content {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.position-section {
|
||||
margin-bottom: 4rem;
|
||||
}
|
||||
|
||||
.pos-title {
|
||||
color: var(--accent-color);
|
||||
font-size: 1.5rem;
|
||||
margin-bottom: 2rem;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 2px;
|
||||
border-left: 4px solid var(--accent-color);
|
||||
padding-left: 1rem;
|
||||
}
|
||||
|
||||
.candidates-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
|
||||
gap: 2rem;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.candidate-card {
|
||||
background: var(--card-bg);
|
||||
border-radius: 16px;
|
||||
overflow: hidden;
|
||||
border: 1px solid var(--border-color);
|
||||
cursor: pointer;
|
||||
position: relative;
|
||||
transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
|
||||
}
|
||||
|
||||
.candidate-card:hover {
|
||||
transform: translateY(-8px);
|
||||
}
|
||||
|
||||
.candidate-card.selected {
|
||||
border-color: var(--accent-color);
|
||||
background: rgba(124, 58, 237, 0.1);
|
||||
box-shadow: 0 0 20px rgba(124, 58, 237, 0.2);
|
||||
}
|
||||
|
||||
.image-box {
|
||||
width: 100%;
|
||||
aspect-ratio: 1/1;
|
||||
background: #252932;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.image-box img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
.selected-check {
|
||||
position: absolute;
|
||||
top: 10px;
|
||||
right: 10px;
|
||||
background: var(--accent-color);
|
||||
color: #fff;
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
border-radius: 50%;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.candidate-info {
|
||||
padding: 1rem;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.candidate-info h3 {
|
||||
margin: 0;
|
||||
font-size: 1.1rem;
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.ballot-footer {
|
||||
width: 100%;
|
||||
margin-top: 4rem;
|
||||
padding: 2rem;
|
||||
text-align: center;
|
||||
border-top: 1px solid var(--border-color);
|
||||
}
|
||||
|
||||
.warning-text {
|
||||
color: var(--danger-color);
|
||||
margin-bottom: 1.5rem;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.submit-ballot-btn {
|
||||
padding: 1.5rem 4rem;
|
||||
font-size: 1.5rem;
|
||||
font-weight: 800;
|
||||
border-radius: 50px;
|
||||
}
|
||||
|
||||
.submit-ballot-btn:disabled {
|
||||
background: #252932;
|
||||
color: var(--text-secondary);
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
/* Success */
|
||||
.success-step {
|
||||
justify-content: center;
|
||||
height: 80vh;
|
||||
}
|
||||
|
||||
.success-card {
|
||||
text-align: center;
|
||||
background: var(--card-bg);
|
||||
padding: 4rem;
|
||||
border-radius: 16px;
|
||||
border: 2px solid var(--accent-color);
|
||||
max-width: 500px;
|
||||
}
|
||||
|
||||
.check-icon {
|
||||
width: 80px;
|
||||
height: 80px;
|
||||
background: var(--accent-color);
|
||||
color: #fff;
|
||||
font-size: 3rem;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
border-radius: 50%;
|
||||
margin: 0 auto 2rem;
|
||||
}
|
||||
|
||||
.progress-bar-container {
|
||||
width: 100%;
|
||||
height: 6px;
|
||||
background: #252932;
|
||||
border-radius: 3px;
|
||||
margin: 2rem 0 1rem;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.progress-bar {
|
||||
height: 100%;
|
||||
background: var(--accent-color);
|
||||
transition: width 0.06s linear;
|
||||
}
|
||||
|
||||
.timer-text {
|
||||
color: var(--text-secondary);
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
/* Modal */
|
||||
.modal-backdrop {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background: rgba(0,0,0,0.85);
|
||||
backdrop-filter: blur(8px);
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
z-index: 1000;
|
||||
}
|
||||
|
||||
.modal {
|
||||
background: var(--card-bg);
|
||||
padding: 3rem;
|
||||
border-radius: 20px;
|
||||
border: 1px solid var(--border-color);
|
||||
max-width: 440px;
|
||||
width: 90%;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.modal-icon {
|
||||
font-size: 4rem;
|
||||
margin-bottom: 1.5rem;
|
||||
}
|
||||
|
||||
.modal-footer {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1rem;
|
||||
margin-top: 2rem;
|
||||
}
|
||||
|
||||
.confirm-btn {
|
||||
background: var(--accent-color);
|
||||
color: #fff;
|
||||
border: none;
|
||||
padding: 1rem;
|
||||
border-radius: 8px;
|
||||
font-weight: 700;
|
||||
font-size: 1.1rem;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.cancel-btn {
|
||||
background: transparent;
|
||||
color: var(--text-secondary);
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
padding: 0.5rem;
|
||||
}
|
||||
|
||||
.ghost-btn {
|
||||
background: transparent;
|
||||
border: 1px solid var(--border-color);
|
||||
color: var(--text-secondary);
|
||||
padding: 0.5rem 1rem;
|
||||
border-radius: 6px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.fade-enter-active, .fade-leave-active {
|
||||
transition: opacity 0.3s;
|
||||
}
|
||||
.fade-enter-from, .fade-leave-to {
|
||||
opacity: 0;
|
||||
}
|
||||
</style>
|
||||
43
client/src/views/VotingForm.vue
Normal file
43
client/src/views/VotingForm.vue
Normal file
@@ -0,0 +1,43 @@
|
||||
<template>
|
||||
<div class="voting-container">
|
||||
<h1>Cast Your Vote</h1>
|
||||
<div v-if="!voted">
|
||||
<input v-model="admissionNumber" placeholder="Student Admission Number" />
|
||||
<!-- Candidate selection will go here -->
|
||||
<button @click="submitVote">Submit Vote</button>
|
||||
</div>
|
||||
<div v-else>
|
||||
<h2>Thank you for voting!</h2>
|
||||
<button @click="reset">Next Voter</button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from 'vue';
|
||||
|
||||
const admissionNumber = ref('');
|
||||
const voted = ref(false);
|
||||
|
||||
const submitVote = () => {
|
||||
if (admissionNumber.value) {
|
||||
// TODO: Send vote to backend
|
||||
console.log(`Vote submitted for ${admissionNumber.value}`);
|
||||
voted.value = true;
|
||||
}
|
||||
};
|
||||
|
||||
const reset = () => {
|
||||
admissionNumber.value = '';
|
||||
voted.value = false;
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.voting-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
margin-top: 50px;
|
||||
}
|
||||
</style>
|
||||
11
client/vite.config.js
Executable file
11
client/vite.config.js
Executable file
@@ -0,0 +1,11 @@
|
||||
import { defineConfig } from 'vite'
|
||||
import vue from '@vitejs/plugin-vue'
|
||||
|
||||
// https://vite.dev/config/
|
||||
export default defineConfig({
|
||||
plugins: [vue()],
|
||||
server: {
|
||||
host: '0.0.0.0',
|
||||
port: 5173
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user