Skip to content

Commit cfae6cf

Browse files
refactor: remove Tooltip component and integrate tooltip functionality in LeadFormCard
- Deleted the Tooltip component from the UI library. - Added tooltip functionality directly in LeadFormCard for the "Codante PRO" subscription checkbox. - Updated form handling to include a new checkbox for Codante PRO subscribers, enhancing user experience with contextual information.
1 parent 9b79a03 commit cfae6cf

2 files changed

Lines changed: 67 additions & 45 deletions

File tree

app/components/ui/tooltip.tsx

Lines changed: 0 additions & 28 deletions
This file was deleted.

app/routes/_layout-app/_landing-pages/codando-com-ia/index.tsx

Lines changed: 67 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ import {
3434
Code,
3535
FolderOpen,
3636
} from "lucide-react";
37+
import TooltipWrapper from "~/components/ui/tooltip";
38+
import { BsInfoCircle } from "react-icons/bs";
3739

3840
const COURSE_TAG = "curso-ao-vivo-codando-com-ia-v1";
3941

@@ -285,18 +287,28 @@ export const action = async ({ request }: ActionFunctionArgs) => {
285287
const email = (formData.get("email") as string) ?? "";
286288
const name = (formData.get("name") as string) ?? "";
287289
const phone = (formData.get("phone") as string) ?? "";
290+
const isCodantePro = formData.get("isCodantePro") === "true";
291+
const leadTag = isCodantePro ? `${COURSE_TAG}-assinante-codante` : COURSE_TAG;
288292

289293
const leadResponse = await registerMarketingLead(request, {
290294
email,
291295
name,
292296
phone,
293-
tag: COURSE_TAG,
297+
tag: leadTag,
294298
});
295299

296300
if (leadResponse?.error) {
297301
return leadResponse;
298302
}
299303

304+
if (isCodantePro) {
305+
return {
306+
success:
307+
leadResponse?.success ??
308+
"Cadastro realizado. Como assinante Codante PRO, você já tem acesso gratuito ao curso!",
309+
} satisfies LeadFeedback;
310+
}
311+
300312
try {
301313
const checkout = await createCodandoComIaCheckout({
302314
request,
@@ -374,7 +386,7 @@ function Hero({ actionData }: { actionData: LeadFeedback | undefined }) {
374386
<span className="text-sm uppercase tracking-wide text-amber-500">
375387
🔴 Curso ao vivo do Codante
376388
</span>
377-
<h1 className="text-4xl xl:text-5xl font-lexend max-w-3xl dark:text-white text-gray-800">
389+
<h1 className="text-4xl xl:text-7xl font-bold font-lexend max-w-3xl dark:text-white text-gray-800">
378390
Codando com IA
379391
</h1>
380392
<p className="text-lg font-light max-w-2xl text-gray-700 dark:text-gray-500">
@@ -444,16 +456,12 @@ function LeadFormCard({
444456
name: "",
445457
phone: "",
446458
email: "",
459+
isCodantePro: false,
447460
});
448461

449-
const phoneDigits = formValues.phone.replace(/\D/g, "");
450462
const navigation = useNavigation();
451463
const isSubmitting = navigation.state === "submitting";
452-
const isFormValid =
453-
formValues.name.trim().length > 0 &&
454-
phoneDigits.length >= 10 &&
455-
formValues.email.trim().length > 0;
456-
const isDisabled = !isFormValid || isSubmitting;
464+
const isDisabled = isSubmitting;
457465

458466
return (
459467
<div className="w-full rounded-2xl border border-background-200 dark:border-background-700 bg-white dark:bg-background-900 p-6 shadow-xl">
@@ -464,7 +472,12 @@ function LeadFormCard({
464472
Avise a gente que você quer participar. Vamos te enviar a abertura das
465473
vagas e os próximos passos direto no seu e-mail.
466474
</p>
467-
<Form method="post" replace className="flex flex-col gap-4" noValidate>
475+
<Form
476+
id="lead-form"
477+
method="post"
478+
replace
479+
className="flex flex-col gap-4"
480+
>
468481
<label className="flex flex-col gap-2 text-sm font-medium text-gray-800 dark:text-gray-200">
469482
Nome
470483
<input
@@ -514,6 +527,27 @@ function LeadFormCard({
514527
className="w-full rounded-lg border border-background-200 dark:border-background-700 bg-transparent px-4 py-2 text-base focus:outline-none focus:ring-2 focus:ring-amber-500"
515528
/>
516529
</label>
530+
<div className="flex items-center justify-start gap-2 rounded-lg px-4 pl-2 py-3">
531+
<label className="flex items-center gap-3 text-sm font-medium text-gray-800 dark:text-gray-200">
532+
<input
533+
type="checkbox"
534+
name="isCodantePro"
535+
value="true"
536+
checked={formValues.isCodantePro}
537+
onChange={(event) =>
538+
setFormValues((prev) => ({
539+
...prev,
540+
isCodantePro: event.target.checked,
541+
}))
542+
}
543+
className="h-4 w-4 rounded border-background-300 text-amber-500 focus:ring-amber-500"
544+
/>
545+
<span>Já sou assinante do Codante PRO</span>
546+
</label>
547+
<TooltipWrapper text="Se você já é assinante do Codante, você já tem acesso a esse curso gratuitamente, basta se inscrever.">
548+
<BsInfoCircle className="h-5 w-5 text-gray-400 hover:text-gray-600 dark:text-background-500 dark:hover:text-background-300" />
549+
</TooltipWrapper>
550+
</div>
517551
<button
518552
type="submit"
519553
disabled={isDisabled}
@@ -1026,7 +1060,7 @@ function OfferCard({
10261060
accent: string;
10271061
}) {
10281062
const scrollToForm = () => {
1029-
const formElement = document.querySelector('form[method="post"]');
1063+
const formElement = document.getElementById("lead-form");
10301064
if (formElement) {
10311065
formElement.scrollIntoView({ behavior: "smooth", block: "center" });
10321066
}
@@ -1170,23 +1204,18 @@ function LeadFormCompact({
11701204
name: "",
11711205
phone: "",
11721206
email: "",
1207+
isCodantePro: false,
11731208
});
11741209

1175-
const compactPhoneDigits = formValues.phone.replace(/\D/g, "");
11761210
const navigation = useNavigation();
11771211
const isSubmitting = navigation.state === "submitting";
1178-
const isFormValid =
1179-
formValues.name.trim().length > 0 &&
1180-
compactPhoneDigits.length >= 10 &&
1181-
formValues.email.trim().length > 0;
1182-
const isDisabled = !isFormValid || isSubmitting;
1212+
const isDisabled = isSubmitting;
11831213

11841214
return (
11851215
<Form
11861216
method="post"
11871217
replace
11881218
className="flex flex-col gap-3 bg-white dark:bg-background-900 rounded-2xl border border-amber-200 dark:border-amber-500/30 p-6 shadow-sm"
1189-
noValidate
11901219
>
11911220
<label className="flex flex-col text-xs font-semibold text-gray-700 dark:text-gray-300 gap-1">
11921221
Nome
@@ -1237,6 +1266,27 @@ function LeadFormCompact({
12371266
className="rounded-lg border border-background-200 dark:border-background-700 bg-transparent px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-amber-500"
12381267
/>
12391268
</label>
1269+
<div className="flex items-center justify-between rounded-lg px-3 py-2">
1270+
<label className="flex items-center gap-2 text-xs font-semibold text-gray-700 dark:text-gray-300">
1271+
<input
1272+
type="checkbox"
1273+
name="isCodantePro"
1274+
value="true"
1275+
checked={formValues.isCodantePro}
1276+
onChange={(event) =>
1277+
setFormValues((prev) => ({
1278+
...prev,
1279+
isCodantePro: event.target.checked,
1280+
}))
1281+
}
1282+
className="h-3.5 w-3.5 rounded border-background-300 text-amber-500 focus:ring-amber-500"
1283+
/>
1284+
<span>Já sou assinante do Codante PRO</span>
1285+
</label>
1286+
<TooltipWrapper text="Se você já é assinante do Codante, você já tem acesso a esse curso gratuitamente, basta se inscrever.">
1287+
<BsInfoCircle className="h-4 w-4 text-gray-400 hover:text-gray-600 dark:text-background-500 dark:hover:text-background-300" />
1288+
</TooltipWrapper>
1289+
</div>
12401290
<button
12411291
type="submit"
12421292
disabled={isDisabled}

0 commit comments

Comments
 (0)