-
Notifications
You must be signed in to change notification settings - Fork 14
Feat/system admin #1108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat/system admin #1108
Changes from 1 commit
228b71f
2d59f23
11232bd
774a8f5
580617f
af68445
88fe2bf
2be1b57
59d8bc6
9510de9
d558ca8
a9b4b2b
f3d3e67
366c806
21fad4a
07ac31d
b261088
9204d86
a82243b
6f686e3
5ddb252
538deb9
5fd7ac7
a8a6f0a
58b5490
c367efe
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,7 +34,7 @@ export const RolesTable: FC<Props> = (props: Props) => { | |
<Link to={`${data.id}/role-members`}>{data.id}</Link> | ||
</div> | ||
), | ||
type: 'element', | ||
type: 'numberElement', // Change from 'element' to 'numberElement' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The change from 'element' to 'numberElement' should be verified to ensure that it aligns with the expected data type and rendering logic. If 'data.id' is not a number, this change might cause issues. |
||
}, | ||
{ | ||
label: 'Role Name', | ||
|
@@ -187,6 +187,13 @@ export const RolesTable: FC<Props> = (props: Props) => { | |
}, | ||
], | ||
], [columns]) | ||
|
||
// Convert id fields to numbers to ensure proper sorting | ||
const processedData = useMemo(() => props.datas.map(role => ({ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider adding a type check to ensure that |
||
...role, | ||
id: Number(role.id), | ||
})), [props.datas]) | ||
|
||
const { | ||
page, | ||
setPage, | ||
|
@@ -195,7 +202,7 @@ export const RolesTable: FC<Props> = (props: Props) => { | |
setSort, | ||
sort, | ||
}: useTableFilterLocalProps<UserRole> = useTableFilterLocal( | ||
props.datas ?? [], | ||
processedData ?? [], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The variable |
||
undefined, | ||
{ | ||
createdAtString: 'createdAt', | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -102,12 +102,14 @@ export function useManageAddGroupMembers( | |
) | ||
.then(() => { | ||
if (!hasSubmissionErrors) { | ||
// Change the success message based on the membership type | ||
const entityType = membershipType === 'user' ? 'Member' : 'Group' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider extracting the logic for determining |
||
toast.success( | ||
`${ | ||
memberIds.length > 1 ? 'Groups' : 'Group' | ||
memberIds.length > 1 ? `${entityType}s` : entityType | ||
} added successfully`, | ||
{ | ||
toastId: 'Add groups', | ||
toastId: `Add ${entityType.toLowerCase()}s`, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ensure that the |
||
}, | ||
) | ||
callBack() | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,7 +54,24 @@ export function useTableFilterLocal<T>( | |
sortField = mappingSortField[sortField] | ||
} | ||
|
||
datas = _.orderBy(datas, [sortField], [sort.direction]) | ||
datas = [...datas].sort((a, b) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The spread operator |
||
const aValue = (a as Record<string, any>)[sortField] | ||
const bValue = (b as Record<string, any>)[sortField] | ||
|
||
// Add special case for id field | ||
if (sortField === 'id') { | ||
return sort.direction === 'asc' | ||
? Number(aValue) - Number(bValue) | ||
: Number(bValue) - Number(aValue) | ||
} | ||
|
||
// Existing string comparison logic | ||
return sort.direction === 'asc' | ||
? String(aValue) | ||
.localeCompare(String(bValue)) | ||
: String(bValue) | ||
.localeCompare(String(aValue)) | ||
}) | ||
} | ||
|
||
setSortedDatas(datas) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ import { TABLE_DATE_FORMAT } from '../../config/index.config' | |
* Model for user role info | ||
*/ | ||
export interface UserRole { | ||
id: string | ||
id: string | number | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The change from |
||
roleName: string | ||
createdBy?: string | ||
createdByHandle?: string | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider checking if
data.id
is already a string before converting it withString(data.id)
. This can help avoid unnecessary conversions and potential issues ifdata.id
is not a valid input forString()
.