Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Guest tickets #237

Merged
merged 2 commits into from
Mar 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 46 additions & 24 deletions client/src/components/support/CreateTicketFlow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ import {
Dropdown,
Form,
Icon,
Label,
Message,
TextArea,
} from "semantic-ui-react";
import useGlobalError from "../error/ErrorHooks";
import { useEffect, useMemo, useState } from "react";
import { useEffect, useMemo, useRef, useState } from "react";
import axios from "axios";
import { CentralIdentityApp, SupportTicket } from "../../types";
import { Controller, get, useForm } from "react-hook-form";
Expand Down Expand Up @@ -56,6 +57,8 @@ const CreateTicketFlow: React.FC<CreateTicketFlowProps> = ({ isLoggedIn }) => {
const [files, setFiles] = useState<File[]>([]);
const [turnstileToken, setTurnstileToken] = useState<string>("");
const [challengePassed, setChallengePassed] = useState(true);
const [confirmEmail, setConfirmEmail] = useState<string>("");
const [startedConfirming, setStartedConfirming] = useState(false);

useEffect(() => {
const searchParams = new URLSearchParams(location.search);
Expand Down Expand Up @@ -109,6 +112,7 @@ const CreateTicketFlow: React.FC<CreateTicketFlowProps> = ({ isLoggedIn }) => {
}, []);

const submitDisabled = useMemo(() => {
if (loading) return true;
if ((!user || !user.uuid) && !challengePassed) {
return true;
}
Expand All @@ -122,6 +126,10 @@ const CreateTicketFlow: React.FC<CreateTicketFlowProps> = ({ isLoggedIn }) => {
) {
return true;
}

if (getValues("guest.email") !== confirmEmail) {
return true;
}
}

if (
Expand Down Expand Up @@ -271,29 +279,43 @@ const CreateTicketFlow: React.FC<CreateTicketFlowProps> = ({ isLoggedIn }) => {
/>
</div>
</div>
<div className="flex flex-col lg:flex-row w-full mt-4">
<div className="w-full mr-8">
<CtlTextInput
control={control}
name="guest.email"
label="Email"
placeholder="Enter your email"
rules={required}
required
fluid
/>
</div>
<div className="w-full">
<CtlTextInput
control={control}
name="guest.organization"
label="Organization"
placeholder="Enter your school or organization"
rules={required}
required
fluid
/>
</div>
<div className="w-full mt-4">
<CtlTextInput
control={control}
name="guest.organization"
label="Organization"
placeholder="Enter your school or organization"
rules={required}
required
fluid
/>
</div>
<div className="w-full mt-4">
<CtlTextInput
control={control}
name="guest.email"
label="Email"
placeholder="Enter your email"
rules={required}
required
fluid
/>
</div>
<div className="w-full mt-4">
<Form.Input
label="Confirm Email"
placeholder="Confirm your email"
value={confirmEmail}
onChange={(e) => {
setConfirmEmail(e.target.value);
setStartedConfirming(true);
}}
required
/>
{startedConfirming &&
confirmEmail !== watch("guest.email") && (
<p className="text-red-500">Emails do not match</p>
)}
</div>
<Divider className="" />
</div>
Expand Down
Loading