feat: add mobile application structure with emotion picker and API integration
- Added favicon and icon assets for the mobile app. - Implemented EmotionPicker component for selecting emotions with child options. - Created hooks for fetching emotions, feeds, and rapport data. - Established API service for handling requests and authentication. - Integrated Zustand for state management of user authentication. - Defined color palette for the application. - Set up TypeScript types for various entities including User, Emotion, and Feed. - Configured Babel and TypeScript for the mobile project. - Added package.json with necessary dependencies for Expo and React Native.
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import api from '@/lib/api';
|
||||
import type { Emotion } from '@/types';
|
||||
|
||||
export function useEmotions() {
|
||||
return useQuery<Emotion[]>({
|
||||
queryKey: ['emotions'],
|
||||
queryFn: async () => {
|
||||
const response = await api.get('/emotions');
|
||||
return response.data;
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import api from '@/lib/api';
|
||||
import type { Feed } from '@/types';
|
||||
|
||||
export function useFeeds() {
|
||||
return useQuery<Feed[]>({
|
||||
queryKey: ['feeds'],
|
||||
queryFn: async () => {
|
||||
const response = await api.get('/feeds');
|
||||
return response.data.data ?? response.data;
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export function useFeed(slug: string) {
|
||||
return useQuery<Feed>({
|
||||
queryKey: ['feed', slug],
|
||||
queryFn: async () => {
|
||||
const response = await api.get(`/feeds/${slug}`);
|
||||
return response.data;
|
||||
},
|
||||
enabled: !!slug,
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import api from '@/lib/api';
|
||||
import type { RapportData } from '@/types';
|
||||
|
||||
export function useRapport(period: 'week' | 'month' | 'quarter' | 'year') {
|
||||
return useQuery<RapportData>({
|
||||
queryKey: ['rapport', period],
|
||||
queryFn: async () => {
|
||||
const response = await api.get('/tracker/rapports', { params: { period } });
|
||||
return response.data;
|
||||
},
|
||||
enabled: !!period,
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
|
||||
import api from '@/lib/api';
|
||||
import type { SaisieTracker } from '@/types';
|
||||
|
||||
interface SaisieFilters {
|
||||
date_debut?: string;
|
||||
date_fin?: string;
|
||||
emotion_id?: number;
|
||||
}
|
||||
|
||||
export function useSaisies(filters?: SaisieFilters) {
|
||||
return useQuery<SaisieTracker[]>({
|
||||
queryKey: ['saisies', filters],
|
||||
queryFn: async () => {
|
||||
const response = await api.get('/tracker/saisies', { params: filters });
|
||||
return response.data.data ?? response.data;
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export function useCreateSaisie() {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: async (data: {
|
||||
emotion_id: number;
|
||||
intensite: number;
|
||||
note?: string;
|
||||
date_saisie?: string;
|
||||
}) => {
|
||||
const response = await api.post('/tracker/saisies', data);
|
||||
return response.data;
|
||||
},
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: ['saisies'] });
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export function useUpdateSaisie() {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: async ({ id, ...data }: {
|
||||
id: number;
|
||||
emotion_id?: number;
|
||||
intensite?: number;
|
||||
note?: string;
|
||||
date_saisie?: string;
|
||||
}) => {
|
||||
const response = await api.put(`/tracker/saisies/${id}`, data);
|
||||
return response.data;
|
||||
},
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: ['saisies'] });
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export function useDeleteSaisie() {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: async (id: number) => {
|
||||
const response = await api.delete(`/tracker/saisies/${id}`);
|
||||
return response.data;
|
||||
},
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: ['saisies'] });
|
||||
},
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user