-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Working on removing duplication in code
Pair-Programmed With @avichaljadeja2002
- Loading branch information
1 parent
ab45dfe
commit a227da9
Showing
26 changed files
with
328 additions
and
404 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,14 @@ | ||
import { IPAddr, formatTime } from './constants'; | ||
import { Task } from '../components/Types'; | ||
import axios from 'axios'; | ||
import GenericMainPageForm from './mainPageTemplate'; | ||
import React, { useState, useCallback } from 'react'; | ||
import { useFocusEffect } from '@react-navigation/native'; | ||
import { cLog } from './log' | ||
import AsyncStorage from '@react-native-async-storage/async-storage'; | ||
import React from 'react'; | ||
import GenericMainPageForm from './genericMainPage'; | ||
|
||
export default function FinanceTracker() { | ||
const [tasks, setTasks] = useState<Task[]>([]); | ||
|
||
const fetchEvents = async () => { | ||
const hit = IPAddr + '/get_finance_events/' + (await AsyncStorage.getItem('userId')); | ||
cLog('Fetching finance events from:' + hit); | ||
axios.get(hit) | ||
.then(response => { | ||
const events = response.data.map((event: any) => ({ | ||
id: event.id.toString(), | ||
title: `${event.title} at ${event.event_date}, ${formatTime(event.event_time)}`, | ||
done: false, | ||
icon: 'wallet-outline', | ||
event: event | ||
})).slice(0, 10);; | ||
setTasks(events); | ||
}) | ||
.catch(error => console.error('Error fetching events:', error)); | ||
} | ||
|
||
useFocusEffect( | ||
useCallback(() => { | ||
fetchEvents(); | ||
}, []) | ||
); | ||
|
||
return ( | ||
<GenericMainPageForm | ||
title='Finance Tracker' | ||
header='Upcoming Events' | ||
nextPage='addFinanceEvents' | ||
thisPage='finance' | ||
tasks={tasks} | ||
/>); | ||
} | ||
hitAddress={`/get_finance_events/`} | ||
eventIconFunc={() => 'wallet-outline'} | ||
/> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.