feat: implement frontend Web UI pages

- Add types for all API models (MealPlan, Recipe, Ingredient, etc.)
- Add API client with mealPlannerApi wrapper for all endpoints
- Implement Dashboard with weekly meal plan grid view
- Implement Pantry page with add/remove functionality
- Implement MealDetail page with recipe display
- Implement ShoppingList page with aisle grouping
- Add ShoppingList route to App.tsx
- Add vite-env.d.ts for Vite env type support
This commit is contained in:
2026-05-04 20:54:54 -07:00
parent 933a0cc9db
commit 08e196b0ab
8 changed files with 773 additions and 11 deletions
+64
View File
@@ -0,0 +1,64 @@
import axios from 'axios'
const API_BASE = import.meta.env.VITE_API_URL || '/api'
const api = axios.create({
baseURL: API_BASE,
headers: {
'Content-Type': 'application/json',
},
})
export const mealPlannerApi = {
profile: {
get: () => api.get('/profile'),
update: (data: any) => api.put('/profile', data),
getMembers: () => api.get('/profile/members'),
addMember: (data: any) => api.post('/profile/members', data),
deleteMember: (id: string) => api.delete(`/profile/members/${id}`),
},
recipes: {
list: (params?: any) => api.get('/recipes', { params }),
get: (id: string) => api.get(`/recipes/${id}`),
create: (data: any) => api.post('/recipes', data),
delete: (id: string) => api.delete(`/recipes/${id}`),
listIngredients: () => api.get('/recipes/ingredients/list'),
createIngredient: (data: any) => api.post('/recipes/ingredients', data),
},
meals: {
getPlanned: () => api.get('/meals/planned'),
get: (id: string) => api.get(`/meals/${id}`),
getItem: (id: string) => api.get(`/meals/items/${id}`),
create: (data: any) => api.post('/meals', data),
lock: (id: string) => api.post(`/meals/${id}/lock`),
getVotePage: (itemId: string, token: string) => api.get(`/meals/items/${itemId}/vote/${token}`),
submitVote: (itemId: string, token: string, data: any) => api.post(`/meals/items/${itemId}/vote/${token}`, data),
swapItem: (itemId: string, newRecipeId: string) => api.post(`/meals/items/${itemId}/swap?new_recipe_id=${newRecipeId}`),
},
pantry: {
list: () => api.get('/pantry'),
add: (data: any) => api.post('/pantry', data),
update: (id: string, data: any) => api.put(`/pantry/${id}`, data),
remove: (id: string) => api.delete(`/pantry/${id}`),
},
shoppingList: {
get: () => api.get('/shopping-list'),
getPrint: () => api.get('/shopping-list/print'),
},
admin: {
triggerScrape: (source?: string, type?: string) => api.post('/admin/scrape', null, { params: { source, scrape_type: type } }),
getLogs: (params?: any) => api.get('/admin/logs', { params }),
getLog: (id: string) => api.get(`/admin/logs/${id}`),
getEmailLogs: (params?: any) => api.get('/admin/email-logs', { params }),
getMealPlans: (params?: any) => api.get('/admin/meal-plans', { params }),
getStats: () => api.get('/admin/stats'),
testEmail: (email: string) => api.post('/admin/test-email', null, { params: { email } }),
},
}
export default api