mekasu0124

Untitled

Mar 17th, 2024
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import { View, Text } from "react-native";
  2. import { styles } from "../styles/pages/profile_styles";
  3.  
  4. export default function ProfileScreen({ navigation }) {
  5.   const userData = {
  6.     "firstName": "John",
  7.     "lastName": "Doe",
  8.     "emailAddress": "[email protected]",
  9.     "phoneNumber": "1234567890",
  10.     "username": "johnDoe123",
  11.     "password": "password123!",
  12.     "payRate": 12.00,
  13.     "totalAnnualGrossPay": GetAnnualPay(),
  14.     "records": {
  15.       "12/19/2020 - 12/23/2020": {
  16.         "weeklyPay": GetWeeklyPay("12/19/2020 - 12/23/2020"),
  17.         "12/19/1919": {
  18.           "timeIn": "06:00:00 AM",
  19.           "lunchOut": "12:00:00 PM",
  20.           "lunchIn": "12:30:00 PM",
  21.           "timeOut": "4:30:00 PM",
  22.           "totalHours": 10,
  23.           "totalPay": GetDailyPay("12/19/2020")
  24.         },
  25.         "12/20/2020": {
  26.           "timeIn": "06:00:00 AM",
  27.           "lunchOut": "12:00:00 PM",
  28.           "lunchIn": "12:30:00 PM",
  29.           "timeOut": "4:30:00 PM",
  30.           "totalHours": 10,
  31.           "totalPay": GetDailyPay("12/20/2020")
  32.         },
  33.         "12/21/2020": {
  34.           "timeIn": "06:00:00 AM",
  35.           "lunchOut": "12:00:00 PM",
  36.           "lunchIn": "12:30:00 PM",
  37.           "timeOut": "4:30:00 PM",
  38.           "totalHours": 10,
  39.           "totalPay": GetDailyPay("12/21/2020")
  40.         },
  41.         "12/22/2020": {
  42.           "timeIn": "06:00:00 AM",
  43.           "lunchOut": "12:00:00 PM",
  44.           "lunchIn": "12:30:00 PM",
  45.           "timeOut": "4:30:00 PM",
  46.           "totalHours": 10,
  47.           "totalPay": GetDailyPay("12/22/2020")
  48.         },
  49.         "12/23/2020": {
  50.           "timeIn": "06:00:00 AM",
  51.           "timeOut": "12:00:00 PM",
  52.           "totalHours": 6,
  53.           "totalPay": GetDailyPay("12/23/2020")
  54.         }
  55.       },
  56.     }
  57.   };
  58.  
  59.   function GetDailyPay(date) {
  60.     const userRecords = userData["records"];
  61.     const userPay = userData["payRate"];
  62.     const dailyHours = userRecords[date]["totalHours"];
  63.     return dailyHours * userPay;
  64.   }
  65.  
  66.   function GetWeeklyPay(dateRange) {
  67.     const userRecords = userData["records"];
  68.     const userPay = userData["payRate"];
  69.     const userOTpay = (userPay / 2) + userPay;
  70.     const weeklyRecords = userRecords[dateRange];
  71.     const maxWeeklyHours = 40;
  72.  
  73.     let totalWeeklyHours = 0;
  74.  
  75.     for (let i = 0; i < Object.keys(weeklyRecords).length; i++) {
  76.       totalWeeklyHours += weeklyRecords[i]["totalHours"];
  77.     }
  78.  
  79.     let overTimeHours = totalWeeklyHours - maxWeeklyHours;
  80.  
  81.     let regularPay = maxWeeklyHours * userPay;
  82.     let overTimePay = overTimeHours * userOTpay;
  83.  
  84.     let grossWeeklyPay = regularPay + overTimePay;
  85.     return grossWeeklyPay;
  86.   }
  87.  
  88.   function GetAnnualPay() {
  89.     const userRecords = userData["records"];
  90.  
  91.     let totalGrossPay = 0;
  92.  
  93.     for (let i = 0; i < Object.keys(userRecords).length; i++) {
  94.       totalGrossPay = userRecords[i]["weeklyPay"];
  95.     }
  96.  
  97.     // multiple the weekly gross (paid weekly)
  98.     // by 50 weeks in a year as the average
  99.     // individual who gets every saturday and
  100.     // sunday off typically takes an average
  101.     // of 2 weeks off per year.
  102.     return totalGrossPay * 50;
  103.   }
  104.  
  105.   const generateUserProfile = () => {
  106.     return userData.map((user) => {
  107.       return (
  108.         <View>
  109.          
  110.         </View>
  111.       );
  112.     });
  113.   };
  114.  
  115.   return (
  116.     <View style={{ backgroundColor: "darkgray" }}>
  117.       <Text> Profile Screen </Text>
  118.     </View>
  119.   );
  120. }
Advertisement
Add Comment
Please, Sign In to add comment