Skip to content

Commit 596a555

Browse files
authored
[resumes][feat] re-route to sign-in page + prefix resume for components (yangshun#370)
1 parent 9787ff8 commit 596a555

File tree

7 files changed

+26
-25
lines changed

7 files changed

+26
-25
lines changed

apps/portal/src/components/resumes/browse/FilterPill.tsx renamed to apps/portal/src/components/resumes/browse/ResumeFilterPill.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ type Props = Readonly<{
33
title: string;
44
}>;
55

6-
export default function FilterPill({ title, onClick }: Props) {
6+
export default function ResumeFilterPill({ title, onClick }: Props) {
77
return (
88
<button
99
className="rounded-xl border border-indigo-500 border-transparent bg-white px-2 py-1 text-xs font-medium text-indigo-500 focus:bg-indigo-500 focus:text-white"

apps/portal/src/components/resumes/comments/CommentsList.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { trpc } from '~/utils/trpc';
77

88
import CommentListItems from './CommentListItems';
99
import { COMMENTS_SECTIONS } from './constants';
10-
import SignInButton from '../SignInButton';
10+
import ResumeSignInButton from '../shared/ResumeSignInButton';
1111

1212
type CommentsListProps = Readonly<{
1313
resumeId: string;
@@ -24,7 +24,7 @@ export default function CommentsList({
2424
const commentsQuery = trpc.useQuery(['resumes.reviews.list', { resumeId }]);
2525
const renderButton = () => {
2626
if (sessionData === null) {
27-
return <SignInButton text="to join discussion" />;
27+
return <ResumeSignInButton text="to join discussion" />;
2828
}
2929
return (
3030
<Button

apps/portal/src/components/resumes/SignInButton.tsx renamed to apps/portal/src/components/resumes/shared/ResumeSignInButton.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ type Props = Readonly<{
44
text: string;
55
}>;
66

7-
export default function SignInButton({ text }: Props) {
7+
export default function ResumeSignInButton({ text }: Props) {
88
return (
99
<div className="flex justify-center pt-4">
1010
<p>

apps/portal/src/pages/resumes/[resumeId].tsx

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,18 @@ export default function ResumeReviewPage() {
3535
},
3636
);
3737
const starMutation = trpc.useMutation('resumes.resume.star', {
38-
onError() {
38+
onSuccess() {
3939
setStarDetails({
40-
isStarred: false,
41-
numStars: starDetails.numStars - 1,
40+
isStarred: true,
41+
numStars: starDetails.numStars + 1,
4242
});
4343
},
4444
});
4545
const unstarMutation = trpc.useMutation('resumes.resume.unstar', {
46-
onError() {
46+
onSuccess() {
4747
setStarDetails({
48-
isStarred: true,
49-
numStars: starDetails.numStars + 1,
48+
isStarred: false,
49+
numStars: starDetails.numStars - 1,
5050
});
5151
},
5252
});
@@ -65,12 +65,11 @@ export default function ResumeReviewPage() {
6565
}, [detailsQuery.data]);
6666

6767
const onStarButtonClick = () => {
68-
setStarDetails({
69-
isStarred: !starDetails.isStarred,
70-
numStars: starDetails.isStarred
71-
? starDetails.numStars - 1
72-
: starDetails.numStars + 1,
73-
});
68+
if (session?.user?.id == null) {
69+
router.push('/api/auth/signin');
70+
return;
71+
}
72+
7473
// Star button only rendered if resume exists
7574
// Star button only clickable if user exists
7675
if (starDetails.isStarred) {
@@ -110,7 +109,7 @@ export default function ResumeReviewPage() {
110109
: '',
111110
'isolate inline-flex max-h-10 items-center space-x-4 rounded-md border border-gray-300 bg-white px-4 py-2 text-sm font-medium text-gray-700 shadow-sm hover:bg-gray-50 disabled:hover:bg-white',
112111
)}
113-
disabled={session?.user === undefined}
112+
disabled={starMutation.isLoading || unstarMutation.isLoading}
114113
id="star-button"
115114
type="button"
116115
onClick={onStarButtonClick}>
@@ -166,7 +165,7 @@ export default function ResumeReviewPage() {
166165
</div>
167166
</div>
168167
{detailsQuery.data.additionalInfo && (
169-
<div className="flex items-center pt-2 text-sm text-gray-500">
168+
<div className="flex items-start whitespace-pre-wrap pt-2 text-sm text-gray-500">
170169
<InformationCircleIcon
171170
aria-hidden="true"
172171
className="mr-1.5 h-5 w-5 flex-shrink-0 text-gray-400"

apps/portal/src/pages/resumes/index.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ import {
1919
ROLES,
2020
SORT_OPTIONS,
2121
TOP_HITS,
22-
} from '~/components/resumes/browse/constants';
23-
import FilterPill from '~/components/resumes/browse/FilterPill';
22+
} from '~/components/resumes/browse/resumeConstants';
23+
import ResumeFilterPill from '~/components/resumes/browse/ResumeFilterPill';
2424
import ResumeListItems from '~/components/resumes/browse/ResumeListItems';
2525
import ResumeReviewsTitle from '~/components/resumes/ResumeReviewsTitle';
26-
import SignInButton from '~/components/resumes/SignInButton';
26+
import ResumeSignInButton from '~/components/resumes/shared/ResumeSignInButton';
2727

2828
import { trpc } from '~/utils/trpc';
2929

@@ -98,7 +98,7 @@ export default function ResumeHomePage() {
9898
if (sessionData?.user?.id) {
9999
router.push('/resumes/submit');
100100
} else {
101-
// TODO: Handle non-logged in user behaviour
101+
router.push('/api/auth/signin');
102102
}
103103
};
104104

@@ -221,7 +221,7 @@ export default function ResumeHomePage() {
221221
{TOP_HITS.map((category) => (
222222
<li key={category.name}>
223223
{/* TODO: Replace onClick with filtering function */}
224-
<FilterPill
224+
<ResumeFilterPill
225225
title={category.name}
226226
onClick={() => true}
227227
/>
@@ -287,7 +287,9 @@ export default function ResumeHomePage() {
287287
</div>
288288
</div>
289289
<div className="col-span-10 pr-8">
290-
{renderSignInButton && <SignInButton text={signInButtonText} />}
290+
{renderSignInButton && (
291+
<ResumeSignInButton text={signInButtonText} />
292+
)}
291293
<ResumeListItems
292294
isLoading={
293295
allResumesQuery.isFetching ||

apps/portal/src/pages/resumes/submit.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
EXPERIENCE,
1313
LOCATION,
1414
ROLES,
15-
} from '~/components/resumes/browse/constants';
15+
} from '~/components/resumes/browse/resumeConstants';
1616

1717
import { RESUME_STORAGE_KEY } from '~/constants/file-storage-keys';
1818
import { trpc } from '~/utils/trpc';

0 commit comments

Comments
 (0)