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:
Azmog
2026-04-15 16:09:20 +02:00
parent 88f5863cb5
commit bfd35905c9
60 changed files with 2437 additions and 42 deletions
+37
View File
@@ -0,0 +1,37 @@
import axios from 'axios';
import * as SecureStore from 'expo-secure-store';
import { Platform } from 'react-native';
const API_URL = Platform.select({
android: 'http://10.0.2.2:8000/api/v1',
ios: 'http://localhost:8000/api/v1',
default: 'http://localhost:8000/api/v1',
});
const api = axios.create({
baseURL: API_URL,
headers: {
'Content-Type': 'application/json',
Accept: 'application/json',
},
});
api.interceptors.request.use(async (config) => {
const token = await SecureStore.getItemAsync('cesizen_token');
if (token) {
config.headers.Authorization = `Bearer ${token}`;
}
return config;
});
api.interceptors.response.use(
(response) => response,
async (error) => {
if (error.response?.status === 401) {
await SecureStore.deleteItemAsync('cesizen_token');
}
return Promise.reject(error);
}
);
export default api;
+72
View File
@@ -0,0 +1,72 @@
import { create } from 'zustand';
import * as SecureStore from 'expo-secure-store';
import api from './api';
import type { Utilisateur } from '@/types';
interface AuthState {
user: Utilisateur | null;
token: string | null;
isAuthenticated: boolean;
isLoading: boolean;
login: (email: string, password: string) => Promise<void>;
register: (data: {
nom: string;
prenom: string;
email: string;
password: string;
password_confirmation: string;
}) => Promise<void>;
logout: () => Promise<void>;
fetchUser: () => Promise<void>;
loadToken: () => Promise<void>;
}
export const useAuthStore = create<AuthState>()((set) => ({
user: null,
token: null,
isAuthenticated: false,
isLoading: true,
loadToken: async () => {
const token = await SecureStore.getItemAsync('cesizen_token');
if (token) {
set({ token, isAuthenticated: true, isLoading: false });
try {
const response = await api.get('/auth/me');
set({ user: response.data });
} catch {
await SecureStore.deleteItemAsync('cesizen_token');
set({ token: null, isAuthenticated: false, user: null, isLoading: false });
}
} else {
set({ isLoading: false });
}
},
login: async (email, password) => {
const response = await api.post('/auth/login', { email, password });
const { utilisateur, token } = response.data;
await SecureStore.setItemAsync('cesizen_token', token);
set({ user: utilisateur, token, isAuthenticated: true });
},
register: async (data) => {
const response = await api.post('/auth/register', data);
const { utilisateur, token } = response.data;
await SecureStore.setItemAsync('cesizen_token', token);
set({ user: utilisateur, token, isAuthenticated: true });
},
logout: async () => {
try {
await api.post('/auth/logout');
} catch {}
await SecureStore.deleteItemAsync('cesizen_token');
set({ user: null, token: null, isAuthenticated: false });
},
fetchUser: async () => {
const response = await api.get('/auth/me');
set({ user: response.data });
},
}));
+29
View File
@@ -0,0 +1,29 @@
export const Colors = {
primary: '#fce117',
primaryDark: '#e5cc15',
secondary: '#06c656',
secondaryDark: '#05a348',
black: '#000000',
white: '#FFFFFF',
gray: {
50: '#f9fafb',
100: '#f3f4f6',
200: '#e5e7eb',
300: '#d1d5db',
400: '#9ca3af',
500: '#6b7280',
600: '#4b5563',
700: '#374151',
800: '#1f2937',
900: '#111827',
},
emotions: {
joie: '#FFD700',
tristesse: '#4169E1',
colere: '#DC143C',
peur: '#9932CC',
degout: '#228B22',
surprise: '#FF8C00',
amour: '#FF69B4',
},
};