mirror of
https://github.com/urosran/cally.git
synced 2025-11-26 08:24:55 +00:00
Merge branch 'dev'
# Conflicts: # ios/cally/Info.plist
This commit is contained in:
@ -1,5 +1,4 @@
|
||||
export async function fetchGoogleCalendarEvents(token, email, familyId, startDate, endDate) {
|
||||
console.log(token);
|
||||
const response = await fetch(
|
||||
`https://www.googleapis.com/calendar/v3/calendars/primary/events?single_events=true&time_min=${startDate}&time_max=${endDate}`,
|
||||
{
|
||||
@ -10,7 +9,6 @@ export async function fetchGoogleCalendarEvents(token, email, familyId, startDat
|
||||
);
|
||||
|
||||
const data = await response.json();
|
||||
console.log(data);
|
||||
const googleEvents = [];
|
||||
data.items?.forEach((item) => {
|
||||
let isAllDay = false;
|
||||
@ -41,7 +39,7 @@ export async function fetchGoogleCalendarEvents(token, email, familyId, startDat
|
||||
|
||||
const googleEvent = {
|
||||
id: item.id,
|
||||
title: item.summary,
|
||||
title: item.summary ?? "",
|
||||
startDate: startDateTime,
|
||||
endDate: endDateTime,
|
||||
allDay: isAllDay,
|
||||
|
||||
@ -421,7 +421,7 @@ export const ManuallyAddEventModal = () => {
|
||||
</View>
|
||||
|
||||
<View marginL-35>
|
||||
<AssigneesDisplay setSlectedAttendees={setSelectedAttendees}
|
||||
<AssigneesDisplay setSelectedAttendees={setSelectedAttendees}
|
||||
selectedAttendees={selectedAttendees}/>
|
||||
</View>
|
||||
|
||||
|
||||
@ -90,8 +90,11 @@ const CalendarSettingsPage = (props: {
|
||||
const userInfo = await userInfoResponse.json();
|
||||
const googleMail = userInfo.email;
|
||||
|
||||
let googleAccounts = profileData?.googleAccounts;
|
||||
const updatedGoogleAccounts = googleAccounts ? {...googleAccounts, [googleMail]: accessToken} : {[googleMail]: accessToken};
|
||||
|
||||
await updateUserData({
|
||||
newUserData: {googleToken: accessToken, googleMail: googleMail},
|
||||
newUserData: {googleAccounts: updatedGoogleAccounts},
|
||||
});
|
||||
|
||||
await fetchAndSaveGoogleEvents({token: accessToken, email: googleMail})
|
||||
@ -171,9 +174,12 @@ const CalendarSettingsPage = (props: {
|
||||
} else {
|
||||
const outlookMail = userInfo.mail || userInfo.userPrincipalName;
|
||||
|
||||
let microsoftAccounts = profileData?.microsoftAccounts;
|
||||
const updatedMicrosoftAccounts = microsoftAccounts ? {...microsoftAccounts, [outlookMail]: tokenData.access_token} : {[outlookMail]: tokenData.access_token};
|
||||
|
||||
// Update user data with Microsoft token and email
|
||||
await updateUserData({
|
||||
newUserData: {microsoftToken: tokenData.access_token, outlookMail: outlookMail},
|
||||
newUserData: {microsoftAccounts: updatedMicrosoftAccounts},
|
||||
});
|
||||
|
||||
await fetchAndSaveOutlookEvents(tokenData.access_token, outlookMail)
|
||||
@ -263,21 +269,61 @@ const CalendarSettingsPage = (props: {
|
||||
debouncedUpdateUserData(color);
|
||||
};
|
||||
|
||||
const clearToken = async (provider: "google" | "outlook" | "apple") => {
|
||||
const clearToken = async (provider: "google" | "outlook" | "apple", email: string) => {
|
||||
const newUserData: Partial<UserProfile> = {};
|
||||
if (provider === "google") {
|
||||
newUserData.googleToken = null;
|
||||
newUserData.googleMail = null;
|
||||
let googleAccounts = profileData?.googleAccounts;
|
||||
if (googleAccounts) {
|
||||
googleAccounts[email] = null;
|
||||
newUserData.googleAccounts = googleAccounts;
|
||||
}
|
||||
} else if (provider === "outlook") {
|
||||
newUserData.microsoftToken = null;
|
||||
newUserData.outlookMail = null;
|
||||
let microsoftAccounts = profileData?.microsoftAccounts;
|
||||
if (microsoftAccounts) {
|
||||
microsoftAccounts[email] = null;
|
||||
newUserData.microsoftAccounts = microsoftAccounts;
|
||||
}
|
||||
} else if (provider === "apple") {
|
||||
newUserData.appleToken = null;
|
||||
newUserData.appleMail = null;
|
||||
let appleAccounts = profileData?.appleAccounts;
|
||||
if (appleAccounts) {
|
||||
appleAccounts[email] = null;
|
||||
newUserData.appleAccounts = appleAccounts;
|
||||
}
|
||||
}
|
||||
await updateUserData({newUserData});
|
||||
};
|
||||
|
||||
let isConnectedToGoogle = false;
|
||||
if (profileData?.googleAccounts) {
|
||||
Object.values(profileData?.googleAccounts).forEach((item) => {
|
||||
if (item !== null) {
|
||||
isConnectedToGoogle = true;
|
||||
return;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
let isConnectedToMicrosoft = false;
|
||||
const microsoftAccounts = profileData?.microsoftAccounts;
|
||||
if (microsoftAccounts) {
|
||||
Object.values(profileData?.microsoftAccounts).forEach((item) => {
|
||||
if (item !== null) {
|
||||
isConnectedToMicrosoft = true;
|
||||
return;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
let isConnectedToApple = false;
|
||||
if (profileData?.appleAccounts) {
|
||||
Object.values(profileData?.appleAccounts).forEach((item) => {
|
||||
if (item !== null) {
|
||||
isConnectedToApple = true;
|
||||
return;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return (
|
||||
<ScrollView>
|
||||
<View marginH-30 marginB-30>
|
||||
@ -378,8 +424,8 @@ const CalendarSettingsPage = (props: {
|
||||
</Text>
|
||||
|
||||
<Button
|
||||
onPress={() => !profileData?.googleToken ? promptAsync() : clearToken("google")}
|
||||
label={profileData?.googleToken ? `Disconnect ${profileData.googleMail}` : "Connect Google"}
|
||||
onPress={() => promptAsync()}
|
||||
label={"Connect Google"}
|
||||
labelStyle={styles.addCalLbl}
|
||||
labelProps={{
|
||||
numberOfLines: 2
|
||||
@ -393,9 +439,30 @@ const CalendarSettingsPage = (props: {
|
||||
color="black"
|
||||
text70BL
|
||||
/>
|
||||
{profileData?.googleAccounts ? Object.keys(profileData?.googleAccounts)?.map((googleMail) => {
|
||||
const googleToken = profileData?.googleAccounts?.[googleMail];
|
||||
return googleToken && <Button
|
||||
key={googleMail}
|
||||
onPress={() => clearToken("google", googleMail)}
|
||||
label={`Disconnect ${googleMail}`}
|
||||
labelStyle={styles.addCalLbl}
|
||||
labelProps={{
|
||||
numberOfLines: 2
|
||||
}}
|
||||
iconSource={() => (
|
||||
<View marginR-15>
|
||||
<GoogleIcon/>
|
||||
</View>
|
||||
)}
|
||||
style={styles.addCalBtn}
|
||||
color="black"
|
||||
text70BL
|
||||
/>
|
||||
}) : null}
|
||||
|
||||
<Button
|
||||
onPress={() => !profileData?.appleToken ? handleAppleSignIn() : clearToken("google")}
|
||||
label={profileData?.appleToken ? `Disconnect ${profileData.appleMail}` : "Connect Apple"}
|
||||
onPress={() => handleAppleSignIn()}
|
||||
label={"Connect Apple"}
|
||||
labelStyle={styles.addCalLbl}
|
||||
labelProps={{
|
||||
numberOfLines: 2
|
||||
@ -409,9 +476,30 @@ const CalendarSettingsPage = (props: {
|
||||
color="black"
|
||||
text70BL
|
||||
/>
|
||||
{profileData?.appleAccounts ? Object.keys(profileData?.appleAccounts)?.map((appleEmail) => {
|
||||
const appleToken = profileData?.appleAccounts?.[appleEmail];
|
||||
return appleToken && <Button
|
||||
key={appleEmail}
|
||||
onPress={() => clearToken("apple", appleEmail)}
|
||||
label={`Disconnect ${appleEmail}`}
|
||||
labelStyle={styles.addCalLbl}
|
||||
labelProps={{
|
||||
numberOfLines: 2
|
||||
}}
|
||||
iconSource={() => (
|
||||
<View marginR-15>
|
||||
<AppleIcon/>
|
||||
</View>
|
||||
)}
|
||||
style={styles.addCalBtn}
|
||||
color="black"
|
||||
text70BL
|
||||
/>
|
||||
}) : null}
|
||||
|
||||
<Button
|
||||
onPress={() => !profileData?.microsoftToken ? handleMicrosoftSignIn() : clearToken("outlook")}
|
||||
label={profileData?.microsoftToken ? `Disconnect ${profileData.outlookMail}` : "Connect Outlook"}
|
||||
onPress={() => handleMicrosoftSignIn()}
|
||||
label={"Connect Outlook"}
|
||||
labelStyle={styles.addCalLbl}
|
||||
labelProps={{
|
||||
numberOfLines: 2
|
||||
@ -425,8 +513,28 @@ const CalendarSettingsPage = (props: {
|
||||
color="black"
|
||||
text70BL
|
||||
/>
|
||||
{profileData?.microsoftAccounts ? Object.keys(profileData?.microsoftAccounts)?.map((microsoftEmail) => {
|
||||
const microsoftToken = profileData?.microsoftAccounts?.[microsoftEmail];
|
||||
return microsoftToken && <Button
|
||||
key={microsoftEmail}
|
||||
onPress={() => clearToken("outlook", microsoftEmail)}
|
||||
label={`Disconnect ${microsoftEmail}`}
|
||||
labelStyle={styles.addCalLbl}
|
||||
labelProps={{
|
||||
numberOfLines: 2
|
||||
}}
|
||||
iconSource={() => (
|
||||
<View marginR-15>
|
||||
<OutlookIcon/>
|
||||
</View>
|
||||
)}
|
||||
style={styles.addCalBtn}
|
||||
color="black"
|
||||
text70BL
|
||||
/>
|
||||
}) : null}
|
||||
|
||||
{(profileData?.googleMail || profileData?.outlookMail || profileData?.appleMail) && (
|
||||
{(isConnectedToGoogle || isConnectedToMicrosoft || isConnectedToApple) && (
|
||||
<>
|
||||
<Text style={styles.subTitle} marginT-30 marginB-20>
|
||||
Connected Calendars
|
||||
@ -434,21 +542,17 @@ const CalendarSettingsPage = (props: {
|
||||
|
||||
<View style={styles.noPaddingCard}>
|
||||
<View style={{marginTop: 20}}>
|
||||
{!!profileData?.googleMail && (
|
||||
{profileData?.googleAccounts && Object.keys(profileData?.googleAccounts)?.map((googleEmail) => {
|
||||
const googleToken = profileData?.googleAccounts?.[googleEmail];
|
||||
return googleToken && (
|
||||
<TouchableOpacity
|
||||
onPress={() => fetchAndSaveGoogleEvents({
|
||||
token: profileData?.googleToken!,
|
||||
email: profileData?.googleMail!
|
||||
})}
|
||||
onPress={() => fetchAndSaveGoogleEvents({token: googleToken, email: googleEmail})}
|
||||
>
|
||||
<View row paddingR-20 center>
|
||||
<Button
|
||||
disabled={isSyncingGoogle}
|
||||
onPress={() => fetchAndSaveGoogleEvents({
|
||||
token: profileData?.googleToken!,
|
||||
email: profileData?.googleMail!
|
||||
})}
|
||||
label={`Sync ${profileData?.googleMail}`}
|
||||
onPress={() => fetchAndSaveGoogleEvents({token: googleToken, email: googleEmail})}
|
||||
label={`Sync ${googleEmail}`}
|
||||
labelStyle={styles.addCalLbl}
|
||||
labelProps={{numberOfLines: 3}}
|
||||
iconSource={() => (
|
||||
@ -468,23 +572,25 @@ const CalendarSettingsPage = (props: {
|
||||
)}
|
||||
</View>
|
||||
</TouchableOpacity>
|
||||
)}
|
||||
)
|
||||
})}
|
||||
|
||||
|
||||
{!!profileData?.appleMail && (
|
||||
{profileData?.appleAccounts && Object.keys(profileData?.appleAccounts)?.map((appleEmail) => {
|
||||
const appleToken = profileData?.appleAccounts?.[appleEmail];
|
||||
return appleToken && (
|
||||
<TouchableOpacity
|
||||
onPress={() => fetchAndSaveAppleEvents({
|
||||
email: profileData?.appleMail!,
|
||||
token: profileData?.appleToken!
|
||||
email: appleEmail,
|
||||
token: appleToken
|
||||
})}>
|
||||
<View row paddingR-20 center>
|
||||
<Button
|
||||
disabled={isSyncingApple}
|
||||
onPress={() => fetchAndSaveAppleEvents({
|
||||
email: profileData?.appleMail!,
|
||||
token: profileData?.appleToken!
|
||||
email: appleEmail,
|
||||
token: appleToken
|
||||
})}
|
||||
label={`Sync ${profileData?.appleMail}`}
|
||||
label={`Sync ${appleEmail}`}
|
||||
labelStyle={styles.addCalLbl}
|
||||
labelProps={{numberOfLines: 3}}
|
||||
iconSource={() => (
|
||||
@ -503,23 +609,26 @@ const CalendarSettingsPage = (props: {
|
||||
)}
|
||||
</View>
|
||||
</TouchableOpacity>
|
||||
)}
|
||||
)
|
||||
})}
|
||||
|
||||
{!!profileData?.outlookMail && (
|
||||
{profileData?.microsoftAccounts && Object.keys(profileData?.microsoftAccounts)?.map((microsoftEmail) => {
|
||||
const microsoftToken = profileData?.microsoftAccounts?.[microsoftEmail];
|
||||
return microsoftToken && (
|
||||
<TouchableOpacity
|
||||
onPress={() => fetchAndSaveOutlookEvents({
|
||||
token: profileData?.microsoftToken!,
|
||||
email: profileData?.outlookMail!
|
||||
token: microsoftToken,
|
||||
email: microsoftEmail
|
||||
})}
|
||||
>
|
||||
<View row paddingR-20 center>
|
||||
<Button
|
||||
disabled={isSyncingOutlook}
|
||||
onPress={() => fetchAndSaveOutlookEvents({
|
||||
token: profileData?.microsoftToken!,
|
||||
email: profileData?.outlookMail!
|
||||
token: microsoftToken,
|
||||
email: microsoftEmail
|
||||
})}
|
||||
label={`Sync ${profileData?.outlookMail}`}
|
||||
label={`Sync ${microsoftEmail}`}
|
||||
labelStyle={styles.addCalLbl}
|
||||
labelProps={{numberOfLines: 3}}
|
||||
iconSource={() => (
|
||||
@ -538,7 +647,8 @@ const CalendarSettingsPage = (props: {
|
||||
)}
|
||||
</View>
|
||||
</TouchableOpacity>
|
||||
)}
|
||||
)
|
||||
})}
|
||||
</View>
|
||||
</View>
|
||||
</>
|
||||
|
||||
@ -174,7 +174,7 @@ const MyGroup = () => {
|
||||
padding-10
|
||||
>
|
||||
<Avatar
|
||||
source={{uri: "https://via.placeholder.com/60"}}
|
||||
source={{uri: member?.pfp ?? undefined}}
|
||||
size={40}
|
||||
backgroundColor={Colors.grey60}
|
||||
/>
|
||||
@ -213,7 +213,7 @@ const MyGroup = () => {
|
||||
padding-10
|
||||
>
|
||||
<Avatar
|
||||
source={{uri: "https://via.placeholder.com/60"}}
|
||||
source={{uri: member?.pfp ?? undefined}}
|
||||
size={40}
|
||||
backgroundColor={Colors.grey60}
|
||||
/>
|
||||
|
||||
@ -1,30 +1,34 @@
|
||||
import {Colors, Picker, Text, TextField, View} from "react-native-ui-lib";
|
||||
import React, {useEffect, useRef, useState} from "react";
|
||||
import {ImageBackground, StyleSheet} from "react-native";
|
||||
import {StyleSheet, TouchableOpacity} from "react-native";
|
||||
import {ScrollView} from "react-native-gesture-handler";
|
||||
import * as ImagePicker from "expo-image-picker";
|
||||
import {Colors, Image, Picker, Text, TextField, View} from "react-native-ui-lib";
|
||||
import Ionicons from "@expo/vector-icons/Ionicons";
|
||||
import * as tz from "tzdata";
|
||||
import * as Localization from "expo-localization";
|
||||
import debounce from "debounce";
|
||||
import {useAuthContext} from "@/contexts/AuthContext";
|
||||
import {useUpdateUserData} from "@/hooks/firebase/useUpdateUserData";
|
||||
import Ionicons from "@expo/vector-icons/Ionicons";
|
||||
import * as tz from 'tzdata';
|
||||
import * as Localization from 'expo-localization';
|
||||
import debounce from "debounce";
|
||||
import {useChangeProfilePicture} from "@/hooks/firebase/useChangeProfilePicture";
|
||||
|
||||
const MyProfile = () => {
|
||||
const {user, profileData} = useAuthContext();
|
||||
|
||||
const [timeZone, setTimeZone] = useState<string>(profileData?.timeZone! ?? Localization.getCalendars()[0].timeZone);
|
||||
const [timeZone, setTimeZone] = useState<string>(
|
||||
profileData?.timeZone! ?? Localization.getCalendars()[0].timeZone
|
||||
);
|
||||
const [lastName, setLastName] = useState<string>(profileData?.lastName || "");
|
||||
const [firstName, setFirstName] = useState<string>(
|
||||
profileData?.firstName || ""
|
||||
);
|
||||
const [profileImage, setProfileImage] = useState<string | ImagePicker.ImagePickerAsset | null>(profileData?.pfp || null);
|
||||
|
||||
const {mutateAsync: updateUserData} = useUpdateUserData();
|
||||
const {mutateAsync: changeProfilePicture} = useChangeProfilePicture();
|
||||
const isFirstRender = useRef(true);
|
||||
|
||||
|
||||
const handleUpdateUserData = async () => {
|
||||
await updateUserData({newUserData: {firstName, lastName, timeZone}});
|
||||
}
|
||||
};
|
||||
|
||||
const debouncedUserDataUpdate = debounce(handleUpdateUserData, 500);
|
||||
|
||||
@ -34,22 +38,68 @@ const MyProfile = () => {
|
||||
return;
|
||||
}
|
||||
debouncedUserDataUpdate();
|
||||
}, [timeZone, lastName, firstName]);
|
||||
}, [timeZone, lastName, firstName, profileImage]);
|
||||
|
||||
useEffect(() => {
|
||||
if (profileData) {
|
||||
setFirstName(profileData.firstName || "");
|
||||
setLastName(profileData.lastName || "");
|
||||
// setProfileImage(profileData.pfp || null);
|
||||
setTimeZone(profileData.timeZone || Localization.getCalendars()[0].timeZone!);
|
||||
}
|
||||
}, [profileData]);
|
||||
|
||||
const pickImage = async () => {
|
||||
const permissionResult = await ImagePicker.requestMediaLibraryPermissionsAsync();
|
||||
if (!permissionResult.granted) {
|
||||
alert("Permission to access camera roll is required!");
|
||||
return;
|
||||
}
|
||||
|
||||
const result = await ImagePicker.launchImageLibraryAsync({
|
||||
mediaTypes: ImagePicker.MediaTypeOptions.Images,
|
||||
allowsEditing: true,
|
||||
aspect: [1, 1],
|
||||
quality: 1,
|
||||
});
|
||||
|
||||
if (!result.canceled) {
|
||||
setProfileImage(result.assets[0].uri);
|
||||
changeProfilePicture(result.assets[0])
|
||||
}
|
||||
};
|
||||
|
||||
const handleClearImage = async () => {
|
||||
await updateUserData({newUserData: {pfp: null}});
|
||||
setProfileImage(null)
|
||||
}
|
||||
|
||||
const pfpUri = profileImage && typeof profileImage === 'object' && 'uri' in profileImage ? profileImage.uri : profileImage;
|
||||
|
||||
return (
|
||||
<ScrollView style={{paddingBottom: 100, flex: 1}}>
|
||||
<View style={styles.card}>
|
||||
<Text style={styles.subTit}>Your Profile</Text>
|
||||
<View row spread paddingH-15 centerV marginV-15>
|
||||
<ImageBackground
|
||||
<TouchableOpacity onPress={pickImage}>
|
||||
<Image
|
||||
key={pfpUri}
|
||||
style={styles.pfp}
|
||||
source={require("../../../../assets/images/profile-picture.png")}
|
||||
source={pfpUri ? {uri: pfpUri} : null}
|
||||
/>
|
||||
</TouchableOpacity>
|
||||
|
||||
<Text style={styles.photoSet} color="#50be0c">
|
||||
Change Photo
|
||||
<TouchableOpacity onPress={pickImage}>
|
||||
<Text style={styles.photoSet} color="#50be0c" onPress={pickImage}>
|
||||
{profileData?.pfp ? "Change" : "Add"} Photo
|
||||
</Text>
|
||||
</TouchableOpacity>
|
||||
|
||||
{profileData?.pfp && (
|
||||
<TouchableOpacity onPress={handleClearImage}>
|
||||
<Text style={styles.photoSet}>Remove Photo</Text>
|
||||
</TouchableOpacity>
|
||||
)}
|
||||
</View>
|
||||
<View paddingH-15>
|
||||
<Text text80 marginT-10 marginB-7 style={styles.label}>
|
||||
@ -94,24 +144,27 @@ const MyProfile = () => {
|
||||
<Text style={styles.jakarta12}>Time Zone</Text>
|
||||
<View style={styles.viewPicker}>
|
||||
<Picker
|
||||
// editable={!isLoading}
|
||||
value={timeZone}
|
||||
onChange={(item) => {
|
||||
setTimeZone(item as string)
|
||||
}}
|
||||
onChange={(item) => setTimeZone(item as string)}
|
||||
showSearch
|
||||
floatingPlaceholder
|
||||
style={styles.inViewPicker}
|
||||
trailingAccessory={
|
||||
<View style={{
|
||||
<View
|
||||
style={{
|
||||
justifyContent: "center",
|
||||
alignItems: "center",
|
||||
height: "100%",
|
||||
marginTop: -38,
|
||||
paddingRight: 15
|
||||
}}>
|
||||
<Ionicons name={"chevron-down"} style={{alignSelf: "center"}} size={20}
|
||||
color={"#000000"}/>
|
||||
paddingRight: 15,
|
||||
}}
|
||||
>
|
||||
<Ionicons
|
||||
name={"chevron-down"}
|
||||
style={{alignSelf: "center"}}
|
||||
size={20}
|
||||
color={"#000000"}
|
||||
/>
|
||||
</View>
|
||||
}
|
||||
>
|
||||
@ -123,9 +176,11 @@ const MyProfile = () => {
|
||||
);
|
||||
};
|
||||
|
||||
const timeZoneItems = Object.keys(tz.zones).sort().map((zone) => (
|
||||
const timeZoneItems = Object.keys(tz.zones)
|
||||
.sort()
|
||||
.map((zone) => (
|
||||
<Picker.Item key={zone} label={zone.replace("/", " / ").replace("_", " ")} value={zone}/>
|
||||
));
|
||||
));
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
card: {
|
||||
@ -139,7 +194,7 @@ const styles = StyleSheet.create({
|
||||
pfp: {
|
||||
aspectRatio: 1,
|
||||
width: 65.54,
|
||||
backgroundColor: "green",
|
||||
backgroundColor: "gray",
|
||||
borderRadius: 20,
|
||||
},
|
||||
txtBox: {
|
||||
@ -150,7 +205,7 @@ const styles = StyleSheet.create({
|
||||
padding: 15,
|
||||
height: 45,
|
||||
fontFamily: "PlusJakartaSans_500Medium",
|
||||
fontSize: 13
|
||||
fontSize: 13,
|
||||
},
|
||||
subTit: {
|
||||
fontFamily: "Manrope_500Medium",
|
||||
@ -159,11 +214,11 @@ const styles = StyleSheet.create({
|
||||
label: {
|
||||
fontFamily: "PlusJakartaSans_500Medium",
|
||||
fontSize: 12,
|
||||
color: "#a1a1a1"
|
||||
color: "#a1a1a1",
|
||||
},
|
||||
photoSet: {
|
||||
fontFamily: "PlusJakartaSans_500Medium",
|
||||
fontSize: 13.07
|
||||
fontSize: 13.07,
|
||||
},
|
||||
jakarta12: {
|
||||
paddingVertical: 10,
|
||||
@ -171,18 +226,6 @@ const styles = StyleSheet.create({
|
||||
fontSize: 12,
|
||||
color: "#a1a1a1",
|
||||
},
|
||||
picker: {
|
||||
borderRadius: 50,
|
||||
paddingVertical: 12,
|
||||
paddingHorizontal: 16,
|
||||
backgroundColor: Colors.grey80,
|
||||
marginBottom: 16,
|
||||
borderColor: Colors.grey50,
|
||||
borderWidth: 1,
|
||||
marginTop: -20,
|
||||
height: 40,
|
||||
zIndex: 10,
|
||||
},
|
||||
viewPicker: {
|
||||
borderRadius: 50,
|
||||
backgroundColor: Colors.grey80,
|
||||
|
||||
@ -1,18 +1,17 @@
|
||||
import { StyleSheet } from "react-native";
|
||||
import React, { useState } from "react";
|
||||
import { Button, ButtonSize, Text, View } from "react-native-ui-lib";
|
||||
import { AntDesign } from "@expo/vector-icons";
|
||||
import {StyleSheet} from "react-native";
|
||||
import React, {useState} from "react";
|
||||
import {Button, ButtonSize, Text, View} from "react-native-ui-lib";
|
||||
import {AntDesign} from "@expo/vector-icons";
|
||||
import LinearGradient from "react-native-linear-gradient";
|
||||
import AddChoreDialog from "./AddChoreDialog";
|
||||
|
||||
const AddChore = () => {
|
||||
|
||||
const [isVisible, setIsVisible] = useState<boolean>(false);
|
||||
|
||||
return (
|
||||
<LinearGradient
|
||||
colors={["transparent", "#f9f8f7"]}
|
||||
locations={[0, 0.5]}
|
||||
colors={["#f9f8f700", "#f9f8f7", "#f9f8f700"]}
|
||||
locations={[0, 0.5, 1]}
|
||||
style={styles.gradient}
|
||||
>
|
||||
<View style={styles.buttonContainer}>
|
||||
@ -22,13 +21,13 @@ const AddChore = () => {
|
||||
style={styles.button}
|
||||
onPress={() => setIsVisible(!isVisible)}
|
||||
>
|
||||
<AntDesign name="plus" size={24} color="white" />
|
||||
<AntDesign name="plus" size={24} color="white"/>
|
||||
<Text white text60R marginL-10>
|
||||
Add To Do
|
||||
Create new to do
|
||||
</Text>
|
||||
</Button>
|
||||
</View>
|
||||
<AddChoreDialog isVisible={isVisible} setIsVisible={setIsVisible} />
|
||||
<AddChoreDialog isVisible={isVisible} setIsVisible={setIsVisible}/>
|
||||
</LinearGradient>
|
||||
);
|
||||
};
|
||||
@ -36,29 +35,22 @@ const AddChore = () => {
|
||||
export default AddChore;
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
divider: { height: 1, backgroundColor: "#e4e4e4", marginVertical: 15 },
|
||||
gradient: {
|
||||
height: "25%",
|
||||
height: 150,
|
||||
position: "absolute",
|
||||
bottom: 0,
|
||||
width: "100%",
|
||||
justifyContent: "center",
|
||||
alignItems: "center",
|
||||
},
|
||||
buttonContainer: {
|
||||
position: "absolute",
|
||||
bottom: 25,
|
||||
width: "100%",
|
||||
alignItems: "center",
|
||||
},
|
||||
button: {
|
||||
backgroundColor: "rgb(253, 23, 117)",
|
||||
paddingVertical: 20,
|
||||
},
|
||||
topBtn: {
|
||||
backgroundColor: "white",
|
||||
color: "#05a8b6",
|
||||
},
|
||||
rotateSwitch: {
|
||||
marginLeft: 35,
|
||||
marginBottom: 10,
|
||||
marginTop: 25,
|
||||
paddingVertical: 15,
|
||||
paddingHorizontal: 30,
|
||||
borderRadius: 30,
|
||||
},
|
||||
});
|
||||
@ -1,4 +1,4 @@
|
||||
import { View, Text, Button, Switch } from "react-native-ui-lib";
|
||||
import {View, Text, Button, Switch, PickerModes} from "react-native-ui-lib";
|
||||
import React, { useRef, useState } from "react";
|
||||
import PointsSlider from "@/components/shared/PointsSlider";
|
||||
import { repeatOptions, useToDosContext } from "@/contexts/ToDosContext";
|
||||
@ -15,6 +15,7 @@ import { Dimensions, StyleSheet } from "react-native";
|
||||
import DropModalIcon from "@/assets/svgs/DropModalIcon";
|
||||
import { IToDo } from "@/hooks/firebase/types/todoData";
|
||||
import AssigneesDisplay from "@/components/shared/AssigneesDisplay";
|
||||
import {useGetFamilyMembers} from "@/hooks/firebase/useGetFamilyMembers";
|
||||
|
||||
interface IAddChoreDialog {
|
||||
isVisible: boolean;
|
||||
@ -29,6 +30,7 @@ const defaultTodo = {
|
||||
date: new Date(),
|
||||
rotate: false,
|
||||
repeatType: "Every week",
|
||||
assignees: []
|
||||
};
|
||||
|
||||
const AddChoreDialog = (addChoreDialogProps: IAddChoreDialog) => {
|
||||
@ -36,12 +38,15 @@ const AddChoreDialog = (addChoreDialogProps: IAddChoreDialog) => {
|
||||
const [todo, setTodo] = useState<IToDo>(
|
||||
addChoreDialogProps.selectedTodo ?? defaultTodo
|
||||
);
|
||||
const [selectedAssignees, setSelectedAssignees] = useState<string[]>(addChoreDialogProps?.selectedTodo?.assignees ?? []);
|
||||
const { width, height } = Dimensions.get("screen");
|
||||
|
||||
const [points, setPoints] = useState<number>(todo.points);
|
||||
|
||||
const {data: members} = useGetFamilyMembers();
|
||||
|
||||
const handleClose = () => {
|
||||
setTodo(defaultTodo);
|
||||
setSelectedAssignees([]);
|
||||
addChoreDialogProps.setIsVisible(false);
|
||||
};
|
||||
|
||||
@ -95,12 +100,13 @@ const AddChoreDialog = (addChoreDialogProps: IAddChoreDialog) => {
|
||||
onPress={() => {
|
||||
try {
|
||||
if (addChoreDialogProps.selectedTodo) {
|
||||
updateToDo({ ...todo, points: points });
|
||||
updateToDo({ ...todo, points: points, assignees: selectedAssignees });
|
||||
} else {
|
||||
addToDo({
|
||||
...todo,
|
||||
done: false,
|
||||
points: points,
|
||||
assignees: selectedAssignees
|
||||
});
|
||||
}
|
||||
handleClose();
|
||||
@ -182,11 +188,21 @@ const AddChoreDialog = (addChoreDialogProps: IAddChoreDialog) => {
|
||||
<Text text70R marginL-10>
|
||||
Assignees
|
||||
</Text>
|
||||
<View flex-1/>
|
||||
<Picker
|
||||
marginL-8
|
||||
value={selectedAssignees}
|
||||
onChange={(value) => {
|
||||
setSelectedAssignees([...selectedAssignees, ...value]);
|
||||
}}
|
||||
style={{ marginVertical: 5 }}
|
||||
mode={PickerModes.MULTI}
|
||||
renderInput={() =>
|
||||
<Button
|
||||
size={ButtonSize.small}
|
||||
paddingH-8
|
||||
iconSource={() => (
|
||||
<Ionicons name="add-outline" size={20} color="#ea156c" />
|
||||
<Ionicons name="add-outline" size={20} color="#ea156c"/>
|
||||
)}
|
||||
style={{
|
||||
marginLeft: "auto",
|
||||
@ -197,10 +213,21 @@ const AddChoreDialog = (addChoreDialogProps: IAddChoreDialog) => {
|
||||
}}
|
||||
color="#ea156c"
|
||||
label="Assign"
|
||||
labelStyle={{fontFamily: "Manrope_600SemiBold", fontSize: 14}}
|
||||
/>
|
||||
}
|
||||
>
|
||||
{members?.map((member) => (
|
||||
<Picker.Item
|
||||
key={member.uid}
|
||||
label={member?.firstName + " " + member?.lastName}
|
||||
value={member?.uid!}
|
||||
/>
|
||||
))}
|
||||
</Picker>
|
||||
</View>
|
||||
<View row marginL-27 marginT-0>
|
||||
<AssigneesDisplay />
|
||||
<AssigneesDisplay selectedAttendees={selectedAssignees} setSelectedAttendees={setSelectedAssignees}/>
|
||||
</View>
|
||||
<View row centerV style={styles.rotateSwitch}>
|
||||
<Text text80>Take Turns</Text>
|
||||
|
||||
@ -17,7 +17,7 @@ import AddChoreDialog from "@/components/pages/todos/AddChoreDialog";
|
||||
|
||||
const ToDoItem = (props: { item: IToDo; isSettings?: boolean }) => {
|
||||
const { updateToDo } = useToDosContext();
|
||||
const [editing, setEditing] = useState<boolean>(false);
|
||||
const [visible, setVisible] = useState<boolean>(false);
|
||||
const [points, setPoints] = useState(props.item.points);
|
||||
const [pointsModalVisible, setPointsModalVisible] = useState<boolean>(false);
|
||||
|
||||
@ -42,7 +42,7 @@ const ToDoItem = (props: { item: IToDo; isSettings?: boolean }) => {
|
||||
opacity: props.item.done ? 0.3 : 1,
|
||||
}}
|
||||
>
|
||||
<AddChoreDialog isVisible={editing} setIsVisible={setEditing} selectedTodo={props.item}/>
|
||||
{visible && <AddChoreDialog isVisible={visible} setIsVisible={setVisible} selectedTodo={props.item}/>}
|
||||
<View paddingB-8 row spread>
|
||||
<Text
|
||||
text70
|
||||
@ -52,7 +52,7 @@ const ToDoItem = (props: { item: IToDo; isSettings?: boolean }) => {
|
||||
fontSize: 15,
|
||||
}}
|
||||
onPress={() => {
|
||||
setEditing(true);
|
||||
setVisible(true);
|
||||
}}
|
||||
>
|
||||
{props.item.title}
|
||||
|
||||
@ -1,28 +1,28 @@
|
||||
import { View, Text, Button, ButtonSize } from "react-native-ui-lib";
|
||||
import React, { useState } from "react";
|
||||
import {Button, Text, View} from "react-native-ui-lib";
|
||||
import React, {useState} from "react";
|
||||
import HeaderTemplate from "@/components/shared/HeaderTemplate";
|
||||
import AddChore from "./AddChore";
|
||||
import ProgressCard from "./ProgressCard";
|
||||
import ToDosList from "./ToDosList";
|
||||
import { Dimensions, ScrollView } from "react-native";
|
||||
import { StyleSheet } from "react-native";
|
||||
import { TouchableOpacity } from "react-native-gesture-handler";
|
||||
import { ProfileType, useAuthContext } from "@/contexts/AuthContext";
|
||||
import {Dimensions, ScrollView, StyleSheet} from "react-native";
|
||||
import {TouchableOpacity} from "react-native-gesture-handler";
|
||||
import {ProfileType, useAuthContext} from "@/contexts/AuthContext";
|
||||
import FamilyChoresProgress from "./family-chores/FamilyChoresProgress";
|
||||
import UserChoresProgress from "./user-chores/UserChoresProgress";
|
||||
|
||||
const ToDosPage = () => {
|
||||
const [pageIndex, setPageIndex] = useState<number>(0);
|
||||
const { profileData } = useAuthContext();
|
||||
const { width, height } = Dimensions.get("screen");
|
||||
const {profileData} = useAuthContext();
|
||||
const {width, height} = Dimensions.get("screen");
|
||||
const pageLink = (
|
||||
<TouchableOpacity onPress={() => setPageIndex(1)}>
|
||||
<Text color="#ea156d" style={{ fontSize: 14 }}>
|
||||
<Text color="#ea156d" style={{fontSize: 14}}>
|
||||
View family progress
|
||||
</Text>
|
||||
</TouchableOpacity>
|
||||
);
|
||||
return (
|
||||
<>
|
||||
<View paddingH-25 backgroundColor="#f9f8f7" height={"100%"} width={width}>
|
||||
{pageIndex == 0 && (
|
||||
<View>
|
||||
@ -57,16 +57,20 @@ const ToDosPage = () => {
|
||||
/>
|
||||
</View>
|
||||
)}
|
||||
<ToDosList />
|
||||
<ToDosList/>
|
||||
</View>
|
||||
</ScrollView>
|
||||
{profileData?.userType == ProfileType.PARENT && <AddChore />}
|
||||
</View>
|
||||
)}
|
||||
{pageIndex == 1 && <FamilyChoresProgress setPageIndex={setPageIndex} />}
|
||||
{pageIndex == 2 && <UserChoresProgress setPageIndex={setPageIndex} />}
|
||||
{pageIndex == 1 && <FamilyChoresProgress setPageIndex={setPageIndex}/>}
|
||||
{pageIndex == 2 && <UserChoresProgress setPageIndex={setPageIndex}/>}
|
||||
</View>
|
||||
);
|
||||
{
|
||||
profileData?.userType == ProfileType.PARENT && <AddChore/>
|
||||
}
|
||||
</>
|
||||
)
|
||||
;
|
||||
};
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
|
||||
@ -1,23 +1,23 @@
|
||||
import React from "react";
|
||||
import {ImageBackground, StyleSheet} from "react-native";
|
||||
import {Text, TouchableOpacity, View} from "react-native-ui-lib";
|
||||
import {StyleSheet} from "react-native";
|
||||
import {Image, Text, TouchableOpacity, View} from "react-native-ui-lib";
|
||||
import RemoveAssigneeBtn from "./RemoveAssigneeBtn";
|
||||
import {useGetFamilyMembers} from "@/hooks/firebase/useGetFamilyMembers";
|
||||
|
||||
const AssigneesDisplay = ({selectedAttendees, setSlectedAttendees}: {
|
||||
const AssigneesDisplay = ({selectedAttendees, setSelectedAttendees}: {
|
||||
selectedAttendees: string[],
|
||||
setSlectedAttendees: (value: React.SetStateAction<string[]>) => void
|
||||
setSelectedAttendees: (value: React.SetStateAction<string[]>) => void
|
||||
}) => {
|
||||
const {data: members} = useGetFamilyMembers(true);
|
||||
|
||||
const selectedMembers = members?.filter((x) => selectedAttendees.includes(x?.uid!));
|
||||
const selectedMembers = members?.filter((x) => selectedAttendees?.includes(x?.uid!));
|
||||
|
||||
const getInitials = (firstName: string, lastName: string) => {
|
||||
return `${firstName.charAt(0)}${lastName.charAt(0)}`;
|
||||
};
|
||||
|
||||
const removeAttendee = (uid: string) => {
|
||||
setSlectedAttendees((prev) => prev.filter((x) => x !== uid));
|
||||
setSelectedAttendees((prev) => prev.filter((x) => x !== uid));
|
||||
}
|
||||
|
||||
return (
|
||||
@ -26,7 +26,7 @@ const AssigneesDisplay = ({selectedAttendees, setSlectedAttendees}: {
|
||||
<TouchableOpacity key={member.uid} style={styles.assigneeWrapper}
|
||||
onPress={() => removeAttendee(member.uid!)}>
|
||||
{member?.pfp ? (
|
||||
<ImageBackground
|
||||
<Image
|
||||
source={{uri: member?.pfp}}
|
||||
style={styles.image}
|
||||
children={<RemoveAssigneeBtn/>}
|
||||
@ -42,7 +42,7 @@ const AssigneesDisplay = ({selectedAttendees, setSlectedAttendees}: {
|
||||
</TouchableOpacity>
|
||||
))}
|
||||
|
||||
{selectedAttendees.length === 0 && <Text>No attendees added</Text>}
|
||||
{selectedAttendees?.length === 0 && <Text>No attendees added</Text>}
|
||||
</View>
|
||||
);
|
||||
};
|
||||
|
||||
@ -188,31 +188,47 @@ exports.refreshTokens = functions.pubsub.schedule('every 12 hours').onRun(async
|
||||
profilesSnapshot.forEach(async (profileDoc) => {
|
||||
const profileData = profileDoc.data();
|
||||
|
||||
if (profileData.googleToken) {
|
||||
if (profileData.googleAccounts) {
|
||||
try {
|
||||
const refreshedGoogleToken = await refreshGoogleToken(profileData.googleToken);
|
||||
await profileDoc.ref.update({googleToken: refreshedGoogleToken});
|
||||
for (const googleEmail of Object.keys(profileData?.googleAccounts)) {
|
||||
const googleToken = profileData?.googleAccounts?.[googleEmail];
|
||||
if (googleToken) {
|
||||
const refreshedGoogleToken = await refreshGoogleToken(googleToken);
|
||||
const updatedGoogleAccounts = {...profileData.googleAccounts, [googleEmail]: refreshedGoogleToken};
|
||||
await profileDoc.ref.update({googleAccounts: updatedGoogleAccounts});
|
||||
console.log(`Google token updated for user ${profileDoc.id}`);
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(`Error refreshing Google token for user ${profileDoc.id}:`, error.message);
|
||||
}
|
||||
}
|
||||
|
||||
if (profileData.microsoftToken) {
|
||||
if (profileData.microsoftAccounts) {
|
||||
try {
|
||||
const refreshedMicrosoftToken = await refreshMicrosoftToken(profileData.microsoftToken);
|
||||
await profileDoc.ref.update({microsoftToken: refreshedMicrosoftToken});
|
||||
for (const microsoftEmail of Object.keys(profileData?.microsoftAccounts)) {
|
||||
const microsoftToken = profileData?.microsoftAccounts?.[microsoftEmail];
|
||||
if (microsoftToken) {
|
||||
const refreshedMicrosoftToken = await refreshMicrosoftToken(microsoftToken);
|
||||
const updatedMicrosoftAccounts = {...profileData.microsoftAccounts, [microsoftEmail]: refreshedMicrosoftToken};
|
||||
await profileDoc.ref.update({microsoftAccounts: updatedMicrosoftAccounts});
|
||||
console.log(`Microsoft token updated for user ${profileDoc.id}`);
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(`Error refreshing Microsoft token for user ${profileDoc.id}:`, error.message);
|
||||
}
|
||||
}
|
||||
|
||||
if (profileData.appleToken) {
|
||||
if (profileData.appleAccounts) {
|
||||
try {
|
||||
const refreshedAppleToken = await refreshAppleToken(profileData.appleToken);
|
||||
await profileDoc.ref.update({appleToken: refreshedAppleToken});
|
||||
for (const appleEmail of Object.keys(profileData?.appleAccounts)) {
|
||||
const appleToken = profileData?.appleAccounts?.[appleEmail];
|
||||
const refreshedAppleToken = await refreshAppleToken(appleToken);
|
||||
const updatedAppleAccounts = {...profileData.appleAccounts, [appleEmail]: refreshedAppleToken};
|
||||
await profileDoc.ref.update({appleAccunts: updatedAppleAccounts});
|
||||
console.log(`Apple token updated for user ${profileDoc.id}`);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(`Error refreshing Apple token for user ${profileDoc.id}:`, error.message);
|
||||
}
|
||||
|
||||
@ -17,16 +17,13 @@ export interface UserProfile {
|
||||
password: string;
|
||||
familyId?: string;
|
||||
uid?: string;
|
||||
pfp?: string;
|
||||
googleToken?: string | null;
|
||||
microsoftToken?: string | null;
|
||||
appleToken?: string | null;
|
||||
pfp?: string | null;
|
||||
eventColor?: string | null;
|
||||
googleMail?: string | null;
|
||||
outlookMail?: string | null;
|
||||
appleMail?: string | null;
|
||||
timeZone?: string | null;
|
||||
firstDayOfWeek?: string | null;
|
||||
googleAccounts?: Object;
|
||||
microsoftAccounts?: Object;
|
||||
appleAccounts?: Object;
|
||||
}
|
||||
|
||||
export interface ParentProfile extends UserProfile {
|
||||
|
||||
@ -7,5 +7,6 @@ export interface IToDo {
|
||||
rotate: boolean;
|
||||
repeatType: string;
|
||||
creatorId?: string,
|
||||
familyId?: string
|
||||
familyId?: string,
|
||||
assignees?: string[]; // Optional list of assignees
|
||||
}
|
||||
57
hooks/firebase/useChangeProfilePicture.ts
Normal file
57
hooks/firebase/useChangeProfilePicture.ts
Normal file
@ -0,0 +1,57 @@
|
||||
import { useMutation, useQueryClient } from "react-query";
|
||||
import firestore from "@react-native-firebase/firestore";
|
||||
import storage from "@react-native-firebase/storage";
|
||||
import { useAuthContext } from "@/contexts/AuthContext";
|
||||
import * as ImagePicker from "expo-image-picker";
|
||||
import { Platform } from "react-native";
|
||||
|
||||
export const useChangeProfilePicture = () => {
|
||||
const queryClient = useQueryClient();
|
||||
const { user, refreshProfileData } = useAuthContext();
|
||||
|
||||
return useMutation({
|
||||
mutationKey: ["changeProfilePicture"],
|
||||
mutationFn: async (profilePicture: ImagePicker.ImagePickerAsset) => {
|
||||
if (!profilePicture?.uri) {
|
||||
throw new Error("No image selected");
|
||||
}
|
||||
|
||||
let imageUri = profilePicture.uri;
|
||||
|
||||
console.log("Selected image URI:", imageUri);
|
||||
|
||||
if (Platform.OS === 'ios' && !imageUri.startsWith('file://')) {
|
||||
imageUri = `file://${imageUri}`;
|
||||
console.log("Updated image URI for iOS:", imageUri);
|
||||
}
|
||||
|
||||
const fileName = `profilePictures/${new Date().getTime()}_profile.jpg`;
|
||||
console.log("Firebase Storage file path:", fileName);
|
||||
|
||||
try {
|
||||
const reference = storage().ref(fileName);
|
||||
|
||||
console.log('Uploading image to Firebase Storage...');
|
||||
await reference.putFile(imageUri);
|
||||
console.log('Image uploaded successfully!');
|
||||
|
||||
const downloadURL = await reference.getDownloadURL();
|
||||
console.log("Download URL:", downloadURL);
|
||||
|
||||
await firestore()
|
||||
.collection("Profiles")
|
||||
.doc(user?.uid)
|
||||
.update({ pfp: downloadURL });
|
||||
|
||||
} catch (e) {
|
||||
console.error("Error uploading profile picture:", e.message);
|
||||
throw e;
|
||||
}
|
||||
},
|
||||
onSuccess: () => {
|
||||
// Invalidate queries to refresh profile data
|
||||
queryClient.invalidateQueries("Profiles");
|
||||
refreshProfileData();
|
||||
},
|
||||
});
|
||||
};
|
||||
@ -15,10 +15,24 @@ export const useGetFamilyMembers = (excludeSelf?: boolean) => {
|
||||
.get();
|
||||
|
||||
if (excludeSelf) {
|
||||
return snapshot.docs.map((doc) => doc.data()).filter((doc) => doc.id !== user?.uid) as UserProfile[];
|
||||
return snapshot.docs.map((doc) => {
|
||||
let documentData = doc.data();
|
||||
|
||||
return {
|
||||
...documentData,
|
||||
uid: doc.id
|
||||
}
|
||||
}).filter((doc) => doc.id !== user?.uid) as UserProfile[];
|
||||
}
|
||||
|
||||
return snapshot.docs.map((doc) => doc.data()) as UserProfile[];
|
||||
return snapshot.docs.map((doc) => {
|
||||
let documentData = doc.data();
|
||||
|
||||
return {
|
||||
...documentData,
|
||||
uid: doc.id
|
||||
}
|
||||
}) as UserProfile[];
|
||||
}
|
||||
})
|
||||
}
|
||||
@ -1,6 +1,8 @@
|
||||
import { useQuery } from "react-query";
|
||||
import firestore from "@react-native-firebase/firestore";
|
||||
import { useAuthContext } from "@/contexts/AuthContext";
|
||||
import {UserProfile} from "@/hooks/firebase/types/profileTypes";
|
||||
import {IToDo} from "@/hooks/firebase/types/todoData";
|
||||
|
||||
export const useGetTodos = () => {
|
||||
const { user, profileData } = useAuthContext();
|
||||
@ -17,16 +19,11 @@ export const useGetTodos = () => {
|
||||
const data = doc.data();
|
||||
|
||||
return {
|
||||
...data,
|
||||
id: doc.id,
|
||||
title: data.title,
|
||||
done: data.done,
|
||||
date: data.date ? new Date(data.date.seconds * 1000) : null,
|
||||
points: data.points,
|
||||
rotate: data.points,
|
||||
repeatType: data.repeatType,
|
||||
creatorId: data.creatorId
|
||||
};
|
||||
});
|
||||
}) as IToDo[];
|
||||
}
|
||||
})
|
||||
};
|
||||
@ -14,12 +14,12 @@ export const useFetchAndSaveGoogleEvents = () => {
|
||||
const timeMin = new Date(new Date().setFullYear(new Date().getFullYear() - 1));
|
||||
const timeMax = new Date(new Date().setFullYear(new Date().getFullYear() + 5));
|
||||
|
||||
console.log("Token: ", token ?? profileData?.googleToken);
|
||||
console.log("Token: ", token);
|
||||
|
||||
try {
|
||||
const response = await fetchGoogleCalendarEvents(
|
||||
token ?? profileData?.googleToken,
|
||||
email ?? profileData?.googleMail,
|
||||
token,
|
||||
email,
|
||||
profileData?.familyId,
|
||||
timeMin.toISOString().slice(0, -5) + "Z",
|
||||
timeMax.toISOString().slice(0, -5) + "Z"
|
||||
|
||||
@ -1311,6 +1311,9 @@ PODS:
|
||||
- Firebase/Functions (10.29.0):
|
||||
- Firebase/CoreOnly
|
||||
- FirebaseFunctions (~> 10.29.0)
|
||||
- Firebase/Storage (10.29.0):
|
||||
- Firebase/CoreOnly
|
||||
- FirebaseStorage (~> 10.29.0)
|
||||
- FirebaseAppCheckInterop (10.29.0)
|
||||
- FirebaseAuth (10.29.0):
|
||||
- FirebaseAppCheckInterop (~> 10.17)
|
||||
@ -1382,6 +1385,13 @@ PODS:
|
||||
- nanopb (< 2.30911.0, >= 2.30908.0)
|
||||
- PromisesSwift (~> 2.1)
|
||||
- FirebaseSharedSwift (10.29.0)
|
||||
- FirebaseStorage (10.29.0):
|
||||
- FirebaseAppCheckInterop (~> 10.0)
|
||||
- FirebaseAuthInterop (~> 10.25)
|
||||
- FirebaseCore (~> 10.0)
|
||||
- FirebaseCoreExtension (~> 10.0)
|
||||
- GoogleUtilities/Environment (~> 7.12)
|
||||
- GTMSessionFetcher/Core (< 4.0, >= 2.1)
|
||||
- fmt (9.1.0)
|
||||
- glog (0.3.5)
|
||||
- GoogleDataTransport (9.4.1):
|
||||
@ -2719,6 +2729,10 @@ PODS:
|
||||
- Firebase/Functions (= 10.29.0)
|
||||
- React-Core
|
||||
- RNFBApp
|
||||
- RNFBStorage (21.0.0):
|
||||
- Firebase/Storage (= 10.29.0)
|
||||
- React-Core
|
||||
- RNFBApp
|
||||
- RNGestureHandler (2.16.2):
|
||||
- DoubleConversion
|
||||
- glog
|
||||
@ -2897,6 +2911,7 @@ DEPENDENCIES:
|
||||
- "RNFBCrashlytics (from `../node_modules/@react-native-firebase/crashlytics`)"
|
||||
- "RNFBFirestore (from `../node_modules/@react-native-firebase/firestore`)"
|
||||
- "RNFBFunctions (from `../node_modules/@react-native-firebase/functions`)"
|
||||
- "RNFBStorage (from `../node_modules/@react-native-firebase/storage`)"
|
||||
- RNGestureHandler (from `../node_modules/react-native-gesture-handler`)
|
||||
- RNReanimated (from `../node_modules/react-native-reanimated`)
|
||||
- RNScreens (from `../node_modules/react-native-screens`)
|
||||
@ -2924,6 +2939,7 @@ SPEC REPOS:
|
||||
- FirebaseRemoteConfigInterop
|
||||
- FirebaseSessions
|
||||
- FirebaseSharedSwift
|
||||
- FirebaseStorage
|
||||
- GoogleDataTransport
|
||||
- GoogleUtilities
|
||||
- "gRPC-C++"
|
||||
@ -3138,6 +3154,8 @@ EXTERNAL SOURCES:
|
||||
:path: "../node_modules/@react-native-firebase/firestore"
|
||||
RNFBFunctions:
|
||||
:path: "../node_modules/@react-native-firebase/functions"
|
||||
RNFBStorage:
|
||||
:path: "../node_modules/@react-native-firebase/storage"
|
||||
RNGestureHandler:
|
||||
:path: "../node_modules/react-native-gesture-handler"
|
||||
RNReanimated:
|
||||
@ -3210,6 +3228,7 @@ SPEC CHECKSUMS:
|
||||
FirebaseRemoteConfigInterop: 6efda51fb5e2f15b16585197e26eaa09574e8a4d
|
||||
FirebaseSessions: dbd14adac65ce996228652c1fc3a3f576bdf3ecc
|
||||
FirebaseSharedSwift: 20530f495084b8d840f78a100d8c5ee613375f6e
|
||||
FirebaseStorage: 436c30aa46f2177ba152f268fe4452118b8a4856
|
||||
fmt: 4c2741a687cc09f0634a2e2c72a838b99f1ff120
|
||||
glog: fdfdfe5479092de0c4bdbebedd9056951f092c4f
|
||||
GoogleDataTransport: 6c09b596d841063d76d4288cc2d2f42cc36e1e2a
|
||||
@ -3283,6 +3302,7 @@ SPEC CHECKSUMS:
|
||||
RNFBCrashlytics: f465771d96a2eaf9f6104b30abb002cfe78fc0be
|
||||
RNFBFirestore: e47cdde04ea3d9e73e58e037e1aa1d0b1141c316
|
||||
RNFBFunctions: 738cc9e2177d060d29b5d143ef2f9ed0eda4bb1f
|
||||
RNFBStorage: 2dab66f3fcc51de3acd838c72c0ff081e61a0960
|
||||
RNGestureHandler: 20a4307fd21cbff339abfcfa68192f3f0a6a518b
|
||||
RNReanimated: d51431fd3597a8f8320319dce8e42cee82a5445f
|
||||
RNScreens: 30249f9331c3b00ae7cb7922e11f58b3ed369c07
|
||||
|
||||
@ -47,7 +47,7 @@
|
||||
</dict>
|
||||
</array>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>38</string>
|
||||
<string>34</string>
|
||||
<key>LSRequiresIPhoneOS</key>
|
||||
<true/>
|
||||
<key>NSAppTransportSecurity</key>
|
||||
@ -113,6 +113,7 @@
|
||||
<string>$(PRODUCT_BUNDLE_IDENTIFIER).expo.index_route</string>
|
||||
<string>$(PRODUCT_BUNDLE_IDENTIFIER).expo.index_route</string>
|
||||
<string>$(PRODUCT_BUNDLE_IDENTIFIER).expo.index_route</string>
|
||||
<string>$(PRODUCT_BUNDLE_IDENTIFIER).expo.index_route</string>
|
||||
</array>
|
||||
<key>UILaunchStoryboardName</key>
|
||||
<string>SplashScreen</string>
|
||||
|
||||
@ -38,6 +38,7 @@
|
||||
"@react-native-firebase/crashlytics": "^20.3.0",
|
||||
"@react-native-firebase/firestore": "^20.4.0",
|
||||
"@react-native-firebase/functions": "^20.4.0",
|
||||
"@react-native-firebase/storage": "^21.0.0",
|
||||
"@react-navigation/drawer": "^6.7.2",
|
||||
"@react-navigation/native": "^6.0.2",
|
||||
"date-fns": "^3.6.0",
|
||||
|
||||
@ -2432,6 +2432,11 @@
|
||||
resolved "https://registry.npmjs.org/@react-native-firebase/functions/-/functions-20.4.0.tgz"
|
||||
integrity sha512-g4kAWZboTE9cTdT7KT6k1haHDmEBA36bPCvrh2MJ2RACo2JxotB2MIOEPZ5U/cT94eIAlgI5YtxQQGQfC+VcBQ==
|
||||
|
||||
"@react-native-firebase/storage@^21.0.0":
|
||||
version "21.0.0"
|
||||
resolved "https://registry.yarnpkg.com/@react-native-firebase/storage/-/storage-21.0.0.tgz#0905fd67c74629d947f176bfb988d7cc4d85e244"
|
||||
integrity sha512-meft5Pu0nI7zxhpnP49ko9Uw8GaIy9hXGJfa/fCFrpf2vA9OXdTr3CvgloH/b9DpbkwQGcGTshRqltuttXI67w==
|
||||
|
||||
"@react-native/assets-registry@0.74.85":
|
||||
version "0.74.85"
|
||||
resolved "https://registry.npmjs.org/@react-native/assets-registry/-/assets-registry-0.74.85.tgz"
|
||||
@ -8987,7 +8992,7 @@ react-native-linear-gradient@^2.8.3:
|
||||
|
||||
react-native-onboarding-swiper@^1.3.0:
|
||||
version "1.3.0"
|
||||
resolved "https://registry.npmjs.org/react-native-onboarding-swiper/-/react-native-onboarding-swiper-1.3.0.tgz"
|
||||
resolved "https://registry.yarnpkg.com/react-native-onboarding-swiper/-/react-native-onboarding-swiper-1.3.0.tgz#a97f945f03a036845242b3e1f319c6fdb262bc2b"
|
||||
integrity sha512-2ZPMrZrJFgR5dmVWIj60x/vTBWrm0BZPuc2w7Cz2Sq/8ChypCi3oL8F7GYMrzky1fmknCS6Z0WPphfZVpnLUnQ==
|
||||
dependencies:
|
||||
tinycolor2 "^1.4.1"
|
||||
|
||||
Reference in New Issue
Block a user