Skip to content

Commit cb7d20c

Browse files
All schema issue from schema list (#1048)
* resolved: comments on PR Signed-off-by: pranalidhanavade <pranali.dhanavade@ayanworks.com> * fix: issue regarding passkey Signed-off-by: pranalidhanavade <pranali.dhanavade@ayanworks.com> * fix: all schemas issue from schema list Signed-off-by: pranalidhanavade <pranali.dhanavade@ayanworks.com> * fix: schema list pagination issue Signed-off-by: pranalidhanavade <pranali.dhanavade@ayanworks.com> --------- Signed-off-by: pranalidhanavade <pranali.dhanavade@ayanworks.com>
1 parent 92a871d commit cb7d20c

File tree

5 files changed

+86
-24
lines changed

5 files changed

+86
-24
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: 75 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,13 @@ const SchemaList = (props: {
251251
setLoading(false)
252252
})
253253
}
254-
}, [organizationId, schemaListAPIParameter, allSchemaFlag])
254+
}, [organizationId])
255+
256+
useEffect(() => {
257+
if (organizationId) {
258+
getSchemaList(schemaListAPIParameter, allSchemaFlag)
259+
}
260+
}, [schemaListAPIParameter.page])
255261

256262
const onSearch = (event: ChangeEvent<HTMLInputElement>): void => {
257263
const inputValue = event.target.value
@@ -267,12 +273,41 @@ const SchemaList = (props: {
267273
}
268274

269275
const handleFilterChange = async (value: string): Promise<void> => {
270-
const isAllSchemas = value === 'all'
276+
const isAllSchemas = value === 'All schemas'
271277

272278
setSelectedValue(value)
273279
setAllSchemaFlag(isAllSchemas)
274280

275-
setSchemaListAPIParameter((prev) => ({ ...prev, page: 1 }))
281+
// Reset pagination and search parameters
282+
setSchemaListAPIParameter({
283+
itemPerPage,
284+
page: 1,
285+
search: '',
286+
sortBy: 'id',
287+
sortingOrder: 'desc',
288+
allSearch: '',
289+
})
290+
291+
setSearchValue('')
292+
293+
if (organizationId) {
294+
setLoading(true)
295+
try {
296+
await getSchemaList(
297+
{
298+
itemPerPage,
299+
page: 1,
300+
search: '',
301+
sortBy: 'id',
302+
sortingOrder: 'desc',
303+
allSearch: '',
304+
},
305+
isAllSchemas,
306+
)
307+
} finally {
308+
setLoading(false)
309+
}
310+
}
276311
}
277312

278313
const schemaSelectionCallback = ({
@@ -319,6 +354,30 @@ const SchemaList = (props: {
319354
}
320355
props.W3CSchemaSelectionCallback?.(schemaId, w3cSchemaDetails)
321356
}
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+
}
322381

323382
return (
324383
<PageContainer>
@@ -422,30 +481,32 @@ const SchemaList = (props: {
422481
</PaginationItem>
423482
)}
424483

425-
{Array.from({ length: lastPage }).map((_, index) => {
426-
const page = index + 1
427-
const isActive = page === schemaListAPIParameter.page
428-
return (
429-
<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+
) : (
430491
<PaginationLink
431492
className={`${
432-
isActive
433-
? 'bg-primary text-[var(--color-white)]'
493+
page === schemaListAPIParameter.page
494+
? 'bg-primary text-white'
434495
: 'bg-background text-muted-foreground'
435496
} rounded-lg px-4 py-2`}
436497
href="#"
437498
onClick={() =>
438499
setSchemaListAPIParameter((prev) => ({
439500
...prev,
440-
page,
501+
page: page as number,
441502
}))
442503
}
443504
>
444505
{page}
445506
</PaginationLink>
446-
</PaginationItem>
447-
)
448-
})}
507+
)}
508+
</PaginationItem>
509+
))}
449510

450511
{schemaListAPIParameter.page < lastPage && (
451512
<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)