This commit is contained in:
2024-08-05 15:39:34 +05:00
parent f0bd42a81d
commit d73b200979
5 changed files with 9 additions and 22 deletions
+2 -15
View File
@@ -1,6 +1,5 @@
/* eslint-disable react-hooks/exhaustive-deps */
import { useMask } from "@react-input/mask";
import { useEffect, useState } from "react";
interface InputProps {
type?: "text" | "email" | "password" | "time" | "tel";
@@ -9,7 +8,6 @@ interface InputProps {
autoFocus?: boolean;
required?: boolean;
readOnly?: boolean;
defaultValue?: string;
className?: string;
handleChange?: (value: string) => void;
handleFocus?: () => void;
@@ -22,7 +20,6 @@ function Input({
autoFocus,
required,
readOnly,
defaultValue = "",
className,
handleChange,
handleFocus,
@@ -32,16 +29,6 @@ function Input({
replacement: { _: /\d/ },
});
const [_value, setValue] = useState<string>(value || defaultValue || "");
useEffect(() => {
if (!_value || !handleChange) {
return;
}
handleChange(_value);
}, [_value]);
return (
<input
ref={type === "tel" ? inputRef : undefined}
@@ -50,8 +37,8 @@ function Input({
autoFocus={autoFocus}
required={required}
readOnly={readOnly}
value={value || defaultValue || ""}
onChange={(e) => setValue(e.target.value)}
value={value}
onChange={(e) => handleChange && handleChange(e.target.value)}
onFocus={handleFocus}
className={`px-3 py-2.5 outline-none rounded-lg border border-[#DAE0E5] focus:border-[#49A1F5] transition-colors text-sm ${className}`}
/>
+1 -1
View File
@@ -33,7 +33,7 @@ function Select({ defaultValue, options, handleChange }: SelectProps) {
<Input
readOnly
handleFocus={() => setIsShow(true)}
defaultValue={options?.find((option) => option.value === value).text}
value={options?.find((option) => option.value === value).text}
className="w-full cursor-pointer"
/>
<button
@@ -66,7 +66,7 @@ function CreateBuildModal({ companyId }: Props) {
<Input
placeholder="Кол-во слотов"
className="w-64"
defaultValue={sessionLimit?.toString()}
value={sessionLimit?.toString()}
handleChange={(value) => setSessionLimit(+value)}
required
/>
@@ -160,7 +160,7 @@ function CreateScheduleModal() {
<Label value="Начало" />
<Input
type="time"
defaultValue={startTime}
value={startTime}
handleChange={(value) => setStartTime(value)}
className="w-[137px]"
/>
@@ -170,7 +170,7 @@ function CreateScheduleModal() {
<Label value="Конец" />
<Input
type="time"
defaultValue={endTime}
value={endTime}
handleChange={changeEndTime}
className="w-[137px]"
/>
@@ -108,7 +108,7 @@ function CreateScheduledSessionModal({ buildId, startAt, duration }: Props) {
<Input
type="email"
className="h-10"
defaultValue={email}
value={email}
handleChange={(value) => setEmail(value)}
/>
</div>
@@ -117,7 +117,7 @@ function CreateScheduledSessionModal({ buildId, startAt, duration }: Props) {
<Input
type="tel"
className="h-10"
defaultValue={phone}
value={phone}
handleChange={(value) => setPhone(value)}
/>
</div>
@@ -125,7 +125,7 @@ function CreateScheduledSessionModal({ buildId, startAt, duration }: Props) {
<Label value="Имя" />
<Input
className="h-10"
defaultValue={name}
value={name}
handleChange={(value) => setName(value)}
/>
</div>