Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Satisfies User Settings w/ New Schema #112

Merged
merged 99 commits into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
99 commits
Select commit Hold shift + click to select a range
ac57850
renames users table
xwilson03 Aug 3, 2024
6eb7a3c
moves registration data fields to user data
xwilson03 Aug 3, 2024
12691fa
moves all profile data into user data
xwilson03 Aug 3, 2024
bdc6d33
moves some user data into registration data
xwilson03 Aug 3, 2024
4e391d8
TEMP: removes migrations:apply step from build
xwilson03 Aug 3, 2024
a4a84ad
removes checkedIn from user data
xwilson03 Aug 3, 2024
e128066
organizes fields for user and reg data
xwilson03 Aug 3, 2024
0b01091
renames reg data to hacker data
xwilson03 Aug 3, 2024
1f1af2f
adds serial PK to user data
xwilson03 Aug 3, 2024
fe47e2a
shortens lengthy column names
xwilson03 Aug 3, 2024
4488f94
updates userdata-hackerdata relation name
xwilson03 Aug 3, 2024
b6f174b
renames booleans
xwilson03 Aug 3, 2024
4eaee36
updates package lock
xwilson03 Aug 3, 2024
01a10b8
changes naming convention for user data tables
xwilson03 Aug 3, 2024
9eeafa2
updates trivial instances of changed schema columns
xwilson03 Aug 3, 2024
f8760a9
removes commented references to old schema
xwilson03 Aug 3, 2024
34088c0
updates scanner checkin action
xwilson03 Aug 3, 2024
6a3fdc8
updates more trivial substitutions
xwilson03 Aug 4, 2024
fd75399
reverts serial id change
xwilson03 Aug 4, 2024
b1b25dd
fixes team members relation
xwilson03 Aug 4, 2024
5e8c1e6
adds db migration
xwilson03 Aug 4, 2024
1cb2689
updates checkin page
xwilson03 Aug 5, 2024
d118050
slightly refactors checkin
xwilson03 Aug 5, 2024
b61c3c9
updates user interface
xwilson03 Aug 5, 2024
11468ac
updates and simplifies admin user table component
xwilson03 Aug 5, 2024
aebcde3
restructures user type interface
xwilson03 Aug 6, 2024
1478e2e
updates server sections of admin user table
xwilson03 Aug 6, 2024
a70247a
adds commonData relation to hackerData
xwilson03 Aug 6, 2024
bb6ce86
updates team page
xwilson03 Aug 6, 2024
e4a9950
updates trivial schema references
xwilson03 Aug 6, 2024
5ffeffd
updates last known references
xwilson03 Aug 7, 2024
3d609b2
deletes unused code in event columns
xwilson03 Aug 7, 2024
5c8d395
replaces last profileData refs
xwilson03 Aug 7, 2024
209e243
updates pass scanner
xwilson03 Aug 7, 2024
0dff0ea
runs formatter
xwilson03 Aug 7, 2024
5d66688
Merge remote-tracking branch 'origin/dev' into feat/refactor-user-schema
xwilson03 Aug 11, 2024
6b620f9
fixes schoolID rename
xwilson03 Aug 13, 2024
6cd422a
patcches user section of admin panel
xwilson03 Aug 14, 2024
5c146bd
slightly refactors scanner code
xwilson03 Aug 14, 2024
73a92be
slightly simplifies leaveTeam action
xwilson03 Aug 14, 2024
5a5edad
fixes scanner page
xwilson03 Aug 15, 2024
45febfc
adjusts formatting
xwilson03 Aug 15, 2024
a277824
adjusts whitespace
xwilson03 Aug 15, 2024
2179bdb
fixes admin export
xwilson03 Aug 15, 2024
fc1e67a
reruns formatter
xwilson03 Aug 15, 2024
1273865
Updated settings for User and Registration
jacobellerbrock Aug 27, 2024
f6d6296
Added settings menu:
jacobellerbrock Sep 5, 2024
47ae8c5
Added settings menu:
jacobellerbrock Sep 5, 2024
ed3b305
Removed old settings menus
jacobellerbrock Sep 5, 2024
92e2b00
Added Registration Settings menu
jacobellerbrock Sep 8, 2024
dff44bf
moves invite relation to hacker data
xwilson03 Sep 8, 2024
82425a1
updates references to invite relation
xwilson03 Sep 8, 2024
a422b9b
trims schema imports
xwilson03 Sep 8, 2024
a8488a6
reruns formatter
xwilson03 Sep 8, 2024
acd7be2
Fixed page.tsx error
jacobellerbrock Sep 8, 2024
f9eef0a
General types adjusted
jacobellerbrock Sep 8, 2024
5db824b
Added resume
jacobellerbrock Sep 9, 2024
cf1084d
Added resume
jacobellerbrock Sep 9, 2024
909ac01
Merge branch 'dev' into feat/user-settings
jacobellerbrock Sep 9, 2024
3c68817
Added UI/UX
jacobellerbrock Sep 10, 2024
3b54765
Updated lockfile
jacobellerbrock Sep 10, 2024
15d90c7
Fixed with Prettier
jacobellerbrock Sep 10, 2024
5198638
Fixed important changes
jacobellerbrock Sep 10, 2024
fc1890e
Removed .idea folder
jacobellerbrock Sep 10, 2024
7c62ff3
Prettier updated
jacobellerbrock Sep 10, 2024
5e58266
Modified .gitignore to filter out .idea file
jacobellerbrock Sep 10, 2024
d7e474e
Prettier check
jacobellerbrock Sep 10, 2024
3cb3c04
removes back button
christianhelp Sep 11, 2024
0aa79dd
updates lock
christianhelp Sep 11, 2024
1e66114
runs formatter
christianhelp Sep 11, 2024
513196a
Merge remote-tracking branch 'origin/dev' into feat/refactor-user-schema
christianhelp Sep 11, 2024
1a64b15
updates eventform schema
christianhelp Sep 11, 2024
0cd1a70
updates events type
christianhelp Sep 11, 2024
60948c3
updates lock file
christianhelp Sep 11, 2024
936fc69
adds back migrations
christianhelp Sep 11, 2024
6f2b531
Merge remote-tracking branch 'origin/feat/refactor-user-schema' into …
jacobellerbrock Sep 16, 2024
43ef3db
Merged
jacobellerbrock Sep 16, 2024
d4b93f3
Exported dietaryRestriction, schools, and majors in config
jacobellerbrock Sep 17, 2024
e5f254f
Settings updated and helper function added for hacker data
jacobellerbrock Sep 17, 2024
22ebf50
Cleaned up unused imports
jacobellerbrock Sep 17, 2024
86cdeae
Changed race settings to use config
jacobellerbrock Sep 17, 2024
df6103e
Prettier write
jacobellerbrock Sep 17, 2024
969e300
Fixed schoolID not filling correctly
jacobellerbrock Sep 17, 2024
9351bea
Prettier write
jacobellerbrock Sep 17, 2024
889e387
Discord username no longer required
jacobellerbrock Sep 18, 2024
2d1fe3c
Added phone number (can't be empty) and country of residence
jacobellerbrock Sep 19, 2024
77cee98
Prettier write
jacobellerbrock Sep 19, 2024
6dd5524
Simplified types and useAction
jacobellerbrock Sep 23, 2024
60368ec
Hotfix: Age can no longer be set to below 18 in settings
jacobellerbrock Sep 24, 2024
4ff3be9
Hotfix: Profanity is no longer allowed in hacker tag when changing in…
jacobellerbrock Sep 24, 2024
a72009e
Removed unused imports/constants
jacobellerbrock Sep 27, 2024
0f8fbb8
Removed unnecessary statements and combined parallel Promises
jacobellerbrock Sep 29, 2024
7e61f80
Merge remote-tracking branch 'origin/dev' into feat/user-settings-new…
christianhelp Oct 24, 2024
17fe6ed
updates for new use action compatability
christianhelp Oct 24, 2024
1085b05
runs formatter
christianhelp Oct 24, 2024
68c3a6a
remove commented code
christianhelp Oct 24, 2024
3463cb9
Merge remote-tracking branch 'origin/dev' into feat/user-settings-new…
christianhelp Oct 24, 2024
8d21805
slight touchups
christianhelp Oct 24, 2024
eb94e99
format write
christianhelp Oct 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,6 @@ yarn-error.log*

# vscode
.vscode

christianhelp marked this conversation as resolved.
Show resolved Hide resolved
#Jetbrians
.idea
187 changes: 165 additions & 22 deletions apps/web/src/actions/user-profile-mod.ts
jacobellerbrock marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -3,54 +3,198 @@
import { authenticatedAction } from "@/lib/safe-action";
import { z } from "zod";
import { db } from "db";
import { userCommonData } from "db/schema";
import { userCommonData, userHackerData } from "db/schema";
import { eq } from "db/drizzle";
import { put } from "@vercel/blob";
import { decodeBase64AsFile } from "@/lib/utils/shared/files";
import { returnValidationErrors } from "next-safe-action";
import { revalidatePath } from "next/cache";
import { getUser } from "db/functions";
import { getUser, getUserByTag } from "db/functions";
import { RegistrationSettingsFormValidator } from "@/validators/shared/RegistrationSettingsForm";

// TODO: Add skill updating
export const modifyRegistrationData = authenticatedAction
.schema(RegistrationSettingsFormValidator)
.action(
async ({
parsedInput: {
age,
gender,
race,
ethnicity,
isEmailable,
university,
major,
levelOfStudy,
schoolID,
hackathonsAttended,
softwareBuildingExperience,
heardAboutEvent,
shirtSize,
dietaryRestrictions,
accommodationNote,
github,
linkedin,
personalWebsite,
phoneNumber,
countryOfResidence,
},
ctx: { userId },
}) => {
const user = await getUser(userId);
if (!user) throw new Error("User not found");
await Promise.all([
db
.update(userCommonData)
.set({
age,
gender,
race,
ethnicity,
shirtSize,
dietRestrictions: dietaryRestrictions,
accommodationNote,
phoneNumber,
countryOfResidence,
})
.where(eq(userCommonData.clerkID, user.clerkID)),
db
.update(userHackerData)
.set({
isEmailable,
university,
major,
levelOfStudy,
schoolID,
hackathonsAttended,
softwareExperience: softwareBuildingExperience,
heardFrom: heardAboutEvent,
GitHub: github,
LinkedIn: linkedin,
PersonalWebsite: personalWebsite,
})
.where(eq(userHackerData.clerkID, user.clerkID)),
]);
return {
success: true,
newAge: age,
newGender: gender,
newRace: race,
newEthnicity: ethnicity,
newWantsToReceiveMLHEmails: isEmailable,
newUniversity: university,
newMajor: major,
newLevelOfStudy: levelOfStudy,
newSchoolID: schoolID,
newHackathonsAttended: hackathonsAttended,
newSoftwareExperience: softwareBuildingExperience,
newHeardFrom: heardAboutEvent,
newShirtSize: shirtSize,
newDietaryRestrictions: dietaryRestrictions,
newAccommodationNote: accommodationNote,
newGitHub: github,
newLinkedIn: linkedin,
newPersonalWebsite: personalWebsite,
newPhoneNumber: phoneNumber,
newCountryOfResidence: countryOfResidence,
};
},
);

export const modifyResume = authenticatedAction
.schema(
z.object({
bio: z.string().max(500),
skills: z.string().max(100),
resume: z.string(),
}),
)
.action(async ({ parsedInput: { bio, skills }, ctx: { userId } }) => {
const user = await getUser(userId);
if (!user)
returnValidationErrors(z.null(), { _errors: ["User not found"] });

.action(async ({ parsedInput: { resume }, ctx: { userId } }) => {
await db
.update(userCommonData)
.set({ bio })
.where(eq(userCommonData.clerkID, user.clerkID));
return { success: true, newbio: bio };
.update(userHackerData)
.set({ resume })
.where(eq(userHackerData.clerkID, userId));
return {
success: true,
newResume: resume,
};
});

export const modifyProfileData = authenticatedAction
.schema(
z.object({
pronouns: z.string(),
bio: z.string(),
skills: z.string().array(),
discord: z.string(),
}),
)
.action(
async ({
parsedInput: { bio, discord, pronouns, skills },
ctx: { userId },
}) => {
const user = await getUser(userId);
if (!user) {
throw new Error("User not found");
}
await db
.update(userCommonData)
.set({ pronouns, bio, skills, discord })
.where(eq(userCommonData.clerkID, user.clerkID));
return {
success: true,
newPronouns: pronouns,
newBio: bio,
newSkills: skills,
newDiscord: discord,
};
},
);

// TODO: Fix after registration enhancements to allow for failure on conflict and return appropriate error message
export const modifyAccountSettings = authenticatedAction
.schema(
z.object({
firstName: z.string().min(1).max(50),
lastName: z.string().min(1).max(50),
hackerTag: z.string().min(1).max(50),
hasSearchableProfile: z.boolean(),
}),
)
.action(
async ({ parsedInput: { firstName, lastName }, ctx: { userId } }) => {
async ({
parsedInput: {
firstName,
lastName,
hackerTag,
hasSearchableProfile,
},
ctx: { userId },
}) => {
const user = await getUser(userId);
if (!user) throw new Error("User not found");

let oldHackerTag = user.hackerTag; // change when hackertag is not PK on profileData table
if (oldHackerTag != hackerTag)
if (await getUserByTag(hackerTag))
//if hackertag changed
// copied from /api/registration/create
return {
success: false,
message: "hackertag_not_unique",
};
await db
.update(userCommonData)
.set({ firstName, lastName })
.set({
firstName,
lastName,
hackerTag,
isSearchable: hasSearchableProfile,
})
.where(eq(userCommonData.clerkID, userId));
return {
success: true,
newFirstName: firstName,
newLastName: lastName,
newHackerTag: hackerTag,
newHasSearchableProfile: hasSearchableProfile,
};
},
);
Expand All @@ -60,11 +204,10 @@ export const updateProfileImage = authenticatedAction
.action(
async ({ parsedInput: { fileBase64, fileName }, ctx: { userId } }) => {
const image = await decodeBase64AsFile(fileBase64, fileName);
const user = await getUser(userId);
if (!user)
returnValidationErrors(z.null(), {
_errors: ["User not found"],
});
const user = await db.query.userCommonData.findFirst({
where: eq(userCommonData.clerkID, userId),
});
if (!user) throw new Error("User not found");

const blobUpload = await put(image.name, image, {
access: "public",
Expand Down
15 changes: 0 additions & 15 deletions apps/web/src/app/settings/account/page.tsx

This file was deleted.

15 changes: 9 additions & 6 deletions apps/web/src/app/settings/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,15 @@ export default async function ({ children }: { children: ReactNode }) {
</div>
</div>
</div>
<div>
{/* <SettingsSection name="Settings" path="/settings" /> */}
<SettingsSection name="Account" path="/settings/account" />
<SettingsSection name="Profile" path="/settings/profile" />
</div>
<div className="col-span-4">{children}</div>
<aside className="sticky top-20 hidden h-screen md:block">
<SettingsSection name="Account" path="/settings#account" />
<SettingsSection name="Profile" path="/settings#profile" />
<SettingsSection
name="Registration"
path="/settings#registration"
/>
</aside>
<div className="col-span-4 mb-20 ml-5">{children}</div>
</div>
</>
);
Expand Down
33 changes: 31 additions & 2 deletions apps/web/src/app/settings/page.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,32 @@
export default function Page() {
return <span>howdy</span>;
import AccountSettings from "@/components/settings/AccountSettings";
import { auth } from "@clerk/nextjs";
import { redirect } from "next/navigation";
import ProfileSettings from "@/components/settings/ProfileSettings";
import RegistrationSettings from "@/components/settings/RegistrationSettings";
import { getUser } from "db/functions";

export default async function Page() {
const { userId } = auth();
if (!userId) return redirect("/sign-in");
const user = await getUser(userId);
if (!user) return redirect("/sign-in");

return (
<main>
<Header tag="Account" />
<AccountSettings user={user} />
<Header tag="Profile" />
<ProfileSettings profile={user} />
<Header tag={"Registration"} />
<RegistrationSettings />
</main>
);
}

function Header({ tag }: { tag: string }) {
return (
<h1 id={tag.toLowerCase()} className="mt-10 pb-5 text-4xl font-bold">
{tag}
</h1>
);
}
19 changes: 0 additions & 19 deletions apps/web/src/app/settings/profile/page.tsx

This file was deleted.

15 changes: 15 additions & 0 deletions apps/web/src/app/settings/registration/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { auth } from "@clerk/nextjs";
import { redirect } from "next/navigation";
import RegistrationFormSettings from "@/components/settings/RegistrationForm/RegisterFormSettings";
import { getHackerData, getUser } from "db/functions";

export default async function Page() {
const { userId } = auth();
if (!userId) return redirect("/sign-in");
const user = await getUser(userId);
if (!user) return redirect("/sign-in");
const hackerData = await getHackerData(userId);
if (!hackerData) return redirect("/sign-in");

return <RegistrationFormSettings user={user} data={hackerData} />;
}
4 changes: 0 additions & 4 deletions apps/web/src/components/registration/RegisterForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,6 @@ export default function RegisterForm({ defaultEmail }: RegisterFormProps) {
}
}, [universityValue]);

useEffect(() => {
console.log(countryValue);
}, [countryValue]);

async function onSubmit(data: z.infer<typeof RegisterFormValidator>) {
console.log(data);
setIsLoading(true);
Expand Down
Loading
Loading