708 lines
31 KiB
JavaScript
708 lines
31 KiB
JavaScript
"use strict";
|
|
exports.id = 8374;
|
|
exports.ids = [8374];
|
|
exports.modules = {
|
|
|
|
/***/ 8374:
|
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
|
|
|
|
// EXPORTS
|
|
__webpack_require__.d(__webpack_exports__, {
|
|
"Z": () => (/* binding */ SocialLogin)
|
|
});
|
|
|
|
// EXTERNAL MODULE: external "react/jsx-runtime"
|
|
var jsx_runtime_ = __webpack_require__(997);
|
|
// EXTERNAL MODULE: external "react"
|
|
var external_react_ = __webpack_require__(6689);
|
|
var external_react_default = /*#__PURE__*/__webpack_require__.n(external_react_);
|
|
// EXTERNAL MODULE: ./functions/frontend/fetchApi.js
|
|
var frontend_fetchApi = __webpack_require__(6729);
|
|
;// CONCATENATED MODULE: ./components/pages/login/GoogleIdentityButton.jsx
|
|
/**
|
|
* Imports
|
|
* ==============================================================================
|
|
*/ /** ********************* React/Next Imports */
|
|
|
|
|
|
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /**
|
|
* Main Component { Functional }
|
|
* ==============================================================================
|
|
* @param {Object} props - Props from getServerSideProps or getStaticProps
|
|
* @param {import("@/package-shared/types").UserType} props.user
|
|
* @param {string} [props.userType]
|
|
* @param {React.Dispatch<React.SetStateAction<boolean>>} props.setLoading
|
|
*/ function GoogleIdentityButton({ user , userType , setLoading }) {
|
|
/**
|
|
* Get Contexts
|
|
*
|
|
* @abstract { React.useContext }
|
|
*/ ////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
/**
|
|
* Javascript Variables
|
|
*
|
|
* @abstract Non hook variables and functions
|
|
*/ if (user?.logged_in_status || user?.current?.logged_in_status) return /*#__PURE__*/ jsx_runtime_.jsx((external_react_default()).Fragment, {});
|
|
////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
/**
|
|
* React Hooks
|
|
*
|
|
* @abstract { useState, useEffect, useRef, etc ... }
|
|
*/ external_react_default().useEffect(()=>{
|
|
function handleCredentialResponse(response) {
|
|
window.activeGooglePrompt = false;
|
|
userLoginWithGoogle({
|
|
gUser: null,
|
|
tokenRes: response.credential,
|
|
setLoading
|
|
});
|
|
}
|
|
////////////////////////////////////////
|
|
google.accounts.id.initialize({
|
|
client_id: "392696781563-imb0ddojfn6m4bdokjk5v80jn546t9tq.apps.googleusercontent.com",
|
|
callback: handleCredentialResponse
|
|
});
|
|
////////////////////////////////////////
|
|
google.accounts.id.renderButton(document.getElementById("google-identity-button"), {
|
|
theme: "outline",
|
|
size: "large",
|
|
logo_alignment: "center"
|
|
});
|
|
////////////////////////////////////////
|
|
// if (user?.logged_in_status || document.cookie.match(/google_prompt_skipped=true/)) {
|
|
// google.accounts.id.cancel();
|
|
// return;
|
|
// }
|
|
////////////////////////////////////////
|
|
// window.activeGooglePrompt = true;
|
|
// google.accounts.id.prompt((notification) => {
|
|
// console.log("getMomentType => ", notification.getMomentType());
|
|
// console.log("getDismissedReason => ", notification.getDismissedReason());
|
|
// console.log("getNotDisplayedReason => ", notification.getNotDisplayedReason());
|
|
// console.log("getSkippedReason => ", notification.getSkippedReason());
|
|
// console.log("isDismissedMoment => ", notification.isDismissedMoment());
|
|
// console.log("isDisplayMoment => ", notification.isDisplayMoment());
|
|
// console.log("isDisplayed => ", notification.isDisplayed());
|
|
// console.log("isNotDisplayed => ", notification.isNotDisplayed());
|
|
// console.log("isSkippedMoment => ", notification.isSkippedMoment());
|
|
// if (notification.isSkippedMoment()) {
|
|
// document.cookie = "google_prompt_skipped=true;max-age=" + 60000 * 60 * 24 * 5;
|
|
// window.activeGooglePrompt = false;
|
|
// }
|
|
// if (notification.isNotDisplayed()) {
|
|
// window.activeGooglePrompt = false;
|
|
// }
|
|
// }); // also display the One Tap dialog
|
|
}, []);
|
|
/**
|
|
* Function Return
|
|
*
|
|
* @abstract Main Function Return
|
|
*/ return /*#__PURE__*/ jsx_runtime_.jsx("div", {
|
|
className: "w-full flex items-center justify-center h-[45px] overflow-hidden button outlined normal-weight small-text gray p-0",
|
|
style: {
|
|
padding: 0
|
|
},
|
|
children: /*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
|
|
className: "relative w-full h-full justify-center",
|
|
children: [
|
|
/*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
|
|
className: "w-full h-full justify-center bg-white dark:bg-slate-800 relative z-10 pointer-events-none",
|
|
style: {
|
|
border: "none"
|
|
},
|
|
children: [
|
|
/*#__PURE__*/ jsx_runtime_.jsx("img", {
|
|
src: "/images/google.png",
|
|
width: 18,
|
|
height: 18,
|
|
alt: ""
|
|
}),
|
|
/*#__PURE__*/ jsx_runtime_.jsx("span", {
|
|
children: "Login With Google"
|
|
})
|
|
]
|
|
}),
|
|
/*#__PURE__*/ jsx_runtime_.jsx("div", {
|
|
id: "google-identity-button",
|
|
className: "w-full absolute justify-center top-0 left-0",
|
|
style: {
|
|
transform: "scale(2)"
|
|
}
|
|
})
|
|
]
|
|
})
|
|
});
|
|
////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
}
|
|
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ function userLoginWithGoogle({ gUser , tokenRes , setLoading }) {
|
|
setLoading(true);
|
|
if (!tokenRes) {
|
|
console.log("No Token Response received!");
|
|
return closeLoader();
|
|
}
|
|
(0,frontend_fetchApi/* default */.Z)(`/api/social-login/google-auth${window.location.search}`, {
|
|
method: "post",
|
|
body: {
|
|
token: tokenRes
|
|
}
|
|
}).then(async (res)=>{
|
|
if (res.success && res.user) {
|
|
localStorage.setItem("csrf", res.user.csrf_k);
|
|
localStorage.setItem("user", JSON.stringify(res.user));
|
|
window.location.reload();
|
|
} else {
|
|
console.log(res);
|
|
setLoading(false);
|
|
if (res.alert) {
|
|
window.alert(res.msg);
|
|
}
|
|
}
|
|
}).catch(async (err)=>{
|
|
alert("Login Failed");
|
|
console.log("Google login fetch error => ", err);
|
|
setLoading(false);
|
|
});
|
|
}
|
|
|
|
// EXTERNAL MODULE: ./functions/frontend/clearCaches.js
|
|
var clearCaches = __webpack_require__(9137);
|
|
;// CONCATENATED MODULE: ./components/pages/login/GithubLogin.jsx
|
|
// @ts-check
|
|
/**
|
|
* ==============================================================================
|
|
* Imports
|
|
* ==============================================================================
|
|
*/
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|
/**
|
|
* ==============================================================================
|
|
* Main Component { Functional }
|
|
* ==============================================================================
|
|
* @param {Object} props - Props from getServerSideProps or getStaticProps
|
|
* @param {import("@/package-shared/types").UserType} [props.user]
|
|
* @param {React.Dispatch<React.SetStateAction<boolean>>} props.setLoading
|
|
*/ function GithubLogin({ user , setLoading }) {
|
|
/**
|
|
* Get Contexts
|
|
*
|
|
* @abstract { React.useContext }
|
|
*/ ////////////////////////////////////////////////
|
|
////////////////////////////////////////////////
|
|
////////////////////////////////////////////////
|
|
/**
|
|
* Javascript Variables
|
|
*
|
|
* @abstract Non hook variables and functions
|
|
*/ if (user?.logged_in_status) return /*#__PURE__*/ jsx_runtime_.jsx((external_react_default()).Fragment, {});
|
|
////////////////////////////////////////////////
|
|
////////////////////////////////////////////////
|
|
////////////////////////////////////////////////
|
|
/**
|
|
* React Hooks
|
|
*
|
|
* @abstract { useState, useEffect, useRef, etc ... }
|
|
*/ external_react_default().useEffect(()=>{
|
|
const urlQuery = window.location.search;
|
|
const urlQueryParams = new URLSearchParams(urlQuery);
|
|
const codeParam = urlQueryParams.get("code");
|
|
const emailParam = urlQueryParams.get("email");
|
|
if (codeParam) {
|
|
setLoading(true);
|
|
(0,frontend_fetchApi/* default */.Z)(`/api/social-login/github-auth?code=${codeParam}${emailParam ? "&email=" + emailParam : ""}`).then((res)=>{
|
|
if (!res?.success) {
|
|
if (res.msg?.match(/Github User Email not present/i)) {
|
|
const enterEmail = window.prompt(`Cannot access the email address of this github account. Please enter an email address to continue.`);
|
|
if (enterEmail && enterEmail?.match(/.*@.*\..*/) && !enterEmail?.match(/ /)) {
|
|
const newFetchUrl = `https://github.com/login/oauth/authorize?client_id=${"0729d312ff3108b79188"}&scope=user&redirect_uri=${"http://localhost:7070"}${window.location.pathname}?email=${enterEmail}`;
|
|
window.location.assign(newFetchUrl);
|
|
}
|
|
}
|
|
}
|
|
if (res?.msg && res?.alert) {
|
|
window.alert(res.msg);
|
|
}
|
|
if (res?.success && res?.user) {
|
|
localStorage.setItem("csrf", res.user.csrf_k);
|
|
localStorage.setItem("user", JSON.stringify(res.user));
|
|
(0,clearCaches/* default */.Z)().then(()=>{
|
|
window.location.reload();
|
|
});
|
|
}
|
|
setTimeout(()=>{
|
|
setLoading(false);
|
|
}, 1000);
|
|
}).catch((error)=>{
|
|
console.log(error);
|
|
setTimeout(()=>{
|
|
setLoading(false);
|
|
}, 1000);
|
|
});
|
|
}
|
|
}, []);
|
|
////////////////////////////////////////////////
|
|
////////////////////////////////////////////////
|
|
////////////////////////////////////////////////
|
|
/**
|
|
* Function Return
|
|
*
|
|
* @abstract Main Function Return
|
|
*/ return /*#__PURE__*/ jsx_runtime_.jsx("div", {
|
|
className: "w-full flex items-center justify-center",
|
|
children: /*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
|
|
className: "button outlined gray w-full more-padding small-text normal-weight gap-6",
|
|
onClick: (e)=>{
|
|
setLoading(true);
|
|
const fetchUrl = `https://github.com/login/oauth/authorize?client_id=${"0729d312ff3108b79188"}&scope=user&redirect_uri=${"http://localhost:7070"}${window.location.pathname}`;
|
|
console.log(fetchUrl);
|
|
window.location.assign(fetchUrl);
|
|
// fetch(fetchUrl, {
|
|
// headers: {
|
|
// "Access-Control-Allow-Origin": "*",
|
|
// },
|
|
// })
|
|
// .then((res) => res.json())
|
|
// .then((data) => {
|
|
// console.log(data);
|
|
// setTimeout(() => {
|
|
// setLoading(false);
|
|
// }, 1000);
|
|
// })
|
|
// .catch((error) => {
|
|
// console.log(error);
|
|
// setTimeout(() => {
|
|
// setLoading(false);
|
|
// }, 1000);
|
|
// });
|
|
setTimeout(()=>{
|
|
setLoading(false);
|
|
}, 1000);
|
|
// fetchApi(fetchUrl).then((res) => {
|
|
// console.log(res);
|
|
// setTimeout(() => {
|
|
// setLoading(false);
|
|
// }, 1000);
|
|
// });
|
|
},
|
|
children: [
|
|
/*#__PURE__*/ jsx_runtime_.jsx("img", {
|
|
src: "/images/github.png",
|
|
width: 18,
|
|
height: 18,
|
|
alt: "",
|
|
className: "flex dark:hidden"
|
|
}),
|
|
/*#__PURE__*/ jsx_runtime_.jsx("img", {
|
|
src: "/images/github-white.png",
|
|
width: 18,
|
|
height: 18,
|
|
alt: "",
|
|
className: "hidden dark:flex"
|
|
}),
|
|
/*#__PURE__*/ jsx_runtime_.jsx("span", {
|
|
children: "Login With Github"
|
|
})
|
|
]
|
|
})
|
|
});
|
|
////////////////////////////////////////////////
|
|
////////////////////////////////////////////////
|
|
////////////////////////////////////////////////
|
|
} //////////////////////////////////////////////////////////////////////////////////
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|
|
|
;// CONCATENATED MODULE: ./components/pages/login/FacebookSignInButton.jsx
|
|
/**
|
|
* ==============================================================================
|
|
* Imports
|
|
* ==============================================================================
|
|
*/ /** ********************* React/Next Imports */
|
|
|
|
|
|
/** ~ End React/Next Imports *************** */ /** ********************* Functions and Other Page Imports */ // import clearCaches from "../functions/frontend/ ";
|
|
// import { closeLoader, openLoader } from "./PageLoaderBlock";
|
|
/** ~ End Functions and Other Page Imports *************** */ /** ********************* Context Providers */ /** ~ End Context Providers *************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /**
|
|
* Main Component { Functional }
|
|
* ==============================================================================
|
|
* @param {object} props - React component props object
|
|
* @param {function(): void} props.setLoading - Props from getServerSideProps or getStaticProps
|
|
*/ function FacebookSignInButton({ setLoading }) {
|
|
/**
|
|
* Get Contexts
|
|
*
|
|
* @abstract { React.useContext }
|
|
*/ ////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
/**
|
|
* Javascript Variables
|
|
*
|
|
* @abstract Non hook variables and functions
|
|
*/ ////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
/**
|
|
* React Hooks
|
|
*
|
|
* @abstract { useState, useEffect, useRef, etc ... }
|
|
*/ let [isSignedIn, setIsSignedIn] = React.useState(false);
|
|
let [refresh, setRefresh] = React.useState(0);
|
|
React.useEffect(()=>{
|
|
// let reloads = localStorage.getItem("login_reloads");
|
|
// if (reloads && parseInt(reloads) >= 1) return;
|
|
FB.init({
|
|
appId: "2910275882608968",
|
|
cookie: true,
|
|
xfbml: true,
|
|
version: "v13.0"
|
|
});
|
|
if (isSignedIn) return;
|
|
FB.getLoginStatus((response)=>{
|
|
// console.log(response);
|
|
// if (!response.authResponse) {
|
|
// } else
|
|
if (response.status === "connected") {
|
|
// console.log("Facebook User Signed in");
|
|
setIsSignedIn(true);
|
|
userLoginWithFacebook(response, setIsSignedIn, setLoading);
|
|
} else {
|
|
setIsSignedIn(false);
|
|
}
|
|
});
|
|
}, [
|
|
refresh
|
|
]);
|
|
/**
|
|
* Function Return
|
|
*
|
|
* @abstract Main Function Return
|
|
*/ return /*#__PURE__*/ _jsx("div", {
|
|
className: "w-full",
|
|
children: /*#__PURE__*/ _jsxs("div", {
|
|
className: "w-full",
|
|
children: [
|
|
!isSignedIn && /*#__PURE__*/ _jsxs("div", {
|
|
className: "button outlined gray w-full more-padding normal-weight small-text gap-6",
|
|
onClick: ()=>{
|
|
if (setLoading) setLoading(true);
|
|
FB.login((res)=>{
|
|
if (res.status === "connected") {
|
|
setIsSignedIn(true);
|
|
userLoginWithFacebook(res, setIsSignedIn, setLoading);
|
|
} else {
|
|
if (setLoading) setLoading(false);
|
|
}
|
|
setRefresh((prev)=>prev + 1);
|
|
}, {
|
|
auth_type: "rerequest",
|
|
scope: "email,public_profile",
|
|
return_scopes: true,
|
|
enable_profile_selector: true
|
|
});
|
|
},
|
|
children: [
|
|
/*#__PURE__*/ _jsx("img", {
|
|
src: "/images/facebook.png",
|
|
width: 18,
|
|
height: 18,
|
|
alt: ""
|
|
}),
|
|
/*#__PURE__*/ _jsx("span", {
|
|
children: "Login With Facebook"
|
|
})
|
|
]
|
|
}),
|
|
isSignedIn && /*#__PURE__*/ _jsxs("div", {
|
|
className: "button outlined gray w-full pointer-events-none more-padding",
|
|
onClick: ()=>{
|
|
if (setLoading) setLoading(true);
|
|
FB.logout((res)=>{
|
|
// console.log(res);
|
|
setIsSignedIn(false);
|
|
if (setLoading) setLoading(false);
|
|
});
|
|
},
|
|
children: [
|
|
/*#__PURE__*/ _jsx("img", {
|
|
src: "/images/facebook.png",
|
|
width: 20,
|
|
alt: ""
|
|
}),
|
|
/*#__PURE__*/ _jsx("span", {
|
|
children: "Sign Out of Facebook"
|
|
})
|
|
]
|
|
})
|
|
]
|
|
})
|
|
});
|
|
////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
}
|
|
/**
|
|
* Facebook Login Function
|
|
* ==============================================================================
|
|
* @param {object} fbUser - React component props object
|
|
* @param {object} fbUser.authResponse - React component props object
|
|
* @param {function(): void} signInDispatch - Set signin status
|
|
* @param {function(): void} setLoading - Set loading function
|
|
*/ function userLoginWithFacebook(fbUser, signInDispatch, setLoading) {
|
|
console.log("LOGGING IN WITH FB ...");
|
|
if (!fbUser.authResponse) {
|
|
if (setLoading) setLoading(false);
|
|
return;
|
|
}
|
|
FB.api("/me", {
|
|
fields: "first_name,last_name,email,name,picture"
|
|
}, async (response)=>{
|
|
/**
|
|
* React Hooks
|
|
*
|
|
* @abstract { useState, useEffect, useRef, etc ... }
|
|
*/ let existingSocialId = await fetchApi(`/api/social-login/utils/checkSocialId?social_id=${response.id}&social_platform=facebook`);
|
|
/**
|
|
* React Hooks
|
|
*
|
|
* @abstract { useState, useEffect, useRef, etc ... }
|
|
*/ let finalEmail, supEmail;
|
|
if (!response.email) {
|
|
/**
|
|
* Get Email Function
|
|
* ==============================================================================
|
|
*
|
|
* @description get email from server
|
|
*/ async function getEmail() {
|
|
if (existingSocialId.social_id) {
|
|
let existingEmailExistingUser = await fetchApi(`/api/social-login/utils/getEmailFromSocialId?social_id=${response.id}&social_platform=facebook`);
|
|
finalEmail = existingEmailExistingUser.email;
|
|
return existingEmailExistingUser.email;
|
|
}
|
|
let userEmail = window.prompt("You have no email linked with this account: please Enter an email address to continue");
|
|
if (!userEmail) {
|
|
alert("Can't create account without an email address: please provide an email address for easy contact. Thanks.");
|
|
return false;
|
|
}
|
|
let isEmailValid = userEmail.match(/.*@.*\..*/);
|
|
if (!isEmailValid) {
|
|
alert("Email not valid: Please enter a valid email address");
|
|
return await getEmail();
|
|
}
|
|
let existingEmail = await fetchApi(`/api/social-login/utils/checkEmail?email=${userEmail}`);
|
|
if (existingEmail?.email) {
|
|
alert("Email already taken: please enter another email address");
|
|
return await getEmail();
|
|
} else {
|
|
supEmail = userEmail;
|
|
return userEmail;
|
|
}
|
|
}
|
|
let isEmailResolved = await getEmail();
|
|
if (isEmailResolved) {
|
|
finalEmail = isEmailResolved;
|
|
} else {
|
|
finalEmail = null;
|
|
}
|
|
} else {
|
|
finalEmail = response.email;
|
|
}
|
|
////////////////////////////////////////
|
|
if (!finalEmail) {
|
|
alert("No Email Provided, Please try again");
|
|
if (setLoading) setLoading(false);
|
|
return;
|
|
}
|
|
////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
let usernamEmail = (()=>{
|
|
if (!response.email) {
|
|
return `facebook_${response.name.toLowerCase().replace(/ /g, "-")}`;
|
|
} else {
|
|
return `facebook_${response.email.replace(/@.*/, "")}`;
|
|
}
|
|
})();
|
|
let fbUserImage = `https://graph.facebook.com/${response.id}/picture?type=large`;
|
|
let fbUserImageTiny = response.picture.data.url;
|
|
fetch(`/api/social-login/facebook-auth${window.location.search}`, {
|
|
method: "post",
|
|
headers: {
|
|
"Content-Type": "application/json"
|
|
},
|
|
body: JSON.stringify({
|
|
facebookUserId: response.id,
|
|
facebookUserImage: fbUserImage,
|
|
facebookUserFullName: response.name,
|
|
facebookUserFirstName: response.first_name,
|
|
facebookUserLastName: response.last_name,
|
|
facebookUserEmail: finalEmail,
|
|
supEmail: supEmail
|
|
})
|
|
}).then((res)=>res.json()).then(async (data)=>{
|
|
signInDispatch(true);
|
|
localStorage.setItem("user", JSON.stringify(data.user));
|
|
localStorage.setItem("csrf", JSON.stringify(data.user.csrf_k));
|
|
window.location.reload();
|
|
}).catch(async (err)=>{
|
|
console.log(err);
|
|
signInDispatch(true);
|
|
});
|
|
});
|
|
}
|
|
|
|
;// CONCATENATED MODULE: ./components/pages/login/SocialLogin.jsx
|
|
// @ts-check
|
|
/**
|
|
* ==============================================================================
|
|
* Imports
|
|
* ==============================================================================
|
|
*/
|
|
|
|
|
|
|
|
|
|
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /**
|
|
* ==============================================================================
|
|
* Main Component { Functional }
|
|
* ==============================================================================
|
|
* @param {Object} props - React component props including { children }
|
|
* @param {any} props.user
|
|
* @param {string} props.userType
|
|
* @param {React.Dispatch<React.SetStateAction<boolean>>} props.setLoading
|
|
*/ function SocialLogin({ user , userType , setLoading }) {
|
|
/**
|
|
* Get Contexts
|
|
*
|
|
* @abstract { React.useContext }
|
|
*/ if (true) {
|
|
return null;
|
|
}
|
|
////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
/**
|
|
* Javascript Variables
|
|
*
|
|
* @abstract Non hook variables and functions
|
|
*/ if (user?.logged_in_status) return /*#__PURE__*/ jsx_runtime_.jsx((external_react_default()).Fragment, {});
|
|
////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
/**
|
|
* React Hooks
|
|
*
|
|
* @abstract { useState, useEffect, useRef, etc ... }
|
|
*/ const [googleLogin, setGoogleLogin] = external_react_default().useState(false);
|
|
// const [facebookLogin, setFacebookLogin] = React.useState(false);
|
|
external_react_default().useEffect(()=>{
|
|
if (!user?.logged_in_status) {
|
|
// if (window.location.protocol.match(/https/i)) {
|
|
// const facebookScript = document.createElement("script");
|
|
// facebookScript.src = `https://connect.facebook.net/en_US/sdk.js#xfbml=1&version=v14.0&appId=${process.env.NEXT_PUBLIC_DSQL_FACEBOOK_ID}&autoLogAppEvents=1`;
|
|
// facebookScript.className = "social-script-tag";
|
|
// facebookScript.crossOrigin = "anonymous";
|
|
// document.body.appendChild(facebookScript);
|
|
// facebookScript.onload = function (e) {
|
|
// // console.log("Facebook SDK loaded");
|
|
// setFacebookLogin(true);
|
|
// };
|
|
// }
|
|
////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
const googleScript = document.createElement("script");
|
|
googleScript.src = "https://accounts.google.com/gsi/client";
|
|
googleScript.className = "social-script-tag";
|
|
document.body.appendChild(googleScript);
|
|
googleScript.onload = function(e) {
|
|
// @ts-ignore
|
|
if (google) setGoogleLogin(true);
|
|
};
|
|
////////////////////////////////////////
|
|
return function cleanup() {
|
|
document.querySelectorAll(".social-script-tag")?.forEach((scriptTag)=>{
|
|
scriptTag.parentNode?.removeChild(scriptTag);
|
|
});
|
|
};
|
|
}
|
|
}, [
|
|
user
|
|
]);
|
|
////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
/**
|
|
* Function Return
|
|
*
|
|
* @abstract Main Function Return
|
|
*/ return /*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
|
|
className: "flex flex-col items-stretch gap-3 w-full",
|
|
children: [
|
|
/*#__PURE__*/ jsx_runtime_.jsx(GithubLogin, {
|
|
user: user,
|
|
setLoading: setLoading
|
|
}),
|
|
googleLogin && /*#__PURE__*/ jsx_runtime_.jsx(GoogleIdentityButton, {
|
|
user: user,
|
|
userType: userType,
|
|
setLoading: setLoading
|
|
})
|
|
]
|
|
});
|
|
////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
}
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 9137:
|
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
|
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
/* harmony export */ "Z": () => (/* binding */ clearCaches)
|
|
/* harmony export */ });
|
|
// @ts-check
|
|
/**
|
|
* Clear Caches function
|
|
* ==============================================================================
|
|
*/ async function clearCaches() {
|
|
try {
|
|
/** Initialize
|
|
* ==============================================================================
|
|
*/ /** ********************* Variables */ const keys = await caches.keys();
|
|
if (keys[0]) {
|
|
await Promise.all(keys.map((key)=>{
|
|
return caches.delete(key);
|
|
}));
|
|
}
|
|
} catch (/** @type {any} */ error) {
|
|
console.log("Error in clearing cache =>", error.message);
|
|
}
|
|
}
|
|
|
|
|
|
/***/ })
|
|
|
|
};
|
|
; |