Skip to content

Commit c33e6e8

Browse files
fix: schema list pagination issue
Signed-off-by: pranalidhanavade <pranali.dhanavade@ayanworks.com>
1 parent a925bd7 commit c33e6e8

File tree

5 files changed

+54
-21
lines changed

5 files changed

+54
-21
lines changed
62.1 KB
Binary file not shown.

nextjs/src/components/layout/app-sidebar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export default function AppSidebar(): React.JSX.Element {
5656

5757
const collapsedLogoImageSrc =
5858
activeTheme === 'credebl'
59-
? '/images/favicon-credebl.ico'
59+
? '/images/CREDEBL_ICON.ico'
6060
: '/images/favicon-sovio.ico'
6161

6262
const dispatch = useAppDispatch()

nextjs/src/features/profile/components/DisplayUserProfile.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ const DisplayUserProfile = ({
130130
onClick={toggleEditProfile}
131131
>
132132
<span>
133-
<Edit className="mr-12" />
133+
<Edit className="text-foreground mr-12" />
134134
</span>
135135
</Button>
136136
</div>

nextjs/src/features/schemas/components/SchemaList.tsx

Lines changed: 43 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,12 @@ const SchemaList = (props: {
253253
}
254254
}, [organizationId])
255255

256+
useEffect(() => {
257+
if (organizationId) {
258+
getSchemaList(schemaListAPIParameter, allSchemaFlag)
259+
}
260+
}, [schemaListAPIParameter.page])
261+
256262
const onSearch = (event: ChangeEvent<HTMLInputElement>): void => {
257263
const inputValue = event.target.value
258264
setSearchValue(inputValue)
@@ -348,6 +354,30 @@ const SchemaList = (props: {
348354
}
349355
props.W3CSchemaSelectionCallback?.(schemaId, w3cSchemaDetails)
350356
}
357+
const paginationRange = 2
358+
const currentPage = schemaListAPIParameter.page
359+
const startPage = Math.max(1, currentPage - paginationRange)
360+
const endPage = Math.min(lastPage, currentPage + paginationRange)
361+
362+
const paginationNumbers = []
363+
364+
if (startPage > 1) {
365+
paginationNumbers.push(1)
366+
if (startPage > 2) {
367+
paginationNumbers.push('...')
368+
}
369+
}
370+
371+
for (let i = startPage; i <= endPage; i++) {
372+
paginationNumbers.push(i)
373+
}
374+
375+
if (endPage < lastPage) {
376+
if (endPage < lastPage - 1) {
377+
paginationNumbers.push('...')
378+
}
379+
paginationNumbers.push(lastPage)
380+
}
351381

352382
return (
353383
<PageContainer>
@@ -451,30 +481,32 @@ const SchemaList = (props: {
451481
</PaginationItem>
452482
)}
453483

454-
{Array.from({ length: lastPage }).map((_, index) => {
455-
const page = index + 1
456-
const isActive = page === schemaListAPIParameter.page
457-
return (
458-
<PaginationItem key={page}>
484+
{paginationNumbers.map((page, idx) => (
485+
<PaginationItem key={idx}>
486+
{page === '...' ? (
487+
<span className="text-muted-foreground px-3 py-2">
488+
489+
</span>
490+
) : (
459491
<PaginationLink
460492
className={`${
461-
isActive
462-
? 'bg-primary text-[var(--color-white)]'
493+
page === schemaListAPIParameter.page
494+
? 'bg-primary text-white'
463495
: 'bg-background text-muted-foreground'
464496
} rounded-lg px-4 py-2`}
465497
href="#"
466498
onClick={() =>
467499
setSchemaListAPIParameter((prev) => ({
468500
...prev,
469-
page,
501+
page: page as number,
470502
}))
471503
}
472504
>
473505
{page}
474506
</PaginationLink>
475-
</PaginationItem>
476-
)
477-
})}
507+
)}
508+
</PaginationItem>
509+
))}
478510

479511
{schemaListAPIParameter.page < lastPage && (
480512
<PaginationItem>

src/components/Profile/EditUserProfile.tsx

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
1-
import { useEffect, useRef, useState} from "react";
2-
import type { IUserProfile } from "./interfaces";
3-
import { getFromLocalStorage, setToLocalStorage, updateUserProfile } from "../../api/Auth";
1+
import * as yup from "yup"
2+
3+
import { Alert, Button } from "flowbite-react";
4+
import { Form, Formik } from "formik";
45
import { IMG_MAX_HEIGHT, IMG_MAX_WIDTH, imageSizeAccepted, storageKeys } from "../../config/CommonConstant";
6+
import { calculateSize, dataURItoBlob } from "../../utils/CompressImage";
7+
import { getFromLocalStorage, setToLocalStorage, updateUserProfile } from "../../api/Auth";
8+
import { useEffect, useRef, useState } from "react";
9+
510
import type { AxiosResponse } from "axios";
611
import CustomAvatar from '../Avatar'
7-
import { calculateSize, dataURItoBlob } from "../../utils/CompressImage";
8-
import { Alert, Button } from "flowbite-react";
9-
import { Form, Formik } from "formik";
1012
import type { FormikHelpers as FormikActions } from 'formik';
11-
12-
import * as yup from "yup"
13+
import type { IUserProfile } from "./interfaces";
1314

1415
interface Values {
1516
profileImg: string;

0 commit comments

Comments
 (0)