Merge branch 'main' into dev

This commit is contained in:
Milan Paunovic
2024-10-29 10:33:04 +01:00
12 changed files with 277 additions and 232 deletions

View File

@ -16,7 +16,7 @@
"supportsTablet": true,
"bundleIdentifier": "com.cally.app",
"googleServicesFile": "./ios/GoogleService-Info.plist",
"buildNumber": "40",
"buildNumber": "52",
"usesAppleSignIn": true
},
"android": {

View File

@ -161,6 +161,7 @@ export const ManuallyAddEventModal = () => {
if (editEvent?.id) eventData.id = editEvent?.id
await createEvent(eventData);
setEditEvent(undefined)
close();
};

View File

@ -8,7 +8,7 @@ const Entry = () => {
const [tab, setTab] = useState<"register" | "login" | "reset-password">("login");
return (
<View>
<View style={{height:"100%"}}>
{tab === "register" && <SignUpPage setTab={setTab}/>}
{tab === "login" && <SignInPage setTab={setTab}/>}
{tab === "reset-password" && <ResetPasswordPage setTab={setTab}/>}

View File

@ -167,7 +167,7 @@ const SignInPage = ({
bottom
width="100%"
height="70%"
containerStyle={{ padding: 0 }}
containerStyle={{ padding: 15, backgroundColor:"white" }}
>
{hasPermission === null ? (
<Text>Requesting camera permissions...</Text>
@ -175,7 +175,7 @@ const SignInPage = ({
<Text>No access to camera</Text>
) : (
<CameraView
style={{ flex: 1 }}
style={{ flex: 1, borderRadius: 15 }}
onBarcodeScanned={handleQrCodeScanned}
barcodeScannerSettings={{
barcodeTypes: ["qr"],
@ -186,7 +186,7 @@ const SignInPage = ({
label="Cancel"
onPress={() => setShowCameraDialog(false)}
backgroundColor="#fd1775"
style={{ margin: 10 }}
style={{ margin: 10, marginBottom: 30 }}
/>
</Dialog>
</View>

View File

@ -10,8 +10,7 @@ import {
View,
} from "react-native-ui-lib";
import {useSignUp} from "@/hooks/firebase/useSignUp";
import { ProfileType } from "@/contexts/AuthContext";
import { Dimensions, StyleSheet } from "react-native";
import {StyleSheet} from "react-native";
import {AntDesign} from "@expo/vector-icons";
const SignUpPage = ({
@ -40,7 +39,7 @@ const SignUpPage = ({
};
return (
<View padding-15 marginT-30 height={Dimensions.get("window").height} flexG>
<View height={"100%"} padding-15 marginT-30>
<Text style={styles.title}>Get started with Cally</Text>
<Text style={styles.subtitle} marginT-15 color="#919191">
Please enter your details.
@ -144,6 +143,7 @@ const SignUpPage = ({
</View>
</View>
</View>
<View flex-1/>
<View style={styles.bottomView}>
<Button
label="Register"
@ -193,7 +193,7 @@ const styles = StyleSheet.create({
color: "#919191",
},
//mora da se izmeni kako treba
bottomView: { marginTop: "auto", marginBottom: 30 },
bottomView: {marginTop: "auto", marginBottom: 30, marginTop: "auto"},
jakartaLight: {
fontFamily: "PlusJakartaSans_300Light",
fontSize: 13,

View File

@ -67,10 +67,10 @@ const MyGroup = () => {
return;
}
if (selectedStatus !== ProfileType.FAMILY_DEVICE && !email) {
console.error("Email is required for non-family device users");
return;
}
// if (selectedStatus !== ProfileType.FAMILY_DEVICE && !email) {
// console.error("Email is required for non-family device users");
// return;
// }
if (email && !email.includes("@")) {
console.error("Invalid email address");

View File

@ -18,7 +18,12 @@ exports.sendNotificationOnEventCreation = functions.firestore
.document('Events/{eventId}')
.onCreate(async (snapshot, context) => {
const eventData = snapshot.data();
const {familyId, creatorId} = eventData;
const {familyId, creatorId, email} = eventData;
if (email) {
console.log('Event has an email field. Skipping notification.');
return;
}
if (!familyId || !creatorId) {
console.error('Missing familyId or creatorId in event data');
@ -33,14 +38,12 @@ exports.sendNotificationOnEventCreation = functions.firestore
}
}
// Increment event count for debouncing
eventCount++;
if (notificationTimeout) {
clearTimeout(notificationTimeout); // Reset the timer if events keep coming
clearTimeout(notificationTimeout);
}
// Set a debounce time (e.g., 5 seconds)
notificationTimeout = setTimeout(async () => {
const eventMessage = eventCount === 1
? `An event "${eventData.title}" has been added. Check it out!`
@ -88,7 +91,7 @@ exports.sendNotificationOnEventCreation = functions.firestore
eventCount = 0; // Reset the event count after sending notification
pushTokens = []; // Reset push tokens for the next round
}, 5000); // Debounce time (5 seconds)
}, 5000);
});

View File

@ -15,7 +15,7 @@ export const useCreateSubUser = () => {
return await functions().httpsCallable("createSubUser")({
...userProfile,
email,
familyId: profileData?.familyId
familyId: profileData?.familyId!
}) as HttpsCallableResult<{ userId: string }>
} else {
throw Error("Can't create sub-users as a non-parent.")

View File

@ -13,11 +13,12 @@ export const useGetEvents = () => {
queryKey: ["events", user?.uid, isFamilyView],
queryFn: async () => {
const db = firestore();
const userId = user?.uid;
const familyId = profileData?.familyId;
let allEvents = [];
// If family view is active, include family, creator, and attendee events
if (isFamilyView) {
const familyQuery = db.collection("Events").where("familyID", "==", familyId);
const creatorQuery = db.collection("Events").where("creatorId", "==", userId);
@ -29,12 +30,14 @@ export const useGetEvents = () => {
attendeeQuery.get(),
]);
// Collect all events
const familyEvents = familySnapshot.docs.map(doc => doc.data());
const creatorEvents = creatorSnapshot.docs.map(doc => doc.data());
const attendeeEvents = attendeeSnapshot.docs.map(doc => doc.data());
allEvents = [...familyEvents, ...creatorEvents, ...attendeeEvents];
} else {
// Only include creator and attendee events when family view is off
const creatorQuery = db.collection("Events").where("creatorId", "==", userId);
const attendeeQuery = db.collection("Events").where("attendees", "array-contains", userId);
@ -49,19 +52,28 @@ export const useGetEvents = () => {
allEvents = [...creatorEvents, ...attendeeEvents];
}
allEvents = allEvents.filter((event, index, self) =>
index === self.findIndex(e => e.id === event.id)
);
// Use a Map to ensure uniqueness only for events with IDs
const uniqueEventsMap = new Map();
allEvents.forEach(event => {
if (event.id) {
uniqueEventsMap.set(event.id, event); // Ensure uniqueness for events with IDs
} else {
uniqueEventsMap.set(Math.random().toString(36), event); // Generate a temp key for events without ID
}
});
const uniqueEvents = Array.from(uniqueEventsMap.values());
allEvents = allEvents.filter(event => {
// Filter out private events unless the user is the creator
const filteredEvents = uniqueEvents.filter(event => {
if (event.private) {
return event.creatorId === userId;
}
return true;
});
// Attach event colors and return the final list of events
return await Promise.all(
allEvents.map(async (event) => {
filteredEvents.map(async (event) => {
const profileSnapshot = await db
.collection("Profiles")
.doc(event.creatorId)
@ -71,13 +83,13 @@ export const useGetEvents = () => {
const eventColor = profileData?.eventColor || colorMap.pink;
return {
id: event.id,
id: event.id || Math.random().toString(36).substr(2, 9), // Generate temp ID if missing
title: event.title,
start: new Date(event.startDate.seconds * 1000),
end: new Date(event.endDate.seconds * 1000),
hideHours: event.allDay,
eventColor: eventColor,
notes: event.notes
eventColor,
notes: event.notes,
};
})
);

View File

@ -47,7 +47,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>40</string>
<string>52</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSAppTransportSecurity</key>
@ -119,6 +119,18 @@
<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>
<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>
<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>
<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>

17
package-lock.json generated
View File

@ -56,6 +56,7 @@
"react-native-app-auth": "^8.0.0",
"react-native-big-calendar": "^4.14.0",
"react-native-calendars": "^1.1306.0",
"react-native-element-dropdown": "^2.12.2",
"react-native-gesture-handler": "~2.16.1",
"react-native-gifted-charts": "^1.4.41",
"react-native-keyboard-manager": "^6.5.16-0",
@ -15939,6 +15940,22 @@
"moment": "^2.29.4"
}
},
"node_modules/react-native-element-dropdown": {
"version": "2.12.2",
"resolved": "https://registry.npmjs.org/react-native-element-dropdown/-/react-native-element-dropdown-2.12.2.tgz",
"integrity": "sha512-Tf8hfRuniYEXo+LGoVgIMoItKWuPLX6jbqlwAFgMbBhmWGTuV+g1OVOAx/ny16kgnwp+NhgJoWpxhVvr7HSmXA==",
"license": "MIT",
"dependencies": {
"lodash": "^4.17.21"
},
"engines": {
"node": ">= 16.0.0"
},
"peerDependencies": {
"react": "*",
"react-native": "*"
}
},
"node_modules/react-native-gesture-handler": {
"version": "2.16.2",
"resolved": "https://registry.npmjs.org/react-native-gesture-handler/-/react-native-gesture-handler-2.16.2.tgz",

View File

@ -8852,7 +8852,7 @@ react-native-calendars@^1.1306.0:
react-native-element-dropdown@^2.12.2:
version "2.12.2"
resolved "https://registry.yarnpkg.com/react-native-element-dropdown/-/react-native-element-dropdown-2.12.2.tgz#48d0c12b87591e2498c73bbde80e18374a4c262e"
resolved "https://registry.npmjs.org/react-native-element-dropdown/-/react-native-element-dropdown-2.12.2.tgz"
integrity sha512-Tf8hfRuniYEXo+LGoVgIMoItKWuPLX6jbqlwAFgMbBhmWGTuV+g1OVOAx/ny16kgnwp+NhgJoWpxhVvr7HSmXA==
dependencies:
lodash "^4.17.21"