Skip to content

Commit 0556208

Browse files
authored
Merge pull request #189 from Netsbump/fix/login-web-athlete-redirection
🐛 fix: resolve athlete redirect loop and improve download page UI
2 parents d31d15c + 45766cc commit 0556208

File tree

4 files changed

+25
-70
lines changed

4 files changed

+25
-70
lines changed

apps/web/src/routes/__home.tsx

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,28 +12,23 @@ export const Route = createFileRoute('/__home')({
1212
throw redirect({ to: '/login' });
1313
}
1414

15-
try {
16-
// Vérifier si l'utilisateur a un membre actif dans une organisation
17-
const activeMember = await authClient.organization.getActiveMember();
18-
if (!activeMember?.data) {
19-
throw redirect({ to: '/onboarding' });
20-
}
15+
// Vérifier si l'utilisateur a un membre actif dans une organisation
16+
const activeMember = await authClient.organization.getActiveMember();
17+
if (!activeMember?.data) {
18+
throw redirect({ to: '/onboarding' });
19+
}
2120

22-
// Vérifier le rôle de l'utilisateur - seuls les coachs peuvent accéder au dashboard
23-
const userRole = activeMember.data.role;
21+
// Vérifier le rôle de l'utilisateur - seuls les coachs peuvent accéder au dashboard
22+
const userRole = activeMember.data.role;
2423

25-
// Si c'est un membre (athlète), rediriger vers download-app
26-
if (userRole === 'member') {
27-
throw redirect({ to: '/download-app' });
28-
}
24+
// Si c'est un membre (athlète), rediriger vers download-app
25+
if (userRole === 'member') {
26+
throw redirect({ to: '/download-app' });
27+
}
2928

30-
// Les owner et admin peuvent continuer
31-
if (userRole !== 'owner' && userRole !== 'admin') {
32-
throw redirect({ to: '/download-app' });
33-
}
34-
} catch (error) {
35-
// Si erreur lors de la récupération du membre actif, rediriger vers onboarding
36-
throw redirect({ to: '/onboarding' });
29+
// Les owner et admin peuvent continuer
30+
if (userRole !== 'owner' && userRole !== 'admin') {
31+
throw redirect({ to: '/download-app' });
3732
}
3833
},
3934
component: HomeLayout,

apps/web/src/routes/download-app.tsx

Lines changed: 9 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { createFileRoute, redirect } from "@tanstack/react-router";
33
import { useTranslation } from "@dropit/i18n";
44
import { Button } from "@/shared/components/ui/button";
55
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/shared/components/ui/card";
6-
import { Smartphone, Download, Apple, Chrome, ArrowRight, CheckCircle, Star } from "lucide-react";
6+
import { Smartphone, Download, Apple, ArrowRight, CheckCircle, Star } from "lucide-react";
77
import { Badge } from "@/shared/components/ui/badge";
88
import { useState, useEffect } from "react";
99

@@ -13,17 +13,6 @@ export const Route = createFileRoute('/download-app')({
1313
if (!session) {
1414
throw redirect({ to: '/login' });
1515
}
16-
17-
try {
18-
// Vérifier si l'utilisateur a un membre actif dans une organisation
19-
const activeMember = await authClient.organization.getActiveMember();
20-
if (!activeMember?.data) {
21-
throw redirect({ to: '/onboarding' });
22-
}
23-
} catch (error) {
24-
// Si erreur lors de la récupération du membre actif, rediriger vers onboarding
25-
throw redirect({ to: '/onboarding' });
26-
}
2716
},
2817
component: DownloadAppPage,
2918
});
@@ -53,7 +42,7 @@ function DownloadAppPage() {
5342
// Vérifier si l'utilisateur est un membre (athlète)
5443
const isAthlete = activeMember?.role === 'member';
5544

56-
const handleDownload = (platform: 'ios' | 'android' | 'web') => {
45+
const handleDownload = (platform: 'ios' | 'android') => {
5746
// TODO: Implémenter les liens de téléchargement
5847
switch (platform) {
5948
case 'ios':
@@ -62,15 +51,11 @@ function DownloadAppPage() {
6251
case 'android':
6352
window.open('https://play.google.com/store/apps/details?id=com.dropit', '_blank');
6453
break;
65-
case 'web':
66-
// Rediriger vers la version web mobile
67-
window.location.href = '/mobile';
68-
break;
6954
}
7055
};
7156

7257
return (
73-
<div className="min-h-screen bg-gradient-to-br from-purple-50 to-indigo-100 flex items-center justify-center p-4">
58+
<div className="min-h-screen flex items-center justify-center p-4">
7459
<div className="w-full max-w-4xl mx-auto">
7560
<div className="text-center mb-8">
7661
<div className="mx-auto mb-6 flex h-16 w-16 items-center justify-center rounded-full bg-purple-100">
@@ -81,30 +66,22 @@ function DownloadAppPage() {
8166
</h1>
8267
<p className="text-xl text-gray-600 max-w-2xl mx-auto">
8368
{isAthlete
84-
? 'En tant qu\'athlète, votre expérience optimale se trouve sur notre application mobile. Téléchargez l\'app pour accéder à tous vos entraînements, performances et communications avec votre coach.'
69+
? 'L\'interface web est réservée aux coachs pour la gestion des programmes d\'entraînement. Votre espace athlète vous attend sur mobile !'
8570
: t('download_app.description')
8671
}
8772
</p>
88-
{isAthlete && (
89-
<div className="mt-4 p-4 bg-purple-50 rounded-lg max-w-2xl mx-auto">
90-
<p className="text-sm text-purple-700">
91-
💡 L'interface web est réservée aux coachs pour la gestion des programmes d'entraînement.
92-
Votre espace athlète vous attend sur mobile !
93-
</p>
94-
</div>
95-
)}
9673
</div>
9774

98-
<div className="grid md:grid-cols-2 gap-8 items-start">
75+
<div className="grid md:grid-cols-2 gap-8 items-stretch">
9976
{/* Carte principale */}
100-
<Card className="w-full">
77+
<Card className="w-full h-full flex flex-col shadow-none">
10178
<CardHeader className="text-center">
10279
<CardTitle className="text-2xl">{t('download_app.download_section.title')}</CardTitle>
10380
<CardDescription>
10481
{t('download_app.download_section.subtitle')}
10582
</CardDescription>
10683
</CardHeader>
107-
<CardContent className="space-y-4">
84+
<CardContent className="space-y-4 flex-1 flex flex-col justify-center">
10885
{/* App Store */}
10986
<Button
11087
onClick={() => handleDownload('ios')}
@@ -132,26 +109,11 @@ function DownloadAppPage() {
132109
</div>
133110
<ArrowRight className="h-5 w-5 ml-auto" />
134111
</Button>
135-
136-
{/* Version Web */}
137-
<Button
138-
onClick={() => handleDownload('web')}
139-
variant="outline"
140-
className="w-full h-16 text-lg"
141-
size="lg"
142-
>
143-
<Chrome className="h-6 w-6 mr-3" />
144-
<div className="text-left">
145-
<div className="text-xs">{t('download_app.platforms.web.label')}</div>
146-
<div className="font-semibold">{t('download_app.platforms.web.store')}</div>
147-
</div>
148-
<ArrowRight className="h-5 w-5 ml-auto" />
149-
</Button>
150112
</CardContent>
151113
</Card>
152114

153115
{/* Carte des fonctionnalités */}
154-
<Card className="w-full">
116+
<Card className="w-full h-full flex flex-col shadow-none">
155117
<CardHeader>
156118
<CardTitle className="flex items-center gap-2">
157119
<Star className="h-5 w-5 text-yellow-500" />
@@ -161,7 +123,7 @@ function DownloadAppPage() {
161123
{t('download_app.features.subtitle')}
162124
</CardDescription>
163125
</CardHeader>
164-
<CardContent>
126+
<CardContent className="flex-1 flex flex-col">
165127
<div className="space-y-3">
166128
{features.map((feature) => (
167129
<div key={feature} className="flex items-start gap-3">

packages/i18n/src/locales/en/onboarding.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,7 @@
112112
"Real-time training tracking",
113113
"Performance history",
114114
"Personalized programs from your coach",
115-
"Session notifications",
116-
"Mobile-optimized interface"
115+
"Session notifications"
117116
]
118117
},
119118
"stats": {

packages/i18n/src/locales/fr/onboarding.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,7 @@
112112
"Suivi de vos entraînements en temps réel",
113113
"Historique de vos performances",
114114
"Programmes personnalisés par votre coach",
115-
"Notifications pour vos séances",
116-
"Interface optimisée pour mobile"
115+
"Notifications pour vos séances"
117116
]
118117
},
119118
"stats": {

0 commit comments

Comments
 (0)