[resumes][fix] search and pagination bugs (#419)

pull/420/head
Peirong 2 years ago committed by GitHub
parent c3d2b4d325
commit b7f4cf93a0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

Binary file not shown.

Before

Width:  |  Height:  |  Size: 652 KiB

After

Width:  |  Height:  |  Size: 586 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1006 KiB

After

Width:  |  Height:  |  Size: 909 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 437 KiB

After

Width:  |  Height:  |  Size: 396 KiB

@ -126,6 +126,7 @@ export default function ResumeHomePage() {
searchValue: useDebounceValue(searchValue, DEBOUNCE_DELAY), searchValue: useDebounceValue(searchValue, DEBOUNCE_DELAY),
skip, skip,
sortOrder, sortOrder,
take: PAGE_LIMIT,
}, },
], ],
{ {
@ -144,6 +145,7 @@ export default function ResumeHomePage() {
searchValue: useDebounceValue(searchValue, DEBOUNCE_DELAY), searchValue: useDebounceValue(searchValue, DEBOUNCE_DELAY),
skip, skip,
sortOrder, sortOrder,
take: PAGE_LIMIT,
}, },
], ],
{ {
@ -163,6 +165,7 @@ export default function ResumeHomePage() {
searchValue: useDebounceValue(searchValue, DEBOUNCE_DELAY), searchValue: useDebounceValue(searchValue, DEBOUNCE_DELAY),
skip, skip,
sortOrder, sortOrder,
take: PAGE_LIMIT,
}, },
], ],
{ {
@ -489,17 +492,16 @@ export default function ResumeHomePage() {
</div> </div>
<div className="flex flex-wrap items-center justify-start gap-8"> <div className="flex flex-wrap items-center justify-start gap-8">
<div className="w-64"> <div className="w-64">
<form> <TextInput
<TextInput isLabelHidden={true}
label="" label="search"
placeholder="Search Resumes" placeholder="Search Resumes"
startAddOn={MagnifyingGlassIcon} startAddOn={MagnifyingGlassIcon}
startAddOnType="icon" startAddOnType="icon"
type="text" type="text"
value={searchValue} value={searchValue}
onChange={setSearchValue} onChange={setSearchValue}
/> />
</form>
</div> </div>
<div> <div>
<DropdownMenu align="end" label={SORT_OPTIONS[sortOrder]}> <DropdownMenu align="end" label={SORT_OPTIONS[sortOrder]}>
@ -559,7 +561,7 @@ export default function ResumeHomePage() {
end={getTabTotalPages()} end={getTabTotalPages()}
label="pagination" label="pagination"
start={1} start={1}
onSelect={(page) => setCurrentPage(page)} onSelect={setCurrentPage}
/> />
</div> </div>
)} )}

