Skip to content

Commit 6b40e74

Browse files
authored
Merge branch 'main' into ToniGrbic/635-geolocation-validation
2 parents ed5a02e + 285b7bd commit 6b40e74

File tree

30 files changed

+1051
-151
lines changed

30 files changed

+1051
-151
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ node_modules
22
.turbo
33
.env.local
44
dist
5-
apps/api/db/migrations/meta/_journal.json
5+
apps/api/db/migrations/meta/_journal.json
6+
AI_README.md

apps/api/src/company/company.controller.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {
22
CompanyAdminDto,
3+
CompanyBoothPlanDto,
34
CompanyDto,
45
CompanyModifyDescriptionDto,
56
CompanyModifyDto,
@@ -49,6 +50,13 @@ export class CompanyController {
4950
return await this.companyService.getAllPublic();
5051
}
5152

53+
@UseGuards(SponsorGuard)
54+
@ApiBearerAuth()
55+
@Get('booth-plans')
56+
async getBoothPlans(): Promise<CompanyBoothPlanDto[]> {
57+
return await this.companyService.getBoothPlans();
58+
}
59+
5260
@UseGuards(AdminGuard)
5361
@Get('all-for-admin')
5462
async getAllForAdmin(): Promise<CompanyAdminDto[]> {
@@ -182,6 +190,26 @@ export class CompanyController {
182190
return await this.companyService.updateAccreditation(user.id, data);
183191
}
184192

193+
@UseGuards(SponsorGuard)
194+
@ApiBearerAuth()
195+
@Patch('/booth-plan')
196+
async updateBoothPlan(
197+
@Req() { user }: AuthenticatedRequest,
198+
@Body() data: { boothPlan: string },
199+
) {
200+
return await this.companyService.updateBoothPlan(user.id, data);
201+
}
202+
203+
@UseGuards(SponsorGuard)
204+
@ApiBearerAuth()
205+
@Patch('/equipment')
206+
async updateEquipment(
207+
@Req() { user }: AuthenticatedRequest,
208+
@Body() data: { equipment: string },
209+
) {
210+
return await this.companyService.updateEquipment(user.id, data);
211+
}
212+
185213
@UseGuards(SponsorGuard)
186214
@ApiBearerAuth()
187215
@Patch('/flytalk-holders')

apps/api/src/company/company.service.ts

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {
22
CompanyAdminDto,
3+
CompanyBoothPlanDto,
34
CompanyDto,
45
CompanyModifyDescriptionDto,
56
CompanyModifyDto,
@@ -53,6 +54,8 @@ export class CompanyService {
5354
},
5455
password: false,
5556
campfireParticipation: true,
57+
boothPlan: true,
58+
category: true,
5659
},
5760
orderBy: { name: 'asc' },
5861
});
@@ -656,4 +659,73 @@ export class CompanyService {
656659
campfireParticipation: company.campfireParticipation,
657660
}));
658661
}
662+
663+
async updateEquipment(
664+
companyId: number,
665+
data: { equipment: string },
666+
): Promise<CompanyPublicDto> {
667+
const updatedCompany = await this.prisma.company.update({
668+
where: { id: companyId },
669+
data: {
670+
equipment: data.equipment === '[]' ? null : data.equipment,
671+
},
672+
include: {
673+
booth: { select: { name: true, id: true } },
674+
},
675+
});
676+
677+
return {
678+
...updatedCompany,
679+
booth: updatedCompany.booth?.name || null,
680+
boothId: updatedCompany.booth?.id || null,
681+
flytalkHolders:
682+
(updatedCompany.flytalkHolders as unknown as JSON) || null,
683+
};
684+
}
685+
686+
async updateBoothPlan(
687+
companyId: number,
688+
data: { boothPlan: string },
689+
): Promise<CompanyPublicDto> {
690+
const updatedCompany = await this.prisma.company.update({
691+
where: { id: companyId },
692+
data: {
693+
boothPlan: data.boothPlan === '' ? null : data.boothPlan,
694+
},
695+
include: {
696+
booth: { select: { name: true, id: true } },
697+
},
698+
});
699+
700+
return {
701+
...updatedCompany,
702+
booth: updatedCompany.booth?.name || null,
703+
boothId: updatedCompany.booth?.id || null,
704+
flytalkHolders:
705+
(updatedCompany.flytalkHolders as unknown as JSON) || null,
706+
};
707+
}
708+
async getBoothPlans(): Promise<CompanyBoothPlanDto[]> {
709+
const companies = await this.prisma.company.findMany({
710+
where: {
711+
boothPlan: {
712+
not: null,
713+
},
714+
},
715+
select: {
716+
id: true,
717+
name: true,
718+
category: true,
719+
boothPlan: true,
720+
},
721+
orderBy: { name: 'asc' },
722+
});
723+
724+
return companies.map((company) => ({
725+
id: company.id,
726+
name: company.name,
727+
category: company.category,
728+
boothPlan: company.boothPlan,
729+
}));
730+
}
659731
}

