feat:UX and fix drinkkaart payment logic
This commit is contained in:
@@ -21,14 +21,25 @@ interface PerformerErrors {
|
||||
|
||||
interface Props {
|
||||
onBack: () => void;
|
||||
onSuccess: (token: string) => void;
|
||||
onSuccess: (token: string, email: string, name: string) => void;
|
||||
prefillFirstName?: string;
|
||||
prefillLastName?: string;
|
||||
prefillEmail?: string;
|
||||
isLoggedIn?: boolean;
|
||||
}
|
||||
|
||||
export function PerformerForm({ onBack, onSuccess }: Props) {
|
||||
export function PerformerForm({
|
||||
onBack,
|
||||
onSuccess,
|
||||
prefillFirstName = "",
|
||||
prefillLastName = "",
|
||||
prefillEmail = "",
|
||||
isLoggedIn = false,
|
||||
}: Props) {
|
||||
const [data, setData] = useState({
|
||||
firstName: "",
|
||||
lastName: "",
|
||||
email: "",
|
||||
firstName: prefillFirstName,
|
||||
lastName: prefillLastName,
|
||||
email: prefillEmail,
|
||||
phone: "",
|
||||
artForm: "",
|
||||
experience: "",
|
||||
@@ -42,7 +53,12 @@ export function PerformerForm({ onBack, onSuccess }: Props) {
|
||||
const submitMutation = useMutation({
|
||||
...orpc.submitRegistration.mutationOptions(),
|
||||
onSuccess: (result) => {
|
||||
if (result.managementToken) onSuccess(result.managementToken);
|
||||
if (result.managementToken)
|
||||
onSuccess(
|
||||
result.managementToken,
|
||||
data.email.trim(),
|
||||
`${data.firstName.trim()} ${data.lastName.trim()}`.trim(),
|
||||
);
|
||||
},
|
||||
onError: (error) => {
|
||||
toast.error(`Er is iets misgegaan: ${error.message}`);
|
||||
@@ -249,14 +265,15 @@ export function PerformerForm({ onBack, onSuccess }: Props) {
|
||||
id="p-email"
|
||||
name="email"
|
||||
value={data.email}
|
||||
onChange={handleChange}
|
||||
onBlur={handleBlur}
|
||||
onChange={isLoggedIn ? undefined : handleChange}
|
||||
onBlur={isLoggedIn ? undefined : handleBlur}
|
||||
readOnly={isLoggedIn}
|
||||
placeholder="jouw@email.be"
|
||||
autoComplete="email"
|
||||
inputMode="email"
|
||||
aria-required="true"
|
||||
aria-invalid={touched.email && !!errors.email}
|
||||
className={inputCls(!!touched.email && !!errors.email)}
|
||||
className={`${inputCls(!!touched.email && !!errors.email)}${isLoggedIn ? "cursor-not-allowed opacity-60" : ""}`}
|
||||
/>
|
||||
{touched.email && errors.email && (
|
||||
<span className="text-red-300 text-sm" role="alert">
|
||||
|
||||
Reference in New Issue
Block a user