Untitled
unknown
plain_text
a year ago
7.1 kB
7
Indexable
export const convertNotificationText = (notification: any) => {
switch (notification?.action) {
case "CREATE":
return <Link
to={`/data/${slug(notification?.value?.name)}/${notification?.value?.id}?tab=infor${getUrlParameter('redirect') ? `&redirect=${getUrlParameter('redirect')}` : ''}${getUrlParameter('allocationId') ? `&allocationId=${getUrlParameter('allocationId')}` : ''}`}
className='history_client__item--content'>
<div className='history_client__item--info'>
<span className='history_client__item--name me-2'>{notification?.performedBy?.name}</span>
<span
className='history_client__item--text me-1'>{convertNameActivity(notification?.action)}</span>
<span
className='history_client__item--text me-1'>{convertObjectNameActivity(notification?.objectName)}</span>
</div>
<div className='history_client__item--time'>
<span>{dateUtils.convertTimeLog(notification?.createdAt)}</span>
</div>
</Link>
case "CHANGE_STATE":
return <Link
to={`/data/${slug(notification?.value?.name)}/${notification?.value?.id}?tab=infor${getUrlParameter('redirect') ? `&redirect=${getUrlParameter('redirect')}` : ''}${getUrlParameter('allocationId') ? `&allocationId=${getUrlParameter('allocationId')}` : ''}`}
className='history_client__item--content'>
<div className='history_client__item--info'>
<span className='history_client__item--name me-2'>{notification?.performedBy?.name}</span>
<span
className='history_client__item--text me-1'>{convertNameActivity(notification?.action)}</span>
<span
className='history_client__item--text me-1'>{convertObjectNameActivity(notification?.objectName)}</span>
</div>
<div className='history_client__item--time'>
<span>{dateUtils.convertTimeLog(notification?.createdAt)}</span>
</div>
</Link>
case "DELETE":
return <Link
to={`/data/client-data`}
className='history_client__item--content'>
<div className='history_client__item--info'>
<span className='history_client__item--name me-2'>{notification?.performedBy?.name}</span>
<span
className='history_client__item--text me-1'>{convertNameActivity(notification?.action)}</span>
<span
className='history_client__item--text me-1'>{convertObjectNameActivity(notification?.objectName)}</span>
</div>
<div className='history_client__item--time'>
<span>{dateUtils.convertTimeLog(notification?.createdAt)}</span>
</div>
</Link>
case "UPDATE":
return <Link
to={`/data/${slug(notification?.value?.name)}/${notification?.value?.id}?tab=infor${getUrlParameter('redirect') ? `&redirect=${getUrlParameter('redirect')}` : ''}${getUrlParameter('allocationId') ? `&allocationId=${getUrlParameter('allocationId')}` : ''}`}
className='history_client__item--content'>
<div className='history_client__item--info'>
<span className='history_client__item--name me-2'>{notification?.performedBy?.name}</span>
<span
className='history_client__item--text me-1'>{convertNameActivity(notification?.action)}</span>
<span
className='history_client__item--text me-1'>{convertObjectNameActivity(notification?.objectName)}</span>
{convertUpdateFields(notification?.updatedFields)}
</div>
<div className='history_client__item--time'>
<span>{dateUtils.convertTimeLog(notification?.createdAt)}</span>
</div>
</Link>
default:
return null;
}
};
export const convertNameActivity = (value: string) => {
switch (value) {
case "CHANGE_STATE":
return 'chuyển trạng thái của'
case "CREATE":
return 'tạo mới'
case "DELETE":
return 'xóa'
case "DETAIL":
return 'chi tiết'
case "FILTER":
return 'lọc'
case "UPDATE":
return 'cập nhật thông tin'
default:
return null;
}
};
export const convertObjectNameActivity = (value: string) => {
switch (value) {
case "CLIENT":
return 'khách hàng'
default:
return null;
}
};
export const convertNameFieldUpdate = (value: string) => {
switch (value) {
case "name":
return 'Tên khách hàng'
case "careers":
return 'Ngành nghề'
case "clientSources":
return 'Nguồn khách hàng'
case "address":
return 'Địa chỉ'
case "tin":
return 'Mã số thuế'
case "level":
return 'Phân loại'
case "contactPersons":
return 'Người liên hệ'
case "description":
return 'Mô tả'
case "businessType":
return 'Loại hình'
case "enterpriseScale":
return 'Quy mô'
case "email":
return 'Người liên hệ'
case "fields":
return 'Lĩnh vực'
case "segment":
return 'Phân khúc'
case "relationship":
return 'Mối quan hệ'
case "foundingDate":
return 'Ngày thành lập'
case "logo":
return 'Logo'
case "phone":
return 'Số điện thoại'
default:
return null;
}
};
export const convertUpdateFields = (updateFields: any) => {
return updateFields?.filter((field: any) => (field !== 'updatedAt' && field !== 'createdAt' && field !== 'clientEnterprise' && field !== 'updatedUser' && field !== 'sale')).map((item: any, index: number) => {
return <span className='history_client__item--text me-1' key={index}>
{index === 0 && '('}
{convertNameFieldUpdate(item)}
{index !== (updateFields?.filter((field: any) => (field !== 'updatedAt' && field !== 'createdAt' && field !== 'clientEnterprise' && field !== 'updatedUser' && field !== 'sale'))?.length - 1) && ','}
{index === (updateFields?.filter((field: any) => (field !== 'updatedAt' && field !== 'createdAt' && field !== 'clientEnterprise' && field !== 'updatedUser' && field !== 'sale'))?.length - 1) && ')'}
</span>
})
};
Editor is loading...
Leave a Comment