@ -15,6 +15,7 @@ export const resumesRouter = createRouter()
searchValue: z.string(), searchValue: z.string(),
skip: z.number(), skip: z.number(),
sortOrder: z.string(), sortOrder: z.string(),
take: z.number(),
}), }),
async resolve({ ctx, input }) { async resolve({ ctx, input }) {
const { const {
@ -25,6 +26,7 @@ export const resumesRouter = createRouter()
numComments, numComments,
skip, skip,
searchValue, searchValue,
take,
} = input; } = input;
const userId = ctx.session?.user?.id; const userId = ctx.session?.user?.id;
const totalRecords = await ctx.prisma.resumesResume.count({ const totalRecords = await ctx.prisma.resumesResume.count({
@ -37,6 +39,7 @@ export const resumesRouter = createRouter()
experience: { in: experienceFilters }, experience: { in: experienceFilters },
location: { in: locationFilters }, location: { in: locationFilters },
role: { in: roleFilters }, role: { in: roleFilters },
title: { contains: searchValue, mode: 'insensitive' },
}, },
}); });
const resumesData = await ctx.prisma.resumesResume.findMany({ const resumesData = await ctx.prisma.resumesResume.findMany({
@ -74,7 +77,7 @@ export const resumesRouter = createRouter()
} }
: { comments: { _count: 'desc' } }, : { comments: { _count: 'desc' } },
skip, skip,
take: 10, take,
where: { where: {
...(numComments === 0 && { ...(numComments === 0 && {
comments: { comments: {

@ -53,6 +53,7 @@ export const resumesResumeUserRouter = createProtectedRouter()
searchValue: z.string(), searchValue: z.string(),
skip: z.number(), skip: z.number(),
sortOrder: z.string(), sortOrder: z.string(),
take: z.number(),
}), }),
async resolve({ ctx, input }) { async resolve({ ctx, input }) {
const userId = ctx.session.user.id; const userId = ctx.session.user.id;
@ -64,6 +65,7 @@ export const resumesResumeUserRouter = createProtectedRouter()
sortOrder, sortOrder,
numComments, numComments,
skip, skip,
take,
} = input; } = input;
const totalRecords = await ctx.prisma.resumesStar.count({ const totalRecords = await ctx.prisma.resumesStar.count({
where: { where: {
@ -76,6 +78,7 @@ export const resumesResumeUserRouter = createProtectedRouter()
experience: { in: experienceFilters }, experience: { in: experienceFilters },
location: { in: locationFilters }, location: { in: locationFilters },
role: { in: roleFilters }, role: { in: roleFilters },
title: { contains: searchValue, mode: 'insensitive' },
}, },
userId, userId,
}, },
@ -121,7 +124,7 @@ export const resumesResumeUserRouter = createProtectedRouter()
}, },
}, },
skip, skip,
take: 10, take,
where: { where: {
resume: { resume: {
...(numComments === 0 && { ...(numComments === 0 && {
@ -167,6 +170,7 @@ export const resumesResumeUserRouter = createProtectedRouter()
searchValue: z.string(), searchValue: z.string(),
skip: z.number(), skip: z.number(),
sortOrder: z.string(), sortOrder: z.string(),
take: z.number(),
}), }),
async resolve({ ctx, input }) { async resolve({ ctx, input }) {
const userId = ctx.session.user.id; const userId = ctx.session.user.id;
@ -177,6 +181,7 @@ export const resumesResumeUserRouter = createProtectedRouter()
sortOrder, sortOrder,
searchValue, searchValue,
numComments, numComments,
take,
skip, skip,
} = input; } = input;
const totalRecords = await ctx.prisma.resumesResume.count({ const totalRecords = await ctx.prisma.resumesResume.count({
@ -189,6 +194,7 @@ export const resumesResumeUserRouter = createProtectedRouter()
experience: { in: experienceFilters }, experience: { in: experienceFilters },
location: { in: locationFilters }, location: { in: locationFilters },
role: { in: roleFilters }, role: { in: roleFilters },
title: { contains: searchValue, mode: 'insensitive' },
userId, userId,
}, },
}); });
@ -224,7 +230,7 @@ export const resumesResumeUserRouter = createProtectedRouter()
} }
: { comments: { _count: 'desc' } }, : { comments: { _count: 'desc' } },
skip, skip,
take: 10, take,
where: { where: {
...(numComments === 0 && { ...(numComments === 0 && {
comments: { comments: {

@ -69,6 +69,7 @@ export default function Pagination({
pageNumberSet.add(page); pageNumberSet.add(page);
elements.push( elements.push(
<PaginationPage <PaginationPage
key={page}
isCurrent={current === page} isCurrent={current === page}
label={page} label={page}
onClick={(event) => { onClick={(event) => {
@ -83,7 +84,7 @@ export default function Pagination({
addPage(i); addPage(i);
} }
if (lastAddedPage < current - pagePadding) { if (lastAddedPage < current - pagePadding - 1) {
elements.push(<PaginationEllipsis />); elements.push(<PaginationEllipsis />);
} }
@ -91,7 +92,7 @@ export default function Pagination({
addPage(i); addPage(i);
} }
if (lastAddedPage < end - pagePadding) { if (lastAddedPage < end - pagePadding - 1) {
elements.push(<PaginationEllipsis />); elements.push(<PaginationEllipsis />);
} }

Loading…
Cancel
Save