apps/app/src/router/Router.tsx

Lines changed: 77 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ import FloorPlanPage from '@/pages/FloorPlanPage/FloorPlanPage';
3838
import AccreditationScanPage from '@/pages/AccreditationScanPage';
3939
import { GoogleCallback } from '@/pages/GoogleCallbackPage/GoogleCallback';
4040

41-
// import ClosedAppPage from '@/pages/ClosedAppPage';
41+
import ClosedAppPage from '@/pages/ClosedAppPage';
42+
43+
const isAppOpen = false;
4244

4345
const router = createBrowserRouter(
4446
createRoutesFromElements(
@@ -47,69 +49,93 @@ const router = createBrowserRouter(
4749
path={RouteNames.TERMS_AND_CONDITIONS}
4850
element={<TermsAndConditionsPage />}
4951
/>
50-
<Route path={RouteNames.LOGIN} element={<LoginPage />} />
51-
<Route element={<RegistrationLayout />}>
52-
<Route path={RouteNames.REGISTER} element={<RegisterPage />} />
53-
<Route path={RouteNames.PROFILE_AVATARS} element={<AvatarsPage />} />
54-
</Route>
55-
<Route path={RouteNames.CONFIRM_EMAIL} element={<ConfirmEmailPage />} />
56-
<Route path={RouteNames.PASSWORD_RESET} element={<PasswordResetPage />} />
57-
<Route
58-
path={RouteNames.PASSWORD_RESET_WITH_TOKEN}
59-
element={<PasswordResetPage />}
60-
/>
61-
<Route path={RouteNames.NOTIFICATIONS} element={<NotificationsPage />} />
62-
<Route path={RouteNames.RATE_COMPANY} element={<RateCompanyPage />} />
63-
<Route path={RouteNames.RATE_EVENT} element={<RateLecturePage />} />
64-
<Route path={RouteNames.SCANNER} element={<ScannerPage />} />
65-
<Route path={RouteNames.FLOOR_PLAN} element={<FloorPlanPage />} />
66-
<Route element={<NavigationLayout />} errorElement={<>error</>}>
67-
<Route path={RouteNames.HOME} element={<Home />} />
6852

69-
<Route path={RouteNames.PROFILE}>
70-
<Route index element={<ProfilePage />} />
53+
{isAppOpen ? (
54+
<>
55+
<Route path={RouteNames.LOGIN} element={<LoginPage />} />
7156
<Route
72-
path={RouteNames.PROFILE_INTERESTS}
73-
element={<ProfileInterestsPage />}
57+
path={RouteNames.GOOGLE_CALLBACK}
58+
element={<GoogleCallback />}
7459
/>
75-
<Route path={RouteNames.PROFILE_REWARDS} element={<RewardsPage />} />
60+
61+
<Route element={<RegistrationLayout />}>
62+
<Route path={RouteNames.REGISTER} element={<RegisterPage />} />
63+
<Route
64+
path={RouteNames.PROFILE_AVATARS}
65+
element={<AvatarsPage />}
66+
/>
67+
</Route>
68+
7669
<Route
77-
path={RouteNames.PROFILE_RECOMMENDATIONS}
78-
element={<ProfileRecommendationsPage></ProfileRecommendationsPage>}
70+
path={RouteNames.CONFIRM_EMAIL}
71+
element={<ConfirmEmailPage />}
7972
/>
8073
<Route
81-
path={RouteNames.PROFILE_SETTINGS}
82-
element={<SettingsPage />}
74+
path={RouteNames.PASSWORD_RESET}
75+
element={<PasswordResetPage />}
8376
/>
8477
<Route
85-
path={RouteNames.PROFILE_ACHIEVEMENTS}
86-
element={<ProfileAchievementsPage />}
78+
path={RouteNames.PASSWORD_RESET_WITH_TOKEN}
79+
element={<PasswordResetPage />}
8780
/>
8881
<Route
89-
path={RouteNames.PROFILE_LEADERBOARD}
90-
element={<ProfileLeaderboardPage />}
82+
path={RouteNames.NOTIFICATIONS}
83+
element={<NotificationsPage />}
9184
/>
92-
<Route path={RouteNames.PROFILE_RECOMMENDATIONS} element={<></>} />
93-
</Route>
94-
<Route path={RouteNames.COMPANIES} element={<CompaniesPage />} />
95-
<Route path={RouteNames.SCHEDULE} element={<SchedulePage />} />
96-
<Route path={RouteNames.FLY_TALKS} element={<FlyTalksPage />} />
97-
<Route
98-
path={RouteNames.FLY_TALKS_APPLY}
99-
element={<FlyTalksApplyPage />}
100-
/>
101-
<Route path={RouteNames.SHOPPING} element={<ShoppingPage />} />
102-
<Route
103-
path={RouteNames.ACCREDITATION_SCAN}
104-
element={<AccreditationScanPage />}
105-
/>
106-
</Route>
107-
<Route path='/app/test' element={<TestPage />} />
108-
<Route path='*' element={<NotFoundPage />} />
85+
<Route path={RouteNames.RATE_COMPANY} element={<RateCompanyPage />} />
86+
<Route path={RouteNames.RATE_EVENT} element={<RateLecturePage />} />
87+
<Route path={RouteNames.SCANNER} element={<ScannerPage />} />
88+
<Route path={RouteNames.FLOOR_PLAN} element={<FloorPlanPage />} />
10989

110-
<Route path={RouteNames.GOOGLE_CALLBACK} element={<GoogleCallback />} />
90+
<Route element={<NavigationLayout />} errorElement={<>error</>}>
91+
<Route path={RouteNames.HOME} element={<Home />} />
92+
<Route path={RouteNames.PROFILE}>
93+
<Route index element={<ProfilePage />} />
94+
<Route
95+
path={RouteNames.PROFILE_INTERESTS}
96+
element={<ProfileInterestsPage />}
97+
/>
98+
<Route
99+
path={RouteNames.PROFILE_REWARDS}
100+
element={<RewardsPage />}
101+
/>
102+
<Route
103+
path={RouteNames.PROFILE_RECOMMENDATIONS}
104+
element={<ProfileRecommendationsPage />}
105+
/>
106+
<Route
107+
path={RouteNames.PROFILE_SETTINGS}
108+
element={<SettingsPage />}
109+
/>
110+
<Route
111+
path={RouteNames.PROFILE_ACHIEVEMENTS}
112+
element={<ProfileAchievementsPage />}
113+
/>
114+
<Route
115+
path={RouteNames.PROFILE_LEADERBOARD}
116+
element={<ProfileLeaderboardPage />}
117+
/>
118+
</Route>
119+
<Route path={RouteNames.COMPANIES} element={<CompaniesPage />} />
120+
<Route path={RouteNames.SCHEDULE} element={<SchedulePage />} />
121+
<Route path={RouteNames.FLY_TALKS} element={<FlyTalksPage />} />
122+
<Route
123+
path={RouteNames.FLY_TALKS_APPLY}
124+
element={<FlyTalksApplyPage />}
125+
/>
126+
<Route path={RouteNames.SHOPPING} element={<ShoppingPage />} />
127+
<Route
128+
path={RouteNames.ACCREDITATION_SCAN}
129+
element={<AccreditationScanPage />}
130+
/>
131+
</Route>
132+
<Route path='/app/test' element={<TestPage />} />
111133

112-
{/* <Route path='*' element={<ClosedAppPage />} />c */}
134+
<Route path='*' element={<NotFoundPage />} />
135+
</>
136+
) : (
137+
<Route path='*' element={<ClosedAppPage />} />
138+
)}
113139
</React.Fragment>,
114140
),
115141
);

apps/sponsor/src/App.tsx

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,6 @@ export const App = () => {
3232
path='/sponsor/materials'
3333
children={<Redirect to={Path.Materials} />}
3434
/>
35-
{/*
36-
<Route
37-
path='/sponsor/stand'
38-
children={<Redirect to={Path.SpotsPage} />}
39-
/>
40-
*/}
4135
</Switch>
4236
<Toaster />
4337
</HelmetProvider>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { CompanyPublicDto } from '@ddays-app/types';
2+
import { useQuery } from 'react-query';
3+
4+
import { api } from '..';
5+
6+
const companyGetAllPublic = async () => {
7+
return (await api.get<CompanyPublicDto[]>('/company')).data;
8+
};
9+
10+
export const useCompanyGetAllPublic = () => {
11+
return useQuery(['company', 'all-public'], companyGetAllPublic);
12+
};
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { CompanyBoothPlanDto } from '@ddays-app/types';
2+
import { useQuery } from 'react-query';
3+
4+
import { api } from '..';
5+
6+
const companyGetBoothPlans = async (): Promise<CompanyBoothPlanDto[]> => {
7+
const response = await api.get<CompanyBoothPlanDto[]>('/company/booth-plans');
8+
return response as unknown as CompanyBoothPlanDto[];
9+
};
10+
11+
export const useCompanyGetBoothPlans = () => {
12+
return useQuery(['company', 'booth-plans'], companyGetBoothPlans);
13+
};
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { CompanyPublicDto } from '@ddays-app/types';
2+
import { useMutation, useQueryClient } from 'react-query';
3+
4+
import { api } from '..';
5+
6+
const companyUpdateBoothPlan = async (data: { boothPlan: string }) => {
7+
return await api.patch<CompanyPublicDto, { boothPlan: string }>(
8+
'/company/booth-plan',
9+
data,
10+
);
11+
};
12+
13+
export const useCompanyUpdateBoothPlan = () => {
14+
const queryClient = useQueryClient();
15+
16+
return useMutation(companyUpdateBoothPlan, {
17+
onSuccess: () => {
18+
queryClient.invalidateQueries(['company', 'current']);
19+
queryClient.invalidateQueries(['company', 'all-public']);
20+
},
21+
});
22+
};
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { CompanyPublicDto } from '@ddays-app/types';
2+
import { useMutation, useQueryClient } from 'react-query';
3+
4+
import { api } from '..';
5+
6+
export const useCompanyUpdateEquipment = () => {
7+
const query = useQueryClient();
8+
9+
return useMutation(
10+
async (data: { equipment: string }) => {
11+
const response = await api.patch<{ equipment: string }, CompanyPublicDto>(
12+
'/company/equipment',
13+
data,
14+
);
15+
return response;
16+
},
17+
{
18+
onSuccess: () => {
19+
query.invalidateQueries('company');
20+
},
21+
},
22+
);
23+
};

apps/sponsor/src/components/BoothConfirmationPage/BoothConfirmationPage.module.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,4 @@
6969

7070
margin-top: 40px;
7171
}
72-
}
72+
}

0 commit comments

Comments
 (0)