Skip to content

Commit 0bf48fd

Browse files
committed
Split login into client and business, and added home page
1 parent 68408d6 commit 0bf48fd

File tree

11 files changed

+487
-140
lines changed

11 files changed

+487
-140
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
"""Add user_type field to User table
2+
3+
Revision ID: 2025110201
4+
Revises: 2025010801
5+
Create Date: 2025-11-02 00:00:00.000000
6+
7+
"""
8+
from alembic import op
9+
import sqlalchemy as sa
10+
import sqlmodel.sql.sqltypes
11+
12+
# revision identifiers, used by Alembic.
13+
revision = '2025110201'
14+
down_revision = '2025010801'
15+
branch_labels = None
16+
depends_on = None
17+
18+
19+
def upgrade():
20+
# Add user_type column to user table with default value
21+
op.add_column('user', sa.Column('user_type', sqlmodel.sql.sqltypes.AutoString(length=50), nullable=False, server_default='team_member'))
22+
23+
24+
def downgrade():
25+
# Remove user_type column from user table
26+
op.drop_column('user', 'user_type')
27+

frontend/src/hooks/useAuth.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,10 @@ const useAuth = () => {
3030
mutationFn: (data: UserRegister) =>
3131
UsersService.registerUser({ requestBody: data }),
3232

33-
onSuccess: () => {
34-
navigate({ to: "/login" })
33+
onSuccess: (_, variables) => {
34+
// Redirect to appropriate login page based on user type
35+
const loginPath = variables.user_type === "client" ? "/client-login" : "/team-login"
36+
navigate({ to: loginPath })
3537
},
3638
onError: (err: ApiError) => {
3739
handleError(err)
@@ -51,7 +53,7 @@ const useAuth = () => {
5153
const loginMutation = useMutation({
5254
mutationFn: login,
5355
onSuccess: () => {
54-
navigate({ to: "/" })
56+
navigate({ to: "/dashboard" })
5557
},
5658
onError: (err: ApiError) => {
5759
handleError(err)
@@ -60,7 +62,7 @@ const useAuth = () => {
6062

6163
const logout = () => {
6264
localStorage.removeItem("access_token")
63-
navigate({ to: "/login" })
65+
navigate({ to: "/" })
6466
}
6567

6668
return {

frontend/src/main.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ OpenAPI.TOKEN = async () => {
1919
const handleApiError = (error: Error) => {
2020
if (error instanceof ApiError && [401, 403].includes(error.status)) {
2121
localStorage.removeItem("access_token")
22-
window.location.href = "/login"
22+
window.location.href = "/"
2323
}
2424
}
2525
const queryClient = new QueryClient({

frontend/src/routeTree.gen.ts

Lines changed: 74 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,26 @@
99
// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified.
1010

1111
import { Route as rootRouteImport } from './routes/__root'
12+
import { Route as TeamLoginRouteImport } from './routes/team-login'
1213
import { Route as SignupRouteImport } from './routes/signup'
1314
import { Route as ResetPasswordRouteImport } from './routes/reset-password'
1415
import { Route as RecoverPasswordRouteImport } from './routes/recover-password'
15-
import { Route as LoginRouteImport } from './routes/login'
16+
import { Route as ClientLoginRouteImport } from './routes/client-login'
1617
import { Route as LayoutRouteImport } from './routes/_layout'
17-
import { Route as LayoutIndexRouteImport } from './routes/_layout/index'
18+
import { Route as IndexRouteImport } from './routes/index'
1819
import { Route as LayoutSettingsRouteImport } from './routes/_layout/settings'
1920
import { Route as LayoutItemsRouteImport } from './routes/_layout/items'
2021
import { Route as LayoutGalleriesRouteImport } from './routes/_layout/galleries'
22+
import { Route as LayoutDashboardRouteImport } from './routes/_layout/dashboard'
2123
import { Route as LayoutAdminRouteImport } from './routes/_layout/admin'
2224
import { Route as LayoutProjectsIndexRouteImport } from './routes/_layout/projects.index'
2325
import { Route as LayoutProjectsProjectIdRouteImport } from './routes/_layout/projects.$projectId'
2426

27+
const TeamLoginRoute = TeamLoginRouteImport.update({
28+
id: '/team-login',
29+
path: '/team-login',
30+
getParentRoute: () => rootRouteImport,
31+
} as any)
2532
const SignupRoute = SignupRouteImport.update({
2633
id: '/signup',
2734
path: '/signup',
@@ -37,19 +44,19 @@ const RecoverPasswordRoute = RecoverPasswordRouteImport.update({
3744
path: '/recover-password',
3845
getParentRoute: () => rootRouteImport,
3946
} as any)
40-
const LoginRoute = LoginRouteImport.update({
41-
id: '/login',
42-
path: '/login',
47+
const ClientLoginRoute = ClientLoginRouteImport.update({
48+
id: '/client-login',
49+
path: '/client-login',
4350
getParentRoute: () => rootRouteImport,
4451
} as any)
4552
const LayoutRoute = LayoutRouteImport.update({
4653
id: '/_layout',
4754
getParentRoute: () => rootRouteImport,
4855
} as any)
49-
const LayoutIndexRoute = LayoutIndexRouteImport.update({
56+
const IndexRoute = IndexRouteImport.update({
5057
id: '/',
5158
path: '/',
52-
getParentRoute: () => LayoutRoute,
59+
getParentRoute: () => rootRouteImport,
5360
} as any)
5461
const LayoutSettingsRoute = LayoutSettingsRouteImport.update({
5562
id: '/settings',
@@ -66,6 +73,11 @@ const LayoutGalleriesRoute = LayoutGalleriesRouteImport.update({
6673
path: '/galleries',
6774
getParentRoute: () => LayoutRoute,
6875
} as any)
76+
const LayoutDashboardRoute = LayoutDashboardRouteImport.update({
77+
id: '/dashboard',
78+
path: '/dashboard',
79+
getParentRoute: () => LayoutRoute,
80+
} as any)
6981
const LayoutAdminRoute = LayoutAdminRouteImport.update({
7082
id: '/admin',
7183
path: '/admin',
@@ -83,99 +95,120 @@ const LayoutProjectsProjectIdRoute = LayoutProjectsProjectIdRouteImport.update({
8395
} as any)
8496

8597
export interface FileRoutesByFullPath {
86-
'/login': typeof LoginRoute
98+
'/': typeof IndexRoute
99+
'/client-login': typeof ClientLoginRoute
87100
'/recover-password': typeof RecoverPasswordRoute
88101
'/reset-password': typeof ResetPasswordRoute
89102
'/signup': typeof SignupRoute
103+
'/team-login': typeof TeamLoginRoute
90104
'/admin': typeof LayoutAdminRoute
105+
'/dashboard': typeof LayoutDashboardRoute
91106
'/galleries': typeof LayoutGalleriesRoute
92107
'/items': typeof LayoutItemsRoute
93108
'/settings': typeof LayoutSettingsRoute
94-
'/': typeof LayoutIndexRoute
95109
'/projects/$projectId': typeof LayoutProjectsProjectIdRoute
96110
'/projects': typeof LayoutProjectsIndexRoute
97111
}
98112
export interface FileRoutesByTo {
99-
'/login': typeof LoginRoute
113+
'/': typeof IndexRoute
114+
'/client-login': typeof ClientLoginRoute
100115
'/recover-password': typeof RecoverPasswordRoute
101116
'/reset-password': typeof ResetPasswordRoute
102117
'/signup': typeof SignupRoute
118+
'/team-login': typeof TeamLoginRoute
103119
'/admin': typeof LayoutAdminRoute
120+
'/dashboard': typeof LayoutDashboardRoute
104121
'/galleries': typeof LayoutGalleriesRoute
105122
'/items': typeof LayoutItemsRoute
106123
'/settings': typeof LayoutSettingsRoute
107-
'/': typeof LayoutIndexRoute
108124
'/projects/$projectId': typeof LayoutProjectsProjectIdRoute
109125
'/projects': typeof LayoutProjectsIndexRoute
110126
}
111127
export interface FileRoutesById {
112128
__root__: typeof rootRouteImport
129+
'/': typeof IndexRoute
113130
'/_layout': typeof LayoutRouteWithChildren
114-
'/login': typeof LoginRoute
131+
'/client-login': typeof ClientLoginRoute
115132
'/recover-password': typeof RecoverPasswordRoute
116133
'/reset-password': typeof ResetPasswordRoute
117134
'/signup': typeof SignupRoute
135+
'/team-login': typeof TeamLoginRoute
118136
'/_layout/admin': typeof LayoutAdminRoute
137+
'/_layout/dashboard': typeof LayoutDashboardRoute
119138
'/_layout/galleries': typeof LayoutGalleriesRoute
120139
'/_layout/items': typeof LayoutItemsRoute
121140
'/_layout/settings': typeof LayoutSettingsRoute
122-
'/_layout/': typeof LayoutIndexRoute
123141
'/_layout/projects/$projectId': typeof LayoutProjectsProjectIdRoute
124142
'/_layout/projects/': typeof LayoutProjectsIndexRoute
125143
}
126144
export interface FileRouteTypes {
127145
fileRoutesByFullPath: FileRoutesByFullPath
128146
fullPaths:
129-
| '/login'
147+
| '/'
148+
| '/client-login'
130149
| '/recover-password'
131150
| '/reset-password'
132151
| '/signup'
152+
| '/team-login'
133153
| '/admin'
154+
| '/dashboard'
134155
| '/galleries'
135156
| '/items'
136157
| '/settings'
137-
| '/'
138158
| '/projects/$projectId'
139159
| '/projects'
140160
fileRoutesByTo: FileRoutesByTo
141161
to:
142-
| '/login'
162+
| '/'
163+
| '/client-login'
143164
| '/recover-password'
144165
| '/reset-password'
145166
| '/signup'
167+
| '/team-login'
146168
| '/admin'
169+
| '/dashboard'
147170
| '/galleries'
148171
| '/items'
149172
| '/settings'
150-
| '/'
151173
| '/projects/$projectId'
152174
| '/projects'
153175
id:
154176
| '__root__'
177+
| '/'
155178
| '/_layout'
156-
| '/login'
179+
| '/client-login'
157180
| '/recover-password'
158181
| '/reset-password'
159182
| '/signup'
183+
| '/team-login'
160184
| '/_layout/admin'
185+
| '/_layout/dashboard'
161186
| '/_layout/galleries'
162187
| '/_layout/items'
163188
| '/_layout/settings'
164-
| '/_layout/'
165189
| '/_layout/projects/$projectId'
166190
| '/_layout/projects/'
167191
fileRoutesById: FileRoutesById
168192
}
169193
export interface RootRouteChildren {
194+
IndexRoute: typeof IndexRoute
170195
LayoutRoute: typeof LayoutRouteWithChildren
171-
LoginRoute: typeof LoginRoute
196+
ClientLoginRoute: typeof ClientLoginRoute
172197
RecoverPasswordRoute: typeof RecoverPasswordRoute
173198
ResetPasswordRoute: typeof ResetPasswordRoute
174199
SignupRoute: typeof SignupRoute
200+
TeamLoginRoute: typeof TeamLoginRoute
175201
}
176202

177203
declare module '@tanstack/react-router' {
178204
interface FileRoutesByPath {
205+
'/team-login': {
206+
id: '/team-login'
207+
path: '/team-login'
208+
fullPath: '/team-login'
209+
preLoaderRoute: typeof TeamLoginRouteImport
210+
parentRoute: typeof rootRouteImport
211+
}
179212
'/signup': {
180213
id: '/signup'
181214
path: '/signup'
@@ -197,11 +230,11 @@ declare module '@tanstack/react-router' {
197230
preLoaderRoute: typeof RecoverPasswordRouteImport
198231
parentRoute: typeof rootRouteImport
199232
}
200-
'/login': {
201-
id: '/login'
202-
path: '/login'
203-
fullPath: '/login'
204-
preLoaderRoute: typeof LoginRouteImport
233+
'/client-login': {
234+
id: '/client-login'
235+
path: '/client-login'
236+
fullPath: '/client-login'
237+
preLoaderRoute: typeof ClientLoginRouteImport
205238
parentRoute: typeof rootRouteImport
206239
}
207240
'/_layout': {
@@ -211,12 +244,12 @@ declare module '@tanstack/react-router' {
211244
preLoaderRoute: typeof LayoutRouteImport
212245
parentRoute: typeof rootRouteImport
213246
}
214-
'/_layout/': {
215-
id: '/_layout/'
247+
'/': {
248+
id: '/'
216249
path: '/'
217250
fullPath: '/'
218-
preLoaderRoute: typeof LayoutIndexRouteImport
219-
parentRoute: typeof LayoutRoute
251+
preLoaderRoute: typeof IndexRouteImport
252+
parentRoute: typeof rootRouteImport
220253
}
221254
'/_layout/settings': {
222255
id: '/_layout/settings'
@@ -239,6 +272,13 @@ declare module '@tanstack/react-router' {
239272
preLoaderRoute: typeof LayoutGalleriesRouteImport
240273
parentRoute: typeof LayoutRoute
241274
}
275+
'/_layout/dashboard': {
276+
id: '/_layout/dashboard'
277+
path: '/dashboard'
278+
fullPath: '/dashboard'
279+
preLoaderRoute: typeof LayoutDashboardRouteImport
280+
parentRoute: typeof LayoutRoute
281+
}
242282
'/_layout/admin': {
243283
id: '/_layout/admin'
244284
path: '/admin'
@@ -265,20 +305,20 @@ declare module '@tanstack/react-router' {
265305

266306
interface LayoutRouteChildren {
267307
LayoutAdminRoute: typeof LayoutAdminRoute
308+
LayoutDashboardRoute: typeof LayoutDashboardRoute
268309
LayoutGalleriesRoute: typeof LayoutGalleriesRoute
269310
LayoutItemsRoute: typeof LayoutItemsRoute
270311
LayoutSettingsRoute: typeof LayoutSettingsRoute
271-
LayoutIndexRoute: typeof LayoutIndexRoute
272312
LayoutProjectsProjectIdRoute: typeof LayoutProjectsProjectIdRoute
273313
LayoutProjectsIndexRoute: typeof LayoutProjectsIndexRoute
274314
}
275315

276316
const LayoutRouteChildren: LayoutRouteChildren = {
277317
LayoutAdminRoute: LayoutAdminRoute,
318+
LayoutDashboardRoute: LayoutDashboardRoute,
278319
LayoutGalleriesRoute: LayoutGalleriesRoute,
279320
LayoutItemsRoute: LayoutItemsRoute,
280321
LayoutSettingsRoute: LayoutSettingsRoute,
281-
LayoutIndexRoute: LayoutIndexRoute,
282322
LayoutProjectsProjectIdRoute: LayoutProjectsProjectIdRoute,
283323
LayoutProjectsIndexRoute: LayoutProjectsIndexRoute,
284324
}
@@ -287,11 +327,13 @@ const LayoutRouteWithChildren =
287327
LayoutRoute._addFileChildren(LayoutRouteChildren)
288328

289329
const rootRouteChildren: RootRouteChildren = {
330+
IndexRoute: IndexRoute,
290331
LayoutRoute: LayoutRouteWithChildren,
291-
LoginRoute: LoginRoute,
332+
ClientLoginRoute: ClientLoginRoute,
292333
RecoverPasswordRoute: RecoverPasswordRoute,
293334
ResetPasswordRoute: ResetPasswordRoute,
294335
SignupRoute: SignupRoute,
336+
TeamLoginRoute: TeamLoginRoute,
295337
}
296338
export const routeTree = rootRouteImport
297339
._addFileChildren(rootRouteChildren)

frontend/src/routes/_layout.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export const Route = createFileRoute("/_layout")({
1010
beforeLoad: async () => {
1111
if (!isLoggedIn()) {
1212
throw redirect({
13-
to: "/login",
13+
to: "/",
1414
})
1515
}
1616
},
@@ -29,5 +29,3 @@ function Layout() {
2929
</Flex>
3030
)
3131
}
32-
33-
export default Layout
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { useQuery } from "@tanstack/react-query"
66
import useAuth from "@/hooks/useAuth"
77
import { ProjectsService, type ProjectPublic } from "@/client"
88

9-
export const Route = createFileRoute("/_layout/")({
9+
export const Route = createFileRoute("/_layout/dashboard")({
1010
component: Dashboard,
1111
})
1212

0 commit comments

Comments
 (0)