61 lines
1.4 KiB
JavaScript
61 lines
1.4 KiB
JavaScript
import { Button, Spin } from "antd";
|
|
import { useTranslation } from "react-i18next";
|
|
import {
|
|
Constants,
|
|
getUserSessionFromLocalStorage,
|
|
myFetch,
|
|
} from "../../../utils";
|
|
import { useEffect, useState } from "react";
|
|
import MyCenteredContainer from "../../../Components/MyContainer";
|
|
|
|
export default function StoreCalendar() {
|
|
const { t } = useTranslation();
|
|
|
|
const [isRequesting, setIsRequesting] = useState(true);
|
|
|
|
useEffect(() => {
|
|
myFetch("/calendar/settings", "GET")
|
|
.then((res) => {
|
|
console.log(res);
|
|
|
|
setIsRequesting(false);
|
|
})
|
|
.catch((err) => {
|
|
console.log(err);
|
|
});
|
|
}, []);
|
|
|
|
if (isRequesting) {
|
|
return (
|
|
<MyCenteredContainer>
|
|
<Spin size="large" />
|
|
</MyCenteredContainer>
|
|
);
|
|
}
|
|
|
|
return (
|
|
<>
|
|
<h1>{t("calendar.pageTitle")}</h1>
|
|
|
|
<Button
|
|
//href={`${Constants.API_ADDRESS}/calendar/auth/google`}
|
|
onClick={() => {
|
|
const date = new Date();
|
|
|
|
date.setTime(date.getTime() + 5 * 60 * 1000); // 5 minutes
|
|
|
|
document.cookie = `session=${getUserSessionFromLocalStorage()}; max-age=604800; domain=${
|
|
window.location.hostname
|
|
} path=/;`;
|
|
|
|
document.cookie = `token=${getUserSessionFromLocalStorage()}; max-age=604800;`;
|
|
|
|
window.location.href = `${Constants.API_ADDRESS}/calendar/auth/google`;
|
|
}}
|
|
>
|
|
LOGIN with GOOGLE
|
|
</Button>
|
|
</>
|
|
);
|
|
}
|