Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import { View, Text } from "react-native";
- import { styles } from "../styles/pages/profile_styles";
- export default function ProfileScreen({ navigation }) {
- const userData = {
- "firstName": "John",
- "lastName": "Doe",
- "phoneNumber": "1234567890",
- "username": "johnDoe123",
- "password": "password123!",
- "payRate": 12.00,
- "totalAnnualGrossPay": GetAnnualPay(),
- "records": {
- "12/19/2020 - 12/23/2020": {
- "weeklyPay": GetWeeklyPay("12/19/2020 - 12/23/2020"),
- "12/19/1919": {
- "timeIn": "06:00:00 AM",
- "lunchOut": "12:00:00 PM",
- "lunchIn": "12:30:00 PM",
- "timeOut": "4:30:00 PM",
- "totalHours": 10,
- "totalPay": GetDailyPay("12/19/2020")
- },
- "12/20/2020": {
- "timeIn": "06:00:00 AM",
- "lunchOut": "12:00:00 PM",
- "lunchIn": "12:30:00 PM",
- "timeOut": "4:30:00 PM",
- "totalHours": 10,
- "totalPay": GetDailyPay("12/20/2020")
- },
- "12/21/2020": {
- "timeIn": "06:00:00 AM",
- "lunchOut": "12:00:00 PM",
- "lunchIn": "12:30:00 PM",
- "timeOut": "4:30:00 PM",
- "totalHours": 10,
- "totalPay": GetDailyPay("12/21/2020")
- },
- "12/22/2020": {
- "timeIn": "06:00:00 AM",
- "lunchOut": "12:00:00 PM",
- "lunchIn": "12:30:00 PM",
- "timeOut": "4:30:00 PM",
- "totalHours": 10,
- "totalPay": GetDailyPay("12/22/2020")
- },
- "12/23/2020": {
- "timeIn": "06:00:00 AM",
- "timeOut": "12:00:00 PM",
- "totalHours": 6,
- "totalPay": GetDailyPay("12/23/2020")
- }
- },
- }
- };
- function GetDailyPay(date) {
- const userRecords = userData["records"];
- const userPay = userData["payRate"];
- const dailyHours = userRecords[date]["totalHours"];
- return dailyHours * userPay;
- }
- function GetWeeklyPay(dateRange) {
- const userRecords = userData["records"];
- const userPay = userData["payRate"];
- const userOTpay = (userPay / 2) + userPay;
- const weeklyRecords = userRecords[dateRange];
- const maxWeeklyHours = 40;
- let totalWeeklyHours = 0;
- for (let i = 0; i < Object.keys(weeklyRecords).length; i++) {
- totalWeeklyHours += weeklyRecords[i]["totalHours"];
- }
- let overTimeHours = totalWeeklyHours - maxWeeklyHours;
- let regularPay = maxWeeklyHours * userPay;
- let overTimePay = overTimeHours * userOTpay;
- let grossWeeklyPay = regularPay + overTimePay;
- return grossWeeklyPay;
- }
- function GetAnnualPay() {
- const userRecords = userData["records"];
- let totalGrossPay = 0;
- for (let i = 0; i < Object.keys(userRecords).length; i++) {
- totalGrossPay = userRecords[i]["weeklyPay"];
- }
- // multiple the weekly gross (paid weekly)
- // by 50 weeks in a year as the average
- // individual who gets every saturday and
- // sunday off typically takes an average
- // of 2 weeks off per year.
- return totalGrossPay * 50;
- }
- const generateUserProfile = () => {
- return userData.map((user) => {
- return (
- <View>
- </View>
- );
- });
- };
- return (
- <View style={{ backgroundColor: "darkgray" }}>
- <Text> Profile Screen </Text>
- </View>
- );
- }
Advertisement
Add Comment
Please, Sign In to add comment