261022_03_ENH: 예약 취소 추가

This commit is contained in:
2026-10-22 15:49:14 +09:00
parent 061ef782bc
commit f65dacdec1
9 changed files with 234 additions and 19 deletions

View File

@@ -10,8 +10,9 @@ import { useAddListEventMutation, useDeleteListEventMutation, useListEventHistor
import { useSendResultBySidQuery } from '@/query/message'
import { useInternalInfoQuery } from '@/query/internal'
import { clientEnv } from '@/lib/env.client'
import { ChannelType } from '@kri/common/noti-hub'
import { ChannelType, isSendCancelable } from '@kri/common/noti-hub'
import type { SendResultInfo } from '@kri/common/noti-hub'
import { useSendCancel } from '@/hooks/useSendCancel'
import { formatKst } from '@kri/common'
import { type ResultCode, ResultCodeType } from '@/types/project'
import { CONTACT_INTERVIEWER_ROLE, FIELD_INTERVIEWER_ROLE } from '@/const/userConst'
@@ -239,6 +240,8 @@ const ContactEventSection = ({
}
const SendResultTable = ({ isLoading, results }: { isLoading: boolean; results: SendResultInfo[] }) => {
const { canCancel: canCancelSend, cancel, isPending: cancelPending } = useSendCancel()
if (isLoading) {
return <div className="rounded-md border p-4 text-center text-sm text-muted-foreground">불러오는 중...</div>
}
@@ -255,16 +258,37 @@ const SendResultTable = ({ isLoading, results }: { isLoading: boolean; results:
<th className="p-2 text-left">수신처</th>
<th className="p-2 text-left">결과</th>
<th className="p-2 text-left">발송일시</th>
{canCancelSend ? <th className="p-2 text-left"><span className="sr-only">예약 취소</span></th> : null}
</tr>
</thead>
<tbody>
{results.map((item) => (
<tr key={item.cmid} className="border-t">
<td className="p-2">{item.destEml || item.destTel || '-'}</td>
<td className="p-2">{item.resultViewLabel || item.resultLabel || item.resultCode}</td>
<td className="p-2">{formatKst(item.sendDt, 'dateHourMin')}</td>
</tr>
))}
{results.map((item) => {
const { sendIdx } = item
// 버튼은 서버의 cancelable로만 판단한다(값이 없는 구버전 응답은 취소 불가). 최종 결과는 취소 API 응답 건수로 안내한다.
const canCancel = isSendCancelable(item) && !!sendIdx
return (
<tr key={sendIdx ?? item.cmid} className="border-t">
<td className="p-2">{item.destEml || item.destTel || '-'}</td>
<td className="p-2">{item.resultViewLabel || item.resultLabel || item.resultCode}</td>
<td className="p-2">{formatKst(item.sendDt, 'dateHourMin')}</td>
{canCancelSend ? (
<td className="p-2 text-right">
{canCancel && sendIdx ? (
<Button
type="button"
size="sm"
variant="outline"
disabled={cancelPending}
onClick={() => cancel({ type: 'single', sendIdx })}
>
예약 취소
</Button>
) : null}
</td>
) : null}
</tr>
)
})}
</tbody>
</table>
</div>