Refactor category type to use enum

This commit is contained in:
Walcher 2024-01-25 17:23:17 +01:00 committed by Jakob Stornig
parent 6ca505d505
commit bdc2ca22f6
6 changed files with 22 additions and 15 deletions

View file

@ -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);
}}
/>