Added settings for user data deletion

This commit is contained in:
Brian McGonagill 2026-03-21 12:23:20 -05:00
parent 59e15cfde8
commit f49490042a
35 changed files with 2758 additions and 499 deletions

View file

@ -1,5 +1,5 @@
import axios from 'axios';
import type { Game, Leg, Team, User, AuthResponse } from '../types';
import type { Game, Route, RouteLeg, Team, User, AuthResponse, LocationHistory, UserGameHistory } from '../types';
const api = axios.create({
baseURL: 'http://localhost:3001/api',
@ -37,13 +37,21 @@ export const gameService = {
getInvite: (id: string) => api.get<{ inviteCode: string }>(`/games/${id}/invite`),
};
export const legService = {
getByGame: (gameId: string) => api.get<Leg[]>(`/legs/game/${gameId}`),
create: (gameId: string, data: Partial<Leg>) => api.post<Leg>(`/legs/game/${gameId}`, data),
update: (legId: string, data: Partial<Leg>) => api.put<Leg>(`/legs/${legId}`, data),
delete: (legId: string) => api.delete(`/legs/${legId}`),
submitPhoto: (legId: string, data: { teamId: string; photoUrl: string }) =>
api.post(`/legs/${legId}/photo`, data),
export const routeService = {
getByGame: (gameId: string) => api.get<Route[]>(`/routes/game/${gameId}`),
get: (routeId: string) => api.get<Route>(`/routes/${routeId}`),
create: (data: { gameId: string; name: string; description?: string; color?: string }) =>
api.post<Route>('/routes', data),
update: (routeId: string, data: Partial<Route>) =>
api.put<Route>(`/routes/${routeId}`, data),
delete: (routeId: string) => api.delete(`/routes/${routeId}`),
copy: (routeId: string) => api.post<Route>(`/routes/${routeId}/copy`),
addLeg: (routeId: string, data: Partial<RouteLeg>) =>
api.post<RouteLeg>(`/routes/${routeId}/legs`, data),
updateLeg: (routeId: string, legId: string, data: Partial<RouteLeg>) =>
api.put<RouteLeg>(`/routes/${routeId}/legs/${legId}`, data),
deleteLeg: (routeId: string, legId: string) =>
api.delete(`/routes/${routeId}/legs/${legId}`),
};
export const teamService = {
@ -52,6 +60,8 @@ export const teamService = {
get: (teamId: string) => api.get<Team>(`/teams/${teamId}`),
join: (teamId: string) => api.post(`/teams/${teamId}/join`),
leave: (teamId: string) => api.post(`/teams/${teamId}/leave`),
assignRoute: (teamId: string, routeId: string) =>
api.post(`/teams/${teamId}/assign-route`, { routeId }),
advance: (teamId: string) => api.post<Team>(`/teams/${teamId}/advance`),
deduct: (teamId: string, seconds: number) => api.post<Team>(`/teams/${teamId}/deduct`, { seconds }),
disqualify: (teamId: string) => api.post<Team>(`/teams/${teamId}/disqualify`),
@ -69,4 +79,14 @@ export const uploadService = {
},
};
export const userService = {
getProfile: () => api.get<User>('/users/me'),
updateProfile: (data: { name?: string; screenName?: string; avatarUrl?: string }) =>
api.put<User>('/users/me', data),
getLocationHistory: () => api.get<{ totalLocations: number; byGame: { game: { id: string; name: string }; locations: LocationHistory[]; locationCount: number }[] }>('/users/me/location-history'),
getGamesHistory: () => api.get<UserGameHistory[]>('/users/me/games'),
deleteLocationData: () => api.delete('/users/me/location-data'),
deleteAccount: () => api.delete('/users/me/account'),
};
export default api;