Merge branch 'dev'

This commit is contained in:
Milan Paunovic
2025-01-15 17:39:07 +01:00
7 changed files with 99 additions and 53 deletions

View File

@ -44,10 +44,6 @@ const UsersList = () => {
return str.charAt(0).toUpperCase() + str.slice(1).toLowerCase(); return str.charAt(0).toUpperCase() + str.slice(1).toLowerCase();
}; };
useEffect(() => {
console.log(selectedUser);
}, [selectedUser]);
return ( return (
<View centerH paddingT-10 marginB-70> <View centerH paddingT-10 marginB-70>
{sortedMembers?.map((member, index) => ( {sortedMembers?.map((member, index) => (

View File

@ -19,7 +19,7 @@ import {Text} from "react-native-ui-lib";
import {addDays, compareAsc, format, isWithinInterval, subDays} from "date-fns"; import {addDays, compareAsc, format, isWithinInterval, subDays} from "date-fns";
import {useCalSync} from "@/hooks/useCalSync"; import {useCalSync} from "@/hooks/useCalSync";
import {useSyncEvents} from "@/hooks/useSyncOnScroll"; import {useSyncEvents} from "@/hooks/useSyncOnScroll";
import {colorMap} from "@/constants/colorMap"; import {colorMap, getEventTextColor} from "@/constants/colorMap";
import {useGetFamilyMembers} from "@/hooks/firebase/useGetFamilyMembers"; import {useGetFamilyMembers} from "@/hooks/firebase/useGetFamilyMembers";
import CachedImage from "expo-cached-image"; import CachedImage from "expo-cached-image";
import { DeviceType } from "expo-device"; import { DeviceType } from "expo-device";
@ -111,7 +111,7 @@ export const MonthCalendar: React.FC<EventCalendarProps> = React.memo(
eventColor = profileData?.eventColor ?? colorMap.teal; eventColor = profileData?.eventColor ?? colorMap.teal;
} }
return {backgroundColor: eventColor, fontSize: 14} return {backgroundColor: eventColor, fontSize: 14, color: getEventTextColor(event?.eventColor)}
}, },
[] []
); );

View File

@ -1,49 +1,78 @@
import {Button, Text, TextField, View} from "react-native-ui-lib"; import { Button, ButtonSize, Text, TextField, View } from "react-native-ui-lib";
import React, {useState} from "react"; import React, { useState } from "react";
import {StyleSheet} from "react-native"; import { StyleSheet } from "react-native";
import {useResetPassword} from "@/hooks/firebase/useResetPassword"; import { useResetPassword } from "@/hooks/firebase/useResetPassword";
import { router } from "expo-router";
export const ResetPasswordPage = () => { export const ResetPasswordPage = () => {
const [email, setEmail] = useState<string>(""); const [email, setEmail] = useState<string>("");
const {mutateAsync: resetPassword, error, isError, isLoading} = useResetPassword(); const {
mutateAsync: resetPassword,
error,
isError,
isLoading,
} = useResetPassword();
const handleResetPassword = async () => { const handleResetPassword = async () => {
await resetPassword({email}); await resetPassword({ email });
alert("Password reset, please check your email") alert("Password reset, please check your email");
}; };
return ( return (
<View padding-10 centerV height={"100%"}> <View padding-10 centerV height={"100%"}>
<Text text70 center> <Text text70 center>
Please enter your email and reset your password Please enter your email and reset your password
</Text> </Text>
<TextField <TextField
placeholder="Email" placeholder="Email"
value={email} value={email}
onChangeText={setEmail} onChangeText={setEmail}
style={styles.textfield} style={styles.textfield}
/> />
<Button <Button
label="Reset Password" label="Reset Password"
onPress={handleResetPassword} onPress={handleResetPassword}
marginB-20 marginB-20
backgroundColor="#fd1775" backgroundColor="#fd1775"
disabled={isLoading} disabled={isLoading}
/> />
<View>
<Button
onPress={() => router.push("/(unauth)/sign_in")}
label="Back"
labelStyle={[
styles.jakartaMedium,
{ textDecorationLine: "none", color: "#fd1575" },
]}
link
size={ButtonSize.xSmall}
padding-0
margin-0
text70
left
color="#fd1775"
/>
</View>
{isError && <Text center style={{marginBottom: 20}}>{`${error}`}</Text>} {isError && <Text center style={{ marginBottom: 20 }}>{`${error}`}</Text>}
</View> </View>
); );
}; };
const styles = StyleSheet.create({ const styles = StyleSheet.create({
textfield: { textfield: {
backgroundColor: "white", backgroundColor: "white",
marginVertical: 10, marginVertical: 10,
padding: 30, padding: 30,
height: 45, height: 45,
borderRadius: 50, borderRadius: 50,
}, },
jakartaMedium: {
fontFamily: "PlusJakartaSans_500Medium",
fontSize: 16,
color: "#919191",
textDecorationLine: "underline",
},
}); });

View File

@ -106,7 +106,7 @@ const SignInPage = () => {
style={{ style={{
flex: 1, flex: 1,
padding: 21, padding: 21,
paddingBottom: 45, paddingBottom: 30,
paddingTop: isLoading ? "20%" : getTopPadding(), paddingTop: isLoading ? "20%" : getTopPadding(),
width: isLoading ? "100%" : isTablet ? 629 : undefined, width: isLoading ? "100%" : isTablet ? 629 : undefined,
}} }}
@ -205,6 +205,23 @@ const SignInPage = () => {
color="#fd1775" color="#fd1775"
/> />
</View> </View>
<View>
<Button
onPress={() => router.replace("/(unauth)/reset_password")}
label="Reset Password"
labelStyle={[
styles.jakartaMedium,
{ textDecorationLine: "none", color: "#fd1575" },
]}
link
size={ButtonSize.xSmall}
padding-0
margin-0
text70
left
color="#fd1775"
/>
</View>
{/*<View row centerH marginB-5 gap-5>*/} {/*<View row centerH marginB-5 gap-5>*/}
{/* <Text text70>Forgot your password?</Text>*/} {/* <Text text70>Forgot your password?</Text>*/}

View File

@ -43,7 +43,7 @@ const SettingsPage = () => {
{pageIndex == 0 && ( {pageIndex == 0 && (
<View flexG centerH marginH-30 marginT-30> <View flexG centerH marginH-30 marginT-30>
<Button <Button
disabled={false} disabled={isntParent}
backgroundColor="white" backgroundColor="white"
style={styles.mainBtn} style={styles.mainBtn}
children={ children={

View File

@ -78,6 +78,8 @@ const UpdateUserDialog = ({ open, handleClose, profileData }: Props) => {
allowsEditing: true, allowsEditing: true,
aspect: [1, 1], aspect: [1, 1],
quality: 1, quality: 1,
base64: false,
exif: false,
}); });
if (!result.canceled) { if (!result.canceled) {

View File

@ -1,10 +1,11 @@
import {useQuery, useQueryClient} from "@tanstack/react-query"; import {useQuery, useQueryClient} from "@tanstack/react-query";
import firestore from "@react-native-firebase/firestore"; import firestore from "@react-native-firebase/firestore";
import {useAuthContext} from "@/contexts/AuthContext"; import {ProfileType, useAuthContext} from "@/contexts/AuthContext";
import {useAtomValue} from "jotai"; import {useAtomValue} from "jotai";
import {isFamilyViewAtom} from "@/components/pages/calendar/atoms"; import {isFamilyViewAtom} from "@/components/pages/calendar/atoms";
import {colorMap} from "@/constants/colorMap"; import {colorMap} from "@/constants/colorMap";
import {useEffect, useRef} from "react"; import {useEffect, useRef} from "react";
import {UserProfile} from "@/hooks/firebase/types/profileTypes";
const createEventHash = (event: any): string => { const createEventHash = (event: any): string => {
const str = `${event.startDate?.seconds || ''}-${event.endDate?.seconds || ''}-${ const str = `${event.startDate?.seconds || ''}-${event.endDate?.seconds || ''}-${
@ -20,12 +21,13 @@ const createEventHash = (event: any): string => {
return hash.toString(36); return hash.toString(36);
}; };
const fetchEvents = async (userId: string, familyId: string | undefined, isFamilyView: boolean) => { const fetchEvents = async (userId: string, profileData: UserProfile | undefined, isFamilyView: boolean) => {
const db = firestore(); const db = firestore();
const eventsQuery = db.collection("Events"); const eventsQuery = db.collection("Events");
let constraints = []; let constraints;
let familyId = profileData?.familyId;
if (isFamilyView) { if (isFamilyView || profileData?.userType === ProfileType.FAMILY_DEVICE) {
constraints = [ constraints = [
eventsQuery.where("familyId", "==", familyId).where("private", "==", false), eventsQuery.where("familyId", "==", familyId).where("private", "==", false),
eventsQuery.where("creatorId", "==", userId), eventsQuery.where("creatorId", "==", userId),
@ -99,13 +101,13 @@ export const useGetEvents = () => {
const prefetchEvents = async () => { const prefetchEvents = async () => {
await queryClient.prefetchQuery({ await queryClient.prefetchQuery({
queryKey: ["events", user.uid, false], // Personal events queryKey: ["events", user.uid, false], // Personal events
queryFn: () => fetchEvents(user.uid, profileData.familyId, false), queryFn: () => fetchEvents(user.uid, profileData, false),
staleTime: 5 * 60 * 1000, staleTime: 5 * 60 * 1000,
}); });
await queryClient.prefetchQuery({ await queryClient.prefetchQuery({
queryKey: ["events", user.uid, true], // Family events queryKey: ["events", user.uid, true], // Family events
queryFn: () => fetchEvents(user.uid, profileData.familyId, true), queryFn: () => fetchEvents(user.uid, profileData, true),
staleTime: 5 * 60 * 1000, staleTime: 5 * 60 * 1000,
}); });
}; };
@ -141,7 +143,7 @@ export const useGetEvents = () => {
return useQuery({ return useQuery({
queryKey: ["events", user?.uid, isFamilyView], queryKey: ["events", user?.uid, isFamilyView],
queryFn: () => fetchEvents(user?.uid!, profileData?.familyId, isFamilyView), queryFn: () => fetchEvents(user?.uid!, profileData, isFamilyView),
staleTime: Infinity, staleTime: Infinity,
gcTime: Infinity, gcTime: Infinity,
placeholderData: (previousData) => previousData, placeholderData: (previousData) => previousData,