2026-02-24 20:44:16 +00:00
|
|
|
|
import AdaptableCard from '@/components/shared/AdaptableCard'
|
|
|
|
|
|
import Container from '@/components/shared/Container'
|
2026-07-06 09:44:26 +00:00
|
|
|
|
import { Table } from '@/components/ui'
|
|
|
|
|
|
import { getUsers } from '@/services/identity.service'
|
2026-02-24 20:44:16 +00:00
|
|
|
|
import { useLocalization } from '@/utils/hooks/useLocalization'
|
|
|
|
|
|
import useThemeClass from '@/utils/hooks/useThemeClass'
|
|
|
|
|
|
import isEmpty from 'lodash/isEmpty'
|
2026-07-06 09:44:26 +00:00
|
|
|
|
import { useEffect, useState } from 'react'
|
2026-02-24 20:44:16 +00:00
|
|
|
|
import { Helmet } from 'react-helmet'
|
|
|
|
|
|
import UsersPermission from './UsersPermission'
|
2026-07-06 09:44:26 +00:00
|
|
|
|
import { IdentityUserDto } from '@/proxy/admin/models'
|
2026-02-24 20:44:16 +00:00
|
|
|
|
import { ROUTES_ENUM } from '@/routes/route.constant'
|
|
|
|
|
|
import { APP_NAME } from '@/constants/app.constant'
|
2026-07-06 09:44:26 +00:00
|
|
|
|
import ActionLink from '@/components/shared/ActionLink'
|
2026-02-24 20:44:16 +00:00
|
|
|
|
|
|
|
|
|
|
const { Tr, Th, Td, THead, TBody } = Table
|
|
|
|
|
|
|
|
|
|
|
|
const Users = () => {
|
|
|
|
|
|
const { textTheme } = useThemeClass()
|
|
|
|
|
|
const [userList, setUserList] = useState<IdentityUserDto[]>([])
|
|
|
|
|
|
const [activeUser, setActiveUser] = useState<IdentityUserDto>()
|
|
|
|
|
|
const [permissionDialogOpen, setPermissionDialogOpen] = useState(false)
|
|
|
|
|
|
|
|
|
|
|
|
const { translate } = useLocalization()
|
|
|
|
|
|
|
|
|
|
|
|
const fetchData = async () => {
|
|
|
|
|
|
const response = await getUsers()
|
|
|
|
|
|
if (response.data?.items) {
|
|
|
|
|
|
setUserList(response.data.items)
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
|
if (isEmpty(userList)) {
|
|
|
|
|
|
fetchData()
|
|
|
|
|
|
}
|
|
|
|
|
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
|
|
|
|
}, [])
|
|
|
|
|
|
|
2026-07-06 09:44:26 +00:00
|
|
|
|
const openPermissionDialog = (user: IdentityUserDto) => {
|
2026-02-24 20:44:16 +00:00
|
|
|
|
setActiveUser(user)
|
2026-07-06 09:44:26 +00:00
|
|
|
|
setPermissionDialogOpen(true)
|
2026-02-24 20:44:16 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
|
<>
|
|
|
|
|
|
<Helmet
|
|
|
|
|
|
titleTemplate={`%s | ${APP_NAME}`}
|
|
|
|
|
|
title={translate('::AbpIdentity.Users')}
|
|
|
|
|
|
defaultTitle={APP_NAME}
|
|
|
|
|
|
></Helmet>
|
|
|
|
|
|
<Container>
|
|
|
|
|
|
<AdaptableCard>
|
|
|
|
|
|
<Table>
|
|
|
|
|
|
<THead>
|
|
|
|
|
|
<Tr>
|
|
|
|
|
|
<Th className="w-1/6"></Th>
|
|
|
|
|
|
<Th>Adı Soyadı</Th>
|
|
|
|
|
|
<Th>E-Posta</Th>
|
|
|
|
|
|
<Th>Telefon</Th>
|
|
|
|
|
|
<Th>Durum</Th>
|
|
|
|
|
|
</Tr>
|
|
|
|
|
|
</THead>
|
|
|
|
|
|
<TBody>
|
|
|
|
|
|
{userList.map((user) => (
|
|
|
|
|
|
<Tr key={user.id}>
|
|
|
|
|
|
<Td>
|
|
|
|
|
|
<div
|
|
|
|
|
|
className={`${textTheme} cursor-pointer select-none font-semibold`}
|
2026-07-06 09:44:26 +00:00
|
|
|
|
onClick={() => openPermissionDialog(user)}
|
2026-02-24 20:44:16 +00:00
|
|
|
|
>
|
|
|
|
|
|
{translate('::Permission')}
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</Td>
|
|
|
|
|
|
<Td>
|
|
|
|
|
|
<ActionLink
|
|
|
|
|
|
href={ROUTES_ENUM.protected.admin.identity.user.detail.replace(
|
|
|
|
|
|
':userId',
|
|
|
|
|
|
user.id!,
|
|
|
|
|
|
)}
|
|
|
|
|
|
className="font-bold"
|
|
|
|
|
|
>
|
|
|
|
|
|
{user.name} {user.surname}
|
|
|
|
|
|
</ActionLink>
|
|
|
|
|
|
</Td>
|
|
|
|
|
|
<Td>{user.email}</Td>
|
|
|
|
|
|
<Td>{user.phoneNumber}</Td>
|
|
|
|
|
|
<Td>{user.isActive ? 'Aktif' : 'Pasif'}</Td>
|
|
|
|
|
|
</Tr>
|
|
|
|
|
|
))}
|
|
|
|
|
|
</TBody>
|
|
|
|
|
|
</Table>
|
|
|
|
|
|
</AdaptableCard>
|
|
|
|
|
|
</Container>
|
|
|
|
|
|
{activeUser?.id && (
|
|
|
|
|
|
<UsersPermission
|
|
|
|
|
|
open={permissionDialogOpen}
|
|
|
|
|
|
onDialogClose={() => setPermissionDialogOpen(false)}
|
2026-07-06 09:44:26 +00:00
|
|
|
|
name={`${activeUser.name ?? ''} ${activeUser.surname ?? ''}`.trim() || activeUser.email || activeUser.id}
|
|
|
|
|
|
id={activeUser.id}
|
2026-02-24 20:44:16 +00:00
|
|
|
|
></UsersPermission>
|
|
|
|
|
|
)}
|
|
|
|
|
|
</>
|
|
|
|
|
|
)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export default Users
|