Fix build errors
This commit is contained in:
parent
785d0965e3
commit
d0f1c1337c
28 changed files with 268 additions and 112 deletions
|
|
@ -25,7 +25,7 @@ LeafcutterDocument.getInitialProps = async (ctx) => {
|
|||
|
||||
ctx.renderPage = () =>
|
||||
originalRenderPage({
|
||||
enhanceApp: (App: any) => (props) =>
|
||||
enhanceApp: (App: any) => (props: any) =>
|
||||
<App emotionCache={cache} {...props} />,
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ LinkDocument.getInitialProps = async (ctx) => {
|
|||
|
||||
ctx.renderPage = () =>
|
||||
originalRenderPage({
|
||||
enhanceApp: (App: any) => (props) =>
|
||||
enhanceApp: (App: any) => (props: any) =>
|
||||
<App emotionCache={cache} {...props} />,
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -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" />
|
||||
|
|
|
|||
|
|
@ -29,8 +29,8 @@ export const cfVerifier = (audience: string, domain: string): VerifyFn => {
|
|||
});
|
||||
|
||||
return async (token) => {
|
||||
const getKey = (header, callback) => {
|
||||
client.getSigningKey(header.kid, function (err, key) {
|
||||
const getKey = (header: any, callback: any) => {
|
||||
client.getSigningKey(header.kid, function (err: any, key: any) {
|
||||
if (err)
|
||||
throw Boom.serverUnavailable(
|
||||
"failed to fetch cloudflare access jwks"
|
||||
|
|
@ -201,6 +201,7 @@ export const CloudflareAccessProvider = (
|
|||
req: IncomingMessage
|
||||
) => {
|
||||
const verifier = cfVerifier(audience, domain);
|
||||
// @ts-expect-error
|
||||
return Providers.Credentials({
|
||||
id: cloudflareAccountProvider,
|
||||
name: "Cloudflare Access",
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import pgDataProvider from "ra-postgraphile";
|
||||
import schema from "./graphql-schema.json";
|
||||
|
||||
export const metamigoDataProvider = async (client) => {
|
||||
export const metamigoDataProvider = async (client: any) => {
|
||||
const graphqlDataProvider = await pgDataProvider(
|
||||
client,
|
||||
// @ts-expect-error: Missing property
|
||||
|
|
@ -9,7 +9,7 @@ export const metamigoDataProvider = async (client) => {
|
|||
{ introspection: { schema: schema.data.__schema } }
|
||||
);
|
||||
|
||||
const dataProvider = async (type, resource, params) => {
|
||||
const dataProvider = async (type: any, resource: any, params: any) => {
|
||||
return graphqlDataProvider(type, resource, params);
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@
|
|||
"version": "0.2.0",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@digiresilience/metamigo-config": "*",
|
||||
"@apollo/client": "^3.7.4",
|
||||
"@digiresilience/metamigo-config": "*",
|
||||
"@hapi/boom": "^10.0.0",
|
||||
"@hapi/wreck": "^18.0.0",
|
||||
"@mui/icons-material": "^5",
|
||||
|
|
@ -27,8 +27,10 @@
|
|||
"react-digit-input": "^2.1.0",
|
||||
"react-dom": "^17",
|
||||
"react-qr-code": "^2.0.11",
|
||||
"react-redux": "^8.0.5",
|
||||
"react-timer-hook": "^3.0.5",
|
||||
"swr": "^2.0.0"
|
||||
"swr": "^2.0.0",
|
||||
"twilio-client": "^1.15.0"
|
||||
},
|
||||
"scripts": {
|
||||
"serve": "next dev -p 2999",
|
||||
|
|
@ -44,10 +46,10 @@
|
|||
"@types/hapi__wreck": "17.0.1",
|
||||
"@types/react": "^17",
|
||||
"@types/react-mic": "12.4.3",
|
||||
"typescript": "^4.9.5",
|
||||
"tsconfig-link": "*",
|
||||
"babel-preset-link": "*",
|
||||
"eslint-config-link": "*",
|
||||
"jest-config-link": "*",
|
||||
"babel-preset-link": "*"
|
||||
"tsconfig-link": "*",
|
||||
"typescript": "^4.9.5"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import { Typography, Box, Button, Grid, Link } from "@material-ui/core";
|
|||
import { FC, PropsWithChildren, useEffect } from "react";
|
||||
import { useRouter } from "next/router";
|
||||
|
||||
export const RedirectToAdmin: FC<PropsWithChildren> = ({ children }) => {
|
||||
export const RedirectToAdmin: FC = ({ children }) => {
|
||||
const router = useRouter();
|
||||
useEffect(() => {
|
||||
router.push("/admin");
|
||||
|
|
@ -15,7 +15,7 @@ export const RedirectToAdmin: FC<PropsWithChildren> = ({ children }) => {
|
|||
const Home: NextPage = () => (
|
||||
<Box>
|
||||
<Typography variant="h3">Metamigo</Typography>
|
||||
<Grid container justify="space-around" style={{ padding: 60 }}>
|
||||
<Grid container justifyContent="space-around" style={{ padding: 60 }}>
|
||||
<Grid item>
|
||||
<Link href="/admin">
|
||||
<Button variant="contained">Admin</Button>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/* eslint-disable camelcase */
|
||||
import logger from "../logger";
|
||||
import { IncomingMessagev1 } from "@digiresilience/node-signald/dist/generated";
|
||||
import { IncomingMessagev1 } from "@digiresilience/node-signald/build/main/generated";
|
||||
import { withDb, AppDatabase } from "../db";
|
||||
import workerUtils from "../utils";
|
||||
|
||||
|
|
|
|||
|
|
@ -5,5 +5,5 @@
|
|||
"esModuleInterop": true
|
||||
},
|
||||
"include": ["**/*.ts", "**/.*.ts"],
|
||||
"exclude": ["node_modules"]
|
||||
"exclude": ["node_modules", "build"]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
FROM zammad/zammad-docker-compose:5.3.1-53 AS builder
|
||||
FROM zammad/zammad-docker-compose:5.4.0 AS builder
|
||||
COPY auto_install ${ZAMMAD_TMP_DIR}/auto_install
|
||||
RUN sed -i "s/# create install ready file/bundle exec rake zammad:package:migrate/g" contrib/docker/docker-entrypoint.sh
|
||||
# RUN sed -i "s/# create install ready file/bundle exec rake zammad:package:migrate/g" contrib/docker/docker-entrypoint.sh
|
||||
|
||||
FROM zammad/zammad-docker-compose:5.3.1-53
|
||||
FROM zammad/zammad-docker-compose:5.4.0
|
||||
COPY --from=builder ${ZAMMAD_TMP_DIR} ${ZAMMAD_TMP_DIR}
|
||||
|
|
|
|||
136
package-lock.json
generated
136
package-lock.json
generated
|
|
@ -637,8 +637,10 @@
|
|||
"react-digit-input": "^2.1.0",
|
||||
"react-dom": "^17",
|
||||
"react-qr-code": "^2.0.11",
|
||||
"react-redux": "^8.0.5",
|
||||
"react-timer-hook": "^3.0.5",
|
||||
"swr": "^2.0.0"
|
||||
"swr": "^2.0.0",
|
||||
"twilio-client": "^1.15.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@next/eslint-plugin-next": "^13.1.2",
|
||||
|
|
@ -6441,6 +6443,11 @@
|
|||
"version": "2.0.6",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@types/use-sync-external-store": {
|
||||
"version": "0.0.3",
|
||||
"resolved": "https://registry.npmjs.org/@types/use-sync-external-store/-/use-sync-external-store-0.0.3.tgz",
|
||||
"integrity": "sha512-EwmlvuaxPNej9+T4v5AuBPJa2x2UOJVdjCtDHgcDqitUeOtjnJKJ+apYjVcAoBEMjKW1VVFGZLUb5+qqa09XFA=="
|
||||
},
|
||||
"node_modules/@types/uuid": {
|
||||
"version": "9.0.1",
|
||||
"dev": true,
|
||||
|
|
@ -18394,6 +18401,44 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"node_modules/react-redux": {
|
||||
"version": "8.0.5",
|
||||
"resolved": "https://registry.npmjs.org/react-redux/-/react-redux-8.0.5.tgz",
|
||||
"integrity": "sha512-Q2f6fCKxPFpkXt1qNRZdEDLlScsDWyrgSj0mliK59qU6W5gvBiKkdMEG2lJzhd1rCctf0hb6EtePPLZ2e0m1uw==",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.12.1",
|
||||
"@types/hoist-non-react-statics": "^3.3.1",
|
||||
"@types/use-sync-external-store": "^0.0.3",
|
||||
"hoist-non-react-statics": "^3.3.2",
|
||||
"react-is": "^18.0.0",
|
||||
"use-sync-external-store": "^1.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@types/react": "^16.8 || ^17.0 || ^18.0",
|
||||
"@types/react-dom": "^16.8 || ^17.0 || ^18.0",
|
||||
"react": "^16.8 || ^17.0 || ^18.0",
|
||||
"react-dom": "^16.8 || ^17.0 || ^18.0",
|
||||
"react-native": ">=0.59",
|
||||
"redux": "^4"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"@types/react": {
|
||||
"optional": true
|
||||
},
|
||||
"@types/react-dom": {
|
||||
"optional": true
|
||||
},
|
||||
"react-dom": {
|
||||
"optional": true
|
||||
},
|
||||
"react-native": {
|
||||
"optional": true
|
||||
},
|
||||
"redux": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/react-router": {
|
||||
"version": "6.8.2",
|
||||
"license": "MIT",
|
||||
|
|
@ -20235,6 +20280,48 @@
|
|||
"node": ">=6.0"
|
||||
}
|
||||
},
|
||||
"node_modules/twilio-client": {
|
||||
"version": "1.15.0",
|
||||
"resolved": "https://registry.npmjs.org/twilio-client/-/twilio-client-1.15.0.tgz",
|
||||
"integrity": "sha512-7JlyDZSDPVH1pwh7OwiZbUVKw+PFjW7h+Xy1thM+IDSdug7qXWpVyvxwaz3+SVHazZBNnz8DxHJTlsdbYkxN9g==",
|
||||
"dependencies": {
|
||||
"@twilio/audioplayer": "1.0.6",
|
||||
"@twilio/voice-errors": "1.0.1",
|
||||
"backoff": "2.5.0",
|
||||
"loglevel": "1.6.7",
|
||||
"rtcpeerconnection-shim": "1.2.8",
|
||||
"ws": "7.4.6",
|
||||
"xmlhttprequest": "1.8.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 12"
|
||||
}
|
||||
},
|
||||
"node_modules/twilio-client/node_modules/@twilio/voice-errors": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/@twilio/voice-errors/-/voice-errors-1.0.1.tgz",
|
||||
"integrity": "sha512-iXzCuiOhNMhrr8DVjRRzI14YwGUIBM83kWSWcDktxmXim0Tz9xoCth4QFAQcMkNL2h9DlfXlob6noH+3h2iA4A=="
|
||||
},
|
||||
"node_modules/twilio-client/node_modules/ws": {
|
||||
"version": "7.4.6",
|
||||
"resolved": "https://registry.npmjs.org/ws/-/ws-7.4.6.tgz",
|
||||
"integrity": "sha512-YmhHDO4MzaDLB+M9ym/mDA5z0naX8j7SIlT8f8z+I0VtzsRbekxEutHSme7NPS2qE8StCYQNUnfWdXta/Yu85A==",
|
||||
"engines": {
|
||||
"node": ">=8.3.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"bufferutil": "^4.0.1",
|
||||
"utf-8-validate": "^5.0.2"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"bufferutil": {
|
||||
"optional": true
|
||||
},
|
||||
"utf-8-validate": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/twilio/node_modules/axios": {
|
||||
"version": "0.26.1",
|
||||
"license": "MIT",
|
||||
|
|
@ -28207,6 +28294,11 @@
|
|||
"@types/unist": {
|
||||
"version": "2.0.6"
|
||||
},
|
||||
"@types/use-sync-external-store": {
|
||||
"version": "0.0.3",
|
||||
"resolved": "https://registry.npmjs.org/@types/use-sync-external-store/-/use-sync-external-store-0.0.3.tgz",
|
||||
"integrity": "sha512-EwmlvuaxPNej9+T4v5AuBPJa2x2UOJVdjCtDHgcDqitUeOtjnJKJ+apYjVcAoBEMjKW1VVFGZLUb5+qqa09XFA=="
|
||||
},
|
||||
"@types/uuid": {
|
||||
"version": "9.0.1",
|
||||
"dev": true
|
||||
|
|
@ -35543,9 +35635,11 @@
|
|||
"react-digit-input": "^2.1.0",
|
||||
"react-dom": "^17",
|
||||
"react-qr-code": "^2.0.11",
|
||||
"react-redux": "^8.0.5",
|
||||
"react-timer-hook": "^3.0.5",
|
||||
"swr": "^2.0.0",
|
||||
"tsconfig-link": "*",
|
||||
"twilio-client": "*",
|
||||
"typescript": "^4.9.5"
|
||||
},
|
||||
"dependencies": {
|
||||
|
|
@ -37380,6 +37474,19 @@
|
|||
"match-sorter": "^6.0.2"
|
||||
}
|
||||
},
|
||||
"react-redux": {
|
||||
"version": "8.0.5",
|
||||
"resolved": "https://registry.npmjs.org/react-redux/-/react-redux-8.0.5.tgz",
|
||||
"integrity": "sha512-Q2f6fCKxPFpkXt1qNRZdEDLlScsDWyrgSj0mliK59qU6W5gvBiKkdMEG2lJzhd1rCctf0hb6EtePPLZ2e0m1uw==",
|
||||
"requires": {
|
||||
"@babel/runtime": "^7.12.1",
|
||||
"@types/hoist-non-react-statics": "^3.3.1",
|
||||
"@types/use-sync-external-store": "^0.0.3",
|
||||
"hoist-non-react-statics": "^3.3.2",
|
||||
"react-is": "^18.0.0",
|
||||
"use-sync-external-store": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"react-router": {
|
||||
"version": "6.8.2",
|
||||
"requires": {
|
||||
|
|
@ -38524,6 +38631,33 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"twilio-client": {
|
||||
"version": "1.15.0",
|
||||
"resolved": "https://registry.npmjs.org/twilio-client/-/twilio-client-1.15.0.tgz",
|
||||
"integrity": "sha512-7JlyDZSDPVH1pwh7OwiZbUVKw+PFjW7h+Xy1thM+IDSdug7qXWpVyvxwaz3+SVHazZBNnz8DxHJTlsdbYkxN9g==",
|
||||
"requires": {
|
||||
"@twilio/audioplayer": "1.0.6",
|
||||
"@twilio/voice-errors": "1.0.1",
|
||||
"backoff": "2.5.0",
|
||||
"loglevel": "1.6.7",
|
||||
"rtcpeerconnection-shim": "1.2.8",
|
||||
"ws": "7.4.6",
|
||||
"xmlhttprequest": "1.8.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@twilio/voice-errors": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/@twilio/voice-errors/-/voice-errors-1.0.1.tgz",
|
||||
"integrity": "sha512-iXzCuiOhNMhrr8DVjRRzI14YwGUIBM83kWSWcDktxmXim0Tz9xoCth4QFAQcMkNL2h9DlfXlob6noH+3h2iA4A=="
|
||||
},
|
||||
"ws": {
|
||||
"version": "7.4.6",
|
||||
"resolved": "https://registry.npmjs.org/ws/-/ws-7.4.6.tgz",
|
||||
"integrity": "sha512-YmhHDO4MzaDLB+M9ym/mDA5z0naX8j7SIlT8f8z+I0VtzsRbekxEutHSme7NPS2qE8StCYQNUnfWdXta/Yu85A==",
|
||||
"requires": {}
|
||||
}
|
||||
}
|
||||
},
|
||||
"type": {
|
||||
"version": "1.2.0"
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue