Fix build errors
This commit is contained in:
parent
785d0965e3
commit
d0f1c1337c
28 changed files with 268 additions and 112 deletions
|
|
@ -28,12 +28,16 @@ export const authProvider = {
|
|||
if (e.networkError && e.networkError.statusCode === 401) {
|
||||
return Promise.reject();
|
||||
}
|
||||
|
||||
return Promise.resolve();
|
||||
},
|
||||
checkAuth: async () => {
|
||||
const session = await getSession();
|
||||
if (!session) {
|
||||
return Promise.reject();
|
||||
}
|
||||
|
||||
return Promise.resolve();
|
||||
},
|
||||
getIdentity: async () => {
|
||||
const session = await getSession();
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
import { FC, PropsWithChildren, useEffect } from "react";
|
||||
import { FC, useEffect } from "react";
|
||||
import { CircularProgress } from "@material-ui/core";
|
||||
import { useSession } from "next-auth/react";
|
||||
import { useRouter } from "next/router";
|
||||
|
||||
export const Auth: FC<PropsWithChildren> = ({ children }) => {
|
||||
export const Auth: FC = ({ children }) => {
|
||||
const router = useRouter();
|
||||
const { data: session, status: loading } = useSession();
|
||||
useEffect(() => {
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ type AccountEditToolbarProps = {
|
|||
record?: any;
|
||||
};
|
||||
|
||||
const AccountEditToolbar: FC<AccountEditToolbarProps> = (props) => {
|
||||
const AccountEditToolbar: FC<AccountEditToolbarProps> = (props: any) => {
|
||||
const { data: session } = useSession();
|
||||
const classes = useStyles(props);
|
||||
return (
|
||||
|
|
|
|||
|
|
@ -14,9 +14,10 @@ type DeleteNotSelfButtonProps = {
|
|||
record?: any;
|
||||
};
|
||||
|
||||
const DeleteNotSelfButton: FC<DeleteNotSelfButtonProps> = (props) => {
|
||||
const DeleteNotSelfButton: FC<DeleteNotSelfButtonProps> = (props: any) => {
|
||||
const { data: session } = useSession();
|
||||
return (
|
||||
// @ts-ignore
|
||||
<DeleteButton
|
||||
disabled={session?.user?.email === props.record.userId}
|
||||
{...props}
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ const Sidebar = ({ record }: any) => {
|
|||
variant="outlined"
|
||||
label="Message"
|
||||
multiline
|
||||
rows={3}
|
||||
minRows={3}
|
||||
fullWidth
|
||||
size="small"
|
||||
value={message}
|
||||
|
|
@ -156,15 +156,15 @@ const handleRequestCode = async ({
|
|||
"Content-Type": "application/json",
|
||||
},
|
||||
});
|
||||
|
||||
if (response && response.ok) {
|
||||
onSuccess();
|
||||
} else {
|
||||
onFailure(response.status || 400);
|
||||
}
|
||||
} catch (error: any) {
|
||||
console.error("Failed to request verification code:", error);
|
||||
}
|
||||
|
||||
if (response && response.ok) {
|
||||
onSuccess();
|
||||
} else {
|
||||
onFailure(response.status || 400);
|
||||
}
|
||||
};
|
||||
|
||||
const VerificationCodeRequest = ({
|
||||
|
|
@ -222,7 +222,7 @@ const VerificationCaptcha = ({
|
|||
setSubmitting(false);
|
||||
};
|
||||
|
||||
const handleCaptchaChange = (value) => {
|
||||
const handleCaptchaChange = (value: any) => {
|
||||
if (value)
|
||||
setCode(
|
||||
value
|
||||
|
|
@ -268,16 +268,16 @@ const VerificationCodeInput = ({
|
|||
handleClose,
|
||||
handleRestartVerification,
|
||||
confirmVerification,
|
||||
}) => {
|
||||
}: any) => {
|
||||
const [code, setValue] = React.useState("");
|
||||
const [isSubmitting, setSubmitting] = React.useState(false);
|
||||
const [isValid, setValid] = React.useState(false);
|
||||
const [submissionError, setSubmissionError] = React.useState(undefined);
|
||||
const translate = useTranslate();
|
||||
|
||||
const validator = (v) => v.trim().length === 6;
|
||||
const validator = (v: any) => v.trim().length === 6;
|
||||
|
||||
const handleValueChange = (newValue) => {
|
||||
const handleValueChange = (newValue: any) => {
|
||||
setValue(newValue);
|
||||
setValid(validator(newValue));
|
||||
};
|
||||
|
|
@ -300,11 +300,14 @@ const VerificationCodeInput = ({
|
|||
if (response.status === 200) {
|
||||
confirmVerification();
|
||||
} else if (responseBody.message)
|
||||
// @ts-expect-error
|
||||
setSubmissionError(`Error: ${responseBody.message}`);
|
||||
else
|
||||
else {
|
||||
setSubmissionError(
|
||||
// @ts-expect-error
|
||||
"There was an error, sorry about that. Please try again later or contact support."
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
const title =
|
||||
|
|
@ -355,7 +358,7 @@ const VerificationCodeInput = ({
|
|||
);
|
||||
};
|
||||
|
||||
const VerificationCodeDialog = (props) => {
|
||||
const VerificationCodeDialog = (props: any) => {
|
||||
const [stage, setStage] = React.useState("request");
|
||||
const onRequestSuccess = () => setStage("verify");
|
||||
const onRestartVerification = () => setStage("request");
|
||||
|
|
@ -406,7 +409,7 @@ const VerificationCodeDialog = (props) => {
|
|||
);
|
||||
};
|
||||
|
||||
const SignalBotShowActions = ({ basePath, data }) => {
|
||||
const SignalBotShowActions = ({ basePath, data }: any) => {
|
||||
const [open, setOpen] = React.useState(false);
|
||||
const [verifyMode, setVerifyMode] = React.useState("");
|
||||
const refresh = useRefresh();
|
||||
|
|
@ -429,7 +432,7 @@ const SignalBotShowActions = ({ basePath, data }) => {
|
|||
|
||||
return (
|
||||
<TopToolbar>
|
||||
<EditButton basePath={basePath} record={data} />
|
||||
<EditButton record={data} />
|
||||
{data && !data.isVerified && (
|
||||
<Button onClick={handleOpenSMS} color="primary">
|
||||
Verify with SMS
|
||||
|
|
@ -455,11 +458,9 @@ const SignalBotShowActions = ({ basePath, data }) => {
|
|||
|
||||
const SignalBotShow = (props: ShowProps) => (
|
||||
<Show
|
||||
// @ts-expect-error: Missing props
|
||||
actions={<SignalBotShowActions />}
|
||||
{...props}
|
||||
title="Signal Bot"
|
||||
// @ts-expect-error: Missing props
|
||||
aside={<Sidebar />}
|
||||
>
|
||||
<SimpleShowLayout>
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import {
|
|||
import { useSession } from "next-auth/react";
|
||||
import { UserRoleInput } from "./shared";
|
||||
|
||||
const UserCreate: FC<CreateProps> = (props) => {
|
||||
const UserCreate: FC<CreateProps> = (props: any) => {
|
||||
const { data: session } = useSession();
|
||||
return (
|
||||
<Create {...props} title="Create Users">
|
||||
|
|
@ -18,7 +18,7 @@ const UserCreate: FC<CreateProps> = (props) => {
|
|||
<TextInput source="name" />
|
||||
<UserRoleInput session={session} initialValue="NONE" />
|
||||
<BooleanInput source="isActive" defaultValue={true} />
|
||||
<TextInput source="createdBy" defaultValue={session.user.name} />
|
||||
<TextInput source="createdBy" defaultValue={session?.user?.name} />
|
||||
</SimpleForm>
|
||||
</Create>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ const useStyles = makeStyles((_theme) => ({
|
|||
},
|
||||
}));
|
||||
|
||||
const UserEditToolbar = (props) => {
|
||||
const UserEditToolbar = (props: any) => {
|
||||
const classes = useStyles(props);
|
||||
const redirect = useRedirect();
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { SelectInput } from "react-admin";
|
||||
|
||||
export const UserRoleInput = (props) => (
|
||||
export const UserRoleInput = (props: any) => (
|
||||
<SelectInput
|
||||
source="userRole"
|
||||
choices={[
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { SelectInput } from "react-admin";
|
||||
|
||||
export const ProviderKindInput = (props) => (
|
||||
export const ProviderKindInput = (props: any) => (
|
||||
<SelectInput
|
||||
source="kind"
|
||||
choices={[{ id: "TWILIO", name: "Twilio" }]}
|
||||
|
|
|
|||
|
|
@ -10,13 +10,17 @@ import { useStopwatch } from "react-timer-hook";
|
|||
import style from "./MicInput.module.css";
|
||||
//import type { ReactMicProps } from "react-mic";
|
||||
|
||||
const ReactMic = dynamic<ReactMicProps>(
|
||||
const ReactMic = dynamic<any>(
|
||||
// eslint-disable-next-line promise/prefer-await-to-then
|
||||
() => { throw new Error("MIC INPUT FEATURE IS DISABLED"); /*return import("react-mic").then((mod) => mod.ReactMic);*/ } ,
|
||||
() => {
|
||||
throw new Error(
|
||||
"MIC INPUT FEATURE IS DISABLED"
|
||||
); /*return import("react-mic").then((mod) => mod.ReactMic);*/
|
||||
},
|
||||
{ ssr: false }
|
||||
);
|
||||
|
||||
const blobToDataUri = (blob) => {
|
||||
const blobToDataUri = (blob: Blob) => {
|
||||
const reader = new FileReader();
|
||||
reader.readAsDataURL(blob);
|
||||
return new Promise((resolve) => {
|
||||
|
|
@ -26,32 +30,32 @@ const blobToDataUri = (blob) => {
|
|||
});
|
||||
};
|
||||
|
||||
const dataUriToObj = (dataUri) => {
|
||||
const dataUriToObj = (dataUri: string) => {
|
||||
const [prefix, base64] = dataUri.split(",");
|
||||
const mime = prefix.slice(5, prefix.indexOf(";"));
|
||||
|
||||
const result = {};
|
||||
const result: any = {};
|
||||
result[mime] = base64;
|
||||
return result;
|
||||
};
|
||||
|
||||
const blobToResult = async (blob) => {
|
||||
const result = dataUriToObj(await blobToDataUri(blob));
|
||||
const blobToResult = async (blob: Blob) => {
|
||||
const result = dataUriToObj((await blobToDataUri(blob)) as string);
|
||||
return result;
|
||||
};
|
||||
|
||||
const resultToDataUri = (result): string => {
|
||||
const resultToDataUri = (result: Record<string, any>): string => {
|
||||
if (!result || !result["audio/webm"]) return "";
|
||||
const base64 = result["audio/webm"];
|
||||
const r = `data:audio/webm;base64,${base64}`;
|
||||
return r;
|
||||
};
|
||||
|
||||
const MicInput = (props) => {
|
||||
const MicInput = (props: any) => {
|
||||
const { seconds, minutes, hours, start, reset, pause } = useStopwatch();
|
||||
const theme = useTheme();
|
||||
const {
|
||||
input: { value, onChange },
|
||||
field: { value, onChange },
|
||||
} = useInput(props);
|
||||
|
||||
let [record, setRecorder] = useState({ record: false });
|
||||
|
|
@ -67,18 +71,16 @@ const MicInput = (props) => {
|
|||
pause();
|
||||
};
|
||||
|
||||
async function onData(recordedBlob) {}
|
||||
async function onData(recordedBlob: any) {}
|
||||
|
||||
async function onStop(recordedBlob) {
|
||||
async function onStop(recordedBlob: any) {
|
||||
const result = await blobToResult(recordedBlob.blob);
|
||||
onChange(result);
|
||||
}
|
||||
|
||||
const isRecording = record.record;
|
||||
const canPlay = !isRecording && decodedValue;
|
||||
const duration = `${hours
|
||||
.toString()
|
||||
.padStart(2, "0")}:${minutes
|
||||
const duration = `${hours.toString().padStart(2, "0")}:${minutes
|
||||
.toString()
|
||||
.padStart(2, "0")}:${seconds.toString().padStart(2, "0")}`;
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ const VoiceLineList = (props: ListProps) => (
|
|||
source="providerId"
|
||||
reference="providers"
|
||||
>
|
||||
<FunctionField render={(p) => `${p.kind}: ${p.name}`} />
|
||||
<FunctionField render={(p: any) => `${p.kind}: ${p.name}`} />
|
||||
</ReferenceField>
|
||||
<TextField source="number" />
|
||||
<TextField source="language" />
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ import TwilioLanguages from "./twilio-languages";
|
|||
|
||||
type TTSProvider = (voice: any, language: any, prompt: any) => Promise<void>;
|
||||
|
||||
const tts = async (providerId): Promise<TTSProvider> => {
|
||||
const tts = async (providerId: any): Promise<TTSProvider> => {
|
||||
const r = await fetch(
|
||||
`/api/v1/voice/twilio/text-to-speech-token/${providerId}`
|
||||
);
|
||||
|
|
@ -39,7 +39,7 @@ const tts = async (providerId): Promise<TTSProvider> => {
|
|||
outgoing: silence,
|
||||
},
|
||||
});
|
||||
device.on("ready", function (device) {
|
||||
device.on("ready", function (device: any) {
|
||||
device.connect({ language, voice, prompt });
|
||||
});
|
||||
device.on("disconnect", () => resolve());
|
||||
|
|
@ -47,7 +47,7 @@ const tts = async (providerId): Promise<TTSProvider> => {
|
|||
});
|
||||
};
|
||||
|
||||
export const TextToSpeechButton = ({ form }) => {
|
||||
export const TextToSpeechButton = ({ form }: any) => {
|
||||
const { providerId, language, voice, promptText: prompt } = form.formData;
|
||||
const [loading, setLoading] = useState<boolean>(false);
|
||||
const [ttsProvider, setTTSProvider] = useState<
|
||||
|
|
@ -90,7 +90,7 @@ export const TextToSpeechButton = ({ form }) => {
|
|||
);
|
||||
};
|
||||
|
||||
export const PromptInput = (form, ...rest) => {
|
||||
export const PromptInput = (form: any, ...rest: any[]) => {
|
||||
return (
|
||||
<TextInput
|
||||
source="promptText"
|
||||
|
|
@ -102,19 +102,23 @@ export const PromptInput = (form, ...rest) => {
|
|||
);
|
||||
};
|
||||
|
||||
const validateVoice = (args, values) => {
|
||||
const validateVoice = (args: any, values: any) => {
|
||||
if (!values.language) return "validation.language";
|
||||
if (!values.voice) return "validation.voice";
|
||||
|
||||
// @ts-expect-error
|
||||
const availableVoices = TwilioLanguages.voices[values.language];
|
||||
const found =
|
||||
availableVoices.filter((v) => v.id === values.voice).length === 1;
|
||||
availableVoices.filter((v: any) => v.id === values.voice).length === 1;
|
||||
if (!found) return "validation.voice";
|
||||
|
||||
return undefined;
|
||||
};
|
||||
|
||||
export const VoiceInput = (form, ...rest) => {
|
||||
export const VoiceInput = (form: any, ...rest: any[]) => {
|
||||
// @ts-expect-error
|
||||
const voice = TwilioLanguages.voices[form.formData.language] || [];
|
||||
return (
|
||||
// @ts-expect-error
|
||||
<SelectInput
|
||||
source="voice"
|
||||
choices={voice}
|
||||
|
|
@ -125,9 +129,9 @@ export const VoiceInput = (form, ...rest) => {
|
|||
};
|
||||
|
||||
let noAvailableNumbers = false;
|
||||
let availableNumbers = [];
|
||||
let availableNumbers: any[] = [];
|
||||
|
||||
const getAvailableNumbers = async (providerId) => {
|
||||
const getAvailableNumbers = async (providerId: string) => {
|
||||
try {
|
||||
const r = await fetch(`/api/v1/voice/providers/${providerId}/freeNumbers`);
|
||||
availableNumbers = await r.json();
|
||||
|
|
@ -141,24 +145,32 @@ const getAvailableNumbers = async (providerId) => {
|
|||
}
|
||||
};
|
||||
|
||||
const sidToNumber = (sid) => {
|
||||
const sidToNumber = (sid: any) => {
|
||||
return availableNumbers
|
||||
.filter(({ id }) => id === sid)
|
||||
.map(({ name }) => name)[0];
|
||||
};
|
||||
|
||||
export const populateNumber = (data) => {
|
||||
export const populateNumber = (data: any) => {
|
||||
return {
|
||||
...data,
|
||||
number: sidToNumber(data.providerLineSid),
|
||||
};
|
||||
};
|
||||
|
||||
const hasNumbers = (args, value, values, translate, ...props) => {
|
||||
const hasNumbers = (
|
||||
args: any,
|
||||
value: any,
|
||||
values: any,
|
||||
translate: any,
|
||||
...props: any[]
|
||||
) => {
|
||||
if (noAvailableNumbers) return "validation.noAvailableNumbers";
|
||||
|
||||
return undefined;
|
||||
};
|
||||
|
||||
export const AvailableNumbersInput = (form, ...rest) => {
|
||||
export const AvailableNumbersInput = (form: any, ...rest: any[]) => {
|
||||
const {
|
||||
// @ts-expect-error: non-existent property
|
||||
meta: { touched, error } = {},
|
||||
|
|
@ -181,7 +193,8 @@ export const AvailableNumbersInput = (form, ...rest) => {
|
|||
? translate("validation.noAvailableNumbers")
|
||||
: "",
|
||||
});
|
||||
if (noAvailableNumbers) notify("validation.noAvailableNumbers", "error");
|
||||
if (noAvailableNumbers)
|
||||
notify("validation.noAvailableNumbers", { type: "error" });
|
||||
setLoading(false);
|
||||
}
|
||||
}, [form && form.formData ? form.formData.providerId : undefined]);
|
||||
|
|
@ -278,19 +291,21 @@ export const AsyncSelectInput = (choiceLoader: () => Promise<any[]>, label, sour
|
|||
export const VoiceLineSelectInput = AsyncSelectInput(getVoiceLineChoices, "Voice Line", "backendId", "validation.noVoiceLines" )
|
||||
*/
|
||||
|
||||
export const VoiceLineSelectInput = (source: string) => () => (
|
||||
<ReferenceInput
|
||||
label="Voice Line"
|
||||
source={source}
|
||||
reference="voiceLines"
|
||||
validate={[required()]}
|
||||
>
|
||||
<SelectInput optionText="number" />
|
||||
</ReferenceInput>
|
||||
);
|
||||
export const VoiceLineSelectInput = (source: string) => () =>
|
||||
(
|
||||
<ReferenceInput
|
||||
label="Voice Line"
|
||||
source={source}
|
||||
reference="voiceLines"
|
||||
validate={[required()]}
|
||||
>
|
||||
<SelectInput optionText="number" />
|
||||
</ReferenceInput>
|
||||
);
|
||||
|
||||
export const VoiceLineField = (source: string) => () => (
|
||||
<ReferenceField label="Voice Line" source={source} reference="voiceLines">
|
||||
<TextField source="number" />
|
||||
</ReferenceField>
|
||||
);
|
||||
export const VoiceLineField = (source: string) => () =>
|
||||
(
|
||||
<ReferenceField label="Voice Line" source={source} reference="voiceLines">
|
||||
<TextField source="number" />
|
||||
</ReferenceField>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ import {
|
|||
} from "react-admin";
|
||||
import { BackendTypeInput, BackendIdInput, HttpMethodInput } from "./shared";
|
||||
|
||||
const WebhookTitle = ({ record }) => {
|
||||
const WebhookTitle = ({ record }: any) => {
|
||||
let title = "";
|
||||
if (record) title = record.name ? record.name : record.email;
|
||||
return <span>Webhook {title}</span>;
|
||||
|
|
@ -19,7 +19,6 @@ const WebhookTitle = ({ record }) => {
|
|||
|
||||
const WebhookEdit = (props: EditProps) => {
|
||||
return (
|
||||
// @ts-expect-error: Missing props
|
||||
<Edit title={<WebhookTitle />} {...props}>
|
||||
<SimpleForm>
|
||||
<TextInput source="name" validate={[required()]} />
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ const httpChoices = [
|
|||
{ id: "post", name: "POST" },
|
||||
{ id: "put", name: "PUT" },
|
||||
];
|
||||
export const HttpMethodInput = (props) => (
|
||||
export const HttpMethodInput = (props: any) => (
|
||||
<SelectInput
|
||||
source="httpMethod"
|
||||
choices={httpChoices}
|
||||
|
|
@ -42,7 +42,7 @@ const backendFieldComponents = {
|
|||
voice: VoiceLineField("backendId"),
|
||||
};
|
||||
|
||||
export const BackendTypeInput = (props) => (
|
||||
export const BackendTypeInput = (props: any) => (
|
||||
<SelectInput
|
||||
source="backendType"
|
||||
choices={backendChoices}
|
||||
|
|
@ -51,18 +51,20 @@ export const BackendTypeInput = (props) => (
|
|||
/>
|
||||
);
|
||||
|
||||
export const BackendIdInput = (form, ...rest) => {
|
||||
export const BackendIdInput = (form: any, ...rest: any[]) => {
|
||||
const Component = form.formData.backendType
|
||||
? backendInputComponents[form.formData.backendType]
|
||||
? // @ts-expect-error
|
||||
backendInputComponents[form.formData.backendType]
|
||||
: false;
|
||||
return <>{Component && <Component form={form} {...rest} />}</>;
|
||||
};
|
||||
|
||||
export const BackendIdField = (form, ...rest) => {
|
||||
export const BackendIdField = (form: any, ...rest: any[]) => {
|
||||
console.log(form);
|
||||
|
||||
const Component = form.record.backendType
|
||||
? backendFieldComponents[form.record.backendType]
|
||||
? // @ts-expect-error
|
||||
backendFieldComponents[form.record.backendType]
|
||||
: false;
|
||||
return <>{Component && <Component form={form} {...rest} />}</>;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { List, Datagrid, TextField } from "react-admin";
|
||||
|
||||
const WhatsappAttachmentList = (props) => (
|
||||
const WhatsappAttachmentList = (props: any) => (
|
||||
<List {...props} exporter={false}>
|
||||
<Datagrid rowClick="show">
|
||||
<TextField source="id" />
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import { SimpleForm, Create, TextInput, required } from "react-admin";
|
|||
import { useSession } from "next-auth/react";
|
||||
import { validateE164Number } from "../../../lib/phone-numbers";
|
||||
|
||||
const WhatsappBotCreate = (props) => {
|
||||
const WhatsappBotCreate = (props: any) => {
|
||||
// const MuiPhoneNumber = dynamic(() => import("material-ui-phone-number"), {
|
||||
// ssr: false,
|
||||
// });
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import {
|
|||
BooleanField,
|
||||
} from "react-admin";
|
||||
|
||||
const WhatsappBotList = (props) => (
|
||||
const WhatsappBotList = (props: any) => (
|
||||
<List {...props} exporter={false}>
|
||||
<Datagrid rowClick="show">
|
||||
<TextField source="phoneNumber" />
|
||||
|
|
|
|||
|
|
@ -12,8 +12,7 @@ import {
|
|||
SimpleShowLayout,
|
||||
TextField,
|
||||
ShowProps,
|
||||
useQuery,
|
||||
useMutation,
|
||||
useGetOne,
|
||||
useRefresh,
|
||||
BooleanField,
|
||||
} from "react-admin";
|
||||
|
|
@ -21,7 +20,7 @@ import QRCode from "react-qr-code";
|
|||
import useSWR from "swr";
|
||||
import RefreshIcon from "@material-ui/icons/Refresh";
|
||||
|
||||
const Sidebar = ({ record }) => {
|
||||
const Sidebar = ({ record }: any) => {
|
||||
const [receivedMessages, setReceivedMessages] = useState([]);
|
||||
const [phoneNumber, setPhoneNumber] = useState("");
|
||||
const handlePhoneNumberChange = (event: any) => {
|
||||
|
|
@ -101,7 +100,7 @@ const Sidebar = ({ record }) => {
|
|||
</IconButton>
|
||||
</Grid>
|
||||
</Grid>
|
||||
{receivedMessages.map((receivedMessage, index) => (
|
||||
{receivedMessages.map((receivedMessage: any, index: number) => (
|
||||
<Grid key={index} item container direction="column" spacing={1}>
|
||||
<Grid item style={{ fontWeight: "bold", color: "#999" }}>
|
||||
{receivedMessage.key.remoteJid.replace("@s.whatsapp.net", "")}
|
||||
|
|
@ -118,11 +117,7 @@ const Sidebar = ({ record }) => {
|
|||
|
||||
const WhatsappBotShow = (props: ShowProps) => {
|
||||
const refresh = useRefresh();
|
||||
const { data } = useQuery({
|
||||
type: "getOne",
|
||||
resource: "whatsappBots",
|
||||
payload: { id: props.id },
|
||||
});
|
||||
const { data } = useGetOne("whatsappBots", props.id as any);
|
||||
|
||||
const { data: registerData, error: registerError } = useSWR(
|
||||
data && !data?.isVerified
|
||||
|
|
@ -150,10 +145,10 @@ const WhatsappBotShow = (props: ShowProps) => {
|
|||
}, 10000);
|
||||
return () => clearInterval(interval);
|
||||
}
|
||||
return undefined;
|
||||
}, [refresh, data]);
|
||||
|
||||
return (
|
||||
// @ts-expect-error: Missing props
|
||||
<Show {...props} title="Bot" aside={<Sidebar />}>
|
||||
<SimpleShowLayout>
|
||||
<TextField source="phoneNumber" />
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue