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,
25 return c.json<ApiResponse>({
26 success: false,
27 error: 'Failed to fetch messages'
28 }, 500);
29 }
126 return c.json<ApiResponse>({
127 success: false,
128 error: 'Failed to fetch dashboard data'
129 }, 500);
130 }
279
280 try {
281 const response = await fetch("/api/analyze", {
282 method: "POST",
283 headers: {
34 return c.json<ApiResponse>({
35 success: false,
36 error: 'Failed to fetch students'
37 }, 500);
38 }
80 return c.json<ApiResponse>({
81 success: false,
82 error: 'Failed to fetch student'
83 }, 500);
84 }
420});
421
422export default app.fetch;
35});
36
37export default app.fetch;