import { Button, Checkbox, DatePicker, FormContainer, FormItem, Input, Notification, Select, Tabs, toast, } from '@/components/ui' import Dialog from '@/components/ui/Dialog' import DateTimepicker from '@/components/ui/DatePicker/DateTimepicker' import Table from '@/components/ui/Table' import TBody from '@/components/ui/Table/TBody' import Td from '@/components/ui/Table/Td' import Th from '@/components/ui/Table/Th' import THead from '@/components/ui/Table/THead' import Tr from '@/components/ui/Table/Tr' import TabContent from '@/components/ui/Tabs/TabContent' import TabList from '@/components/ui/Tabs/TabList' import TabNav from '@/components/ui/Tabs/TabNav' import { deleteClaimUser, getUserDetail, postClaimUser, putUserDetail, putUserLookout, putUserPermission, } from '@/services/identity.service' import { CountryDto, getCountry } from '@/services/home.service' import { useLocalization } from '@/utils/hooks/useLocalization' import dayjs from 'dayjs' import { Field, FieldArray, FieldProps, Form, Formik, FormikHelpers } from 'formik' import { useEffect, useState } from 'react' import { Helmet } from 'react-helmet' import { FaBuilding, FaLockOpen, FaUser, FaFileAlt, FaTrashAlt, FaCheckCircle, FaUserAstronaut, } from 'react-icons/fa' import { useParams } from 'react-router-dom' import * as Yup from 'yup' import { SelectBoxOption, SelectBoxOptionWithGroup } from '@/types/shared' import { ConfirmDialog, Container } from '@/components/shared' import { AssignedClaimViewModel, UserInfoViewModel } from '@/proxy/admin/models' import { APP_NAME } from '@/constants/app.constant' export interface ClaimTypeDto { claimType: string claimValue: string } function UserDetails() { const { userId } = useParams() const { translate } = useLocalization() const [userDetails, setUserDetails] = useState() const [loading, setLoading] = useState(true) const [open, setOpen] = useState(false) const [confirmDeleteClaim, setConfirmDeleteClaim] = useState(null) const [countries, setCountries] = useState([]) const getUser = async () => { const { data } = await getUserDetail(userId || '') setUserDetails(data) } useEffect(() => { getUser() getCountry().then(({ data }) => setCountries(data)) }, []) const scheme = Yup.object().shape({ claimType: Yup.string().required(), claimValue: Yup.string().required(), }) const handleSubmit = async ( values: ClaimTypeDto, { setSubmitting }: FormikHelpers, ) => { setLoading(true) setSubmitting(true) try { await postClaimUser({ userId, claimType: values.claimType, claimValue: values.claimValue }) toast.push( {translate('::Kaydet')} , { placement: 'top-end', }, ) setOpen(false) getUser() } catch (error) { toast.push( {'Hata'} , { placement: 'top-end', }, ) } finally { setLoading(false) setSubmitting(false) } } return userDetails ? ( <> }> {translate('::Abp.Identity.User.UserInformation')} }> {translate('::Abp.Identity.User.Permissions')} }> {translate('::Abp.Identity.User.WorkInformation')} }> {translate('::Abp.Identity.User.IndentityInformation')} }> {translate('::Abp.Identity.User.LockoutManagement')} }> {translate('::Abp.Identity.User.ClaimTypes')}
{ setSubmitting(true) await putUserDetail({ ...values }) toast.push( {translate('::Kaydet')} , { placement: 'top-end', }, ) getUser() setSubmitting(false) }} > {({ isSubmitting, values }) => { return (
{/* Personal Information */}
{translate( '::Abp.Identity.User.UserInformation.ContactInformation', )}
 
{translate( '::Abp.Identity.User.UserInformation.AdditionalInformation', )}
{({ field, form }: FieldProps) => { const nationalityOptions: SelectBoxOption[] = countries.map( (c) => ({ value: c.name, label: c.name }), ) return ( o.value === values.educationLevel, )} onChange={(option) => form.setFieldValue(field.name, option?.value ?? null) } /> ) }} {({ field, form }: FieldProps) => { const bloodTypeOptions: SelectBoxOption[] = [ { value: 'A Rh+', label: 'A Rh+' }, { value: 'A Rh-', label: 'A Rh-' }, { value: 'B Rh+', label: 'B Rh+' }, { value: 'B Rh-', label: 'B Rh-' }, { value: 'AB Rh+', label: 'AB Rh+' }, { value: 'AB Rh-', label: 'AB Rh-' }, { value: '0 Rh+', label: '0 Rh+' }, { value: '0 Rh-', label: '0 Rh-' }, ] return ( )} {({ field, form }: FieldProps) => ( )}
) }}
{ setSubmitting(true) await putUserPermission({ ...values }) toast.push( {translate('::Abp.Identity.User.SavePermission')} , { placement: 'top-end', }, ) getUser() setSubmitting(false) }} > {({ isSubmitting, values }) => { const roles = values.roles const branches = values.branches return (
{/* Şube Management */}
{translate('::Abp.Identity.User.UserInformation.BranchManagement')}
{({ form, remove, push }) => (
{branches && branches.length > 0 ? branches.map((_, index: number) => (
)) : null}
)}
{/* Role Management */}
{translate('::Abp.Identity.User.UserInformation.RoleManagement')}
{({ form, remove, push }) => (
{roles && roles.length > 0 ? roles.map((_, index: number) => (
)) : null}
)}
) }}
{ setSubmitting(true) await putUserDetail({ ...values }) toast.push( {translate('::Kaydet')} , { placement: 'top-end', }, ) getUser() setSubmitting(false) }} > {({ isSubmitting, values }) => { const departments = values.departments const jobPositions = values.jobPositions const departmentOptions: SelectBoxOption[] = departments.map((department) => ({ value: department.id, label: department.name, })) const jobPositionOptions: SelectBoxOptionWithGroup[] = jobPositions.map( (jobPosition) => ({ value: jobPosition.id, label: jobPosition.name, group: jobPosition.departmentId, }), ) return (
{({ field, form }: FieldProps) => ( option.group === values.departmentId, )} isClearable={true} value={jobPositionOptions.filter( (option) => option.value === values.jobPositionId, )} onChange={(option) => form.setFieldValue(field.name, option?.value) } /> )}
{({ field, form }: FieldProps) => ( { form.setFieldValue( field.name, date ? dayjs(date).format('YYYY-MM-DDTHH:mm:ss') : null, ) }} /> )}
{({ field, form }: FieldProps) => ( { form.setFieldValue( field.name, date ? dayjs(date).format('YYYY-MM-DDTHH:mm:ss') : null, ) }} /> )}
) }}
{ setSubmitting(true) await putUserDetail({ ...values }) toast.push( {translate('::Kaydet')} , { placement: 'top-end', }, ) getUser() setSubmitting(false) }} > {({ isSubmitting, values }) => { const maritalStatusOptions: SelectBoxOption[] = [ { value: 'Bekar', label: translate('::App.MaritalStatus.Single') || 'Bekar', }, { value: 'Evli', label: translate('::App.MaritalStatus.Married') || 'Evli', }, { value: 'Boşanmış', label: translate('::App.MaritalStatus.Divorced') || 'Boşanmış', }, { value: 'Dul', label: translate('::App.MaritalStatus.Widowed') || 'Dul', }, ] return (
{({ field, form }: FieldProps) => ( { form.setFieldValue( field.name, date ? dayjs(date).format('YYYY-MM-DDTHH:mm:ss') : null, ) }} /> )}
{({ field, form }: FieldProps) => ( { form.setFieldValue( field.name, date ? dayjs(date).format('YYYY-MM-DDTHH:mm:ss') : null, ) }} /> )}
{({ field, form }: FieldProps) => ( option.value === values.workHour, )} onChange={(option) => form.setFieldValue(field.name, option?.value) } /> )} {({ field, form }: FieldProps) => ( { form.setFieldValue( field.name, date ? dayjs(date).format('YYYY-MM-DDTHH:mm:ss') : null, ) }} /> )}
) }}
{userDetails.claims.filter((a) => a.isAssigned === true) && userDetails.claims.filter((a) => a.isAssigned === true).length > 0 ? ( userDetails.claims.map((claim) => ( )) ) : ( )}
{translate('::Abp.Identity.User.ClaimType')} {translate('::Abp.Identity.User.ClaimValue')}
{claim.claimType} {claim.claimValue}
{translate('::Abp.Identity.User.NoClaimsFound')}
setOpen(false)} onRequestClose={() => setOpen(false)}> {({ touched, errors, values, isSubmitting }) => { const claimOptions: SelectBoxOption[] = userDetails?.claims.map((claim) => ({ value: claim.claimType, label: claim.claimType, })) return (
{({ field, form }: FieldProps) => (