Compare commits

..

10 Commits

Author SHA1 Message Date
Yaël Perret
68d7ea3f9a feat : Création de l'api, chargement des mockups 2026-09-01 18:48:41 +02:00
Yaël Perret
fde710b607 feat : Readme 2026-09-01 17:48:44 +02:00
Yaël Perret
bba2e8f51e feat : Ajout de données d'exemples pour travailler sans API 2026-09-01 17:44:03 +02:00
Yaël Perret
d8aa9956d0 feat : Création de toutes les entités 2026-09-01 17:18:28 +02:00
Yaël Perret
d4246aa2c8 fix : Pas besoin de theming 2026-09-01 16:45:11 +02:00
Yaël Perret
6affbef244 fix : Retrait de React Navigation, pas utile pour le projet 2026-09-01 15:49:13 +02:00
Yaël Perret
4290351ca5 feat : ParticipationSegment 2026-09-01 15:22:42 +02:00
Yaël Perret
5a865d5635 feat : Badge et Chip 2026-09-01 14:43:51 +02:00
Yaël Perret
4c74a27f57 feat : Composant Bouton 2026-09-01 14:16:23 +02:00
Yaël Perret
6a060418b4 feat : Librairie de base 2026-08-31 19:17:46 +02:00
119 changed files with 6526 additions and 177 deletions

View File

