Remove CharacterComponent and CharacterDetail components

- Deleted `CharacterComponent` and `CharacterDetail` files from the project.
- Refactored related logic to improve code maintainability and reduce redundancy.
This commit is contained in:
natreex
2026-02-05 14:12:08 -05:00
parent cec5830360
commit 209dc6f85a
133 changed files with 17673 additions and 3110 deletions

View File

@@ -1,8 +1,9 @@
import {ChangeEvent, Dispatch} from "react";
import React, {ChangeEvent, Dispatch} from "react";
interface NumberInputProps {
value: number;
setValue: Dispatch<React.SetStateAction<number>>;
value: number | null;
setValue?: Dispatch<React.SetStateAction<number>>;
onValueChange?: (value: number | null) => void;
placeholder?: string;
readOnly?: boolean;
disabled?: boolean;
@@ -12,22 +13,34 @@ export default function NumberInput(
{
value,
setValue,
onValueChange,
placeholder,
readOnly = false,
disabled = false
}: NumberInputProps
) {
function handleChange(e: ChangeEvent<HTMLInputElement>) {
const newValue: number = parseInt(e.target.value);
function handleChange(e: ChangeEvent<HTMLInputElement>): void {
const inputValue: string = e.target.value;
if (inputValue === '') {
if (onValueChange) {
onValueChange(null);
}
return;
}
const newValue: number = parseInt(inputValue, 10);
if (!isNaN(newValue)) {
setValue(newValue);
if (onValueChange) {
onValueChange(newValue);
} else if (setValue) {
setValue(newValue);
}
}
}
return (
<input
type="number"
value={value}
value={value ?? ''}
onChange={handleChange}
className={`w-full bg-secondary/50 text-text-primary px-4 py-2.5 rounded-xl border border-secondary/50
focus:border-primary focus:ring-4 focus:ring-primary/20 focus:bg-secondary