fixed euro sign on expense item (dont judge me I know this isnt the correct branch) and fixed the async storage so it acctually loads on the info
This commit is contained in:
parent
7a77b9ca79
commit
4ddc76faa4
2 changed files with 8 additions and 6 deletions
|
|
@ -1,4 +1,5 @@
|
||||||
import AsyncStorage from '@react-native-async-storage/async-storage';
|
import AsyncStorage from '@react-native-async-storage/async-storage';
|
||||||
|
import { useIsFocused } from '@react-navigation/native';
|
||||||
import { router, useNavigation } from 'expo-router';
|
import { router, useNavigation } from 'expo-router';
|
||||||
import { useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
import { StyleSheet, View } from 'react-native';
|
import { StyleSheet, View } from 'react-native';
|
||||||
|
|
@ -13,6 +14,7 @@ export default function Page() {
|
||||||
const containerColor = colors.containerColor;
|
const containerColor = colors.containerColor;
|
||||||
const navigation = useNavigation();
|
const navigation = useNavigation();
|
||||||
const [selectedPage, setSelectedPage] = useState("noPageLoaded");
|
const [selectedPage, setSelectedPage] = useState("noPageLoaded");
|
||||||
|
const isFocused = useIsFocused();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
AsyncStorage.getItem("currentBudgetPage").then((page) => {
|
AsyncStorage.getItem("currentBudgetPage").then((page) => {
|
||||||
|
|
@ -22,15 +24,14 @@ export default function Page() {
|
||||||
}).catch((error) => {
|
}).catch((error) => {
|
||||||
console.log("Error fetching previous page from Async Storage:", error);
|
console.log("Error fetching previous page from Async Storage:", error);
|
||||||
})
|
})
|
||||||
}, []);
|
}, [isFocused]);
|
||||||
|
|
||||||
const {data, isLoading, reFetch} = useFetch({sql: "SELECT c.guid AS category_guid, c.name AS category_name, c.color AS category_color, c.type AS category_type, SUM(e.amount) as total_expenses, c.allocated_amount as allocated_amount FROM category c LEFT JOIN expense e ON e.category_guid = c.guid WHERE c.type = ? GROUP BY c.guid", args: selectedPage === "expenses" ? ["expense"] : selectedPage === "savings" ? ["saving"] : []});
|
const {data, isLoading, reFetch} = useFetch({sql: "SELECT c.guid AS category_guid, c.name AS category_name, c.color AS category_color, c.type AS category_type, SUM(e.amount) as total_expenses, c.allocated_amount as allocated_amount FROM category c LEFT JOIN expense e ON e.category_guid = c.guid WHERE c.type = ? GROUP BY c.guid", args: selectedPage === "expenses" ? ["expense"] : selectedPage === "savings" ? ["saving"] : []});
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
reFetch()
|
reFetch();
|
||||||
}, [selectedPage]);
|
}, [selectedPage]);
|
||||||
|
|
||||||
|
|
||||||
const handlePageSelection = (page: string) => {
|
const handlePageSelection = (page: string) => {
|
||||||
if(page !== selectedPage) {
|
if(page !== selectedPage) {
|
||||||
setSelectedPage(page);
|
setSelectedPage(page);
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { ColorValue, StyleSheet, Text, View } from 'react-native';
|
import { ColorValue, StyleSheet, Text, View } from 'react-native';
|
||||||
|
import { TouchableOpacity } from 'react-native-gesture-handler';
|
||||||
|
import { useTheme } from '../../app/contexts/ThemeContext';
|
||||||
import { SIZES } from '../../constants/theme';
|
import { SIZES } from '../../constants/theme';
|
||||||
import CustomCard from "../common/CustomCard";
|
import CustomCard from "../common/CustomCard";
|
||||||
import { useTheme } from '../../app/contexts/ThemeContext';
|
|
||||||
import { TouchableOpacity } from 'react-native-gesture-handler';
|
|
||||||
|
|
||||||
//export type ExpenseItemProps = {color: ColorValue, category: string, title: string, date: string, value : string}
|
//export type ExpenseItemProps = {color: ColorValue, category: string, title: string, date: string, value : string}
|
||||||
interface ExpenseItemProps {
|
interface ExpenseItemProps {
|
||||||
|
|
@ -44,9 +44,10 @@ export default function ExpenseItem(itemProps : ExpenseItemProps) {
|
||||||
</View>
|
</View>
|
||||||
<View style={[styles.valueSection, {backgroundColor: colors.backgroundColor}]}>
|
<View style={[styles.valueSection, {backgroundColor: colors.backgroundColor}]}>
|
||||||
<Text style={{
|
<Text style={{
|
||||||
|
paddingRight: 10,
|
||||||
fontSize: SIZES.xxLarge,
|
fontSize: SIZES.xxLarge,
|
||||||
color: colors.primaryText
|
color: colors.primaryText
|
||||||
}} numberOfLines={1}>{itemProps.value}</Text>
|
}} numberOfLines={1}>{itemProps.value + " €"}</Text>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
|
|
|
||||||
Reference in a new issue