Waho_Stop_Banmain.tsx2 matches
480<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
481<style>
482@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;600;700&display=swap');
483body {
484margin: 0;
657margin: 10px auto;
658display: block;
659text-transform: capitalize;
660}
661.toggle-additional-fields:hover {
dbssetprofileindex.ts7 matches
22await insertSampleData();
2324// API routes
25app.route("/api/profile", profile);
26app.route("/api/academics", academics);
27app.route("/api/finances", finances);
28app.route("/api/socials", socials);
29app.route("/api/repository", repository);
3031// Serve static files
44const initialData = {
45student: defaultStudent,
46apiBase: "" // Since we're serving from the same domain
47};
48
dbssetprofileindex.html16 matches
67// Global state
68let currentStudent = null;
69let apiBase = '';
7071// Initialize the application
74if (window.__INITIAL_DATA__) {
75currentStudent = window.__INITIAL_DATA__.student;
76apiBase = window.__INITIAL_DATA__.apiBase;
77updateProfileDisplay();
78} else {
87async function loadDefaultStudent() {
88try {
89const response = await fetch(`${apiBase}/api/profile/admission/2023/CS/3`);
90const result = await response.json();
91if (result.success) {
230// Data loading functions
231async function loadUnits() {
232const response = await fetch(`${apiBase}/api/academics/${currentStudent.id}/units`);
233const result = await response.json();
234
255256async function loadExaminations() {
257const response = await fetch(`${apiBase}/api/academics/${currentStudent.id}/examinations`);
258const result = await response.json();
259
283284async function loadProgress() {
285const response = await fetch(`${apiBase}/api/academics/${currentStudent.id}/progress`);
286const result = await response.json();
287
310311async function loadFeePayments() {
312const response = await fetch(`${apiBase}/api/finances/${currentStudent.id}/payments`);
313const result = await response.json();
314
335336async function loadFeeStructure() {
337const response = await fetch(`${apiBase}/api/finances/${currentStudent.id}/structure`);
338const result = await response.json();
339
356357async function loadFeeBalance() {
358const response = await fetch(`${apiBase}/api/finances/${currentStudent.id}/balance`);
359const result = await response.json();
360
377378async function loadEvents() {
379const response = await fetch(`${apiBase}/api/socials/events`);
380const result = await response.json();
381
403404async function loadNews() {
405const response = await fetch(`${apiBase}/api/socials/news`);
406const result = await response.json();
407
428429async function loadClubs() {
430const response = await fetch(`${apiBase}/api/socials/clubs`);
431const result = await response.json();
432
454455async function loadProjects() {
456const response = await fetch(`${apiBase}/api/socials/projects/student/${currentStudent.id}`);
457const result = await response.json();
458
480481async function loadDocuments(type) {
482const response = await fetch(`${apiBase}/api/repository/${currentStudent.id}/${type}`);
483const result = await response.json();
484
505506async function loadAllDocuments() {
507const response = await fetch(`${apiBase}/api/repository/${currentStudent.id}/grouped`);
508const result = await response.json();
509
598599try {
600const response = await fetch(`${apiBase}/api/profile/${currentStudent.id}`, {
601method: 'PUT',
602headers: {
dbssetprofilerepository.ts11 matches
1import { Hono } from "https://esm.sh/hono@3.11.7";
2import { getStudentDocuments } from "../database/queries.ts";
3import type { ApiResponse, Document } from "../../shared/types.ts";
45const repository = new Hono();
10const studentId = parseInt(c.req.param("studentId"));
11if (isNaN(studentId)) {
12return c.json<ApiResponse<null>>({
13success: false,
14error: "Invalid student ID"
18const documents = await getStudentDocuments(studentId);
19
20return c.json<ApiResponse<Document[]>>({
21success: true,
22data: documents
23});
24} catch (error) {
25return c.json<ApiResponse<null>>({
26success: false,
27error: "Internal server error"
37
38if (isNaN(studentId)) {
39return c.json<ApiResponse<null>>({
40success: false,
41error: "Invalid student ID"
45const validTypes = ['logbook', 'insurance', 'mentor-letter', 'transcript', 'certificate'];
46if (!validTypes.includes(type)) {
47return c.json<ApiResponse<null>>({
48success: false,
49error: "Invalid document type"
53const documents = await getStudentDocuments(studentId, type);
54
55return c.json<ApiResponse<Document[]>>({
56success: true,
57data: documents
58});
59} catch (error) {
60return c.json<ApiResponse<null>>({
61success: false,
62error: "Internal server error"
70const studentId = parseInt(c.req.param("studentId"));
71if (isNaN(studentId)) {
72return c.json<ApiResponse<null>>({
73success: false,
74error: "Invalid student ID"
87}, {} as Record<string, Document[]>);
88
89return c.json<ApiResponse<Record<string, Document[]>>>({
90success: true,
91data: grouped
92});
93} catch (error) {
94return c.json<ApiResponse<null>>({
95success: false,
96error: "Internal server error"
dbssetprofilesocials.ts15 matches
1import { Hono } from "https://esm.sh/hono@3.11.7";
2import { getEvents, getNews, getClubs, getProjects, getStudentById } from "../database/queries.ts";
3import type { ApiResponse, Event, News, Club, Project } from "../../shared/types.ts";
45const socials = new Hono();
11const events = await getEvents(limit);
12
13return c.json<ApiResponse<Event[]>>({
14success: true,
15data: events
16});
17} catch (error) {
18return c.json<ApiResponse<null>>({
19success: false,
20error: "Internal server error"
29const news = await getNews(limit);
30
31return c.json<ApiResponse<News[]>>({
32success: true,
33data: news
34});
35} catch (error) {
36return c.json<ApiResponse<null>>({
37success: false,
38error: "Internal server error"
46const clubs = await getClubs();
47
48return c.json<ApiResponse<Club[]>>({
49success: true,
50data: clubs
51});
52} catch (error) {
53return c.json<ApiResponse<null>>({
54success: false,
55error: "Internal server error"
64const projects = await getProjects(department);
65
66return c.json<ApiResponse<Project[]>>({
67success: true,
68data: projects
69});
70} catch (error) {
71return c.json<ApiResponse<null>>({
72success: false,
73error: "Internal server error"
81const studentId = parseInt(c.req.param("studentId"));
82if (isNaN(studentId)) {
83return c.json<ApiResponse<null>>({
84success: false,
85error: "Invalid student ID"
89const student = await getStudentById(studentId);
90if (!student) {
91return c.json<ApiResponse<null>>({
92success: false,
93error: "Student not found"
97const projects = await getProjects(student.department);
98
99return c.json<ApiResponse<Project[]>>({
100success: true,
101data: projects
102});
103} catch (error) {
104return c.json<ApiResponse<null>>({
105success: false,
106error: "Internal server error"
121]);
122123return c.json<ApiResponse<{
124events: Event[];
125news: News[];
136});
137} catch (error) {
138return c.json<ApiResponse<null>>({
139success: false,
140error: "Internal server error"
dbssetprofilefinances.ts16 matches
1import { Hono } from "https://esm.sh/hono@3.11.7";
2import { getStudentFeePayments, getFeeStructure, getFeeBalance, getStudentById } from "../database/queries.ts";
3import type { ApiResponse, FeePayment, FeeStructure } from "../../shared/types.ts";
45const finances = new Hono();
10const studentId = parseInt(c.req.param("studentId"));
11if (isNaN(studentId)) {
12return c.json<ApiResponse<null>>({
13success: false,
14error: "Invalid student ID"
1718const payments = await getStudentFeePayments(studentId);
19return c.json<ApiResponse<FeePayment[]>>({
20success: true,
21data: payments
22});
23} catch (error) {
24return c.json<ApiResponse<null>>({
25success: false,
26error: "Internal server error"
34const studentId = parseInt(c.req.param("studentId"));
35if (isNaN(studentId)) {
36return c.json<ApiResponse<null>>({
37success: false,
38error: "Invalid student ID"
42const student = await getStudentById(studentId);
43if (!student) {
44return c.json<ApiResponse<null>>({
45success: false,
46error: "Student not found"
52
53if (!feeStructure) {
54return c.json<ApiResponse<null>>({
55success: false,
56error: "Fee structure not found for this department and year"
58}
5960return c.json<ApiResponse<FeeStructure>>({
61success: true,
62data: feeStructure
63});
64} catch (error) {
65return c.json<ApiResponse<null>>({
66success: false,
67error: "Internal server error"
75const studentId = parseInt(c.req.param("studentId"));
76if (isNaN(studentId)) {
77return c.json<ApiResponse<null>>({
78success: false,
79error: "Invalid student ID"
84const balance = await getFeeBalance(studentId, year);
85
86return c.json<ApiResponse<{ balance: number; year: string }>>({
87success: true,
88data: { balance, year }
89});
90} catch (error) {
91return c.json<ApiResponse<null>>({
92success: false,
93error: "Internal server error"
101const studentId = parseInt(c.req.param("studentId"));
102if (isNaN(studentId)) {
103return c.json<ApiResponse<null>>({
104success: false,
105error: "Invalid student ID"
109const student = await getStudentById(studentId);
110if (!student) {
111return c.json<ApiResponse<null>>({
112success: false,
113error: "Student not found"
125const totalPaid = payments.reduce((sum, payment) => sum + payment.amount, 0);
126127return c.json<ApiResponse<{
128payments: FeePayment[];
129feeStructure: FeeStructure | null;
142});
143} catch (error) {
144return c.json<ApiResponse<null>>({
145success: false,
146error: "Internal server error"
dbssetprofileacademics.ts13 matches
1import { Hono } from "https://esm.sh/hono@3.11.7";
2import { getStudentUnits, getStudentExaminations, getAcademicProgress } from "../database/queries.ts";
3import type { ApiResponse, Unit, Examination } from "../../shared/types.ts";
45const academics = new Hono();
10const studentId = parseInt(c.req.param("studentId"));
11if (isNaN(studentId)) {
12return c.json<ApiResponse<null>>({
13success: false,
14error: "Invalid student ID"
1718const units = await getStudentUnits(studentId);
19return c.json<ApiResponse<Unit[]>>({
20success: true,
21data: units
22});
23} catch (error) {
24return c.json<ApiResponse<null>>({
25success: false,
26error: "Internal server error"
34const studentId = parseInt(c.req.param("studentId"));
35if (isNaN(studentId)) {
36return c.json<ApiResponse<null>>({
37success: false,
38error: "Invalid student ID"
4142const examinations = await getStudentExaminations(studentId);
43return c.json<ApiResponse<Examination[]>>({
44success: true,
45data: examinations
46});
47} catch (error) {
48return c.json<ApiResponse<null>>({
49success: false,
50error: "Internal server error"
58const studentId = parseInt(c.req.param("studentId"));
59if (isNaN(studentId)) {
60return c.json<ApiResponse<null>>({
61success: false,
62error: "Invalid student ID"
6566const progress = await getAcademicProgress(studentId);
67return c.json<ApiResponse<typeof progress>>({
68success: true,
69data: progress
70});
71} catch (error) {
72return c.json<ApiResponse<null>>({
73success: false,
74error: "Internal server error"
82const studentId = parseInt(c.req.param("studentId"));
83if (isNaN(studentId)) {
84return c.json<ApiResponse<null>>({
85success: false,
86error: "Invalid student ID"
94]);
9596return c.json<ApiResponse<{
97units: Unit[];
98examinations: Examination[];
107});
108} catch (error) {
109return c.json<ApiResponse<null>>({
110success: false,
111error: "Internal server error"
dbssetprofileprofile.ts13 matches
1import { Hono } from "https://esm.sh/hono@3.11.7";
2import { getStudentById, getStudentByAdmission, updateStudent } from "../database/queries.ts";
3import type { ApiResponse, Student } from "../../shared/types.ts";
45const profile = new Hono();
10const id = parseInt(c.req.param("id"));
11if (isNaN(id)) {
12return c.json<ApiResponse<null>>({
13success: false,
14error: "Invalid student ID"
18const student = await getStudentById(id);
19if (!student) {
20return c.json<ApiResponse<null>>({
21success: false,
22error: "Student not found"
24}
2526return c.json<ApiResponse<Student>>({
27success: true,
28data: student
29});
30} catch (error) {
31return c.json<ApiResponse<null>>({
32success: false,
33error: "Internal server error"
43
44if (!student) {
45return c.json<ApiResponse<null>>({
46success: false,
47error: "Student not found"
49}
5051return c.json<ApiResponse<Student>>({
52success: true,
53data: student
54});
55} catch (error) {
56return c.json<ApiResponse<null>>({
57success: false,
58error: "Internal server error"
66const id = parseInt(c.req.param("id"));
67if (isNaN(id)) {
68return c.json<ApiResponse<null>>({
69success: false,
70error: "Invalid student ID"
76// Validate required fields if they're being updated
77if (updates.email && !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(updates.email)) {
78return c.json<ApiResponse<null>>({
79success: false,
80error: "Invalid email format"
84const success = await updateStudent(id, updates);
85if (!success) {
86return c.json<ApiResponse<null>>({
87success: false,
88error: "Failed to update student"
9192const updatedStudent = await getStudentById(id);
93return c.json<ApiResponse<Student>>({
94success: true,
95data: updatedStudent!,
97});
98} catch (error) {
99return c.json<ApiResponse<null>>({
100success: false,
101error: "Internal server error"
dbssetprofiletypes.ts1 match
112}
113114export interface ApiResponse<T> {
115success: boolean;
116data?: T;
dbssetprofileREADME.md8 matches
391. The backend automatically creates the database tables on first run
402. Access the profile page at the root URL
413. Use the API endpoints to manage data
4243## API Endpoints
4445- `GET /api/profile/:id` - Get student profile
46- `PUT /api/profile/:id` - Update student profile
47- `GET /api/academics/:studentId` - Get academic data
48- `GET /api/finances/:studentId` - Get financial data
49- `GET /api/socials/events` - Get events
50- `GET /api/repository/:studentId` - Get documents