Skip to content
This repository was archived by the owner on Oct 7, 2025. It is now read-only.

Commit 2000e1c

Browse files
committed
feat(axiom): implement form builder
1 parent c811b0c commit 2000e1c

File tree

9 files changed

+601
-97
lines changed

9 files changed

+601
-97
lines changed

apps/axiom/src/components/Nav/navIconMap.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
Users,
1010
PersonStanding,
1111
MousePointer2,
12+
Inbox,
1213
Trophy,
1314
CalendarDays,
1415
Cpu
@@ -28,7 +29,8 @@ export const navIconMap: Partial<
2829
challengePrize: Trophy,
2930
"base-event": CalendarDays,
3031
"general-event": CalendarDays,
31-
"application-form": MousePointer2,
32+
forms: MousePointer2,
33+
"form-submissions": Inbox,
3234
hardware: Cpu
3335
}
3436

libs/cms/auth/config.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ export const baseConfig = {
2121

2222
export const githubStrategyConfig = {
2323
strategyName: "github",
24-
subFieldName: 'githubSub',
2524
clientId: process.env.GITHUB_CLIENT_ID || "",
2625
clientSecret: process.env.GITHUB_CLIENT_SECRET || "",
2726
authorizePath: "/oauth/github",
@@ -36,7 +35,6 @@ export const githubStrategyConfig = {
3635

3736
export const linkedinStrategyConfig = {
3837
strategyName: "linkedin",
39-
subFieldName: 'linkedinSub',
4038
clientId: process.env.LINKEDIN_CLIENT_ID || "",
4139
clientSecret: process.env.LINKEDIN_CLIENT_SECRET || "",
4240
authorizePath: "/oauth/linkedin",
@@ -51,7 +49,6 @@ export const linkedinStrategyConfig = {
5149

5250
export const discordStrategyConfig = {
5351
strategyName: "discord",
54-
subFieldName: 'discordSub',
5552
clientId: process.env.DISCORD_CLIENT_ID || "",
5653
clientSecret: process.env.DISCORD_CLIENT_SECRET || "",
5754
authorizePath: "/oauth/discord",
@@ -66,7 +63,6 @@ export const discordStrategyConfig = {
6663

6764
export const googleStrategyConfig = {
6865
strategyName: "google",
69-
subFieldName: 'googleSub',
7066
clientId: process.env.GOOGLE_CLIENT_ID || "",
7167
clientSecret: process.env.GOOGLE_CLIENT_SECRET || "",
7268
authorizePath: "/oauth/google",

libs/cms/auth/strategies/google.ts

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { PayloadRequest } from "payload";
22
import { OAuth2Plugin, defaultGetToken } from "payload-oauth2";
33
import { googleStrategyConfig } from "@/cms/auth/config"
4-
import {generateEmail} from '@/cms/utils'
54

65
export const googleOAuth = OAuth2Plugin({
76
useEmailAsIdentity: true,
@@ -20,40 +19,40 @@ getUserInfo: async (accessToken: string, req: PayloadRequest) => {
2019

2120
const user = await response.json();
2221

23-
// const existingUser = await req.payload.find({
24-
// collection: 'users',
25-
// where: {
26-
// email: {
27-
// equals: req.user?.email,
28-
// },
29-
// },
30-
// limit: 1,
31-
// })
22+
const existingUser = await req.payload.find({
23+
collection: 'users',
24+
where: {
25+
email: {
26+
equals: req.user?.email,
27+
},
28+
},
29+
limit: 1,
30+
})
3231

33-
// if (!existingUser.docs || existingUser.docs.length === 0) {
34-
// console.log('Creating new user for:', req.user)
32+
if (!existingUser.docs || existingUser.docs.length === 0) {
33+
}
3534

36-
// const newUser = await req.payload.create({
37-
// collection: 'users',
38-
// data: {
39-
// email: req.user?.email,
40-
// displayName: req.user?.displayName,
41-
// mediaUrl: req.user?.photoUrl
42-
// // roles: ['hacker'],
43-
// },
44-
// })
45-
// return {
46-
// ...newUser,
47-
// // roles: ['customer'],
48-
// }
49-
// }
35+
// console.log('Creating new user for:', req.user)
36+
37+
// const newUser = await req.payload.create({
38+
// collection: 'users',
39+
// data: {
40+
// email: req.user?.email,
41+
// displayName: req.user?.displayName,
42+
// mediaUrl: req.user?.photoUrl
43+
// // roles: ['hacker'],
44+
// },
45+
// })
46+
// return {
47+
// ...newUser,
48+
// // roles: ['customer'],
49+
// }
5050

5151
// console.log('Found existing user:', existingUser.docs[0])
5252
// const userFromDB = existingUser.docs[0]
5353

5454
return {
5555
email: user.email,
56-
googleSub: user.sub,
5756
googleEmail: user.email,
5857
googleEmailVerified: user.email_verified,
5958
};

libs/cms/auth/strategies/linkedin.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { Payload, PayloadRequest } from "payload";
22
import type { File } from "payload";
33
import { OAuth2Plugin } from "payload-oauth2";
44
import { linkedinStrategyConfig } from "@/cms/auth/config";
5+
import {generateEmail} from '@/cms/utils'
56

67
async function uploadFileByURL(
78
payload: Payload,

libs/cms/configs/server.ts

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// github.com/jhb-software/payload-plugins/tree/main/geocoding
22
/* eslint-disable node/prefer-global/process */
3-
import {Brands, Roles} from "@/db/collections"
3+
import {adminGroups, Brands, Roles} from "@/db/collections"
44
import {Sponsor,
55
Organization,
66
ChallengePrize,
@@ -9,7 +9,6 @@ import {Sponsor,
99
UserToEvent,
1010
GeneralEvent,
1111
BaseEvent,
12-
ApplicationForm,
1312
Media,
1413
Emails,
1514
Hardware,
@@ -18,6 +17,7 @@ import {Sponsor,
1817
import {Constants} from "@/db/globals";
1918
import { linkedinOAuth, githubOAuth, discordOAuth, googleOAuth } from '@/cms/auth'
2019

20+
import { formBuilderPlugin } from '@payloadcms/plugin-form-builder'
2121
import { resendAdapter } from '@payloadcms/email-resend'
2222
import { postgresAdapter } from "@payloadcms/db-postgres";
2323
import { s3Storage } from '@payloadcms/storage-s3'
@@ -38,7 +38,6 @@ export const baseConfig = {
3838
Roles,
3939
BaseEvent,
4040
Hardware,
41-
ApplicationForm,
4241
GeneralEvent,
4342
UserToEvent,
4443
SponsorToEvent,
@@ -55,6 +54,41 @@ export const baseConfig = {
5554
githubOAuth,
5655
discordOAuth,
5756
googleOAuth,
57+
formBuilderPlugin({
58+
defaultToEmail: 'info@cuhacking,ca',
59+
// redirectRelationships: ['pages'],
60+
fields: {
61+
text: true,
62+
textarea: true,
63+
select: true,
64+
email: true,
65+
state: true,
66+
country: true,
67+
checkbox: true,
68+
number: true,
69+
message: true,
70+
payment: false,
71+
},
72+
formOverrides: {
73+
admin: {
74+
group: adminGroups.communication,
75+
livePreview: {
76+
// url: `${process.env.CUHACKING_2025_PORTAL_LOCAL_URL}/registration`,
77+
url: `${process.env.CUHACKING_2025_PORTAL_PUBLIC_URL}/registration`,
78+
}
79+
},
80+
versions: {
81+
drafts: true
82+
},
83+
// access: {
84+
// },
85+
},
86+
formSubmissionOverrides:{
87+
admin: {
88+
group: adminGroups.communication
89+
},
90+
}
91+
}),
5892
process.env.NODE_ENV==='production' && s3Storage({
5993
collections: {
6094
media: {

libs/db/collections/models/Users.ts

Lines changed: 10 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
// https://github.com/shefing/payload-tools/tree/main/packages/authorization
22
/* eslint-disable node/prefer-global/process */
33
import type { CollectionConfig } from 'payload'
4-
import { admins, adminsAndUser, anyone,
4+
import { admins,
5+
adminsAndUser,
6+
anyone,
57
// checkRole
68
} from '@/db/access'
79
// import { authenticated, isAdminFieldLevel } from '@/db/access'
@@ -58,6 +60,10 @@ export const Users: CollectionConfig = {
5860
limits: [10, 20, 50],
5961
},
6062
},
63+
versions: {
64+
drafts: true,
65+
maxPerDoc: 1,
66+
},
6167
fields: [
6268
{
6369
name: 'roles',
@@ -211,15 +217,6 @@ export const Users: CollectionConfig = {
211217
label: 'Handle',
212218
admin: { readOnly: true },
213219
},
214-
// {
215-
// name: 'linkedinSub',
216-
// type: 'text',
217-
// admin: {
218-
// readOnly: true,
219-
// // condition: (data, siblingData, { user }) => {
220-
// // return false
221-
// },
222-
// },
223220
{
224221
name: 'linkedinId',
225222
type: 'text',
@@ -274,10 +271,6 @@ export const Users: CollectionConfig = {
274271
},
275272
},
276273
},
277-
// {
278-
// name: 'githubSub',
279-
// type: 'text',
280-
// },
281274
{
282275
name: 'githubAvatarUrl',
283276
type: 'text',
@@ -374,8 +367,9 @@ export const Users: CollectionConfig = {
374367
type: 'text',
375368
admin: {
376369
readOnly: true,
377-
// condition: (data, siblingData, { user }) => {
378-
// return false
370+
condition: () => {
371+
return false
372+
}
379373
},
380374
},
381375
],
@@ -385,15 +379,6 @@ export const Users: CollectionConfig = {
385379
label: 'Google',
386380
fields: [
387381
{ name: 'googleEmail', type: 'email' },
388-
// {
389-
// name: 'googleSub',
390-
// type: 'text',
391-
// admin: {
392-
// readOnly: true,
393-
// // condition: (data, siblingData, { user }) => {
394-
// // return false
395-
// },
396-
// },
397382
{
398383
name: 'googleEmailVerified',
399384
type: 'checkbox',
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
export * from './Application'
1+
// export * from './Application'
22
export * from './Challenge'
33
export * from './Criteria'
44
export * from './Emails'
55
export * from './Event'
66
export * from './Hackathons'
7+
export * from './Hardware'
78
export * from './Host-To-Event'
89
export * from './Media'
910
export * from './Organization'
1011
export * from './Sponsor-To-Event'
1112
export * from './Teams'
1213
export * from './User-To-Event'
1314
export * from './Users'
14-
export * from './Hardware'

0 commit comments

Comments
 (0)