mirror of
https://github.com/urosran/cally.git
synced 2025-07-15 09:45:20 +00:00
Update fetching google calendar, fix babel config
This commit is contained in:
@ -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',
|
|
||||||
},
|
|
||||||
}]
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -1,55 +1,50 @@
|
|||||||
export async function fetchGoogleCalendarEvents(token, email, familyId, startDate, endDate) {
|
export async function fetchGoogleCalendarEvents(token, email, familyId, startDate, endDate) {
|
||||||
const response = await fetch(
|
const response = await fetch(
|
||||||
`https://www.googleapis.com/calendar/v3/calendars/primary/events?single_events=true&time_min=${startDate}&time_max=${endDate}`,
|
`https://www.googleapis.com/calendar/v3/calendars/primary/events?single_events=true&time_min=${startDate}&time_max=${endDate}`,
|
||||||
{
|
{
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: `Bearer ${token}`,
|
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 = [];
|
if (item.start) {
|
||||||
data.items?.forEach((item) => {
|
if (item.start.dateTime) {
|
||||||
let isAllDay = false;
|
startDateTime = new Date(item.start.dateTime);
|
||||||
const start = item.start;
|
} else if (item.start.date) {
|
||||||
let startDateTime;
|
startDateTime = new Date(item.start.date);
|
||||||
if (start !== undefined) {
|
isAllDay = true;
|
||||||
if (start.dateTime) {
|
}
|
||||||
const stringDate = start.dateTime;
|
}
|
||||||
startDateTime = new Date(stringDate);
|
|
||||||
} else {
|
|
||||||
const stringDate = start.date;
|
|
||||||
startDateTime = new Date(stringDate);
|
|
||||||
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);
|
|
||||||
});
|
|
||||||
|
|
||||||
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>
|
||||||
<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>
|
||||||
|
Reference in New Issue
Block a user