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. 6
      src/components/Componentes/question-text.tsx
  5. 3
      src/components/Componentes/question-textarea.tsx

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

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

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

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

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

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

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

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

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

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

Loading…
Cancel
Save