11 return c.json(messages);
12 } catch (error) {
13 console.error("Error fetching chat messages:", error);
14 return c.json({ error: "Failed to fetch messages" }, 500);
15 }
16});
11 return c.json(jobPosts);
12 } catch (error) {
13 console.error("Error fetching jobs:", error);
14 return c.json({ error: "Failed to fetch jobs" }, 500);
15 }
16});
87
88// This is the entry point for HTTP vals
89export default app.fetch;
89
90 try {
91 const response = await fetch('/api/review', {
92 method: 'POST',
93 headers: {
28 const loadMessages = async () => {
29 try {
30 const response = await fetch('/api/messages');
31 const result: ApiResponse<Message[]> = await response.json();
32
50
51 try {
52 const response = await fetch('/api/messages', {
53 method: 'POST',
54 headers: {
81 const handleMarkAsRead = async (messageId: number) => {
82 try {
83 const response = await fetch(`/api/messages/${messageId}/read`, {
84 method: 'PUT',
85 });
74 const method = isEditing ? 'PUT' : 'POST';
75
76 const response = await fetch(url, {
77 method,
78 headers: {
20 const loadStudents = async () => {
21 try {
22 const response = await fetch('/api/students');
23 const result: ApiResponse<Student[]> = await response.json();
24
39
40 try {
41 const response = await fetch(`/api/students/${studentId}`, {
42 method: 'DELETE',
43 });
18 const loadDashboardData = async () => {
19 try {
20 const response = await fetch('/api/messages/dashboard');
21 const result: ApiResponse<DashboardStats> = await response.json();
22
21
22 try {
23 const response = await fetch('/api/auth/login', {
24 method: 'POST',
25 headers: {
32 const checkAuth = async () => {
33 try {
34 const response = await fetch('/api/auth/check');
35 const result: ApiResponse<User> = await response.json();
36
52 const handleLogout = async () => {
53 try {
54 await fetch('/api/auth/logout', { method: 'POST' });
55 setState(prev => ({
56 ...prev,