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

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

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

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

Loading…
Cancel
Save