68 };
69
70 const response = await fetch('/api/plans/generate', {
71 method: 'POST',
72 headers: {
9 __CONFIG__: {
10 googleClientId: string;
11 apiBaseUrl: string;
12 };
13 }
5
6export class CalendarService {
7 private baseUrl = 'https://www.googleapis.com/calendar/v3';
8
9 async getEvents(accessToken: string, timeMin: string, timeMax: string): Promise<CalendarEvent[]> {
26
27 // Load recent meal plans
28 const plansResponse = await fetch(`/api/plans/user/${user.id}`);
29 if (plansResponse.ok) {
30 const plansData = await plansResponse.json();
46
47 try {
48 const response = await fetch(`/api/plans/${planId}?userId=${user.id}`, {
49 method: 'DELETE'
50 });
89 <div>
90 <p className="text-sm text-gray-600">Fitness Goal</p>
91 <p className="font-semibold capitalize">
92 {user.fitnessGoal.replace('_', ' ')}
93 </p>
101 <div>
102 <p className="text-sm text-gray-600">Activity Level</p>
103 <p className="font-semibold capitalize">
104 {user.activityLevel.replace('_', ' ')}
105 </p>
210 <div className="flex space-x-2 ml-4">
211 <button
212 onClick={() => window.open(`/api/plans/${plan.id}`, '_blank')}
213 className="text-sm text-blue-600 hover:text-blue-800"
214 >
13
14 async exchangeCodeForTokens(code: string) {
15 const tokenEndpoint = 'https://oauth2.googleapis.com/token';
16
17 const params = new URLSearchParams({
41
42 async refreshAccessToken(refreshToken: string) {
43 const tokenEndpoint = 'https://oauth2.googleapis.com/token';
44
45 const params = new URLSearchParams({
68
69 async getUserInfo(accessToken: string) {
70 const response = await fetch('https://www.googleapis.com/oauth2/v2/userinfo', {
71 headers: {
72 'Authorization': `Bearer ${accessToken}`,
42## Development
43
44The website is automatically deployed on Val Town. The backend serves the frontend and handles API requests.
45
46## Sections
37 ),
38 "Backend": personalInfo.skills.filter(skill =>
39 ['Node.js', 'Python', 'Express.js', 'GraphQL', 'REST APIs'].includes(skill)
40 ),
41 "Database": personalInfo.skills.filter(skill =>
216 <div>
217 <h5 className="font-medium text-gray-900 dark:text-white">Backend Development</h5>
218 <p className="text-sm text-gray-600 dark:text-gray-300">Building scalable APIs and server-side applications</p>
219 </div>
220 </div>
96 };
97
98 const url = user ? `/api/users/${user.id}` : '/api/users';
99 const method = user ? 'PUT' : 'POST';
100
50}
51
52export interface ApiResponse<T> {
53 success: boolean;
54 data?: T;
32 try {
33 setLoading(true);
34 const response = await fetch(`/api/users/${userId}`);
35
36 if (response.ok) {