[resumes][feat] Add sign in buttons on browse page (#350)
* [resumes][fix] Add gap between sections in resume list item * [resumes][refactor] Abstract out sign in button * [resumes][feat] Add sign in buttons on browse pagepull/354/head
parent
d3c0c21f1b
commit
cc462ab6ab
@ -0,0 +1,24 @@
|
||||
import { signIn } from 'next-auth/react';
|
||||
|
||||
type Props = Readonly<{
|
||||
text: string;
|
||||
}>;
|
||||
|
||||
export default function SignInButton({ text }: Props) {
|
||||
return (
|
||||
<div className="flex justify-center pt-4">
|
||||
<p>
|
||||
<a
|
||||
className="text-primary-800 hover:text-primary-500"
|
||||
href="/api/auth/signin"
|
||||
onClick={(event) => {
|
||||
event.preventDefault();
|
||||
signIn();
|
||||
}}>
|
||||
Sign in
|
||||
</a>{' '}
|
||||
{text}
|
||||
</p>
|
||||
</div>
|
||||
);
|
||||
}
|
@ -1,48 +0,0 @@
|
||||
import { signIn, useSession } from 'next-auth/react';
|
||||
import { Button } from '@tih/ui';
|
||||
|
||||
type CommentsListButtonProps = {
|
||||
setShowCommentsForm: (show: boolean) => void;
|
||||
};
|
||||
|
||||
export default function CommentsListButton({
|
||||
setShowCommentsForm,
|
||||
}: CommentsListButtonProps) {
|
||||
const { data: session, status } = useSession();
|
||||
const isSessionLoading = status === 'loading';
|
||||
|
||||
// Don't render anything
|
||||
if (isSessionLoading) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Not signed in
|
||||
if (session == null) {
|
||||
return (
|
||||
<div className="flex justify-center">
|
||||
<p>
|
||||
<a
|
||||
className="text-primary-800 hover:text-primary-500"
|
||||
href="/api/auth/signin"
|
||||
onClick={(event) => {
|
||||
event.preventDefault();
|
||||
signIn();
|
||||
}}>
|
||||
Sign in
|
||||
</a>{' '}
|
||||
to join discussion
|
||||
</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
// Signed in. Return Add review button
|
||||
return (
|
||||
<Button
|
||||
display="block"
|
||||
label="Add your review"
|
||||
variant="tertiary"
|
||||
onClick={() => setShowCommentsForm(true)}
|
||||
/>
|
||||
);
|
||||
}
|
Loading…
Reference in new issue