lavoce #35
@@ -26,7 +26,7 @@ export default function RedirectWa() {
|
|||||||
|
|
||||||
console.log('tes', response);
|
console.log('tes', response);
|
||||||
|
|
||||||
const tokenResult = JSON.stringify(response.data?.accessToken);
|
const tokenResult = JSON.stringify(response.data?.data?.accessToken);
|
||||||
|
|
||||||
sessionStorage.setItem('token_redirect', tokenResult);
|
sessionStorage.setItem('token_redirect', tokenResult);
|
||||||
response.data.auth = true;
|
response.data.auth = true;
|
||||||
|
|||||||
@@ -288,14 +288,16 @@ const ListNotification = memo(function ListNotification(props) {
|
|||||||
name: user.contact_name,
|
name: user.contact_name,
|
||||||
phone: user.contact_phone,
|
phone: user.contact_phone,
|
||||||
status: user.is_send ? 'Delivered' : 'Pending',
|
status: user.is_send ? 'Delivered' : 'Pending',
|
||||||
timestamp: user.created_at
|
timestamp: user.updated_at
|
||||||
? new Date(user.created_at).toLocaleString('id-ID', {
|
? new Date(user.updated_at)
|
||||||
day: '2-digit',
|
.toLocaleString('id-ID', {
|
||||||
month: '2-digit',
|
day: '2-digit',
|
||||||
year: 'numeric',
|
month: '2-digit',
|
||||||
hour: '2-digit',
|
year: 'numeric',
|
||||||
minute: '2-digit',
|
hour: '2-digit',
|
||||||
}) + ' WIB'
|
minute: '2-digit',
|
||||||
|
})
|
||||||
|
.replace('.', ':') + ' WIB'
|
||||||
: 'N/A',
|
: 'N/A',
|
||||||
}));
|
}));
|
||||||
setUserHistoryData(transformedUsers);
|
setUserHistoryData(transformedUsers);
|
||||||
@@ -610,9 +612,6 @@ const ListNotification = memo(function ListNotification(props) {
|
|||||||
icon={<SendOutlined />}
|
icon={<SendOutlined />}
|
||||||
onClick={async () => {
|
onClick={async () => {
|
||||||
await resendChatByUser(user.id, user.phone);
|
await resendChatByUser(user.id, user.phone);
|
||||||
// message.info(
|
|
||||||
// 'Resend feature is not available yet. This feature is still under development.'
|
|
||||||
// );
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Resend
|
Resend
|
||||||
|
|||||||
@@ -14,6 +14,8 @@ import {
|
|||||||
message,
|
message,
|
||||||
Avatar,
|
Avatar,
|
||||||
Tag,
|
Tag,
|
||||||
|
Badge,
|
||||||
|
Divider,
|
||||||
} from 'antd';
|
} from 'antd';
|
||||||
import {
|
import {
|
||||||
ArrowLeftOutlined,
|
ArrowLeftOutlined,
|
||||||
@@ -33,6 +35,8 @@ import {
|
|||||||
CheckCircleOutlined,
|
CheckCircleOutlined,
|
||||||
SyncOutlined,
|
SyncOutlined,
|
||||||
SendOutlined,
|
SendOutlined,
|
||||||
|
MobileOutlined,
|
||||||
|
ClockCircleOutlined,
|
||||||
} from '@ant-design/icons';
|
} from '@ant-design/icons';
|
||||||
import {
|
import {
|
||||||
getNotificationDetail,
|
getNotificationDetail,
|
||||||
@@ -40,6 +44,7 @@ import {
|
|||||||
getNotificationLogByNotificationId,
|
getNotificationLogByNotificationId,
|
||||||
updateIsRead,
|
updateIsRead,
|
||||||
resendNotificationToUser,
|
resendNotificationToUser,
|
||||||
|
resendChatByUser,
|
||||||
} from '../../api/notification';
|
} from '../../api/notification';
|
||||||
|
|
||||||
const { Content } = Layout;
|
const { Content } = Layout;
|
||||||
@@ -108,8 +113,19 @@ const getUsersFromNotification = (notification) => {
|
|||||||
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,
|
||||||
status: user.is_send ? 'sent' : 'pending',
|
status: user.is_send ? 'Delivered' : 'Pending',
|
||||||
loading: user.loading || false,
|
loading: user.loading || false,
|
||||||
|
timestamp: user.updated_at
|
||||||
|
? new Date(user.updated_at)
|
||||||
|
.toLocaleString('id-ID', {
|
||||||
|
day: '2-digit',
|
||||||
|
month: '2-digit',
|
||||||
|
year: 'numeric',
|
||||||
|
hour: '2-digit',
|
||||||
|
minute: '2-digit',
|
||||||
|
})
|
||||||
|
.replace('.', ':') + ' WIB'
|
||||||
|
: 'N/A',
|
||||||
}));
|
}));
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -235,8 +251,6 @@ const NotificationDetailTab = (props) => {
|
|||||||
|
|
||||||
// Fetch using the actual API
|
// Fetch using the actual API
|
||||||
const response = await getNotificationDetail(notificationId);
|
const response = await getNotificationDetail(notificationId);
|
||||||
// Fetch using the actual API
|
|
||||||
const resUpdate = await updateIsRead(notificationId);
|
|
||||||
|
|
||||||
if (response && response.data) {
|
if (response && response.data) {
|
||||||
const transformedData = transformNotificationData(response.data);
|
const transformedData = transformNotificationData(response.data);
|
||||||
@@ -244,6 +258,9 @@ const NotificationDetailTab = (props) => {
|
|||||||
|
|
||||||
// Fetch log history
|
// Fetch log history
|
||||||
fetchLogHistory(notificationId);
|
fetchLogHistory(notificationId);
|
||||||
|
|
||||||
|
// Fetch using the actual API
|
||||||
|
const resUpdate = await updateIsRead(notificationId);
|
||||||
} else {
|
} else {
|
||||||
throw new Error('Notification not found');
|
throw new Error('Notification not found');
|
||||||
}
|
}
|
||||||
@@ -465,137 +482,56 @@ const NotificationDetailTab = (props) => {
|
|||||||
<Row align="middle" justify="space-between">
|
<Row align="middle" justify="space-between">
|
||||||
<Col>
|
<Col>
|
||||||
<Space align="center">
|
<Space align="center">
|
||||||
<Avatar
|
<Text strong>{user.name}k</Text>
|
||||||
size="large"
|
<Text>|</Text>
|
||||||
icon={<UserOutlined />}
|
<Text>
|
||||||
|
<MobileOutlined /> {user.phone}
|
||||||
|
</Text>
|
||||||
|
<Text>|</Text>
|
||||||
|
<Badge
|
||||||
|
status={
|
||||||
|
user.status === 'Delivered'
|
||||||
|
? 'success'
|
||||||
|
: 'default'
|
||||||
|
}
|
||||||
|
text={user.status}
|
||||||
/>
|
/>
|
||||||
<div>
|
</Space>
|
||||||
<Text strong>{user.name}</Text>
|
<Divider style={{ margin: '8px 0' }} />
|
||||||
<div
|
<Space align="center">
|
||||||
style={{
|
{user.status === 'Delivered' ? (
|
||||||
display: 'flex',
|
<CheckCircleFilled
|
||||||
alignItems: 'center',
|
style={{ color: '#52c41a' }}
|
||||||
gap: '4px',
|
/>
|
||||||
}}
|
) : (
|
||||||
>
|
<ClockCircleOutlined
|
||||||
<PhoneOutlined
|
style={{ color: '#faad14' }}
|
||||||
style={{
|
/>
|
||||||
color: '#8c8c8c',
|
)}
|
||||||
}}
|
<Text type="secondary">
|
||||||
/>
|
{user.status === 'Delivered'
|
||||||
<Text type="secondary">
|
? 'Success Delivered at'
|
||||||
{user.phone}
|
: 'Status '}{' '}
|
||||||
</Text>
|
{user.timestamp}
|
||||||
</div>
|
</Text>
|
||||||
</div>
|
|
||||||
</Space>
|
</Space>
|
||||||
</Col>
|
</Col>
|
||||||
<Col>
|
<Col>
|
||||||
<Space align="center" size="large">
|
<Col>
|
||||||
{getStatusTag(user.status)}
|
|
||||||
<Button
|
<Button
|
||||||
type="primary"
|
type="primary"
|
||||||
|
ghost
|
||||||
icon={<SendOutlined />}
|
icon={<SendOutlined />}
|
||||||
size="small"
|
onClick={async () => {
|
||||||
loading={user.loading}
|
await resendChatByUser(
|
||||||
onClick={async (e) => {
|
user.id,
|
||||||
e.stopPropagation();
|
user.phone
|
||||||
const userId = parseInt(
|
|
||||||
user.id
|
|
||||||
);
|
);
|
||||||
try {
|
|
||||||
// Update user status to show loading
|
|
||||||
const updatedUsers =
|
|
||||||
notification.users.map(
|
|
||||||
(u) =>
|
|
||||||
u.notification_error_user_id ===
|
|
||||||
userId
|
|
||||||
? {
|
|
||||||
...u,
|
|
||||||
loading: true,
|
|
||||||
}
|
|
||||||
: u
|
|
||||||
);
|
|
||||||
setNotification({
|
|
||||||
...notification,
|
|
||||||
users: updatedUsers,
|
|
||||||
});
|
|
||||||
|
|
||||||
// Call the resend API
|
|
||||||
const response =
|
|
||||||
await resendNotificationToUser(
|
|
||||||
notification.notification_error_id,
|
|
||||||
userId
|
|
||||||
);
|
|
||||||
|
|
||||||
if (
|
|
||||||
response &&
|
|
||||||
response.statusCode ===
|
|
||||||
200
|
|
||||||
) {
|
|
||||||
message.success(
|
|
||||||
`Notification resent to ${user.name}`
|
|
||||||
);
|
|
||||||
|
|
||||||
// Update user status
|
|
||||||
const updatedUsersAfterSuccess =
|
|
||||||
notification.users.map(
|
|
||||||
(u) =>
|
|
||||||
u.notification_error_user_id ===
|
|
||||||
userId
|
|
||||||
? {
|
|
||||||
...u,
|
|
||||||
is_send: true,
|
|
||||||
status: 'sent',
|
|
||||||
loading: false,
|
|
||||||
}
|
|
||||||
: {
|
|
||||||
...u,
|
|
||||||
loading: false,
|
|
||||||
}
|
|
||||||
);
|
|
||||||
setNotification({
|
|
||||||
...notification,
|
|
||||||
users: updatedUsersAfterSuccess,
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
throw new Error(
|
|
||||||
response?.message ||
|
|
||||||
'Failed to resend notification'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.error(
|
|
||||||
'Error resending notification:',
|
|
||||||
error
|
|
||||||
);
|
|
||||||
message.error(
|
|
||||||
error.message ||
|
|
||||||
'Failed to resend notification'
|
|
||||||
);
|
|
||||||
|
|
||||||
// Reset loading state
|
|
||||||
const resetUsers =
|
|
||||||
notification.users.map(
|
|
||||||
(u) =>
|
|
||||||
u.notification_error_user_id ===
|
|
||||||
userId
|
|
||||||
? {
|
|
||||||
...u,
|
|
||||||
loading: false,
|
|
||||||
}
|
|
||||||
: u
|
|
||||||
);
|
|
||||||
setNotification({
|
|
||||||
...notification,
|
|
||||||
users: resetUsers,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Resend
|
Resend
|
||||||
</Button>
|
</Button>
|
||||||
</Space>
|
</Col>
|
||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
</Card>
|
</Card>
|
||||||
|
|||||||
Reference in New Issue
Block a user