Browse Source

refactor: remove redundant form wrappers and name attributes from question components

master
mortezaei 6 days ago
parent
commit
3cb66447a1
  1. 1
      src/components/Componentes/question-birthplace.tsx
  2. 2
      src/components/Componentes/question-number.tsx
  3. 3
      src/components/Componentes/question-phone.tsx
  4. 54
      src/components/Componentes/question-text.tsx
  5. 21
      src/components/Componentes/question-textarea.tsx

1
src/components/Componentes/question-birthplace.tsx

@ -483,7 +483,6 @@ export function QuestionBirthplace({
<Input
ref={cityInputRef}
type="text"
name={`field_${question.id}`}
data-no-auto-focus
disabled={disabled}
value={cityInput}

2
src/components/Componentes/question-number.tsx

@ -190,7 +190,6 @@ export default function QuestionNumber({
<Input
type="text"
inputMode="decimal"
name={`field_${question.id}`}
required={question.required && !disabled}
disabled={disabled || Boolean(derivedFromQuestion)}
placeholder={dynamicPlaceholder}
@ -390,7 +389,6 @@ export default function QuestionNumber({
<QuestionTitle question={question} />
<Input
type="number"
name={`field_${question.id}`}
required={question.required && !disabled}
disabled={disabled || Boolean(derivedFromQuestion)}
min={min || undefined}

3
src/components/Componentes/question-phone.tsx

@ -567,7 +567,6 @@ export function QuestionPhone({
].join(" ")}
>
<QuestionTitle question={question} />
<form autoComplete="off" onSubmit={(e) => e.preventDefault()}>
<div
dir="ltr"
data-snap-drag-ignore="true"
@ -614,7 +613,6 @@ export function QuestionPhone({
type="tel"
inputMode="tel"
data-snap-drag-ignore="true"
name={`field_${question.id}`}
autoComplete="off"
autoCorrect="off"
autoCapitalize="none"
@ -646,7 +644,6 @@ export function QuestionPhone({
/>
</span>
</div>
</form>
{showInvalidState ? (
<span className="block group-10 font-semibold text-[#F2465F]">
Enter a valid phone number with country code.

54
src/components/Componentes/question-text.tsx

@ -92,20 +92,17 @@ export default function QuestionText({
)}
>
<QuestionTitle question={question} />
<form autoComplete="off" onSubmit={(e) => e.preventDefault()}>
<Input
type="text"
inputMode="email"
dir="ltr"
name={`field_${question.id}`}
hasError={showInvalidState}
value={localValue}
onChange={(e) => handleChange(e.target.value)}
onBlur={handleBlur}
placeholder={question.extras.placeHolder}
disabled={disabled || isMuted}
/>
</form>
<Input
type="text"
inputMode="email"
dir="ltr"
hasError={showInvalidState}
value={localValue}
onChange={(e) => handleChange(e.target.value)}
onBlur={handleBlur}
placeholder={question.extras.placeHolder}
disabled={disabled || isMuted}
/>
{showInvalidState ? (
<span className="block group-10 font-semibold text-[#F2465F]">
{question.validation?.errorMessage ||
@ -133,22 +130,19 @@ export default function QuestionText({
)}
>
<QuestionTitle question={question} />
<form autoComplete="off" onSubmit={(e) => e.preventDefault()}>
<Input
type={isNumericQuestion ? "tel" : "text"}
inputMode={isNumericQuestion ? "numeric" : "text"}
pattern={isNumericQuestion ? "[0-9]*" : undefined}
name={`field_${question.id}`}
value={localValue}
onChange={(e) => handleChange(e.target.value)}
onBlur={handleBlur}
placeholder={question.extras.placeHolder}
disabled={disabled || isMuted}
className={cn(
isMuted && "opacity-50 cursor-not-allowed bg-[#F5F5F5] border-[#E2E8F0]",
)}
/>
</form>
<Input
type={isNumericQuestion ? "tel" : "text"}
inputMode={isNumericQuestion ? "numeric" : "text"}
pattern={isNumericQuestion ? "[0-9]*" : undefined}
value={localValue}
onChange={(e) => handleChange(e.target.value)}
onBlur={handleBlur}
placeholder={question.extras.placeHolder}
disabled={disabled || isMuted}
className={cn(
isMuted && "opacity-50 cursor-not-allowed bg-[#F5F5F5] border-[#E2E8F0]",
)}
/>
{isMarjaQuestion ? (
<div className="mt-2.5 flex items-center">
<label className="flex cursor-pointer items-center gap-2 select-none active:scale-[0.99] transition-all">

21
src/components/Componentes/question-textarea.tsx

@ -64,18 +64,15 @@ export function QuestionTextarea({
)}
>
<QuestionTitle question={question} />
<form autoComplete="off" onSubmit={(e) => e.preventDefault()}>
<Textarea
name={`field_${question.id}`}
value={localValue}
onChange={handleChange}
onBlur={handleBlur}
placeholder={question.extras.placeHolder}
disabled={disabled}
rows={5}
className="h-[270px]"
/>
</form>
<Textarea
value={localValue}
onChange={handleChange}
onBlur={handleBlur}
placeholder={question.extras.placeHolder}
disabled={disabled}
rows={5}
className="h-[270px]"
/>
{description ? (
<span className="block group-10 font-semibold text-[#747474]">
{description}

Loading…
Cancel
Save