mirror of
https://github.com/lemeow125/Ivy-Frontend.git
synced 2024-11-17 06:39:25 +08:00
Made stocks color responsive to input
This commit is contained in:
parent
fec3d9a47d
commit
3bd532c02c
1 changed files with 12 additions and 12 deletions
|
@ -22,36 +22,36 @@ export default function Inventory() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function StockRender(in_stock: number) {
|
function StockRender(in_stock: number) {
|
||||||
const [stock, setStock] = useState("" + in_stock);
|
const [stock, setStock] = useState(in_stock);
|
||||||
if (in_stock > 0 && in_stock < 3) {
|
if (stock >= 0 && stock <= 3) {
|
||||||
return (
|
return (
|
||||||
<TableCell style={styles.text_red}>
|
<TableCell>
|
||||||
<input
|
<input
|
||||||
style={{
|
style={{
|
||||||
...styles.text,
|
...styles.text_red,
|
||||||
...{ border: "none", background: "none" },
|
...{ border: "none", background: "none" },
|
||||||
}}
|
}}
|
||||||
value={stock}
|
value={stock}
|
||||||
onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
|
onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
if (is_number(e.target.value) === true) {
|
if (is_number(e.target.value) === true) {
|
||||||
setStock(e.target.value);
|
setStock(parseInt(e.target.value));
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
);
|
);
|
||||||
} else if (in_stock > 3 && in_stock < 9) {
|
} else if (stock >= 4 && stock < 9) {
|
||||||
return (
|
return (
|
||||||
<TableCell style={styles.text_orange}>
|
<TableCell>
|
||||||
<input
|
<input
|
||||||
style={{
|
style={{
|
||||||
...styles.text,
|
...styles.text_orange,
|
||||||
...{ border: "none", background: "none" },
|
...{ border: "none", background: "none" },
|
||||||
}}
|
}}
|
||||||
value={stock}
|
value={stock}
|
||||||
onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
|
onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
if (is_number(e.target.value) === true) {
|
if (is_number(e.target.value) === true) {
|
||||||
setStock(e.target.value);
|
setStock(parseInt(e.target.value));
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
@ -59,16 +59,16 @@ export default function Inventory() {
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return (
|
return (
|
||||||
<TableCell style={styles.text_green}>
|
<TableCell>
|
||||||
<input
|
<input
|
||||||
style={{
|
style={{
|
||||||
...styles.text,
|
...styles.text_green,
|
||||||
...{ border: "none", background: "none" },
|
...{ border: "none", background: "none" },
|
||||||
}}
|
}}
|
||||||
value={stock}
|
value={stock}
|
||||||
onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
|
onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
if (is_number(e.target.value) === true) {
|
if (is_number(e.target.value) === true) {
|
||||||
setStock(e.target.value);
|
setStock(parseInt(e.target.value));
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
Loading…
Reference in a new issue