-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
51b9029
commit bbed79e
Showing
17 changed files
with
373 additions
and
149 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { db } from "@/utils/db"; | ||
import { validateRequest } from "@/utils/lucia"; | ||
import type { NextRequest } from "next/server"; | ||
|
||
export async function GET( | ||
_request: NextRequest, | ||
{ params }: { params: { githubID: string } }, | ||
): Promise<Response> { | ||
const { session } = await validateRequest(); | ||
|
||
if (!session) { | ||
return new Response(null, { | ||
status: 401, | ||
headers: { | ||
Location: "/auth/login", | ||
}, | ||
}); | ||
} | ||
|
||
const user = await db.user.findUnique({ | ||
where: { | ||
githubId: params.githubID ?? "", | ||
}, | ||
select: { | ||
githubId: true, | ||
}, | ||
}); | ||
return new Response(JSON.stringify(user), { | ||
status: user ? 200 : 404, | ||
}); | ||
} |
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
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 |
---|---|---|
@@ -1,17 +1,18 @@ | ||
import type { InputHTMLAttributes } from "react"; | ||
import { forwardRef, type InputHTMLAttributes } from "react"; | ||
import { twMerge } from "tailwind-merge"; | ||
|
||
export const Input = ({ | ||
className, | ||
...rest | ||
}: InputHTMLAttributes<HTMLInputElement>) => { | ||
export const Input = forwardRef< | ||
HTMLInputElement, | ||
InputHTMLAttributes<HTMLInputElement> | ||
>(({ className, ...rest }, ref) => { | ||
return ( | ||
<input | ||
ref={ref} | ||
className={twMerge( | ||
"w-full h-11 px-4 placeholder-text-black/25 bg-white/15 focus-within:ring-0 focus:border-primary/15 focus:shadow-primary/15 hover:bg-white/25 focus:bg-white/25 focus:border-1 text-white ring-0 outline-transparent rounded-[10px] border-gray-300", | ||
className, | ||
)} | ||
{...rest} | ||
/> | ||
); | ||
}; | ||
}); |
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
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
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
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,74 @@ | ||
"use client"; | ||
import React from "react"; | ||
import { Controller, useFieldArray, useFormContext } from "react-hook-form"; | ||
import { Input } from "@/app/components/Input"; | ||
import { twMerge } from "tailwind-merge"; | ||
|
||
interface MemberProps { | ||
loading: boolean; | ||
isEditable: boolean; | ||
} | ||
|
||
const Member = ({ loading, isEditable }: MemberProps) => { | ||
const { control } = useFormContext(); | ||
const { fields, append, remove } = useFieldArray({ | ||
control, | ||
name: "members", | ||
}); | ||
|
||
return ( | ||
<div className="flex flex-col"> | ||
<div> | ||
<label htmlFor="name" className="pb-2"> | ||
Team Members | ||
</label> | ||
{fields.map((member: Record<"id", string>, index: number) => ( | ||
<Controller | ||
name={`members[${index}]`} | ||
key={member.id} | ||
control={control} | ||
render={({ field }) => ( | ||
<div className="w-full flex mt-2"> | ||
<Input | ||
ref={field.ref} | ||
className="rounded-r-none" | ||
disabled={loading || !isEditable} | ||
placeholder="Github Username" | ||
onChange={field.onChange} | ||
onBlur={field.onBlur} | ||
name={`members.${index}.value`} | ||
value={field.value} | ||
/> | ||
<span | ||
className={twMerge( | ||
loading || !isEditable | ||
? "cursor-not-allowed" | ||
: "cursor-pointer bg-white/25", | ||
"text-red font-semibold bg-white/15 flex items-center px-2 border-l border-l-white/15 rounded-r-md", | ||
)} | ||
onKeyDown={() => !loading && isEditable && remove(index)} | ||
onClick={() => !loading && isEditable && remove(index)} | ||
> | ||
Remove | ||
</span> | ||
</div> | ||
)} | ||
/> | ||
))} | ||
</div> | ||
|
||
{fields.length < 3 && ( | ||
<div | ||
className="flex items-center mt-4 text-primary gap-2 py-1 justify-center border-1 pb-1 transition-all duration-200 ease-in-out border-primary rounded-md bg-primary/15 hover:bg-primary/15 cursor-pointer hover:border-dashed" | ||
onClick={() => (loading || !isEditable ? null : append(""))} | ||
onKeyDown={() => (loading || !isEditable ? null : append(""))} | ||
> | ||
<img className="h-10 w-10" src="/images/add-square.svg" alt="add" /> | ||
<span>ADD TEAM MEMBER</span> | ||
</div> | ||
)} | ||
</div> | ||
); | ||
}; | ||
|
||
export { Member }; |
Oops, something went wrong.