-
Notifications
You must be signed in to change notification settings - Fork 2
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
Migrates project submission to judging #58
Draft
anudaweerasinghe
wants to merge
28
commits into
rewrite-nova
Choose a base branch
from
projects
base: rewrite-nova
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 14 commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
53b4e66
implements getProjects trpc procedure
anudaweerasinghe 9b3ee2a
Adds getUserProject trpc procedure
anudaweerasinghe 86fd897
implements saveProject trpc procedure
anudaweerasinghe c56328b
implements submit and unsubmit project to a prize routes
anudaweerasinghe 7f4699e
project submission page wip
anudaweerasinghe 5ca7444
fixes prize/project relations in prisma schema
anudaweerasinghe 50d0ab0
fixes project procedures to match correct schema
anudaweerasinghe 7f6ebfd
implements project submission form
anudaweerasinghe 526aaed
implements project submit button
anudaweerasinghe 6bcf677
project submission and update logic complete
anudaweerasinghe 31defaf
adds user email if it doesn't exist
anudaweerasinghe 88905d3
adds user email if it doesn't exist
anudaweerasinghe 7b8c601
refactors project details into separate component
anudaweerasinghe 26703cd
refactors project details into separate component
anudaweerasinghe 7f85920
adds nullish coalescing of otherResources to empty string
anudaweerasinghe 0ea3972
adds trim to each individual email
anudaweerasinghe 83d170d
Add error handling and error codes in projects router
anudaweerasinghe f42a1aa
uses single prisma query to get user project
anudaweerasinghe f2e6634
removes console.log in project router
anudaweerasinghe ef54628
switches from using promise to prisma. on project save
anudaweerasinghe 41188b7
adds check that team members aren't on a different team
anudaweerasinghe df99eaa
increases project submit form width
anudaweerasinghe d5dda3d
tabs styling wip
anudaweerasinghe b7ef5d5
implements tabs
anudaweerasinghe 1e5e18f
adds drop shadow to tabs
anudaweerasinghe e982b83
adds new tabs to admin page
anudaweerasinghe d7b5765
implements get user prizes endpoint
anudaweerasinghe b391748
prize submission cards wip
anudaweerasinghe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
149 changes: 149 additions & 0 deletions
149
src/components/projectSubmission/ProjectDetailsForm.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
import { useEffect, useState } from "react"; | ||
import { api } from "../../utils/api"; | ||
import Button from "../Button"; | ||
import Spinner from "../Spinner"; | ||
|
||
interface Props { | ||
email: string; | ||
} | ||
|
||
export default function ProjectDetailsForm({ email }: Props) { | ||
const { | ||
isFetching, | ||
data: project, | ||
refetch, | ||
} = api.projects.getUserProject.useQuery(); | ||
|
||
const [teamName, setTeamName] = useState(project?.teamName); | ||
const [projectName, setProjectName] = useState(project?.name); | ||
const [description, setDescription] = useState(project?.description); | ||
const [githubUrl, setGithubUrl] = useState(project?.githubUrl ?? ""); | ||
const [otherResources, setOtherResources] = useState(project?.otherResources); | ||
const [teamMembers, setTeamMembers] = useState( | ||
project?.teamMembers.map((member) => member.email) ?? [] | ||
); | ||
|
||
useEffect(() => { | ||
if (project) { | ||
setTeamName(project.teamName); | ||
setProjectName(project.name); | ||
setDescription(project.description); | ||
setGithubUrl(project.githubUrl ?? ""); | ||
setOtherResources(project.otherResources); | ||
setTeamMembers(project.teamMembers.map((member) => member.email)); | ||
} else { | ||
setTeamMembers([email]); | ||
} | ||
}, [project, email]); | ||
const { isLoading, mutate: saveProject } = | ||
api.projects.saveProject.useMutation({ | ||
onSuccess: async () => { | ||
await refetch(); | ||
}, | ||
}); | ||
|
||
return isFetching || isLoading ? ( | ||
<Spinner /> | ||
) : ( | ||
<> | ||
<div className="flex w-full flex-col gap-2"> | ||
<label htmlFor="teamName" className="font-bold"> | ||
Team Name* | ||
</label> | ||
<input | ||
type="text" | ||
id="teamName" | ||
placeholder="Enter team name" | ||
value={teamName} | ||
required | ||
onChange={(e) => setTeamName(e.target.value)} | ||
className="border-grey w-full rounded-md border-2 p-2" | ||
/> | ||
</div> | ||
|
||
<div className="flex w-full flex-col gap-2"> | ||
<label htmlFor="teamMembers" className="font-bold"> | ||
Team Member Emails* | ||
</label> | ||
<input | ||
type="text" | ||
id="teamMembers" | ||
placeholder="Enter team member emails (comma separated)" | ||
value={teamMembers.join(",")} | ||
required | ||
onChange={(e) => setTeamMembers(e.target.value.trim().split(","))} | ||
anudaweerasinghe marked this conversation as resolved.
Show resolved
Hide resolved
|
||
className="border-grey w-full rounded-md border-2 p-2" | ||
/> | ||
</div> | ||
|
||
<div className="flex w-full flex-col gap-2"> | ||
<label htmlFor="projectName" className="font-bold"> | ||
Project Name* | ||
</label> | ||
<input | ||
type="text" | ||
id="projectName" | ||
placeholder="Enter project name" | ||
value={projectName} | ||
required | ||
onChange={(e) => setProjectName(e.target.value)} | ||
className="border-grey w-full rounded-md border-2 p-2" | ||
/> | ||
</div> | ||
|
||
<div className="flex w-full flex-col gap-2"> | ||
<label htmlFor="githubUrl" className="font-bold"> | ||
GitHub Link | ||
</label> | ||
<input | ||
type="text" | ||
id="githubUrl" | ||
placeholder="Enter GitHub link" | ||
value={githubUrl} | ||
onChange={(e) => setGithubUrl(e.target.value)} | ||
className="border-grey w-full rounded-md border-2 p-2" | ||
/> | ||
</div> | ||
|
||
<div className="flex w-full flex-col gap-2"> | ||
<label htmlFor="description" className="font-bold"> | ||
Description* | ||
</label> | ||
<textarea | ||
id="description" | ||
placeholder="Enter project description" | ||
value={description} | ||
onChange={(e) => setDescription(e.target.value)} | ||
className="border-grey w-full rounded-md border-2 p-2" | ||
></textarea> | ||
</div> | ||
|
||
<div className="flex w-full flex-col gap-2"> | ||
<label htmlFor="otherResources" className="font-bold"> | ||
Other Resources | ||
</label> | ||
<textarea | ||
id="otherResources" | ||
placeholder="Links to other resources associated with your project." | ||
value={otherResources as string} | ||
anudaweerasinghe marked this conversation as resolved.
Show resolved
Hide resolved
|
||
onChange={(e) => setOtherResources(e.target.value)} | ||
className="border-grey w-full rounded-md border-2 p-2" | ||
></textarea> | ||
</div> | ||
<Button | ||
text="Save" | ||
className="m-4 w-full font-bold" | ||
onClick={() => { | ||
saveProject({ | ||
name: projectName ?? "", | ||
githubUrl: githubUrl, | ||
teamName: teamName ?? "", | ||
description: description ?? "", | ||
otherResources: otherResources ?? "", | ||
teamMembers: teamMembers, | ||
}); | ||
}} | ||
/> | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import type { GetServerSidePropsContext, NextPage } from "next"; | ||
import Header from "../components/Header"; | ||
import { getSession } from "next-auth/react"; | ||
import ProjectDetailsForm from "../components/projectSubmission/ProjectDetailsForm"; | ||
interface Props { | ||
email: string; | ||
} | ||
const SubmitProject: NextPage<Props> = ({ email }) => { | ||
return ( | ||
<div className="flex min-h-screen flex-col"> | ||
<Header /> | ||
<main className="flex flex-col items-center gap-5 py-5 px-2 md:px-10"> | ||
<div className="flex w-96 flex-col items-center justify-center gap-3"> | ||
<h2 className="m-2 text-2xl font-bold">Submit your project</h2> | ||
<ProjectDetailsForm email={email} /> | ||
</div> | ||
</main> | ||
</div> | ||
); | ||
}; | ||
export async function getServerSideProps(context: GetServerSidePropsContext) { | ||
const session = await getSession(context); | ||
const email = session?.user?.email as string; | ||
return { | ||
props: { | ||
email: email, | ||
}, | ||
}; | ||
} | ||
|
||
export default SubmitProject; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need to have some failure logic to let the user know some of the inputs are incorrect