Refactor category type to use enum
This commit is contained in:
parent
6ca505d505
commit
bdc2ca22f6
6 changed files with 22 additions and 15 deletions
|
|
@ -5,6 +5,7 @@ import { SafeAreaView } from 'react-native-safe-area-context';
|
|||
import { AutoDecimalInput, CustomColorPicker, NavigationButton, TypeSelectorSwitch } from "../../../components";
|
||||
import { addCategory } from "../../../services/database";
|
||||
import { useTheme } from "../../contexts/ThemeContext";
|
||||
import { CategoryType } from "../../../services/database";
|
||||
|
||||
export default function Page() {
|
||||
const {colors} = useTheme();
|
||||
|
|
@ -13,7 +14,9 @@ export default function Page() {
|
|||
|
||||
const [categoryName, setCategoryName] = useState<string>("");
|
||||
const [categoryColor, setCategoryColor] = useState<string>('#' + Math.floor(Math.random()*16777215).toString(16));
|
||||
const [selectedType, setSelectedType] = useState<string>("expense");
|
||||
|
||||
const [selectedType, setSelectedType] = useState<CategoryType>(CategoryType.EXPENSE);
|
||||
|
||||
const [amount, setAmount] = useState(0);
|
||||
|
||||
return (
|
||||
|
|
@ -35,7 +38,7 @@ export default function Page() {
|
|||
|
||||
<TypeSelectorSwitch
|
||||
currentSelected={selectedType}
|
||||
handleButtonPress={(type) => {
|
||||
handleButtonPress={(type: CategoryType) => {
|
||||
setSelectedType(type);
|
||||
}}
|
||||
/>
|
||||
|
|
|
|||
Reference in a new issue