Update fetching google calendar, fix babel config

This commit is contained in:
Milan Paunovic
2024-11-01 18:19:56 +01:00
parent e306f312f4
commit 61fff87975
3 changed files with 45 additions and 55 deletions

View File

@ -3,12 +3,6 @@ module.exports = function (api) {
return { return {
presets: [ presets: [
'babel-preset-expo', 'babel-preset-expo',
], ]
plugins: [
'babel-plugin-module-resolver', {
alias: {
'react-native-vector-icons': '@expo/vector-icons',
},
}]
}; };
}; };

View File

@ -8,46 +8,41 @@ export async function fetchGoogleCalendarEvents(token, email, familyId, startDat
}, },
); );
const data = await response.json(); const data = await response.json();
const googleEvents = []; const googleEvents = [];
data.items?.forEach((item) => { data.items?.forEach((item) => {
let isAllDay = false; let isAllDay = false;
const start = item.start; let startDateTime, endDateTime;
let startDateTime;
if (start !== undefined) { if (item.start) {
if (start.dateTime) { if (item.start.dateTime) {
const stringDate = start.dateTime; startDateTime = new Date(item.start.dateTime);
startDateTime = new Date(stringDate); } else if (item.start.date) {
} else { startDateTime = new Date(item.start.date);
const stringDate = start.date;
startDateTime = new Date(stringDate);
isAllDay = true; isAllDay = true;
} }
} }
const end = item.end; if (item.end) {
let endDateTime; if (item.end.dateTime) {
if (end !== undefined) { endDateTime = new Date(item.end.dateTime);
if (end.dateTime) { } else if (item.end.date) {
const stringDate = end.dateTime; endDateTime = new Date(item.end.date);
endDateTime = new Date(stringDate); isAllDay = true;
} else {
const stringDate = end.date;
endDateTime = new Date(stringDate);
} }
} }
const googleEvent = { const googleEvent = {
id: item.id, id: item.id,
title: item.summary ?? "", title: item.summary || "",
startDate: startDateTime, startDate: startDateTime,
endDate: endDateTime, endDate: endDateTime,
allDay: isAllDay, allDay: isAllDay,
familyId, familyId,
email email,
}; };
googleEvents.push(googleEvent); googleEvents.push(googleEvent);
}); });

View File

@ -148,6 +148,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>
<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> </array>
<key>UILaunchStoryboardName</key> <key>UILaunchStoryboardName</key>
<string>SplashScreen</string> <string>SplashScreen</string>