Added checkbox for accepted terms
This commit is contained in:
32
src/hooks/useAcceptedTerms.tsx
Normal file
32
src/hooks/useAcceptedTerms.tsx
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
import React from "react";
|
||||||
|
import Link from "next/link";
|
||||||
|
import Checkbox from "@/components/Low/Checkbox";
|
||||||
|
|
||||||
|
const useAcceptedTerms = () => {
|
||||||
|
const [acceptedTerms, setAcceptedTerms] = React.useState(false);
|
||||||
|
|
||||||
|
const renderCheckbox = () => (
|
||||||
|
<Checkbox isChecked={acceptedTerms} onChange={setAcceptedTerms}>
|
||||||
|
I agree to the
|
||||||
|
<Link
|
||||||
|
href={`${process.env.NEXT_PUBLIC_WEBSITE_URL}/terms`}
|
||||||
|
className="text-blue-500"
|
||||||
|
>
|
||||||
|
{" "}
|
||||||
|
Terms and Conditions
|
||||||
|
</Link>{" "}
|
||||||
|
and
|
||||||
|
<Link
|
||||||
|
href={`${process.env.NEXT_PUBLIC_WEBSITE_URL}/privacy-policy`}
|
||||||
|
className="text-blue-500"
|
||||||
|
>
|
||||||
|
{" "}
|
||||||
|
Privacy Policy
|
||||||
|
</Link>
|
||||||
|
</Checkbox>
|
||||||
|
);
|
||||||
|
|
||||||
|
return { acceptedTerms, renderCheckbox };
|
||||||
|
};
|
||||||
|
|
||||||
|
export default useAcceptedTerms;
|
||||||
@@ -10,6 +10,7 @@ import { toast } from "react-toastify";
|
|||||||
import { KeyedMutator } from "swr";
|
import { KeyedMutator } from "swr";
|
||||||
import Select from "react-select";
|
import Select from "react-select";
|
||||||
import moment from "moment";
|
import moment from "moment";
|
||||||
|
import useAcceptedTerms from "@/hooks/useAcceptedTerms";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
isLoading: boolean;
|
isLoading: boolean;
|
||||||
@@ -40,6 +41,7 @@ export default function RegisterCorporate({
|
|||||||
const [companyName, setCompanyName] = useState("");
|
const [companyName, setCompanyName] = useState("");
|
||||||
const [companyUsers, setCompanyUsers] = useState(0);
|
const [companyUsers, setCompanyUsers] = useState(0);
|
||||||
const [subscriptionDuration, setSubscriptionDuration] = useState(1);
|
const [subscriptionDuration, setSubscriptionDuration] = useState(1);
|
||||||
|
const {acceptedTerms, renderCheckbox} = useAcceptedTerms();
|
||||||
|
|
||||||
const { users } = useUsers();
|
const { users } = useUsers();
|
||||||
|
|
||||||
@@ -257,7 +259,9 @@ export default function RegisterCorporate({
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div className="flex w-full flex-col items-start gap-4">
|
||||||
|
{renderCheckbox()}
|
||||||
|
</div>
|
||||||
<Button
|
<Button
|
||||||
className="w-full lg:mt-8"
|
className="w-full lg:mt-8"
|
||||||
color="purple"
|
color="purple"
|
||||||
|
|||||||
@@ -4,9 +4,10 @@ import Input from "@/components/Low/Input";
|
|||||||
import { User } from "@/interfaces/user";
|
import { User } from "@/interfaces/user";
|
||||||
import { sendEmailVerification } from "@/utils/email";
|
import { sendEmailVerification } from "@/utils/email";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import { useEffect, useState } from "react";
|
import { useState } from "react";
|
||||||
import { toast } from "react-toastify";
|
import { toast } from "react-toastify";
|
||||||
import { KeyedMutator } from "swr";
|
import { KeyedMutator } from "swr";
|
||||||
|
import useAcceptedTerms from "@/hooks/useAcceptedTerms";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
queryCode?: string;
|
queryCode?: string;
|
||||||
@@ -35,6 +36,7 @@ export default function RegisterIndividual({
|
|||||||
const [confirmPassword, setConfirmPassword] = useState("");
|
const [confirmPassword, setConfirmPassword] = useState("");
|
||||||
const [code, setCode] = useState(queryCode || "");
|
const [code, setCode] = useState(queryCode || "");
|
||||||
const [hasCode, setHasCode] = useState<boolean>(!!queryCode);
|
const [hasCode, setHasCode] = useState<boolean>(!!queryCode);
|
||||||
|
const {acceptedTerms, renderCheckbox} = useAcceptedTerms();
|
||||||
|
|
||||||
const onSuccess = () =>
|
const onSuccess = () =>
|
||||||
toast.success(
|
toast.success(
|
||||||
@@ -146,7 +148,9 @@ export default function RegisterIndividual({
|
|||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
<div className="flex w-full flex-col items-start gap-4">
|
||||||
|
{renderCheckbox()}
|
||||||
|
</div>
|
||||||
<Button
|
<Button
|
||||||
className="w-full lg:mt-8"
|
className="w-full lg:mt-8"
|
||||||
color="purple"
|
color="purple"
|
||||||
@@ -156,6 +160,7 @@ export default function RegisterIndividual({
|
|||||||
!name ||
|
!name ||
|
||||||
!password ||
|
!password ||
|
||||||
!confirmPassword ||
|
!confirmPassword ||
|
||||||
|
!acceptedTerms ||
|
||||||
password !== confirmPassword ||
|
password !== confirmPassword ||
|
||||||
(hasCode ? !code : false)
|
(hasCode ? !code : false)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user