2022-10-14 16:24:43 +00:00
|
|
|
import { z } from "zod";
|
2022-09-05 21:10:58 +00:00
|
|
|
|
2022-10-14 16:24:43 +00:00
|
|
|
import { SetAppDataGeneric } from "@calcom/app-store/EventTypeAppContext";
|
2022-09-05 21:10:58 +00:00
|
|
|
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
|
|
|
import { SUPPORTED_CHAINS_FOR_FORM } from "@calcom/rainbow/utils/ethereum";
|
2022-11-23 02:55:25 +00:00
|
|
|
import { Select } from "@calcom/ui";
|
2022-09-05 21:10:58 +00:00
|
|
|
|
2022-10-14 16:24:43 +00:00
|
|
|
import { appDataSchema } from "../zod";
|
2022-09-05 21:10:58 +00:00
|
|
|
|
|
|
|
type RainbowInstallFormProps = {
|
2022-10-14 16:24:43 +00:00
|
|
|
setAppData: SetAppDataGeneric<typeof appDataSchema>;
|
|
|
|
} & Pick<z.infer<typeof appDataSchema>, "smartContractAddress" | "blockchainId">;
|
2022-09-05 21:10:58 +00:00
|
|
|
|
|
|
|
const RainbowInstallForm: React.FC<RainbowInstallFormProps> = ({
|
2022-10-14 16:24:43 +00:00
|
|
|
setAppData,
|
2022-09-05 21:10:58 +00:00
|
|
|
blockchainId,
|
|
|
|
smartContractAddress,
|
|
|
|
}) => {
|
|
|
|
const { t } = useLocale();
|
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
2022-10-09 11:08:47 +00:00
|
|
|
<div className="mt-4 block items-center sm:flex">
|
2022-09-05 21:10:58 +00:00
|
|
|
<div className="min-w-48 mb-4 sm:mb-0">
|
2023-01-12 16:57:43 +00:00
|
|
|
<label htmlFor="blockchainId" className="flex text-sm font-medium text-gray-700">
|
2022-09-05 21:10:58 +00:00
|
|
|
{t("Blockchain")}
|
|
|
|
</label>
|
|
|
|
</div>
|
|
|
|
<Select
|
|
|
|
isSearchable={false}
|
|
|
|
className="block w-full min-w-0 flex-1 rounded-sm text-sm"
|
|
|
|
onChange={(e) => {
|
2022-10-14 16:24:43 +00:00
|
|
|
setAppData("blockchainId", (e && e.value) || 1);
|
2022-09-05 21:10:58 +00:00
|
|
|
}}
|
2022-10-14 16:24:43 +00:00
|
|
|
defaultValue={SUPPORTED_CHAINS_FOR_FORM.find((e) => e.value === blockchainId)}
|
2022-09-05 21:10:58 +00:00
|
|
|
options={SUPPORTED_CHAINS_FOR_FORM || [{ value: 1, label: "Ethereum" }]}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
<div className="block items-center sm:flex">
|
|
|
|
<div className="min-w-48 mb-4 sm:mb-0">
|
2023-01-12 16:57:43 +00:00
|
|
|
<label htmlFor="smartContractAddress" className="flex text-sm font-medium text-gray-700">
|
2022-09-05 21:10:58 +00:00
|
|
|
{t("token_address")}
|
|
|
|
</label>
|
|
|
|
</div>
|
|
|
|
<div className="w-full">
|
|
|
|
<div className="relative mt-1 rounded-sm">
|
|
|
|
<input
|
|
|
|
type="text"
|
|
|
|
className="block w-full rounded-sm border-gray-300 text-sm "
|
|
|
|
placeholder={t("Example: 0x71c7656ec7ab88b098defb751b7401b5f6d8976f")}
|
|
|
|
defaultValue={(smartContractAddress || "") as string}
|
2022-10-14 16:24:43 +00:00
|
|
|
onChange={(e) => {
|
|
|
|
setAppData("smartContractAddress", e.target.value);
|
|
|
|
}}
|
2022-09-05 21:10:58 +00:00
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default RainbowInstallForm;
|