styles: format code with prettier

This commit is contained in:
AprilNEA
2024-10-02 18:22:21 +00:00
parent fc38a42587
commit dfd6764320
4 changed files with 24 additions and 31 deletions

View File

@@ -134,7 +134,7 @@ export const UpdatePort = ({ portId }: Props) => {
if (value === "") { if (value === "") {
field.onChange(0); field.onChange(0);
} else { } else {
field.onChange(parseInt(value, 10)); field.onChange(Number.parseInt(value, 10));
} }
}} }}
/> />

View File

@@ -228,10 +228,7 @@ export const AddDomain = ({
<FormItem> <FormItem>
<FormLabel>Container Port</FormLabel> <FormLabel>Container Port</FormLabel>
<FormControl> <FormControl>
<NumberInput <NumberInput placeholder={"3000"} {...field} />
placeholder={"3000"}
{...field}
/>
</FormControl> </FormControl>
<FormMessage /> <FormMessage />
</FormItem> </FormItem>

View File

@@ -364,10 +364,7 @@ export const AddDomainCompose = ({
<FormItem> <FormItem>
<FormLabel>Container Port</FormLabel> <FormLabel>Container Port</FormLabel>
<FormControl> <FormControl>
<NumberInput <NumberInput placeholder={"3000"} {...field} />
placeholder={"3000"}
{...field}
/>
</FormControl> </FormControl>
<FormMessage /> <FormMessage />
</FormItem> </FormItem>

View File

@@ -40,31 +40,30 @@ const NumberInput = React.forwardRef<HTMLInputElement, InputProps>(
ref={ref} ref={ref}
{...props} {...props}
value={props.value === undefined ? undefined : String(props.value)} value={props.value === undefined ? undefined : String(props.value)}
onChange={(e) => { onChange={(e) => {
const value = e.target.value; const value = e.target.value;
if (value === "") { if (value === "") {
props.onChange?.(e); props.onChange?.(e);
} else { } else {
const number = Number.parseInt(value, 10); const number = Number.parseInt(value, 10);
if (!Number.isNaN(number)) { if (!Number.isNaN(number)) {
const syntheticEvent = { const syntheticEvent = {
...e, ...e,
target: { target: {
...e.target, ...e.target,
value: number, value: number,
}, },
}; };
props.onChange?.( props.onChange?.(
syntheticEvent as unknown as React.ChangeEvent<HTMLInputElement> syntheticEvent as unknown as React.ChangeEvent<HTMLInputElement>,
); );
} }
} }
}} }}
/> />
); );
} },
); );
NumberInput.displayName = "NumberInput"; NumberInput.displayName = "NumberInput";
export { Input, NumberInput }; export { Input, NumberInput };