feat(api): add API for resend chat user
This commit is contained in:
@@ -55,6 +55,24 @@ const resendNotificationToUser = async (notificationId, userId) => {
|
||||
return response.data;
|
||||
};
|
||||
|
||||
// Resend Chat by User
|
||||
const resendChatByUser = async (notificationId, userPhone) => {
|
||||
const response = await SendRequest({
|
||||
method: 'put',
|
||||
prefix: `notification-user/resend/${notificationId}/${userPhone}`,
|
||||
});
|
||||
return response.data;
|
||||
};
|
||||
|
||||
// Resend Chat All User
|
||||
const resendChatAllUser = async (notificationId) => {
|
||||
const response = await SendRequest({
|
||||
method: 'post',
|
||||
prefix: `notification-user/resend/${notificationId}`,
|
||||
});
|
||||
return response.data;
|
||||
};
|
||||
|
||||
export {
|
||||
getAllNotification,
|
||||
getNotificationById,
|
||||
@@ -62,4 +80,6 @@ export {
|
||||
createNotificationLog,
|
||||
getNotificationLogByNotificationId,
|
||||
resendNotificationToUser,
|
||||
resendChatByUser,
|
||||
resendChatAllUser,
|
||||
};
|
||||
|
||||
@@ -42,6 +42,8 @@ import {
|
||||
getAllNotification,
|
||||
getNotificationLogByNotificationId,
|
||||
getNotificationDetail,
|
||||
resendChatByUser,
|
||||
resendChatAllUser,
|
||||
} from '../../../api/notification';
|
||||
|
||||
const { Text, Paragraph, Link: AntdLink } = Typography;
|
||||
@@ -65,6 +67,7 @@ const transformNotificationData = (apiData) => {
|
||||
: 'N/A',
|
||||
location: item.plant_sub_section_name || item.device_location || 'Location not specified',
|
||||
details: item.device_name || '-',
|
||||
errId: item.users[0].notification_error_id || 0,
|
||||
link: `/verification-sparepart/${item.notification_error_id}`, // Dummy URL untuk verifikasi spare part
|
||||
subsection: item.plant_sub_section_name || 'N/A',
|
||||
isRead: item.is_read,
|
||||
@@ -195,9 +198,9 @@ const ListNotification = memo(function ListNotification(props) {
|
||||
content: `Are you sure you want to resend the notification for "${notification.title}"?`,
|
||||
okText: 'Resend',
|
||||
cancelText: 'Cancel',
|
||||
onOk() {
|
||||
async onOk() {
|
||||
console.log('Resending notification:', notification.id);
|
||||
|
||||
await resendChatAllUser(notification.errId);
|
||||
message.success(
|
||||
`Notification for "${notification.title}" has been resent successfully.`
|
||||
);
|
||||
@@ -284,6 +287,7 @@ const ListNotification = memo(function ListNotification(props) {
|
||||
id: user.notification_error_user_id.toString(),
|
||||
name: user.contact_name,
|
||||
phone: user.contact_phone,
|
||||
userId: user.notification_error_user_id,
|
||||
status: user.is_send ? 'Delivered' : 'Pending',
|
||||
timestamp: user.created_at
|
||||
? new Date(user.created_at).toLocaleString('id-ID', {
|
||||
@@ -605,7 +609,8 @@ const ListNotification = memo(function ListNotification(props) {
|
||||
type="primary"
|
||||
ghost
|
||||
icon={<SendOutlined />}
|
||||
onClick={() => {
|
||||
onClick={async () => {
|
||||
await resendChatByUser(user.userId, user.phone);
|
||||
message.info(
|
||||
'Resend feature is not available yet. This feature is still under development.'
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user