Skip to content
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

Show users' roles in admin/users grid #1559

Merged
merged 1 commit into from
Aug 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion public/locales/bg/person.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@
"email-confirmed": "Потвърден имейл",
"newsletter": "Известия",
"company": "Компания",
"address": "Адрес"
"address": "Адрес",
"organizer": "Организатор",
"coordinator": "Координатор",
"beneficiary": "Бенефициент"
},
"cta": {
"create": "Създай",
Expand Down
5 changes: 4 additions & 1 deletion public/locales/en/person.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@
"email-confirmed": "Email confirmed",
"newsletter": "Newsletter",
"company": "Company",
"address": "Address"
"address": "Address",
"organizer": "Organizer",
"coordinator": "Coordinator",
"beneficiary": "Beneficiary"
},
"cta": {
"create": "Create",
Expand Down
81 changes: 73 additions & 8 deletions src/components/common/person/grid/Grid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import React, { useState } from 'react'
import { UseQueryResult } from '@tanstack/react-query'
import { useTranslation } from 'next-i18next'
import { Box, Avatar } from '@mui/material'
import { styled } from '@mui/material/styles'
import {
DataGrid,
GridColDef,
Expand All @@ -28,6 +29,13 @@ const defaultSort: SortData = {
sortOrder: 'desc',
}

const Centered = styled('div')({
flex: 1,
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
})

export default observer(function Grid() {
const { t } = useTranslation()

Expand Down Expand Up @@ -165,15 +173,67 @@ export default observer(function Grid() {
minWidth: 130,
valueGetter: (f) => f.row.createdAt?.toString().slice(0, 10),
},
{
field: 'organizer',
headerName: t('person:admin.fields.organizer'),
minWidth: 130,
renderCell: (params: GridRenderCellParams): React.ReactNode => {
return (
<Centered>
{params.row.organizer ? (
<CheckIcon style={{ color: '#00b386' }} />
) : (
<CloseOutlinedIcon style={{ color: '#ff5050' }} />
)}
</Centered>
)
},
},
{
field: 'coordinators',
headerName: t('person:admin.fields.coordinator'),
minWidth: 130,
renderCell: (params: GridRenderCellParams): React.ReactNode => {
return (
<Centered>
{params.row.coordinators ? (
<CheckIcon style={{ color: '#00b386' }} />
) : (
<CloseOutlinedIcon style={{ color: '#ff5050' }} />
)}
</Centered>
)
},
},
{
field: 'beneficiaries',
headerName: t('person:admin.fields.beneficiary'),
minWidth: 130,
renderCell: (params: GridRenderCellParams): React.ReactNode => {
return (
<Centered>
{params.row.beneficiaries.length > 0 ? (
<CheckIcon style={{ color: '#00b386' }} />
) : (
<CloseOutlinedIcon style={{ color: '#ff5050' }} />
)}
</Centered>
)
},
},
{
field: 'emailConfirmed',
headerName: t('person:admin.fields.email-confirmed'),
minWidth: 140,
renderCell: (params: GridRenderCellParams): React.ReactNode => {
return params.row.emailConfirmed === true ? (
<CheckIcon style={{ color: '#00b386' }} />
) : (
<CloseOutlinedIcon style={{ color: '#ff5050' }} />
return (
<Centered>
{params.row.emailConfirmed ? (
<CheckIcon style={{ color: '#00b386' }} />
) : (
<CloseOutlinedIcon style={{ color: '#ff5050' }} />
)}
</Centered>
)
},
},
Expand All @@ -182,10 +242,14 @@ export default observer(function Grid() {
headerName: t('person:admin.fields.newsletter'),
minWidth: 130,
renderCell: (params: GridRenderCellParams): React.ReactNode => {
return params.row.newsletter === true ? (
<CheckIcon style={{ color: '#00b386' }} />
) : (
<CloseOutlinedIcon style={{ color: '#ff5050' }} />
return (
<Centered>
{params.row.newsletter ? (
<CheckIcon style={{ color: '#00b386' }} />
) : (
<CloseOutlinedIcon style={{ color: '#ff5050' }} />
)}
</Centered>
)
},
},
Expand Down Expand Up @@ -235,6 +299,7 @@ export default observer(function Grid() {
pageSizeOptions={[5, 10]}
paginationModel={{ page: paginationModel.pageIndex, pageSize: paginationModel.pageSize }}
paginationMode="server"
sortingMode="server"
rowCount={totalCount}
onPaginationModelChange={handlePaginationModelChange}
onSortModelChange={handleSortModelChange}
Expand Down
Loading