Date fix for alerts and recent calls (#176)

* date fix for alerts and recent calls

* add a check for value to exist

* getRecentCalls with sip_callid

Co-authored-by: EgleHelms <e.helms@cognigy.com>
This commit is contained in:
EgleH
2023-01-23 13:40:23 +01:00
committed by GitHub
parent def7743b9e
commit fd29f986e4
5 changed files with 16 additions and 16 deletions
+6 -6
View File
@@ -530,19 +530,19 @@ export const getRecentCalls = (sid: string, query: Partial<CallQuery>) => {
);
};
export const getRecentCall = (sid: string, callSid: string) => {
export const getRecentCall = (sid: string, sipCallId: string) => {
return getFetch<TotalResponse>(
import.meta.env.DEV
? `${DEV_BASE_URL}/Accounts/${sid}/RecentCalls/${callSid}`
: `${API_ACCOUNTS}/${sid}/RecentCalls/${callSid}`
? `${DEV_BASE_URL}/Accounts/${sid}/RecentCalls/${sipCallId}`
: `${API_ACCOUNTS}/${sid}/RecentCalls/${sipCallId}`
);
};
export const getPcap = (sid: string, callSid: string) => {
export const getPcap = (sid: string, sipCallId: string) => {
return getBlob(
import.meta.env.DEV
? `${DEV_BASE_URL}/Accounts/${sid}/RecentCalls/${callSid}/pcap`
: `${API_ACCOUNTS}/${sid}/RecentCalls/${callSid}/pcap`
? `${DEV_BASE_URL}/Accounts/${sid}/RecentCalls/${sipCallId}/pcap`
: `${API_ACCOUNTS}/${sid}/RecentCalls/${sipCallId}/pcap`
);
};
+1 -1
View File
@@ -110,7 +110,7 @@ export const LocalLimits = ({
Scope.account
}
>
<React.Fragment key={category}>
<React.Fragment>
<label htmlFor={category}>{label}</label>
<input
ref={(el: HTMLInputElement) => {
@@ -101,9 +101,7 @@ export const Alerts = () => {
<div className="item__info">
<div className="item__title txt--jam">
<strong>
{dayjs
.unix(alert.time / 1000)
.format("YYYY MM.DD hh:mm a")}
{dayjs(alert.time).format("YYYY MM.DD hh:mm a")}
</strong>
</div>
<div className="item__meta">
@@ -28,9 +28,7 @@ export const DetailsItem = ({ call }: DetailsItemProps) => {
<div className="item__info">
<div className="item__title">
<strong>
{dayjs
.unix(call.attempted_at / 1000)
.format("YYYY MM.DD hh:mm a")}
{dayjs(call.attempted_at).format("YYYY MM.DD hh:mm a")}
</strong>
<span className="i txt--dark">
{call.direction === "inbound" ? (
@@ -62,7 +60,11 @@ export const DetailsItem = ({ call }: DetailsItemProps) => {
{Object.keys(call).map((key) => (
<React.Fragment key={key}>
<div>{key}:</div>
<div>{call[key as keyof typeof call].toString()}</div>
<div>
{call[key as keyof typeof call]
? call[key as keyof typeof call].toString()
: "null"}
</div>
</React.Fragment>
))}
</div>
@@ -13,10 +13,10 @@ export const PcapButton = ({ call }: PcapButtonProps) => {
const [pcap, setPcap] = useState<Pcap>();
useEffect(() => {
getRecentCall(call.account_sid, call.call_sid)
getRecentCall(call.account_sid, call.sip_callid)
.then(({ json }) => {
if (json.total > 0) {
getPcap(call.account_sid, call.call_sid)
getPcap(call.account_sid, call.sip_callid)
.then(({ blob }) => {
if (blob) {
setPcap({