@@ -1,6 +1,14 @@
# Welcome to your Expo app 👋
# Bahla - On sort où ? Bah là !
This is an [Expo](https://expo.dev) project created with [`create-expo-app`](https://www.npmjs.com/package/create-expo-app).
Ne râtez plus les meilleurs événement prêt de chez vous !
Bahla vous propose différents moyens de vous divertir avec vos potes ou en famille.
## Organisation
### Stratégie d'image
- Utilisation de `expo-image`
- Un placeholder sombre avec des points généré aléatoirement avec un blur
- Dimensions données par le backend
- Image toujours en couverture (object-fit)
## Get started
@@ -23,34 +31,4 @@ In the output, you'll find options to open the app in a
- [iOS simulator](https://docs.expo.dev/workflow/ios-simulator/)
- [Expo Go](https://expo.dev/go), a limited sandbox for trying out app development with Expo
You can start developing by editing the files inside the **app** directory. This project uses [file-based routing](https://docs.expo.dev/router/introduction).
## Get a fresh project
When you're ready, run:
```bash
npm run reset-project
```
This command will move the starter code to the **app-example** directory and create a blank **app** directory where you can start developing.
### Other setup steps
- To set up ESLint for linting, run `npx expo lint`, or follow our guide on ["Using ESLint and Prettier"](https://docs.expo.dev/guides/using-eslint/)
- If you'd like to set up unit testing, follow our guide on ["Unit Testing with Jest"](https://docs.expo.dev/develop/unit-testing/)
- Learn more about the TypeScript setup in this template in our guide on ["Using TypeScript"](https://docs.expo.dev/guides/typescript/)
## Learn more
To learn more about developing your project with Expo, look at the following resources:
- [Expo documentation](https://docs.expo.dev/): Learn fundamentals, or go into advanced topics with our [guides](https://docs.expo.dev/guides).
- [Learn Expo tutorial](https://docs.expo.dev/tutorial/introduction/): Follow a step-by-step tutorial where you'll create a project that runs on Android, iOS, and the web.
## Join the community
Join our community of developers creating universal apps.
- [Expo on GitHub](https://github.com/expo/expo): View our open source platform and contribute.
- [Discord community](https://chat.expo.dev): Chat with Expo users and ask questions.
You can start developing by editing the files inside the **app** directory. This project uses [file-based routing](https://docs.expo.dev/router/introduction).

View File

@@ -1,12 +1,12 @@
{
"expo": {
"name": "bahla_front",
"slug": "bahla_front",
"name": "bahla",
"slug": "bahla",
"version": "1.0.0",
"orientation": "portrait",
"icon": "./assets/images/icon.png",
"scheme": "bahlafront",
"userInterfaceStyle": "automatic",
"scheme": "bahla",
"userInterfaceStyle": "dark",
"ios": {
"icon": "./assets/expo.icon"
},
@@ -18,9 +18,10 @@
"monochromeImage": "./assets/images/android-icon-monochrome.png"
},
"predictiveBackGestureEnabled": false,
"package": "com.anonymous.bahla_front"
"package": "com.anonymous.bahla"
},
"web": {
"bundler": "metro",
"output": "static",
"favicon": "./assets/images/favicon.png"
},
@@ -35,7 +36,9 @@
"imageWidth": 76
}
}
]
],
"expo-image",
"expo-font"
],
"experiments": {
"typedRoutes": true,

9
babel.config.js Normal file
View File

@@ -0,0 +1,9 @@
module.exports = function (api) {
api.cache(true);
return {
presets: [
["babel-preset-expo", { jsxImportSource: "nativewind" }],
"nativewind/babel",
],
};
};

8
metro.config.js Normal file
View File

@@ -0,0 +1,8 @@
// Learn more https://docs.expo.io/guides/customizing-metro
const { getDefaultConfig } = require('expo/metro-config');
const { withNativeWind } = require('nativewind/metro');
/** @type {import('expo/metro-config').MetroConfig} */
const config = getDefaultConfig(__dirname);
module.exports = withNativeWind(config, { input: './src/global.css' })

1
nativewind-env.d.ts vendored Normal file
View File

@@ -0,0 +1 @@
/// <reference types="nativewind/types" />

608
output.css Normal file
View File

@@ -0,0 +1,608 @@
*, ::before, ::after {
--tw-border-spacing-x: 0;
--tw-border-spacing-y: 0;
--tw-translate-x: 0;
--tw-translate-y: 0;
--tw-rotate: 0;
--tw-skew-x: 0;
--tw-skew-y: 0;
--tw-scale-x: 1;
--tw-scale-y: 1;
--tw-pan-x: ;
--tw-pan-y: ;
--tw-pinch-zoom: ;
--tw-scroll-snap-strictness: proximity;
--tw-gradient-from-position: ;
--tw-gradient-via-position: ;
--tw-gradient-to-position: ;
--tw-ordinal: ;
--tw-slashed-zero: ;
--tw-numeric-figure: ;
--tw-numeric-spacing: ;
--tw-numeric-fraction: ;
--tw-ring-inset: ;
--tw-ring-offset-width: 0px;
--tw-ring-offset-color: #fff;
--tw-ring-color: rgb(59 130 246 / 0.5);
--tw-ring-offset-shadow: 0 0 #0000;
--tw-ring-shadow: 0 0 #0000;
--tw-shadow: 0 0 #0000;
--tw-shadow-colored: 0 0 #0000;
--tw-blur: ;
--tw-brightness: ;
--tw-contrast: ;
--tw-grayscale: ;
--tw-hue-rotate: ;
--tw-invert: ;
--tw-saturate: ;
--tw-sepia: ;
--tw-drop-shadow: ;
--tw-backdrop-blur: ;
--tw-backdrop-brightness: ;
--tw-backdrop-contrast: ;
--tw-backdrop-grayscale: ;
--tw-backdrop-hue-rotate: ;
--tw-backdrop-invert: ;
--tw-backdrop-opacity: ;
--tw-backdrop-saturate: ;
--tw-backdrop-sepia: ;
--tw-contain-size: ;
--tw-contain-layout: ;
--tw-contain-paint: ;
--tw-contain-style: ;
}
::backdrop {
--tw-border-spacing-x: 0;
--tw-border-spacing-y: 0;
--tw-translate-x: 0;
--tw-translate-y: 0;
--tw-rotate: 0;
--tw-skew-x: 0;
--tw-skew-y: 0;
--tw-scale-x: 1;
--tw-scale-y: 1;
--tw-pan-x: ;
--tw-pan-y: ;
--tw-pinch-zoom: ;
--tw-scroll-snap-strictness: proximity;
--tw-gradient-from-position: ;
--tw-gradient-via-position: ;
--tw-gradient-to-position: ;
--tw-ordinal: ;
--tw-slashed-zero: ;
--tw-numeric-figure: ;
--tw-numeric-spacing: ;
--tw-numeric-fraction: ;
--tw-ring-inset: ;
--tw-ring-offset-width: 0px;
--tw-ring-offset-color: #fff;
--tw-ring-color: rgb(59 130 246 / 0.5);
--tw-ring-offset-shadow: 0 0 #0000;
--tw-ring-shadow: 0 0 #0000;
--tw-shadow: 0 0 #0000;
--tw-shadow-colored: 0 0 #0000;
--tw-blur: ;
--tw-brightness: ;
--tw-contrast: ;
--tw-grayscale: ;
--tw-hue-rotate: ;
--tw-invert: ;
--tw-saturate: ;
--tw-sepia: ;
--tw-drop-shadow: ;
--tw-backdrop-blur: ;
--tw-backdrop-brightness: ;
--tw-backdrop-contrast: ;
--tw-backdrop-grayscale: ;
--tw-backdrop-hue-rotate: ;
--tw-backdrop-invert: ;
--tw-backdrop-opacity: ;
--tw-backdrop-saturate: ;
--tw-backdrop-sepia: ;
--tw-contain-size: ;
--tw-contain-layout: ;
--tw-contain-paint: ;
--tw-contain-style: ;
}
/*
! tailwindcss v3.4.19 | MIT License | https://tailwindcss.com
*/
/*
1. Prevent padding and border from affecting element width. (https://github.com/mozdevs/cssremedy/issues/4)
2. Allow adding a border to an element by just adding a border-width. (https://github.com/tailwindcss/tailwindcss/pull/116)
*/
*,
::before,
::after {
box-sizing: border-box;
/* 1 */
border-width: 0;
/* 2 */
border-style: solid;
/* 2 */
border-color: #e5e7eb;
/* 2 */
}
::before,
::after {
--tw-content: '';
}
/*
1. Use a consistent sensible line-height in all browsers.
2. Prevent adjustments of font size after orientation changes in iOS.
3. Use a more readable tab size.
4. Use the user's configured `sans` font-family by default.
5. Use the user's configured `sans` font-feature-settings by default.
6. Use the user's configured `sans` font-variation-settings by default.
7. Disable tap highlights on iOS
*/
html,
:host {
line-height: 1.5;
/* 1 */
-webkit-text-size-adjust: 100%;
/* 2 */
-moz-tab-size: 4;
/* 3 */
-o-tab-size: 4;
tab-size: 4;
/* 3 */
font-family: ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
/* 4 */
font-feature-settings: normal;
/* 5 */
font-variation-settings: normal;
/* 6 */
-webkit-tap-highlight-color: transparent;
/* 7 */
}
/*
1. Remove the margin in all browsers.
2. Inherit line-height from `html` so users can set them as a class directly on the `html` element.
*/
body {
margin: 0;
/* 1 */
line-height: inherit;
/* 2 */
}
/*
1. Add the correct height in Firefox.
2. Correct the inheritance of border color in Firefox. (https://bugzilla.mozilla.org/show_bug.cgi?id=190655)
3. Ensure horizontal rules are visible by default.
*/
hr {
height: 0;
/* 1 */
color: inherit;
/* 2 */
border-top-width: 1px;
/* 3 */
}
/*
Add the correct text decoration in Chrome, Edge, and Safari.
*/
abbr:where([title]) {
-webkit-text-decoration: underline dotted;
text-decoration: underline dotted;
}
/*
Remove the default font size and weight for headings.
*/
h1,
h2,
h3,
h4,
h5,
h6 {
font-size: inherit;
font-weight: inherit;
}
/*
Reset links to optimize for opt-in styling instead of opt-out.
*/
a {
color: inherit;
text-decoration: inherit;
}
/*
Add the correct font weight in Edge and Safari.
*/
b,
strong {
font-weight: bolder;
}
/*
1. Use the user's configured `mono` font-family by default.
2. Use the user's configured `mono` font-feature-settings by default.
3. Use the user's configured `mono` font-variation-settings by default.
4. Correct the odd `em` font sizing in all browsers.
*/
code,
kbd,
samp,
pre {
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
/* 1 */
font-feature-settings: normal;
/* 2 */
font-variation-settings: normal;
/* 3 */
font-size: 1em;
/* 4 */
}
/*
Add the correct font size in all browsers.
*/
small {
font-size: 80%;
}
/*
Prevent `sub` and `sup` elements from affecting the line height in all browsers.
*/
sub,
sup {
font-size: 75%;
line-height: 0;
position: relative;
vertical-align: baseline;
}
sub {
bottom: -0.25em;
}
sup {
top: -0.5em;
}
/*
1. Remove text indentation from table contents in Chrome and Safari. (https://bugs.chromium.org/p/chromium/issues/detail?id=999088, https://bugs.webkit.org/show_bug.cgi?id=201297)
2. Correct table border color inheritance in all Chrome and Safari. (https://bugs.chromium.org/p/chromium/issues/detail?id=935729, https://bugs.webkit.org/show_bug.cgi?id=195016)
3. Remove gaps between table borders by default.
*/
table {
text-indent: 0;
/* 1 */
border-color: inherit;
/* 2 */
border-collapse: collapse;
/* 3 */
}
/*
1. Change the font styles in all browsers.
2. Remove the margin in Firefox and Safari.
3. Remove default padding in all browsers.
*/
button,
input,
optgroup,
select,
textarea {
font-family: inherit;
/* 1 */
font-feature-settings: inherit;
/* 1 */
font-variation-settings: inherit;
/* 1 */
font-size: 100%;
/* 1 */
font-weight: inherit;
/* 1 */
line-height: inherit;
/* 1 */
letter-spacing: inherit;
/* 1 */
color: inherit;
/* 1 */
margin: 0;
/* 2 */
padding: 0;
/* 3 */
}
/*
Remove the inheritance of text transform in Edge and Firefox.
*/
button,
select {
text-transform: none;
}
/*
1. Correct the inability to style clickable types in iOS and Safari.
2. Remove default button styles.
*/
button,
input:where([type='button']),
input:where([type='reset']),
input:where([type='submit']) {
-webkit-appearance: button;
/* 1 */
background-color: transparent;
/* 2 */
background-image: none;
/* 2 */
}
/*
Use the modern Firefox focus style for all focusable elements.
*/
:-moz-focusring {
outline: auto;
}
/*
Remove the additional `:invalid` styles in Firefox. (https://github.com/mozilla/gecko-dev/blob/2f9eacd9d3d995c937b4251a5557d95d494c9be1/layout/style/res/forms.css#L728-L737)
*/
:-moz-ui-invalid {
box-shadow: none;
}
/*
Add the correct vertical alignment in Chrome and Firefox.
*/
progress {
vertical-align: baseline;
}
/*
Correct the cursor style of increment and decrement buttons in Safari.
*/
::-webkit-inner-spin-button,
::-webkit-outer-spin-button {
height: auto;
}
/*
1. Correct the odd appearance in Chrome and Safari.
2. Correct the outline style in Safari.
*/
[type='search'] {
-webkit-appearance: textfield;
/* 1 */
outline-offset: -2px;
/* 2 */
}
/*
Remove the inner padding in Chrome and Safari on macOS.
*/
::-webkit-search-decoration {
-webkit-appearance: none;
}
/*
1. Correct the inability to style clickable types in iOS and Safari.
2. Change font properties to `inherit` in Safari.
*/
::-webkit-file-upload-button {
-webkit-appearance: button;
/* 1 */
font: inherit;
/* 2 */
}
/*
Add the correct display in Chrome and Safari.
*/
summary {
display: list-item;
}
/*
Removes the default spacing and border for appropriate elements.
*/
blockquote,
dl,
dd,
h1,
h2,
h3,
h4,
h5,
h6,
hr,
figure,
p,
pre {
margin: 0;
}
fieldset {
margin: 0;
padding: 0;
}
legend {
padding: 0;
}
ol,
ul,
menu {
list-style: none;
margin: 0;
padding: 0;
}
/*
Reset default styling for dialogs.
*/
dialog {
padding: 0;
}
/*
Prevent resizing textareas horizontally by default.
*/
textarea {
resize: vertical;
}
/*
1. Reset the default placeholder opacity in Firefox. (https://github.com/tailwindlabs/tailwindcss/issues/3300)
2. Set the default placeholder color to the user's configured gray 400 color.
*/
input::-moz-placeholder, textarea::-moz-placeholder {
opacity: 1;
/* 1 */
color: #9ca3af;
/* 2 */
}
input::placeholder,
textarea::placeholder {
opacity: 1;
/* 1 */
color: #9ca3af;
/* 2 */
}
/*
Set the default cursor for buttons.
*/
button,
[role="button"] {
cursor: pointer;
}
/*
Make sure disabled buttons don't get the pointer cursor.
*/
:disabled {
cursor: default;
}
/*
1. Make replaced elements `display: block` by default. (https://github.com/mozdevs/cssremedy/issues/14)
2. Add `vertical-align: middle` to align replaced elements more sensibly by default. (https://github.com/jensimmons/cssremedy/issues/14#issuecomment-634934210)
This can trigger a poorly considered lint error in some tools but is included by design.
*/
img,
svg,
video,
canvas,
audio,
iframe,
embed,
object {
display: block;
/* 1 */
vertical-align: middle;
/* 2 */
}
/*
Constrain images and videos to the parent width and preserve their intrinsic aspect ratio. (https://github.com/mozdevs/cssremedy/issues/14)
*/
img,
video {
max-width: 100%;
height: auto;
}
/* Make elements with the HTML hidden attribute stay hidden by default */
[hidden]:where(:not([hidden="until-found"])) {
display: none;
}
:root {
--css-interop-darkMode: media;
--css-interop: true;
--css-interop-nativewind: true;
}
.container {
width: 100%;
}
@media (min-width: 640px) {
.container {
max-width: 640px;
}
}
@media (min-width: 768px) {
.container {
max-width: 768px;
}
}
@media (min-width: 1024px) {
.container {
max-width: 1024px;
}
}
@media (min-width: 1280px) {
.container {
max-width: 1280px;
}
}
@media (min-width: 1536px) {
.container {
max-width: 1536px;
}
}
.flex {
display: flex;
}
.bg-blue-500 {
--tw-bg-opacity: 1;
background-color: rgb(59 130 246 / var(--tw-bg-opacity, 1));
}
.font-bold {
font-weight: 700;
}

1902
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -3,17 +3,23 @@
"main": "expo-router/entry",
"version": "1.0.0",
"dependencies": {
"@expo-google-fonts/inter": "^0.4.2",
"@expo-google-fonts/jetbrains-mono": "^0.4.1",
"@expo-google-fonts/space-grotesk": "^0.4.1",
"@expo/ui": "~56.0.14",
"@react-navigation/elements": "^2.9.19",
"@react-navigation/native": "^7.2.5",
"@react-navigation/native-stack": "^7.16.0",
"@tanstack/react-query": "^5.102.8",
"axios": "^1.20.0",
"babel-preset-expo": "^57.0.9",
"expo": "~56.0.5",
"expo-blur": "~56.0.4",
"expo-constants": "~56.0.16",
"expo-dev-client": "~56.0.16",
"expo-device": "~56.0.4",
"expo-font": "~56.0.5",
"expo-font": "~56.0.7",
"expo-glass-effect": "~56.0.4",
"expo-image": "~56.0.9",
"expo-haptics": "~56.0.3",
"expo-image": "~56.0.12",
"expo-linear-gradient": "~56.0.4",
"expo-linking": "~56.0.12",
"expo-router": "~56.2.7",
"expo-splash-screen": "~56.0.10",
@@ -21,6 +27,10 @@
"expo-symbols": "~56.0.5",
"expo-system-ui": "~56.0.5",
"expo-web-browser": "~56.0.5",
"lucide-react": "^1.38.0",
"lucide-react-native": "^1.38.0",
"nativewind": "^4.2.6",
"prettier-plugin-tailwindcss": "^0.5.14",
"react": "19.2.3",
"react-dom": "19.2.3",
"react-native": "0.85.3",
@@ -28,8 +38,12 @@
"react-native-reanimated": "4.3.1",
"react-native-safe-area-context": "~5.7.0",
"react-native-screens": "4.25.2",
"react-native-svg": "15.15.4",
"react-native-web": "~0.21.0",
"react-native-worklets": "0.8.3"
"react-native-worklets": "0.8.3",
"tailwindcss": "^3.4.19",
"zod": "^4.5.4",
"zustand": "^5.0.15"
},
"devDependencies": {
"@types/react": "~19.2.2",

11
src/api/client.ts Normal file
View File

@@ -0,0 +1,11 @@
import axios from 'axios';
import { API_BASE_URL } from './config';
export const apiClient = axios.create({
baseURL: API_BASE_URL,
timeout: 10000,
headers: {
'Content-Type': 'application/json',
},
});

4
src/api/config.ts Normal file
View File

@@ -0,0 +1,4 @@
export const API_BASE_URL = process.env.EXPO_PUBLIC_API_BASE_URL ?? 'http://localhost:3000';
// Toggle once here to switch all API functions between mocks and real backend.
export const API_USE_MOCKS = (process.env.EXPO_PUBLIC_API_USE_MOCKS ?? 'true') === 'true';

View File

@@ -0,0 +1,9 @@
import type { Animator } from '@/models';
import { mockAnimators } from '@/mocks';
import { createResourceApi } from '../resourceFactory';
export const animatorsApi = createResourceApi<Animator>({
endpoint: 'animators',
mockData: mockAnimators,
resolveMockKey: (item) => item.id,
});

View File

@@ -0,0 +1,9 @@
import { mockCommentLikes } from '@/mocks';
import type { CommentLike } from '@/models';
import { createResourceApi } from '../resourceFactory';
export const comment_likesApi = createResourceApi<CommentLike>({
endpoint: 'comment_likes',
mockData: mockCommentLikes,
resolveMockKey: (item) => `${item.user_id}:${item.comment_id}`,
});

View File

@@ -0,0 +1,9 @@
import type { Comment } from '@/models';
import { mockComments } from '@/mocks';
import { createResourceApi } from '../resourceFactory';
export const commentsApi = createResourceApi<Comment>({
endpoint: 'comments',
mockData: mockComments,
resolveMockKey: (item) => item.id,
});

View File

@@ -0,0 +1,9 @@
import type { EventExternalLink } from '@/models';
import { mockEventExternalLinks } from '@/mocks';
import { createResourceApi } from '../resourceFactory';
export const event_external_linksApi = createResourceApi<EventExternalLink>({
endpoint: 'event_external_links',
mockData: mockEventExternalLinks,
resolveMockKey: (item) => item.id,
});

View File

@@ -0,0 +1,9 @@
import { mockEventHashtags } from '@/mocks';
import type { EventHashtag } from '@/models';
import { createResourceApi } from '../resourceFactory';
export const event_hashtagsApi = createResourceApi<EventHashtag>({
endpoint: 'event_hashtags',
mockData: mockEventHashtags,
resolveMockKey: (item) => `${item.event_id}:${item.hashtag_id}`,
});

View File

@@ -0,0 +1,9 @@
import type { EventImage } from '@/models';
import { mockEventImages } from '@/mocks';
import { createResourceApi } from '../resourceFactory';
export const event_imagesApi = createResourceApi<EventImage>({
endpoint: 'event_images',
mockData: mockEventImages,
resolveMockKey: (item) => item.id,
});

View File

@@ -0,0 +1,9 @@
import type { EventLineup } from '@/models';
import { mockEventLineup } from '@/mocks';
import { createResourceApi } from '../resourceFactory';
export const event_lineupApi = createResourceApi<EventLineup>({
endpoint: 'event_lineup',
mockData: mockEventLineup,
resolveMockKey: (item) => item.id,
});

View File

@@ -0,0 +1,9 @@
import type { EventStatsSnapshot } from '@/models';
import { mockEventStatsSnapshots } from '@/mocks';
import { createResourceApi } from '../resourceFactory';
export const event_stats_snapshotsApi = createResourceApi<EventStatsSnapshot>({
endpoint: 'event_stats_snapshots',
mockData: mockEventStatsSnapshots,
resolveMockKey: (item) => item.id,
});

View File

@@ -0,0 +1,9 @@
import { mockEventThemes } from '@/mocks';
import type { EventTheme } from '@/models';
import { createResourceApi } from '../resourceFactory';
export const event_themesApi = createResourceApi<EventTheme>({
endpoint: 'event_themes',
mockData: mockEventThemes,
resolveMockKey: (item) => `${item.event_id}:${item.theme_id}`,
});

View File

@@ -0,0 +1,9 @@
import type { Event } from '@/models';
import { mockEvents } from '@/mocks';
import { createResourceApi } from '../resourceFactory';
export const eventsApi = createResourceApi<Event>({
endpoint: 'events',
mockData: mockEvents,
resolveMockKey: (item) => item.id,
});

View File

@@ -0,0 +1,9 @@
import type { Hashtag } from '@/models';
import { mockHashtags } from '@/mocks';
import { createResourceApi } from '../resourceFactory';
export const hashtagsApi = createResourceApi<Hashtag>({
endpoint: 'hashtags',
mockData: mockHashtags,
resolveMockKey: (item) => item.id,
});

29
src/api/entities/index.ts Normal file
View File

@@ -0,0 +1,29 @@
export * from './animators';
export * from './comment_likes';
export * from './comments';
export * from './event_external_links';
export * from './event_hashtags';
export * from './event_images';
export * from './event_lineup';
export * from './event_stats_snapshots';
export * from './event_themes';
export * from './events';
export * from './hashtags';
export * from './organizer_members';
export * from './organizer_subscriptions';
export * from './organizers';
export * from './plans';
export * from './post_likes';
export * from './post_media';
export * from './posts';
export * from './search_history';
export * from './social_auth_providers';
export * from './themes';
export * from './tickets';
export * from './user_animator_follows';
export * from './user_event_interactions';
export * from './user_event_shares';
export * from './user_organizer_follows';
export * from './user_theme_preferences';
export * from './users';

View File

@@ -0,0 +1,9 @@
import type { OrganizerMember } from '@/models';
import { mockOrganizerMembers } from '@/mocks';
import { createResourceApi } from '../resourceFactory';
export const organizer_membersApi = createResourceApi<OrganizerMember>({
endpoint: 'organizer_members',
mockData: mockOrganizerMembers,
resolveMockKey: (item) => item.id,
});

View File

@@ -0,0 +1,9 @@
import type { OrganizerSubscription } from '@/models';
import { mockOrganizerSubscriptions } from '@/mocks';
import { createResourceApi } from '../resourceFactory';
export const organizer_subscriptionsApi = createResourceApi<OrganizerSubscription>({
endpoint: 'organizer_subscriptions',
mockData: mockOrganizerSubscriptions,
resolveMockKey: (item) => item.id,
});

View File

@@ -0,0 +1,9 @@
import type { Organizer } from '@/models';
import { mockOrganizers } from '@/mocks';
import { createResourceApi } from '../resourceFactory';
export const organizersApi = createResourceApi<Organizer>({
endpoint: 'organizers',
mockData: mockOrganizers,
resolveMockKey: (item) => item.id,
});

View File

@@ -0,0 +1,9 @@
import type { Plan } from '@/models';
import { mockPlans } from '@/mocks';
import { createResourceApi } from '../resourceFactory';
export const plansApi = createResourceApi<Plan>({
endpoint: 'plans',
mockData: mockPlans,
resolveMockKey: (item) => item.id,
});

View File

@@ -0,0 +1,9 @@
import { mockPostLikes } from '@/mocks';
import type { PostLike } from '@/models';
import { createResourceApi } from '../resourceFactory';
export const post_likesApi = createResourceApi<PostLike>({
endpoint: 'post_likes',
mockData: mockPostLikes,
resolveMockKey: (item) => `${item.user_id}:${item.post_id}`,
});

View File

@@ -0,0 +1,9 @@
import type { PostMedia } from '@/models';
import { mockPostMedia } from '@/mocks';
import { createResourceApi } from '../resourceFactory';
export const post_mediaApi = createResourceApi<PostMedia>({
endpoint: 'post_media',
mockData: mockPostMedia,
resolveMockKey: (item) => item.id,
});

View File

@@ -0,0 +1,9 @@
import type { Post } from '@/models';
import { mockPosts } from '@/mocks';
import { createResourceApi } from '../resourceFactory';
export const postsApi = createResourceApi<Post>({
endpoint: 'posts',
mockData: mockPosts,
resolveMockKey: (item) => item.id,
});

View File

@@ -0,0 +1,9 @@
import type { SearchHistory } from '@/models';
import { mockSearchHistory } from '@/mocks';
import { createResourceApi } from '../resourceFactory';
export const search_historyApi = createResourceApi<SearchHistory>({
endpoint: 'search_history',
mockData: mockSearchHistory,
resolveMockKey: (item) => item.id,
});

View File

@@ -0,0 +1,9 @@
import type { SocialAuthProvider } from '@/models';
import { mockSocialAuthProviders } from '@/mocks';
import { createResourceApi } from '../resourceFactory';
export const social_auth_providersApi = createResourceApi<SocialAuthProvider>({
endpoint: 'social_auth_providers',
mockData: mockSocialAuthProviders,
resolveMockKey: (item) => item.id,
});

View File

@@ -0,0 +1,9 @@
import type { Theme } from '@/models';
import { mockThemes } from '@/mocks';
import { createResourceApi } from '../resourceFactory';
export const themesApi = createResourceApi<Theme>({
endpoint: 'themes',
mockData: mockThemes,
resolveMockKey: (item) => item.id,
});

View File

@@ -0,0 +1,9 @@
import type { Ticket } from '@/models';
import { mockTickets } from '@/mocks';
import { createResourceApi } from '../resourceFactory';
export const ticketsApi = createResourceApi<Ticket>({
endpoint: 'tickets',
mockData: mockTickets,
resolveMockKey: (item) => item.id,
});

View File

@@ -0,0 +1,9 @@
import { mockUserAnimatorFollows } from '@/mocks';
import type { UserAnimatorFollow } from '@/models';
import { createResourceApi } from '../resourceFactory';
export const user_animator_followsApi = createResourceApi<UserAnimatorFollow>({
endpoint: 'user_animator_follows',
mockData: mockUserAnimatorFollows,
resolveMockKey: (item) => `${item.user_id}:${item.animator_id}`,
});

View File

@@ -0,0 +1,9 @@
import { mockUserEventInteractions } from '@/mocks';
import type { UserEventInteraction } from '@/models';
import { createResourceApi } from '../resourceFactory';
export const user_event_interactionsApi = createResourceApi<UserEventInteraction>({
endpoint: 'user_event_interactions',
mockData: mockUserEventInteractions,
resolveMockKey: (item) => `${item.user_id}:${item.event_id}`,
});

View File

@@ -0,0 +1,9 @@
import type { UserEventShare } from '@/models';
import { mockUserEventShares } from '@/mocks';
import { createResourceApi } from '../resourceFactory';
export const user_event_sharesApi = createResourceApi<UserEventShare>({
endpoint: 'user_event_shares',
mockData: mockUserEventShares,
resolveMockKey: (item) => item.id,
});

View File

@@ -0,0 +1,9 @@
import { mockUserOrganizerFollows } from '@/mocks';
import type { UserOrganizerFollow } from '@/models';
import { createResourceApi } from '../resourceFactory';
export const user_organizer_followsApi = createResourceApi<UserOrganizerFollow>({
endpoint: 'user_organizer_follows',
mockData: mockUserOrganizerFollows,
resolveMockKey: (item) => `${item.user_id}:${item.organizer_id}`,
});

View File

@@ -0,0 +1,9 @@
import { mockUserThemePreferences } from '@/mocks';
import type { UserThemePreference } from '@/models';
import { createResourceApi } from '../resourceFactory';
export const user_theme_preferencesApi = createResourceApi<UserThemePreference>({
endpoint: 'user_theme_preferences',
mockData: mockUserThemePreferences,
resolveMockKey: (item) => `${item.user_id}:${item.theme_id}`,
});

View File

@@ -0,0 +1,9 @@
import type { User } from '@/models';
import { mockUsers } from '@/mocks';
import { createResourceApi } from '../resourceFactory';
export const usersApi = createResourceApi<User>({
endpoint: 'users',
mockData: mockUsers,
resolveMockKey: (item) => item.id,
});

33
src/api/index.ts Normal file
View File

@@ -0,0 +1,33 @@
export * from './client';
export * from './config';
export * from './resourceFactory';
export * from './types';
export * from './entities/animators';
export * from './entities/comment_likes';
export * from './entities/comments';
export * from './entities/event_external_links';
export * from './entities/event_hashtags';
export * from './entities/event_images';
export * from './entities/event_lineup';
export * from './entities/event_stats_snapshots';
export * from './entities/event_themes';
export * from './entities/events';
export * from './entities/hashtags';
export * from './entities/organizer_members';
export * from './entities/organizer_subscriptions';
export * from './entities/organizers';
export * from './entities/plans';
export * from './entities/post_likes';
export * from './entities/post_media';
export * from './entities/posts';
export * from './entities/search_history';
export * from './entities/social_auth_providers';
export * from './entities/themes';
export * from './entities/tickets';
export * from './entities/user_animator_follows';
export * from './entities/user_event_interactions';
export * from './entities/user_event_shares';
export * from './entities/user_organizer_follows';
export * from './entities/user_theme_preferences';
export * from './entities/users';

90
src/api/mockStore.ts Normal file
View File

@@ -0,0 +1,90 @@
type KeyResolver<T> = (item: T) => string;
type MockStoreOptions<T> = {
data: T[];
resolveKey: KeyResolver<T>;
};
const clone = <T>(value: T): T => {
if (typeof globalThis.structuredClone === 'function') {
return globalThis.structuredClone(value);
}
return JSON.parse(JSON.stringify(value)) as T;
};
const createMockId = (): string => {
const random = Math.random().toString(16).slice(2, 10).padEnd(8, '0');
return `00000000-0000-4000-8000-${random}`;
};
const ensureHasId = <T>(payload: Partial<T>): Partial<T> => {
if ('id' in payload && typeof payload.id === 'string' && payload.id.length > 0) {
return payload;
}
return {
...payload,
id: createMockId(),
};
};
export const createMockStore = <T>(options: MockStoreOptions<T>) => {
const { resolveKey } = options;
const records = [...options.data];
const findIndex = (id: string): number => records.findIndex((item) => resolveKey(item) === id);
return {
list: async (): Promise<T[]> => clone(records),
get: async (id: string): Promise<T> => {
const index = findIndex(id);
if (index === -1) {
throw new Error(`Mock record not found for id "${id}"`);
}
return clone(records[index]);
},
create: async (payload: Partial<T>): Promise<T> => {
const next = ensureHasId(payload) as T;
records.push(next);
return clone(next);
},
update: async (id: string, payload: Partial<T>): Promise<T> => {
const index = findIndex(id);
if (index === -1) {
throw new Error(`Mock record not found for id "${id}"`);
}
const next = {
...records[index],
...payload,
};
records[index] = next;
return clone(next);
},
patch: async (id: string, payload: Partial<T>): Promise<T> => {
const index = findIndex(id);
if (index === -1) {
throw new Error(`Mock record not found for id "${id}"`);
}
const next = {
...records[index],
...payload,
};
records[index] = next;
return clone(next);
},
remove: async (id: string): Promise<void> => {
const index = findIndex(id);
if (index === -1) {
throw new Error(`Mock record not found for id "${id}"`);
}
records.splice(index, 1);
},
};
};

View File

@@ -0,0 +1,66 @@
import type { AxiosInstance } from 'axios';
import { apiClient } from './client';
import { API_USE_MOCKS } from './config';
import { createMockStore } from './mockStore';
import type { CreatePayload, CrudApi, UpdatePayload } from './types';
type CreateResourceApiOptions<T> = {
endpoint: string;
mockData: T[];
resolveMockKey: (item: T) => string;
client?: AxiosInstance;
useMocks?: boolean;
};
export const createResourceApi = <T>(options: CreateResourceApiOptions<T>): CrudApi<T> => {
const {
endpoint,
mockData,
resolveMockKey,
client = apiClient,
useMocks = API_USE_MOCKS,
} = options;
const mockStore = createMockStore<T>({
data: mockData,
resolveKey: resolveMockKey,
});
if (useMocks) {
return {
list: () => mockStore.list(),
get: (id) => mockStore.get(id),
create: (payload) => mockStore.create(payload),
update: (id, payload) => mockStore.update(id, payload),
patch: (id, payload) => mockStore.patch(id, payload),
remove: (id) => mockStore.remove(id),
};
}
return {
list: async () => {
const response = await client.get<T[]>(`/${endpoint}`);
return response.data;
},
get: async (id: string) => {
const response = await client.get<T>(`/${endpoint}/${id}`);
return response.data;
},
create: async (payload: CreatePayload<T>) => {
const response = await client.post<T>(`/${endpoint}`, payload);
return response.data;
},
update: async (id: string, payload: UpdatePayload<T>) => {
const response = await client.put<T>(`/${endpoint}/${id}`, payload);
return response.data;
},
patch: async (id: string, payload: UpdatePayload<T>) => {
const response = await client.patch<T>(`/${endpoint}/${id}`, payload);
return response.data;
},
remove: async (id: string) => {
await client.delete(`/${endpoint}/${id}`);
},
};
};

13
src/api/types.ts Normal file
View File

@@ -0,0 +1,13 @@
export type EntityWithId = { id: string };
export type CreatePayload<T> = Partial<T>;
export type UpdatePayload<T> = Partial<T>;
export type CrudApi<T> = {
list: () => Promise<T[]>;
get: (id: string) => Promise<T>;
create: (payload: CreatePayload<T>) => Promise<T>;
update: (id: string, payload: UpdatePayload<T>) => Promise<T>;
patch: (id: string, payload: UpdatePayload<T>) => Promise<T>;
remove: (id: string) => Promise<void>;
};

View File

@@ -1,5 +1,19 @@
import { Stack } from "expo-router";
import { QueryClientProvider } from '@tanstack/react-query';
import { Stack } from 'expo-router';
import { queryClient } from '../hooks/queryClient';
import { useAppFonts } from '../theme/typography';
export default function RootLayout() {
return <Stack />;
const [fontsLoaded] = useAppFonts();
if (!fontsLoaded) {
return null;
}
return (
<QueryClientProvider client={queryClient}>
<Stack />
</QueryClientProvider>
);
}

View File

@@ -1,17 +1,228 @@
import { Text, View, StyleSheet } from "react-native";
import { ArrowUp, ArrowUpRight, Plus } from 'lucide-react-native';
import { useCallback, useMemo, useState } from 'react';
import { ScrollView, StyleSheet, Text, View } from 'react-native';
import { Badge } from '@/components/Badge';
import { Button } from '@/components/Button';
import { ParticipationSegment } from '@/components/ParticipationSegment';
import { ThemeChip } from '@/components/ThemeChip';
import { colors } from '@/theme/colors';
import { spacing } from '@/theme/spacing';
import { typography } from '@/theme/typography';
import '../global.css';
export default function Index() {
const [selectedThemes, setSelectedThemes] = useState<string[]>(['Soirée', 'Techno', 'Festival']);
const themeOptions = useMemo(
() => ['Soirée', 'Techno', 'Festival', 'Fête de jeunesse', 'Concert', 'Bal', 'Afterwork', 'Gratuit'],
[],
);
const simulateSubmit = useCallback(async () => {
await new Promise<void>((resolve) => {
setTimeout(resolve, 1300);
});
}, []);
const handleThemeSelect = useCallback((value: string, nextSelected: boolean) => {
setSelectedThemes((prev) => {
if (nextSelected) {
if (prev.includes(value)) {
return prev;
}
return [...prev, value];
}
return prev.filter((theme) => theme !== value);
});
}, []);
return (
<View style={styles.container}>
<Text>Edit src/app/index.tsx to edit this screen.</Text>
<View style={[styles.screen, { backgroundColor: colors.deepBackground }]}>
<ScrollView
contentContainerStyle={[
styles.content,
{
padding: spacing[24],
gap: spacing[24],
},
]}
showsVerticalScrollIndicator={false}
>
<View style={{ gap: spacing[8] }}>
<Text
style={[
typography.sectionLabel,
{
color: colors.textSecondary,
letterSpacing: 1.1,
},
]}
>
BOUTONS · HAUTEUR 52 PX · RAYON 14 PX
</Text>
</View>
<View style={styles.row}>
<View style={styles.cell}>
<Button label="Publier" variant="primary" />
<Text style={[styles.caption, typography.digits, { color: colors.textSecondary }]}>Primaire</Text>
</View>
<View style={styles.cell}>
<Button label="Publier" variant="primary" />
<Text style={[styles.caption, typography.digits, { color: colors.textSecondary }]}>Pressé (tap)</Text>
</View>
</View>
<View style={styles.row}>
<View style={styles.cell}>
<Button label="Intéressé" variant="secondary" rightIcon={ArrowUpRight} />
<Text style={[styles.caption, typography.digits, { color: colors.textSecondary }]}>Secondaire</Text>
</View>
<View style={styles.cell}>
<Button label="Publier" variant="primary" disabled />
<Text style={[styles.caption, typography.digits, { color: colors.textSecondary }]}>Désactivé</Text>
</View>
</View>
<View style={styles.row}>
<View style={styles.cell}>
<Button label="Tout voir" variant="ghost" fullWidth={false} style={styles.autoWidthButton} />
<Text style={[styles.caption, typography.digits, { color: colors.textSecondary }]}>Texte</Text>
</View>
<View style={styles.cell}>
<Button label="Envoyer" variant="primary" autoLoading loadingLabel="Envoi..." onPress={simulateSubmit} />
<Text style={[styles.caption, typography.digits, { color: colors.textSecondary }]}>Chargement</Text>
</View>
</View>
<View style={styles.row}>
<View style={styles.cell}>
<Button label="Supprimer" variant="destructive" />
<Text style={[styles.caption, typography.digits, { color: colors.textSecondary }]}>Destructif</Text>
</View>
<View style={styles.cell}>
<View style={styles.iconRow}>
<Button
iconOnly
variant="secondary"
fullWidth={false}
icon={ArrowUp}
iconOnlyShape="default"
accessibilityLabel="Partager"
/>
<Button
iconOnly
variant="primary"
fullWidth={false}
icon={Plus}
iconOnlyShape="round"
accessibilityLabel="Ajouter"
/>
</View>
<Text style={[styles.caption, typography.digits, { color: colors.textSecondary }]}>Icône / FAB</Text>
</View>
</View>
<View style={{ gap: spacing[12] }}>
<Text style={[typography.sectionLabel, { color: colors.textSecondary, letterSpacing: 1.1 }]}>PARTICIPATION</Text>
<View style={{ gap: spacing[12] }}>
<ParticipationSegment defaultValue={{ going: false, interested: false }} />
<ParticipationSegment defaultValue={{ going: true, interested: true }} />
</View>
</View>
<View style={{ gap: spacing[12] }}>
<Text style={[typography.sectionLabel, { color: colors.textSecondary, letterSpacing: 1.1 }]}>BADGES</Text>
<View style={styles.badgeWrap}>
<Badge variant="verified" />
<Badge variant="free" />
<Badge variant="complete" />
<Badge variant="tonight" />
<Badge variant="pro" />
<Badge variant="draft" />
<Badge date={{ day: '04', month: 'sept' }} />
</View>
</View>
<View style={{ gap: spacing[12] }}>
<Text style={[typography.sectionLabel, { color: colors.textSecondary, letterSpacing: 1.1 }]}>CHIPS DE THÈME · CAPSULE 34 PX</Text>
<View style={styles.chipWrap}>
<ThemeChip label="Soirée" selected selectedVariant="gradient" showCross={false} />
<ThemeChip label="Festival" selected selectedVariant="accent" />
<ThemeChip label="Fête de jeunesse" />
<ThemeChip label="Concert" />
<ThemeChip label="Bal" />
<ThemeChip label="Techno" />
<ThemeChip label="Afterwork" />
<ThemeChip label="Gratuit" selected selectedVariant="accent" showRemoveIcon={false} />
</View>
</View>
<View style={{ gap: spacing[12] }}>
<Text style={[typography.sectionLabel, { color: colors.textSecondary, letterSpacing: 1.1 }]}>THÈMES · MULTI-SÉLECTION</Text>
<View style={styles.chipWrap}>
{themeOptions.map((theme) => {
const selected = selectedThemes.includes(theme);
return (
<ThemeChip
key={theme}
label={theme}
value={theme}
selected={selected}
selectedVariant={theme === 'Soirée' ? 'gradient' : 'accent'}
onSelect={handleThemeSelect}
/>
);
})}
</View>
</View>
</ScrollView>
</View>
);
}
const styles = StyleSheet.create({
container: {
screen: {
flex: 1,
alignItems: "center",
justifyContent: "center",
},
content: {
paddingBottom: 40,
},
row: {
flexDirection: 'row',
gap: 14,
},
cell: {
flex: 1,
gap: 10,
},
caption: {
textAlign: 'center',
},
iconRow: {
flexDirection: 'row',
justifyContent: 'center',
gap: 12,
},
autoWidthButton: {
alignSelf: 'center',
width: 140,
},
badgeWrap: {
flexDirection: 'row',
flexWrap: 'wrap',
gap: 12,
alignItems: 'center',
},
chipWrap: {
flexDirection: 'row',
flexWrap: 'wrap',
gap: 10,
alignItems: 'center',
},
});

245
src/components/Badge.tsx Normal file
View File

@@ -0,0 +1,245 @@
import { Check, type LucideIcon } from 'lucide-react-native';
import { useEffect, useMemo, useRef } from 'react';
import {
Animated,
StyleSheet,
Text,
View,
type StyleProp,
type TextStyle,
type ViewStyle,
} from 'react-native';
import { colors } from '@/theme/colors';
import { borderRadius } from '@/theme/spacing';
import { typography } from '@/theme/typography';
export type BadgeVariant = 'verified' | 'tonight' | 'free' | 'complete' | 'draft' | 'pro' | 'date';
export type BadgeDate = {
day: string;
month: string;
};
type BadgeProps = {
variant?: BadgeVariant;
label?: string;
icon?: LucideIcon;
date?: BadgeDate;
compact?: boolean;
style?: StyleProp<ViewStyle>;
textStyle?: StyleProp<TextStyle>;
};
const DEFAULT_LABELS: Record<BadgeVariant, string> = {
verified: 'Vérifié',
tonight: 'Ce soir',
free: 'Gratuit',
complete: 'Complet',
draft: 'Brouillon',
pro: 'Pro',
date: 'Date',
};
export function Badge({
variant = 'verified',
label,
icon,
date,
compact = true,
style,
textStyle,
}: BadgeProps) {
const pulse = useRef(new Animated.Value(1)).current;
useEffect(() => {
if (variant !== 'tonight') {
return;
}
const animation = Animated.loop(
Animated.sequence([
Animated.timing(pulse, {
toValue: 1.04,
duration: 640,
useNativeDriver: true,
}),
Animated.timing(pulse, {
toValue: 0.98,
duration: 640,
useNativeDriver: true,
}),
]),
);
animation.start();
return () => animation.stop();
}, [pulse, variant]);
const config = useMemo(() => {
if (variant === 'verified') {
return {
backgroundColor: 'rgba(40, 224, 240, 0.12)',
borderColor: 'rgba(40, 224, 240, 0.6)',
textColor: '#A9F4FF',
};
}
if (variant === 'tonight') {
return {
backgroundColor: 'rgba(255, 46, 136, 0.18)',
borderColor: 'rgba(255, 46, 136, 0.7)',
textColor: '#FFD0E3',
};
}
if (variant === 'free') {
return {
backgroundColor: colors.successSoft,
borderColor: colors.successBorder,
textColor: '#A6F5CD',
};
}
if (variant === 'complete') {
return {
backgroundColor: 'rgba(255, 255, 255, 0.06)',
borderColor: 'rgba(255, 255, 255, 0.12)',
textColor: '#F4F5FA',
};
}
if (variant === 'draft') {
return {
backgroundColor: colors.warningSoft,
borderColor: 'rgba(255, 196, 120, 0.55)',
textColor: '#FFE0AE',
};
}
if (variant === 'pro') {
return {
backgroundColor: colors.secondarySoft,
borderColor: 'rgba(123, 61, 255, 0.55)',
textColor: '#DCCBFF',
};
}
return {
backgroundColor: 'rgba(255, 255, 255, 0.04)',
borderColor: 'rgba(255, 255, 255, 0.12)',
textColor: colors.textPrimary,
};
}, [colors, variant]);
if (variant === 'date' || date) {
const day = date?.day ?? '04';
const month = date?.month ?? 'sept';
return (
<View
style={[
styles.dateBadge,
{
backgroundColor: 'rgba(255, 255, 255, 0.02)',
borderColor: 'rgba(255, 255, 255, 0.12)',
},
style,
]}
>
<Text
style={[
styles.dateDay,
{
color: '#F5F7FF',
},
]}
>
{day}
</Text>
<Text
style={[
styles.dateMonth,
{
color: '#DFE3F2',
},
]}
>
{month}
</Text>
</View>
);
}
const Icon = icon ?? (variant === 'verified' ? Check : undefined);
const resolvedLabel = (label ?? DEFAULT_LABELS[variant] ?? '').toUpperCase();
const badgeStyle: ViewStyle = {
backgroundColor: config.backgroundColor,
borderColor: config.borderColor,
borderWidth: 1,
borderRadius: borderRadius.chip,
paddingHorizontal: compact ? 12 : 16,
paddingVertical: compact ? 8 : 10,
minHeight: compact ? 30 : 34,
alignSelf: 'flex-start',
justifyContent: 'center',
flexDirection: 'row',
alignItems: 'center',
gap: 6,
...(variant === 'tonight'
? { shadowColor: '#FF2E88', shadowOffset: { width: 0, height: 0 }, shadowOpacity: 0.45, shadowRadius: 12, elevation: 6 }
: {}),
};
const textStyleResolved: TextStyle = {
color: config.textColor,
...typography.badge,
letterSpacing: 1.45,
opacity: 1,
fontWeight: '600',
};
return (
<Animated.View
style={[
badgeStyle,
variant === 'tonight' ? { transform: [{ scale: pulse }] } : null,
style,
]}
>
{Icon ? <Icon color={config.textColor} size={12} strokeWidth={2.5} /> : null}
<Text style={[textStyleResolved, textStyle]}>{resolvedLabel}</Text>
</Animated.View>
);
}
const styles = StyleSheet.create({
dateBadge: {
width: 54,
aspectRatio: 1,
borderRadius: 14,
borderWidth: 1,
alignItems: 'center',
justifyContent: 'center',
overflow: 'hidden',
paddingVertical: 6,
},
dateDay: {
fontFamily: 'SpaceGrotesk_700Bold',
fontSize: 18,
lineHeight: 20,
letterSpacing: -0.24,
textAlign: 'center',
},
dateMonth: {
fontFamily: 'JetBrainsMono_500Medium',
fontSize: 9,
lineHeight: 10,
letterSpacing: 1.2,
textAlign: 'center',
textTransform: 'uppercase',
marginTop: 1,
},
});

263
src/components/Button.tsx Normal file
View File

@@ -0,0 +1,263 @@
import { LinearGradient } from 'expo-linear-gradient';
import type { LucideIcon } from 'lucide-react-native';
import { useCallback, useMemo, useState } from 'react';
import {
ActivityIndicator,
type GestureResponderEvent,
Pressable,
type StyleProp,
StyleSheet,
Text,
type TextStyle,
View,
type ViewStyle,
} from 'react-native';
import Animated, { useAnimatedStyle, useSharedValue, withTiming } from 'react-native-reanimated';
import { colors, gradientDirection, gradients } from '@/theme/colors';
import { borderRadius } from '@/theme/spacing';
import { typography } from '@/theme/typography';
const BUTTON_HEIGHT = 52;
const PRESSED_SCALE = 0.97;
const AnimatedPressable = Animated.createAnimatedComponent(Pressable);
type ButtonVariant = 'primary' | 'secondary' | 'ghost' | 'destructive';
type IconOnlyShape = 'round' | 'default';
type ButtonProps = {
label?: string;
variant?: ButtonVariant;
disabled?: boolean;
loading?: boolean;
loadingLabel?: string;
autoLoading?: boolean;
iconOnly?: boolean;
iconOnlyShape?: IconOnlyShape;
icon?: LucideIcon;
leftIcon?: LucideIcon;
rightIcon?: LucideIcon;
iconSize?: number;
iconStrokeWidth?: number;
fullWidth?: boolean;
onPress?: (event: GestureResponderEvent) => void | Promise<void>;
style?: StyleProp<ViewStyle>;
textStyle?: StyleProp<TextStyle>;
accessibilityLabel?: string;
testID?: string;
};
export function Button({
label,
variant = 'primary',
disabled = false,
loading = false,
loadingLabel,
autoLoading = false,
iconOnly = false,
iconOnlyShape = 'round',
icon,
leftIcon,
rightIcon,
iconSize = 20,
iconStrokeWidth = 2,
fullWidth = true,
onPress,
style,
textStyle,
accessibilityLabel,
testID,
}: ButtonProps) {
const [internalLoading, setInternalLoading] = useState(false);
const [isPressed, setIsPressed] = useState(false);
const isLoading = loading || internalLoading;
const isDisabled = disabled || isLoading;
const scale = useSharedValue(1);
const animatedStyle = useAnimatedStyle(() => ({
transform: [{ scale: scale.value }],
}));
const handlePressIn = useCallback(() => {
if (isDisabled) {
return;
}
setIsPressed(true);
scale.value = withTiming(PRESSED_SCALE, { duration: 120 });
}, [isDisabled, scale]);
const handlePressOut = useCallback(() => {
setIsPressed(false);
scale.value = withTiming(1, { duration: 140 });
}, [scale]);
const handlePress = useCallback(
async (event: GestureResponderEvent) => {
if (!onPress || isDisabled) {
return;
}
const result = onPress(event);
if (!autoLoading || !(result instanceof Promise)) {
return;
}
setInternalLoading(true);
try {
await result;
} finally {
setInternalLoading(false);
}
},
[autoLoading, isDisabled, onPress],
);
const labelColor = useMemo(() => {
if (isDisabled) {
return colors.textDisabled;
}
if (variant === 'primary') {
return colors.textPrimary;
}
if (variant === 'destructive') {
return colors.danger;
}
if (variant === 'ghost') {
return colors.tertiary;
}
return colors.textPrimary;
}, [colors, isDisabled, variant]);
const loadingColor = variant === 'primary' && !isDisabled ? colors.textPrimary : labelColor;
const iconOnlyRadius = iconOnlyShape === 'round' ? BUTTON_HEIGHT / 2 : borderRadius.button;
const sideIconColor = !isDisabled && variant === 'secondary' ? colors.tertiary : labelColor;
const iconOnlyColor = labelColor;
const IconOnly = icon;
const LeftIcon = leftIcon;
const RightIcon = rightIcon;
const containerStyle: ViewStyle = {
width: fullWidth && !iconOnly ? '100%' : BUTTON_HEIGHT,
height: BUTTON_HEIGHT,
borderRadius: iconOnly ? iconOnlyRadius : borderRadius.button,
overflow: 'hidden',
};
const baseFillStyle: ViewStyle = {
flex: 1,
alignItems: 'center',
justifyContent: 'center',
flexDirection: 'row',
gap: 8,
borderRadius: iconOnly ? iconOnlyRadius : borderRadius.button,
};
const variantFillStyle: ViewStyle = (() => {
if (isDisabled) {
return {
backgroundColor: colors.surface,
borderWidth: 1,
borderColor: colors.border,
};
}
if (variant === 'secondary') {
return {
backgroundColor: colors.surfaceElevated,
borderWidth: 1,
borderColor: colors.border,
};
}
if (variant === 'ghost') {
return {
backgroundColor: 'transparent',
};
}
if (variant === 'destructive') {
return {
backgroundColor: 'rgba(255, 77, 109, 0.08)',
borderWidth: 1,
borderColor: colors.danger,
};
}
return {
backgroundColor: colors.surface,
};
})();
const contentPaddingStyle: ViewStyle = {
paddingHorizontal: iconOnly ? 0 : 24,
};
const textStyles: TextStyle = {
...typography.button,
color: labelColor,
};
const content = (
<>
{isLoading ? <ActivityIndicator color={loadingColor} size="small" /> : null}
{!isLoading && iconOnly && IconOnly ? (
<IconOnly color={iconOnlyColor} size={iconSize} strokeWidth={iconStrokeWidth} />
) : null}
{!iconOnly && !isLoading && LeftIcon ? (
<LeftIcon color={sideIconColor} size={iconSize} strokeWidth={iconStrokeWidth} />
) : null}
{!iconOnly && label ? <Text style={[textStyles, textStyle]}>{isLoading && loadingLabel ? loadingLabel : label}</Text> : null}
{!iconOnly && !isLoading && RightIcon ? (
<RightIcon color={sideIconColor} size={iconSize} strokeWidth={iconStrokeWidth} />
) : null}
</>
);
const fillNode =
variant === 'primary' && !isDisabled ? (
<LinearGradient
colors={isPressed ? gradients.signaturePressed : gradients.signature}
start={gradientDirection.start}
end={gradientDirection.end}
style={[baseFillStyle, contentPaddingStyle]}
>
{content}
</LinearGradient>
) : (
<View style={[baseFillStyle, contentPaddingStyle, variantFillStyle]}>{content}</View>
);
return (
<AnimatedPressable
testID={testID}
accessibilityRole="button"
accessibilityState={{ disabled: isDisabled, busy: isLoading }}
accessibilityLabel={accessibilityLabel ?? label}
disabled={isDisabled}
onPress={handlePress}
onPressIn={handlePressIn}
onPressOut={handlePressOut}
style={[styles.root, containerStyle, animatedStyle, style]}
>
{fillNode}
</AnimatedPressable>
);
}
export default Button;
const styles = StyleSheet.create({
root: {
alignSelf: 'stretch',
},
});

View File

@@ -0,0 +1,373 @@
import * as Haptics from 'expo-haptics';
import { LinearGradient } from 'expo-linear-gradient';
import { Check, Heart } from 'lucide-react-native';
import { useCallback, useEffect, useMemo, useState } from 'react';
import {
ActivityIndicator,
Pressable,
StyleSheet,
Text,
View,
type StyleProp,
type ViewStyle,
} from 'react-native';
import Animated, {
Easing,
interpolate,
useAnimatedStyle,
useSharedValue,
withTiming,
} from 'react-native-reanimated';
import { colors, glow, gradientDirection, gradients } from '@/theme/colors';
import { borderRadius } from '@/theme/spacing';
import { typography } from '@/theme/typography';
type ParticipationValue = {
going: boolean;
interested: boolean;
};
type ParticipationSegmentProps = {
value?: ParticipationValue;
defaultValue?: Partial<ParticipationValue>;
onChange?: (nextValue: ParticipationValue) => void;
onToggleGoing?: (nextGoing: boolean) => void;
onToggleInterested?: (nextInterested: boolean) => void;
disabled?: boolean;
loadingGoing?: boolean;
loadingInterested?: boolean;
style?: StyleProp<ViewStyle>;
testID?: string;
};
const BUTTON_HEIGHT = 52;
const TRANSITION_DURATION = 180;
const ICON_SIZE = 16;
const SPINNER_SIZE = 18;
const AnimatedView = Animated.createAnimatedComponent(View);
export function ParticipationSegment({
value,
defaultValue,
onChange,
onToggleGoing,
onToggleInterested,
disabled = false,
loadingGoing = false,
loadingInterested = false,
style,
testID,
}: ParticipationSegmentProps) {
const [internalValue, setInternalValue] = useState<ParticipationValue>({
going: defaultValue?.going ?? false,
interested: defaultValue?.interested ?? false,
});
const resolvedValue = value ?? internalValue;
const goingProgress = useSharedValue(resolvedValue.going ? 1 : 0);
const interestedProgress = useSharedValue(resolvedValue.interested ? 1 : 0);
useEffect(() => {
goingProgress.value = withTiming(resolvedValue.going ? 1 : 0, {
duration: TRANSITION_DURATION,
easing: Easing.out(Easing.cubic),
});
}, [goingProgress, resolvedValue.going]);
useEffect(() => {
interestedProgress.value = withTiming(resolvedValue.interested ? 1 : 0, {
duration: TRANSITION_DURATION,
easing: Easing.out(Easing.cubic),
});
}, [interestedProgress, resolvedValue.interested]);
const commitChange = useCallback(
(nextValue: ParticipationValue) => {
if (!value) {
setInternalValue(nextValue);
}
onChange?.(nextValue);
},
[onChange, value],
);
const emitHaptic = useCallback(async (nextSelected: boolean) => {
try {
if (nextSelected) {
await Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Medium);
return;
}
await Haptics.selectionAsync();
} catch {
// Haptics can fail on unsupported devices, the toggle should still work.
}
}, []);
const handleToggleGoing = useCallback(async () => {
if (disabled || loadingGoing) {
return;
}
const nextGoing = !resolvedValue.going;
const nextValue = {
...resolvedValue,
going: nextGoing,
};
await emitHaptic(nextGoing);
commitChange(nextValue);
onToggleGoing?.(nextGoing);
}, [commitChange, disabled, emitHaptic, loadingGoing, onToggleGoing, resolvedValue]);
const handleToggleInterested = useCallback(async () => {
if (disabled || loadingInterested) {
return;
}
const nextInterested = !resolvedValue.interested;
const nextValue = {
...resolvedValue,
interested: nextInterested,
};
await emitHaptic(nextInterested);
commitChange(nextValue);
onToggleInterested?.(nextInterested);
}, [commitChange, disabled, emitHaptic, loadingInterested, onToggleInterested, resolvedValue]);
const goingGlowStyle = useAnimatedStyle(() => ({
shadowOpacity: interpolate(goingProgress.value, [0, 1], [glow.primary.shadowOpacity ?? 0, 0]),
elevation: interpolate(goingProgress.value, [0, 1], [glow.primary.elevation ?? 0, 0]),
}));
const goingIdleLayerStyle = useAnimatedStyle(() => ({
opacity: interpolate(goingProgress.value, [0, 1], [1, 0]),
}));
const goingSelectedLayerStyle = useAnimatedStyle(() => ({
opacity: interpolate(goingProgress.value, [0, 1], [0, 1]),
}));
const interestedIdleLayerStyle = useAnimatedStyle(() => ({
opacity: interpolate(interestedProgress.value, [0, 1], [1, 0]),
}));
const interestedSelectedLayerStyle = useAnimatedStyle(() => ({
opacity: interpolate(interestedProgress.value, [0, 1], [0, 1]),
}));
const goingAccessibilityLabel = useMemo(
() => (resolvedValue.going ? 'Se desinscrire de la participation' : 'Participer a cet evenement'),
[resolvedValue.going],
);
const interestedAccessibilityLabel = useMemo(
() =>
resolvedValue.interested
? 'Retirer ce marqueur interesse'
: 'Marquer cet evenement comme interesse',
[resolvedValue.interested],
);
const buttonRadius = borderRadius.button;
return (
<View style={[styles.row, style]} testID={testID}>
<AnimatedView
style={[
styles.buttonShell,
{
borderRadius: buttonRadius,
shadowColor: glow.primary.shadowColor,
shadowOffset: glow.primary.shadowOffset,
shadowRadius: glow.primary.shadowRadius,
},
!disabled ? goingGlowStyle : null,
]}
>
<Pressable
onPress={handleToggleGoing}
disabled={disabled || loadingGoing}
accessibilityRole="button"
accessibilityState={{ selected: resolvedValue.going, disabled: disabled || loadingGoing, busy: loadingGoing }}
accessibilityLabel={goingAccessibilityLabel}
style={styles.pressable}
>
{disabled ? (
<View
style={[
styles.layer,
{
borderRadius: buttonRadius,
backgroundColor: colors.surfaceElevated,
borderColor: colors.border,
borderWidth: 1.5,
opacity: 0.45,
},
]}
>
<Check color={colors.textDisabled} size={ICON_SIZE} strokeWidth={2} />
<Text style={[typography.button, { color: colors.textDisabled }]}>Je participe</Text>
</View>
) : (
<>
<AnimatedView style={[styles.layer, { borderRadius: buttonRadius }, goingIdleLayerStyle]}>
<LinearGradient
colors={gradients.signature}
start={gradientDirection.start}
end={gradientDirection.end}
style={[styles.fill, { borderRadius: buttonRadius }]}
>
{loadingGoing ? (
<ActivityIndicator size={SPINNER_SIZE} color={colors.textPrimary} />
) : (
<>
<Check color={colors.textPrimary} size={ICON_SIZE} strokeWidth={2} />
<Text style={[typography.button, { color: colors.textPrimary }]}>Je participe</Text>
</>
)}
</LinearGradient>
</AnimatedView>
<AnimatedView style={[styles.layer, { borderRadius: buttonRadius }, goingSelectedLayerStyle]}>
<View
style={[
styles.fill,
{
borderRadius: buttonRadius,
backgroundColor: colors.successSoft,
borderWidth: 1.5,
borderColor: colors.successBorder,
},
]}
>
{loadingGoing ? (
<ActivityIndicator size={SPINNER_SIZE} color={colors.success} />
) : (
<>
<Check color={colors.success} size={ICON_SIZE} strokeWidth={2} />
<Text style={[typography.button, { color: colors.success }]}>Inscrit</Text>
</>
)}
</View>
</AnimatedView>
</>
)}
</Pressable>
</AnimatedView>
<View style={[styles.buttonShell, { borderRadius: buttonRadius }]}>
<Pressable
onPress={handleToggleInterested}
disabled={disabled || loadingInterested}
accessibilityRole="button"
accessibilityState={{ selected: resolvedValue.interested, disabled: disabled || loadingInterested, busy: loadingInterested }}
accessibilityLabel={interestedAccessibilityLabel}
style={styles.pressable}
>
{disabled ? (
<View
style={[
styles.layer,
{
borderRadius: buttonRadius,
backgroundColor: colors.surfaceElevated,
borderColor: colors.border,
borderWidth: 1.5,
opacity: 0.45,
},
]}
>
<Heart color={colors.textDisabled} size={ICON_SIZE} strokeWidth={1.7} />
<Text style={[typography.button, { color: colors.textDisabled }]}>Interesse</Text>
</View>
) : (
<>
<AnimatedView style={[styles.layer, { borderRadius: buttonRadius }, interestedIdleLayerStyle]}>
<View
style={[
styles.fill,
{
borderRadius: buttonRadius,
backgroundColor: colors.surfaceElevated,
borderWidth: 1.5,
borderColor: colors.border,
},
]}
>
{loadingInterested ? (
<ActivityIndicator size={SPINNER_SIZE} color={colors.textPrimary} />
) : (
<>
<Heart color={colors.textPrimary} size={ICON_SIZE} strokeWidth={1.7} fill="none" />
<Text style={[typography.button, { color: colors.textPrimary }]}>Interesse</Text>
</>
)}
</View>
</AnimatedView>
<AnimatedView style={[styles.layer, { borderRadius: buttonRadius }, interestedSelectedLayerStyle]}>
<View
style={[
styles.fill,
{
borderRadius: buttonRadius,
backgroundColor: colors.primarySoft,
borderWidth: 1.5,
borderColor: colors.primaryBorder,
},
]}
>
{loadingInterested ? (
<ActivityIndicator size={SPINNER_SIZE} color={colors.primary} />
) : (
<>
<Heart color={colors.primary} size={ICON_SIZE} strokeWidth={0} fill={colors.primary} />
<Text style={[typography.button, { color: colors.primary }]}>Interesse</Text>
</>
)}
</View>
</AnimatedView>
</>
)}
</Pressable>
</View>
</View>
);
}
export type { ParticipationSegmentProps, ParticipationValue };
export default ParticipationSegment;
const styles = StyleSheet.create({
row: {
flexDirection: 'row',
gap: 12,
alignItems: 'center',
},
buttonShell: {
flex: 1,
height: BUTTON_HEIGHT,
overflow: 'hidden',
},
pressable: {
flex: 1,
},
layer: {
...StyleSheet.absoluteFill,
},
fill: {
flex: 1,
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'center',
gap: 8,
},
});

View File

@@ -0,0 +1,132 @@
import { LinearGradient } from 'expo-linear-gradient';
import { X } from 'lucide-react-native';
import { useCallback } from 'react';
import {
Pressable,
type StyleProp,
StyleSheet,
Text,
type TextStyle,
View,
type ViewStyle,
} from 'react-native';
import { colors, gradientDirection, gradients } from '@/theme/colors';
import { borderRadius } from '@/theme/spacing';
import { typography } from '@/theme/typography';
export type ThemeChipSelectedVariant = 'gradient' | 'accent';
export type ThemeChipProps = {
label: string;
value?: string;
selected?: boolean;
selectedVariant?: ThemeChipSelectedVariant;
disabled?: boolean;
showCross?: boolean;
showRemoveIcon?: boolean;
onSelect?: (value: string, nextSelected: boolean) => void;
style?: StyleProp<ViewStyle>;
textStyle?: StyleProp<TextStyle>;
testID?: string;
accessibilityLabel?: string;
};
const CHIP_HEIGHT = 34;
export function ThemeChip({
label,
value,
selected = false,
selectedVariant = 'accent',
disabled = false,
showCross,
showRemoveIcon = true,
onSelect,
style,
textStyle,
testID,
accessibilityLabel,
}: ThemeChipProps) {
const resolvedValue = value ?? label;
const isGradient = selected && selectedVariant === 'gradient';
const showSelectedIcon = selected && (showCross ?? showRemoveIcon);
const handlePress = useCallback(() => {
if (disabled) {
return;
}
onSelect?.(resolvedValue, !selected);
}, [disabled, onSelect, resolvedValue, selected]);
const containerStyle: ViewStyle = {
minHeight: CHIP_HEIGHT,
borderRadius: borderRadius.chip,
paddingHorizontal: 14,
borderWidth: 1,
alignSelf: 'flex-start',
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'center',
gap: 8,
opacity: disabled ? 0.45 : 1,
};
const accentSelectedStyle: ViewStyle = {
backgroundColor: colors.primarySoft,
borderColor: colors.primary,
};
const idleStyle: ViewStyle = {
backgroundColor: colors.surface,
borderColor: '#2A2A3C',
};
const textColor = isGradient
? colors.textPrimary
: selected
? colors.textOnPrimarySoft
: colors.textPrimary;
return (
<Pressable
testID={testID}
disabled={disabled}
onPress={handlePress}
accessibilityRole="button"
accessibilityState={{ disabled, selected }}
accessibilityLabel={accessibilityLabel ?? label}
style={[styles.root, style]}
>
{isGradient ? (
<LinearGradient
colors={gradients.signature}
start={gradientDirection.start}
end={gradientDirection.end}
style={[containerStyle, { borderColor: 'transparent' }]}
>
<Text style={[styles.label, typography.chip, { color: textColor }, textStyle]}>{label}</Text>
{showSelectedIcon ? <X color={textColor} size={12} strokeWidth={2.3} /> : null}
</LinearGradient>
) : (
<View style={[containerStyle, selected ? accentSelectedStyle : idleStyle]}>
<Text style={[styles.label, typography.chip, { color: textColor }, textStyle]}>{label}</Text>
{showSelectedIcon ? <X color={textColor} size={12} strokeWidth={2.3} /> : null}
</View>
)}
</Pressable>
);
}
export default ThemeChip;
const styles = StyleSheet.create({
root: {
alignSelf: 'flex-start',
},
label: {
fontWeight: '600',
},
});

3
src/global.css Normal file
View File

@@ -0,0 +1,3 @@
@tailwind base;
@tailwind components;
@tailwind utilities;

View File

@@ -0,0 +1,5 @@
import type { Animator } from '@/models';
import { animatorsApi } from '@/api/entities/animators';
import { createCrudHooks } from './createCrudHooks';
export const animatorsHooks = createCrudHooks<Animator>('animators', animatorsApi);

View File

@@ -0,0 +1,5 @@
import type { CommentLike } from '@/models';
import { comment_likesApi } from '@/api/entities/comment_likes';
import { createCrudHooks } from './createCrudHooks';
export const comment_likesHooks = createCrudHooks<CommentLike>('comment_likes', comment_likesApi);

View File

@@ -0,0 +1,5 @@
import type { Comment } from '@/models';
import { commentsApi } from '@/api/entities/comments';
import { createCrudHooks } from './createCrudHooks';
export const commentsHooks = createCrudHooks<Comment>('comments', commentsApi);

View File

@@ -0,0 +1,102 @@
import type { CrudApi } from '@/api/types';
import {
useMutation,
useQuery,
useQueryClient,
type UseMutationOptions,
type UseQueryOptions,
} from '@tanstack/react-query';
type ResourceId = string;
type ListKey = [string, 'list'];
type DetailKey = [string, 'detail', ResourceId];
export const createCrudHooks = <T>(resourceKey: string, api: CrudApi<T>) => {
const listKey: ListKey = [resourceKey, 'list'];
const useListQuery = (options?: Omit<UseQueryOptions<T[], Error, T[], ListKey>, 'queryKey' | 'queryFn'>) =>
useQuery({
queryKey: listKey,
queryFn: () => api.list(),
...options,
});
const useDetailQuery = (
id: ResourceId,
options?: Omit<UseQueryOptions<T, Error, T, DetailKey>, 'queryKey' | 'queryFn'>,
) =>
useQuery({
queryKey: [resourceKey, 'detail', id],
queryFn: () => api.get(id),
enabled: id !== undefined && id !== null && (options?.enabled ?? true),
...options,
});
const useCreateMutation = (
options?: UseMutationOptions<T, Error, Partial<T>>,
) => {
const queryClient = useQueryClient();
return useMutation({
mutationFn: (data) => api.create(data),
...options,
onSuccess: (data, variables, onMutateResult, context) => {
queryClient.invalidateQueries({ queryKey: listKey });
options?.onSuccess?.(data, variables, onMutateResult, context);
},
});
};
const useUpdateMutation = (
options?: UseMutationOptions<T, Error, { id: ResourceId; data: Partial<T> }>,
) => {
const queryClient = useQueryClient();
return useMutation({
mutationFn: ({ id, data }) => api.update(id, data),
...options,
onSuccess: (data, variables, onMutateResult, context) => {
queryClient.invalidateQueries({ queryKey: listKey });
queryClient.invalidateQueries({ queryKey: [resourceKey, 'detail', variables.id] });
options?.onSuccess?.(data, variables, onMutateResult, context);
},
});
};
const usePatchMutation = (
options?: UseMutationOptions<T, Error, { id: ResourceId; data: Partial<T> }>,
) => {
const queryClient = useQueryClient();
return useMutation({
mutationFn: ({ id, data }) => api.patch(id, data),
...options,
onSuccess: (data, variables, onMutateResult, context) => {
queryClient.invalidateQueries({ queryKey: listKey });
queryClient.invalidateQueries({ queryKey: [resourceKey, 'detail', variables.id] });
options?.onSuccess?.(data, variables, onMutateResult, context);
},
});
};
const useDeleteMutation = (
options?: UseMutationOptions<void, Error, ResourceId>,
) => {
const queryClient = useQueryClient();
return useMutation({
mutationFn: (id) => api.remove(id),
...options,
onSuccess: (data, variables, onMutateResult, context) => {
queryClient.invalidateQueries({ queryKey: listKey });
queryClient.invalidateQueries({ queryKey: [resourceKey, 'detail', variables] });
options?.onSuccess?.(data, variables, onMutateResult, context);
},
});
};
return {
useListQuery,
useDetailQuery,
useCreateMutation,
useUpdateMutation,
usePatchMutation,
useDeleteMutation,
};
};

View File

@@ -0,0 +1,5 @@
import type { EventExternalLink } from '@/models';
import { event_external_linksApi } from '@/api/entities/event_external_links';
import { createCrudHooks } from './createCrudHooks';
export const event_external_linksHooks = createCrudHooks<EventExternalLink>('event_external_links', event_external_linksApi);

View File

@@ -0,0 +1,5 @@
import type { EventHashtag } from '@/models';
import { event_hashtagsApi } from '@/api/entities/event_hashtags';
import { createCrudHooks } from './createCrudHooks';
export const event_hashtagsHooks = createCrudHooks<EventHashtag>('event_hashtags', event_hashtagsApi);

View File

@@ -0,0 +1,5 @@
import type { EventImage } from '@/models';
import { event_imagesApi } from '@/api/entities/event_images';
import { createCrudHooks } from './createCrudHooks';
export const event_imagesHooks = createCrudHooks<EventImage>('event_images', event_imagesApi);

View File

@@ -0,0 +1,5 @@
import type { EventLineup } from '@/models';
import { event_lineupApi } from '@/api/entities/event_lineup';
import { createCrudHooks } from './createCrudHooks';
export const event_lineupHooks = createCrudHooks<EventLineup>('event_lineup', event_lineupApi);

View File

@@ -0,0 +1,5 @@
import type { EventStatsSnapshot } from '@/models';
import { event_stats_snapshotsApi } from '@/api/entities/event_stats_snapshots';
import { createCrudHooks } from './createCrudHooks';
export const event_stats_snapshotsHooks = createCrudHooks<EventStatsSnapshot>('event_stats_snapshots', event_stats_snapshotsApi);

View File

@@ -0,0 +1,5 @@
import type { EventTheme } from '@/models';
import { event_themesApi } from '@/api/entities/event_themes';
import { createCrudHooks } from './createCrudHooks';
export const event_themesHooks = createCrudHooks<EventTheme>('event_themes', event_themesApi);

5
src/hooks/api/events.ts Normal file
View File

@@ -0,0 +1,5 @@
import type { Event } from '@/models';
import { eventsApi } from '@/api/entities/events';
import { createCrudHooks } from './createCrudHooks';
export const eventsHooks = createCrudHooks<Event>('events', eventsApi);

View File

@@ -0,0 +1,5 @@
import type { Hashtag } from '@/models';
import { hashtagsApi } from '@/api/entities/hashtags';
import { createCrudHooks } from './createCrudHooks';
export const hashtagsHooks = createCrudHooks<Hashtag>('hashtags', hashtagsApi);

30
src/hooks/api/index.ts Normal file
View File

@@ -0,0 +1,30 @@
export * from './createCrudHooks';
export * from './animators';
export * from './comment_likes';
export * from './comments';
export * from './event_external_links';
export * from './event_hashtags';
export * from './event_images';
export * from './event_lineup';
export * from './event_stats_snapshots';
export * from './event_themes';
export * from './events';
export * from './hashtags';
export * from './organizer_members';
export * from './organizer_subscriptions';
export * from './organizers';
export * from './plans';
export * from './post_likes';
export * from './post_media';
export * from './posts';
export * from './search_history';
export * from './social_auth_providers';
export * from './themes';
export * from './tickets';
export * from './user_animator_follows';
export * from './user_event_interactions';
export * from './user_event_shares';
export * from './user_organizer_follows';
export * from './user_theme_preferences';
export * from './users';

View File

@@ -0,0 +1,5 @@
import type { OrganizerMember } from '@/models';
import { organizer_membersApi } from '@/api/entities/organizer_members';
import { createCrudHooks } from './createCrudHooks';
export const organizer_membersHooks = createCrudHooks<OrganizerMember>('organizer_members', organizer_membersApi);

View File

@@ -0,0 +1,5 @@
import type { OrganizerSubscription } from '@/models';
import { organizer_subscriptionsApi } from '@/api/entities/organizer_subscriptions';
import { createCrudHooks } from './createCrudHooks';
export const organizer_subscriptionsHooks = createCrudHooks<OrganizerSubscription>('organizer_subscriptions', organizer_subscriptionsApi);

View File

@@ -0,0 +1,5 @@
import type { Organizer } from '@/models';
import { organizersApi } from '@/api/entities/organizers';
import { createCrudHooks } from './createCrudHooks';
export const organizersHooks = createCrudHooks<Organizer>('organizers', organizersApi);

5
src/hooks/api/plans.ts Normal file
View File

@@ -0,0 +1,5 @@
import type { Plan } from '@/models';
import { plansApi } from '@/api/entities/plans';
import { createCrudHooks } from './createCrudHooks';
export const plansHooks = createCrudHooks<Plan>('plans', plansApi);

View File

@@ -0,0 +1,5 @@
import type { PostLike } from '@/models';
import { post_likesApi } from '@/api/entities/post_likes';
import { createCrudHooks } from './createCrudHooks';
export const post_likesHooks = createCrudHooks<PostLike>('post_likes', post_likesApi);

View File

@@ -0,0 +1,5 @@
import type { PostMedia } from '@/models';
import { post_mediaApi } from '@/api/entities/post_media';
import { createCrudHooks } from './createCrudHooks';
export const post_mediaHooks = createCrudHooks<PostMedia>('post_media', post_mediaApi);

5
src/hooks/api/posts.ts Normal file
View File

@@ -0,0 +1,5 @@
import type { Post } from '@/models';
import { postsApi } from '@/api/entities/posts';
import { createCrudHooks } from './createCrudHooks';
export const postsHooks = createCrudHooks<Post>('posts', postsApi);

View File

@@ -0,0 +1,5 @@
import type { SearchHistory } from '@/models';
import { search_historyApi } from '@/api/entities/search_history';
import { createCrudHooks } from './createCrudHooks';
export const search_historyHooks = createCrudHooks<SearchHistory>('search_history', search_historyApi);

View File

@@ -0,0 +1,5 @@
import type { SocialAuthProvider } from '@/models';
import { social_auth_providersApi } from '@/api/entities/social_auth_providers';
import { createCrudHooks } from './createCrudHooks';
export const social_auth_providersHooks = createCrudHooks<SocialAuthProvider>('social_auth_providers', social_auth_providersApi);

5
src/hooks/api/themes.ts Normal file
View File

@@ -0,0 +1,5 @@
import type { Theme } from '@/models';
import { themesApi } from '@/api/entities/themes';
import { createCrudHooks } from './createCrudHooks';
export const themesHooks = createCrudHooks<Theme>('themes', themesApi);

5
src/hooks/api/tickets.ts Normal file
View File

@@ -0,0 +1,5 @@
import type { Ticket } from '@/models';
import { ticketsApi } from '@/api/entities/tickets';
import { createCrudHooks } from './createCrudHooks';
export const ticketsHooks = createCrudHooks<Ticket>('tickets', ticketsApi);

View File

@@ -0,0 +1,5 @@
import type { UserAnimatorFollow } from '@/models';
import { user_animator_followsApi } from '@/api/entities/user_animator_follows';
import { createCrudHooks } from './createCrudHooks';
export const user_animator_followsHooks = createCrudHooks<UserAnimatorFollow>('user_animator_follows', user_animator_followsApi);

View File

@@ -0,0 +1,5 @@
import type { UserEventInteraction } from '@/models';
import { user_event_interactionsApi } from '@/api/entities/user_event_interactions';
import { createCrudHooks } from './createCrudHooks';
export const user_event_interactionsHooks = createCrudHooks<UserEventInteraction>('user_event_interactions', user_event_interactionsApi);

View File

@@ -0,0 +1,5 @@
import type { UserEventShare } from '@/models';
import { user_event_sharesApi } from '@/api/entities/user_event_shares';
import { createCrudHooks } from './createCrudHooks';
export const user_event_sharesHooks = createCrudHooks<UserEventShare>('user_event_shares', user_event_sharesApi);

View File

@@ -0,0 +1,5 @@
import type { UserOrganizerFollow } from '@/models';
import { user_organizer_followsApi } from '@/api/entities/user_organizer_follows';
import { createCrudHooks } from './createCrudHooks';
export const user_organizer_followsHooks = createCrudHooks<UserOrganizerFollow>('user_organizer_follows', user_organizer_followsApi);

View File

@@ -0,0 +1,5 @@
import type { UserThemePreference } from '@/models';
import { user_theme_preferencesApi } from '@/api/entities/user_theme_preferences';
import { createCrudHooks } from './createCrudHooks';
export const user_theme_preferencesHooks = createCrudHooks<UserThemePreference>('user_theme_preferences', user_theme_preferencesApi);

5
src/hooks/api/users.ts Normal file
View File

@@ -0,0 +1,5 @@
import type { User } from '@/models';
import { usersApi } from '@/api/entities/users';
import { createCrudHooks } from './createCrudHooks';
export const usersHooks = createCrudHooks<User>('users', usersApi);

15
src/hooks/queryClient.ts Normal file
View File

@@ -0,0 +1,15 @@
import { QueryClient } from '@tanstack/react-query';
export const queryClient = new QueryClient({
defaultOptions: {
queries: {
staleTime: 30_000,
gcTime: 5 * 60_000,
refetchOnWindowFocus: false,
retry: 1,
},
mutations: {
retry: 0,
},
},
});

1085
src/mocks/bahla.ts Normal file

File diff suppressed because it is too large Load Diff

2
src/mocks/index.ts Normal file
View File

@@ -0,0 +1,2 @@
export * from './bahla';

17
src/models/_shared.ts Normal file
View File

@@ -0,0 +1,17 @@
import { z } from 'zod';
export const uuidSchema = z.string().uuid();
export const timestampSchema = z.coerce.date();
export const sqlDateSchema = z
.string()
.regex(/^\d{4}-\d{2}-\d{2}$/, 'Expected date format YYYY-MM-DD');
export const nullableText = z.string().trim().min(1).nullable();
export const nullableUrl = z.string().url().nullable();
export const nullableLatitude = z.number().min(-90).max(90).nullable();
export const nullableLongitude = z.number().min(-180).max(180).nullable();

16
src/models/animators.ts Normal file
View File

@@ -0,0 +1,16 @@
import { z } from 'zod';
import { nullableUrl, timestampSchema, uuidSchema } from './_shared';
export const animatorSchema = z.object({
id: uuidSchema,
name: z.string().trim().min(1).max(255),
profile_picture: nullableUrl,
genre: z.string().trim().min(1).max(100).nullable(),
city: z.string().trim().min(1).max(100).nullable(),
bio: z.string().trim().min(1).nullable(),
created_at: timestampSchema,
updated_at: timestampSchema,
});
export type Animator = z.infer<typeof animatorSchema>;

View File

@@ -0,0 +1,11 @@
import { z } from 'zod';
import { timestampSchema, uuidSchema } from './_shared';
export const commentLikeSchema = z.object({
user_id: uuidSchema,
comment_id: uuidSchema,
created_at: timestampSchema,
});
export type CommentLike = z.infer<typeof commentLikeSchema>;

15
src/models/comments.ts Normal file
View File

@@ -0,0 +1,15 @@
import { z } from 'zod';
import { timestampSchema, uuidSchema } from './_shared';
export const commentSchema = z.object({
id: uuidSchema,
post_id: uuidSchema,
user_id: uuidSchema,
parent_comment_id: uuidSchema.nullable(),
content: z.string().trim().min(1),
created_at: timestampSchema,
updated_at: timestampSchema,
});
export type Comment = z.infer<typeof commentSchema>;

View File

@@ -0,0 +1,13 @@
import { z } from 'zod';
import { uuidSchema } from './_shared';
export const eventExternalLinkSchema = z.object({
id: uuidSchema,
event_id: uuidSchema,
url: z.string().trim().min(1),
label: z.string().trim().min(1).max(100).nullable(),
display_order: z.number().int().default(0),
});
export type EventExternalLink = z.infer<typeof eventExternalLinkSchema>;

View File

@@ -0,0 +1,10 @@
import { z } from 'zod';
import { uuidSchema } from './_shared';
export const eventHashtagSchema = z.object({
event_id: uuidSchema,
hashtag_id: uuidSchema,
});
export type EventHashtag = z.infer<typeof eventHashtagSchema>;

View File

@@ -0,0 +1,14 @@
import { z } from 'zod';
import { timestampSchema, uuidSchema } from './_shared';
export const eventImageSchema = z.object({
id: uuidSchema,
event_id: uuidSchema,
url: z.string().url(),
is_cover: z.boolean().default(false),
display_order: z.number().int().default(0),
created_at: timestampSchema,
});
export type EventImage = z.infer<typeof eventImageSchema>;

View File

@@ -0,0 +1,18 @@
import { z } from 'zod';
import { timestampSchema, uuidSchema } from './_shared';
export const eventLineupRoleSchema = z.enum(['HEADLINER', 'OPENING', 'CLOSING']);
export const eventLineupSchema = z.object({
id: uuidSchema,
event_id: uuidSchema,
animator_id: uuidSchema,
stage_name: z.string().trim().min(1).max(100).nullable(),
start_time: timestampSchema.nullable(),
end_time: timestampSchema.nullable(),
role: eventLineupRoleSchema.nullable(),
display_order: z.number().int().default(0),
});
export type EventLineup = z.infer<typeof eventLineupSchema>;

View File

@@ -0,0 +1,15 @@
import { z } from 'zod';
import { sqlDateSchema, uuidSchema } from './_shared';
export const eventStatsSnapshotSchema = z.object({
id: uuidSchema,
event_id: uuidSchema,
snapshot_date: sqlDateSchema,
view_count: z.number().int().min(0).default(0),
participant_count: z.number().int().min(0).default(0),
interested_count: z.number().int().min(0).default(0),
share_count: z.number().int().min(0).default(0),
});
export type EventStatsSnapshot = z.infer<typeof eventStatsSnapshotSchema>;

View File

@@ -0,0 +1,10 @@
import { z } from 'zod';
import { uuidSchema } from './_shared';
export const eventThemeSchema = z.object({
event_id: uuidSchema,
theme_id: uuidSchema,
});
export type EventTheme = z.infer<typeof eventThemeSchema>;

40
src/models/events.ts Normal file
View File

@@ -0,0 +1,40 @@
import { z } from 'zod';
import {
nullableLatitude,
nullableLongitude,
nullableText,
timestampSchema,
uuidSchema,
} from './_shared';
export const eventStatusSchema = z.enum(['DRAFT', 'PUBLISHED', 'CANCELLED']);
export const eventSchema = z.object({
id: uuidSchema,
organizer_id: uuidSchema,
name: z.string().trim().min(1).max(255),
description: z.string().trim().max(600).nullable(),
start_date: timestampSchema,
end_date: timestampSchema,
doors_open_time: timestampSchema.nullable(),
min_age: z.number().int().min(0).nullable(),
address: nullableText,
city: z.string().trim().min(1).max(100).nullable(),
latitude: nullableLatitude,
longitude: nullableLongitude,
price_presale: z.number().min(0).nullable(),
price_door: z.number().min(0).nullable(),
is_free: z.boolean().default(false),
presale_total: z.number().int().min(0).nullable(),
presale_sold: z.number().int().min(0).default(0),
ticketing_enabled: z.boolean().default(false),
ticketing_commission: z.number().min(0).max(100).nullable(),
status: eventStatusSchema,
featured_image_id: uuidSchema.nullable(),
published_at: timestampSchema.nullable(),
created_at: timestampSchema,
updated_at: timestampSchema,
});
export type Event = z.infer<typeof eventSchema>;

10
src/models/hashtags.ts Normal file
View File

@@ -0,0 +1,10 @@
import { z } from 'zod';
import { uuidSchema } from './_shared';
export const hashtagSchema = z.object({
id: uuidSchema,
name: z.string().trim().min(1).max(100),
});
export type Hashtag = z.infer<typeof hashtagSchema>;

30
src/models/index.ts Normal file
View File

@@ -0,0 +1,30 @@
export * from './_shared';
export * from './animators';
export * from './comment_likes';
export * from './comments';
export * from './event_external_links';
export * from './event_hashtags';
export * from './event_images';
export * from './event_lineup';
export * from './event_stats_snapshots';
export * from './event_themes';
export * from './events';
export * from './hashtags';
export * from './organizer_members';
export * from './organizer_subscriptions';
export * from './organizers';
export * from './plans';
export * from './post_likes';
export * from './post_media';
export * from './posts';
export * from './search_history';
export * from './social_auth_providers';
export * from './themes';
export * from './tickets';
export * from './user_animator_follows';
export * from './user_event_interactions';
export * from './user_event_shares';
export * from './user_organizer_follows';
export * from './user_theme_preferences';
export * from './users';

View File

@@ -0,0 +1,20 @@
import { z } from 'zod';
import { timestampSchema, uuidSchema } from './_shared';
export const organizerMemberRoleSchema = z.enum(['ADMIN', 'EDITOR']);
export const organizerMemberStatusSchema = z.enum(['ACTIVE', 'PENDING']);
export const organizerMemberSchema = z.object({
id: uuidSchema,
organizer_id: uuidSchema,
user_id: uuidSchema.nullable(),
email: z.string().trim().email().max(255),
role: organizerMemberRoleSchema,
status: organizerMemberStatusSchema,
invited_at: timestampSchema,
joined_at: timestampSchema.nullable(),
});
export type OrganizerMember = z.infer<typeof organizerMemberSchema>;

View File

@@ -0,0 +1,21 @@
import { z } from 'zod';
import { sqlDateSchema, timestampSchema, uuidSchema } from './_shared';
export const organizerSubscriptionStatusSchema = z.enum([
'ACTIVE',
'CANCELLED',
'EXPIRED',
]);
export const organizerSubscriptionSchema = z.object({
id: uuidSchema,
organizer_id: uuidSchema,
plan_id: uuidSchema,
status: organizerSubscriptionStatusSchema,
started_at: timestampSchema,
renewal_date: sqlDateSchema.nullable(),
cancelled_at: timestampSchema.nullable(),
});
export type OrganizerSubscription = z.infer<typeof organizerSubscriptionSchema>;

23
src/models/organizers.ts Normal file
View File

@@ -0,0 +1,23 @@
import { z } from 'zod';
import { nullableUrl, timestampSchema, uuidSchema } from './_shared';
export const organizerSchema = z.object({
id: uuidSchema,
name: z.string().trim().min(1).max(255),
email: z.string().trim().email().max(255),
profile_picture: nullableUrl,
cover_picture: nullableUrl,
city: z.string().trim().min(1).max(100).nullable(),
is_verified: z.boolean().default(false),
verified_at: timestampSchema.nullable(),
verified_by: uuidSchema.nullable(),
instagram_handle: z.string().trim().min(1).max(100).nullable(),
tiktok_handle: z.string().trim().min(1).max(100).nullable(),
facebook_handle: z.string().trim().min(1).max(100).nullable(),
plan_id: uuidSchema.nullable(),
created_at: timestampSchema,
updated_at: timestampSchema,
});
export type Organizer = z.infer<typeof organizerSchema>;

16
src/models/plans.ts Normal file
View File

@@ -0,0 +1,16 @@
import { z } from 'zod';
import { uuidSchema } from './_shared';
export const planNameSchema = z.enum(['FREE', 'PRO', 'TICKETING']);
export const planSchema = z.object({
id: uuidSchema,
name: planNameSchema,
price_monthly: z.number().min(0),
max_active_events: z.number().int().min(0).nullable(),
ticketing_enabled: z.boolean().default(false),
ticketing_commission: z.number().min(0).max(100).nullable(),
});
export type Plan = z.infer<typeof planSchema>;

Some files were not shown because too many files have changed in this diff Show More