import React from "react"; import { Input } from "@chakra-ui/react"; import { Field } from "../ui/field"; import { Data } from "../../models/game"; interface Props { label: string; textField: string; field: string; bg: string; handleInputChange: ( name: string, value: Data[G], ) => void; required: boolean; } const SingleFieldNumericInput = ({ label, textField, field, bg, handleInputChange, required, }: Props) => { const isValidSteamValue = (v: string) => { const s = v.trim(); if (!s) return false; if (/^\d+$/.test(s)) return true; return s.includes("store.steampowered.com"); }; const showError = field.trim() !== "" && !isValidSteamValue(field); return ( { handleInputChange(textField, e.target.value); }} /> ); }; export default SingleFieldNumericInput;