mirror of
https://github.com/urosran/cally.git
synced 2025-07-10 07:07:16 +00:00
Update fetching google calendar, fix babel config
This commit is contained in:
@ -3,12 +3,6 @@ module.exports = function (api) {
|
||||
return {
|
||||
presets: [
|
||||
'babel-preset-expo',
|
||||
],
|
||||
plugins: [
|
||||
'babel-plugin-module-resolver', {
|
||||
alias: {
|
||||
'react-native-vector-icons': '@expo/vector-icons',
|
||||
},
|
||||
}]
|
||||
]
|
||||
};
|
||||
};
|
||||
|
@ -1,55 +1,50 @@
|
||||
export async function fetchGoogleCalendarEvents(token, email, familyId, startDate, endDate) {
|
||||
const response = await fetch(
|
||||
`https://www.googleapis.com/calendar/v3/calendars/primary/events?single_events=true&time_min=${startDate}&time_max=${endDate}`,
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${token}`,
|
||||
},
|
||||
},
|
||||
);
|
||||
const response = await fetch(
|
||||
`https://www.googleapis.com/calendar/v3/calendars/primary/events?single_events=true&time_min=${startDate}&time_max=${endDate}`,
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${token}`,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
const data = await response.json();
|
||||
const googleEvents = [];
|
||||
|
||||
const data = await response.json();
|
||||
data.items?.forEach((item) => {
|
||||
let isAllDay = false;
|
||||
let startDateTime, endDateTime;
|
||||
|
||||
const googleEvents = [];
|
||||
data.items?.forEach((item) => {
|
||||
let isAllDay = false;
|
||||
const start = item.start;
|
||||
let startDateTime;
|
||||
if (start !== undefined) {
|
||||
if (start.dateTime) {
|
||||
const stringDate = start.dateTime;
|
||||
startDateTime = new Date(stringDate);
|
||||
} else {
|
||||
const stringDate = start.date;
|
||||
startDateTime = new Date(stringDate);
|
||||
isAllDay = true;
|
||||
}
|
||||
}
|
||||
if (item.start) {
|
||||
if (item.start.dateTime) {
|
||||
startDateTime = new Date(item.start.dateTime);
|
||||
} else if (item.start.date) {
|
||||
startDateTime = new Date(item.start.date);
|
||||
isAllDay = true;
|
||||
}
|
||||
}
|
||||
|
||||
const end = item.end;
|
||||
let endDateTime;
|
||||
if (end !== undefined) {
|
||||
if (end.dateTime) {
|
||||
const stringDate = end.dateTime;
|
||||
endDateTime = new Date(stringDate);
|
||||
} else {
|
||||
const stringDate = end.date;
|
||||
endDateTime = new Date(stringDate);
|
||||
}
|
||||
}
|
||||
if (item.end) {
|
||||
if (item.end.dateTime) {
|
||||
endDateTime = new Date(item.end.dateTime);
|
||||
} else if (item.end.date) {
|
||||
endDateTime = new Date(item.end.date);
|
||||
isAllDay = true;
|
||||
}
|
||||
}
|
||||
|
||||
const googleEvent = {
|
||||
id: item.id,
|
||||
title: item.summary ?? "",
|
||||
startDate: startDateTime,
|
||||
endDate: endDateTime,
|
||||
allDay: isAllDay,
|
||||
familyId,
|
||||
email
|
||||
};
|
||||
googleEvents.push(googleEvent);
|
||||
});
|
||||
const googleEvent = {
|
||||
id: item.id,
|
||||
title: item.summary || "",
|
||||
startDate: startDateTime,
|
||||
endDate: endDateTime,
|
||||
allDay: isAllDay,
|
||||
familyId,
|
||||
email,
|
||||
};
|
||||
|
||||
return {googleEvents, success: response.ok};
|
||||
}
|
||||
googleEvents.push(googleEvent);
|
||||
});
|
||||
|
||||
return {googleEvents, success: response.ok};
|
||||
}
|
@ -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>
|
||||
</array>
|
||||
<key>UILaunchStoryboardName</key>
|
||||
<string>SplashScreen</string>
|
||||
|
Reference in New Issue
Block a user