/
page.js
80 lines (73 loc) · 2.35 KB
/
page.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
"use client";
import {useState} from "react";
import {useRouter} from "next/navigation";
export default function Page() {
const router = useRouter();
const [name, setName] = useState("");
const [description, setDescription] = useState("");
const [price, setPrice] = useState(0);
const onAddClick = () => {
console.log("onAddClick()");
}
const onCancelClick = () => {
router.push("/");
}
return (
<div className="bg-gray-50 p-6 rounded-lg shadow-md space-y-4">
<div className="text-lg font-semibold">Add expense</div>
<div className="space-y-2">
<label className="block text-sm font-medium text-gray-700 dark:text-gray-400">
Expense name
</label>
<input
name="name"
type="text"
className="border border-gray-200 dark:border-gray-700 rounded-md w-full p-2"
placeholder="Expense name"
value={name}
onChange={(event) => setName(event.target.value)}
/>
</div>
<div className="space-y-2">
<label className="block text-sm font-medium text-gray-700 dark:text-gray-400">
Expense description
</label>
<input
name="description"
type="text"
className="border border-gray-200 dark:border-gray-700 rounded-md w-full p-2 mt-2"
placeholder="Expense description"
value={description}
onChange={(event) => setDescription(event.target.value)}
/>
</div>
<div className="space-y-2">
<label className="block text-sm font-medium text-gray-700 dark:text-gray-400">
Expense price (in USD)
</label>
<input
name="price"
type="number"
className="border border-gray-200 dark:border-gray-700 rounded-md w-full p-2 mt-2"
placeholder="Price"
value={price}
onChange={(event) => setPrice(event.target.value)}
/>
</div>
<div className="space-x-2">
<button
className="bg-indigo-500 hover:bg-indigo-700 text-white font-bold py-2 px-4 rounded"
onClick={onAddClick}
>
Add expense
</button>
<button
className="bg-red-500 hover:bg-red-700 text-white font-bold py-2 px-4 rounded"
onClick={onCancelClick}
>
Cancel
</button>
</div>
</div>
);
}