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