2022-05-14 10:22:06 +00:00
|
|
|
import { useState } from "react";
|
|
|
|
import { useTransition } from "@remix-run/react";
|
2021-10-15 23:25:13 +00:00
|
|
|
import { IoHelpCircle } from "react-icons/io5";
|
|
|
|
|
|
|
|
import HelpModal from "./help-modal";
|
|
|
|
import Button from "../button";
|
|
|
|
import SettingsSection from "../settings-section";
|
|
|
|
|
|
|
|
export default function TwilioApiForm() {
|
2022-05-14 10:22:06 +00:00
|
|
|
const transition = useTransition();
|
2021-10-15 23:25:13 +00:00
|
|
|
const [isHelpModalOpen, setIsHelpModalOpen] = useState(false);
|
2022-05-14 10:22:06 +00:00
|
|
|
const isSubmitting = transition.state === "submitting";
|
2021-10-15 23:25:13 +00:00
|
|
|
|
2022-05-14 10:22:06 +00:00
|
|
|
const onSubmit = async () => {
|
|
|
|
// await setTwilioApiFieldsMutation({ twilioAccountSid, twilioAuthToken }); // TODO
|
|
|
|
};
|
2021-10-15 23:25:13 +00:00
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<form onSubmit={onSubmit} className="flex flex-col gap-6">
|
|
|
|
<SettingsSection
|
|
|
|
className="relative"
|
|
|
|
footer={
|
|
|
|
<div className="px-4 py-3 bg-gray-50 text-right text-sm font-medium sm:px-6">
|
|
|
|
<Button variant="default" type="submit" isDisabled={isSubmitting}>
|
|
|
|
{isSubmitting ? "Saving..." : "Save"}
|
|
|
|
</Button>
|
|
|
|
</div>
|
|
|
|
}
|
|
|
|
>
|
|
|
|
<button onClick={() => setIsHelpModalOpen(true)} className="absolute top-2 right-2">
|
|
|
|
<IoHelpCircle className="w-6 h-6 text-primary-700" />
|
|
|
|
</button>
|
|
|
|
<article>
|
|
|
|
Shellphone needs some informations about your Twilio account to securely use your phone numbers.
|
|
|
|
</article>
|
|
|
|
|
|
|
|
<div className="w-full">
|
|
|
|
<label htmlFor="twilioAccountSid" className="block text-sm font-medium text-gray-700">
|
|
|
|
Twilio Account SID
|
|
|
|
</label>
|
|
|
|
<input
|
|
|
|
id="twilioAccountSid"
|
2022-05-14 10:22:06 +00:00
|
|
|
name="twilioAccountSid"
|
|
|
|
type="text"
|
2021-10-15 23:25:13 +00:00
|
|
|
className="mt-1 block w-full border border-gray-300 rounded-md shadow-sm py-2 px-3 focus:outline-none focus:ring-primary-500 focus:border-primary-500 sm:text-sm"
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
<div className="w-full">
|
|
|
|
<label htmlFor="twilioAuthToken" className="block text-sm font-medium text-gray-700">
|
|
|
|
Twilio Auth Token
|
|
|
|
</label>
|
|
|
|
<input
|
|
|
|
id="twilioAuthToken"
|
2022-05-14 10:22:06 +00:00
|
|
|
name="twilioAuthToken"
|
|
|
|
type="text"
|
2021-10-15 23:25:13 +00:00
|
|
|
className="mt-1 block w-full border border-gray-300 rounded-md shadow-sm py-2 px-3 focus:outline-none focus:ring-primary-500 focus:border-primary-500 sm:text-sm"
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</SettingsSection>
|
|
|
|
</form>
|
|
|
|
|
|
|
|
<HelpModal closeModal={() => setIsHelpModalOpen(false)} isHelpModalOpen={isHelpModalOpen} />
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
}
|