Skip to content

Commit

Permalink
Merge branch 'working' into pr/Fefedu973/44
Browse files Browse the repository at this point in the history
  • Loading branch information
Truiteseche committed Nov 11, 2024
2 parents fece5a6 + 95f63d4 commit 3366296
Show file tree
Hide file tree
Showing 12 changed files with 781 additions and 635 deletions.
30 changes: 26 additions & 4 deletions src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ function consoleLogEDPLogo() {
consoleLogEDPLogo();

const currentEDPVersion = "0.4.0";
const apiVersion = "4.60.5";
const apiVersion = "4.64.0";

// secret webhooks
const carpeConviviale = "CARPE_CONVIVIALE_WEBHOOK_URL";
Expand Down Expand Up @@ -273,6 +273,7 @@ export default function App({ edpFetch }) {
const [isTabletLayout, setIsTabletLayout] = useState(() => window.matchMedia(`(max-width: ${WINDOW_WIDTH_BREAKPOINT_TABLET_LAYOUT}px)`).matches);
const [isFullScreen, setIsFullScreen] = useState(false);
const [isEDPUnblockInstalled, setIsEDPUnblockInstalled] = useState(true);
const [isEDPUnblockActuallyInstalled, setIsEDPUnblockActuallyInstalled] = useState(false);
const [isStandaloneApp, setIsStandaloneApp] = useState(((window.navigator.standalone ?? false) || window.matchMedia('(display-mode: standalone)').matches)); // détermine si l'utilisateur a installé le site comme application, permet également de modifier le layout en conséquence
const [appKey, setAppKey] = useState(() => crypto.randomUUID());
const [proxyError, setProxyError] = useState(false); // en cas d'erreur sur le serveur proxy d'EDP (toutes les requêtes passent par lui pour contourner les restrictions d'EcoleDirecte)
Expand Down Expand Up @@ -517,6 +518,20 @@ export default function App({ edpFetch }) {
localStorage.setItem("oldActiveAccount", activeAccount)
}, [activeAccount]);

useEffect(() => {
const handleMessage = (event) => {
if (event.data.type === "EDP_UNBLOCK") {
console.log("EDP Unblock v" + event.data.payload.version + " installed");
setIsEDPUnblockActuallyInstalled(true);
}
};

window.addEventListener("message", handleMessage, false);
return () => {
window.removeEventListener("message", handleMessage, false);
}
}, [])

// fonctions de type utils pour modifier le userData
function changeUserData(data, value) {
setUserData((oldData) => {
Expand Down Expand Up @@ -1442,7 +1457,12 @@ export default function App({ edpFetch }) {
}
let token = response.token // collecte du token
let accountsList = [];
let accounts = response.data.accounts[0];
let accounts = response.data.accounts.find((account) => account.typeCompte !== "P") ?? response.data.accounts[0];
if (response.data.accounts.some((account) => account.typeCompte === "P")) {
messages.submitButtonText = "Échec de la connexion";
messages.submitErrorMessage = "Les comptes enseignants ne sont pas supportés par Ecole Directe Plus";
return;
}
const accountType = accounts.typeCompte; // collecte du type de compte
if (accountType === "E") {
// compte élève
Expand Down Expand Up @@ -2549,6 +2569,8 @@ export default function App({ edpFetch }) {
handleEdBan={handleEdBan}
isEDPUnblockInstalled={isEDPUnblockInstalled}
setIsEDPUnblockInstalled={setIsEDPUnblockInstalled}
isEDPUnblockActuallyInstalled={isEDPUnblockActuallyInstalled}
setIsEDPUnblockActuallyInstalled={setIsEDPUnblockActuallyInstalled}
requireA2F={requireA2F}
setRequireA2F={setRequireA2F}
fetchA2F={fetchA2F}
Expand All @@ -2568,7 +2590,7 @@ export default function App({ edpFetch }) {
path: "feedback",
},
{
element: <EdpUnblock />,
element: <EdpUnblock isEDPUnblockActuallyInstalled={isEDPUnblockActuallyInstalled} />,
path: "edp-unblock",
},
{
Expand All @@ -2588,7 +2610,7 @@ export default function App({ edpFetch }) {
path: "unsubscribe-emails",
},
{
element: <Login keepLoggedIn={keepLoggedIn} setKeepLoggedIn={setKeepLoggedIn} A2FInfo={A2FInfo} setRequireA2F={setRequireA2F} bufferUserIds={bufferUserIds} fetchLogin={fetchLogin} logout={logout} loginFromOldAuthInfo={loginFromOldAuthInfo} currentEDPVersion={currentEDPVersion} />,
element: <Login keepLoggedIn={keepLoggedIn} setKeepLoggedIn={setKeepLoggedIn} A2FInfo={A2FInfo} setRequireA2F={setRequireA2F} bufferUserIds={bufferUserIds} fetchLogin={fetchLogin} logout={logout} loginFromOldAuthInfo={loginFromOldAuthInfo} isEDPUnblockInstalledActuallyInstalled={isEDPUnblockActuallyInstalled} currentEDPVersion={currentEDPVersion} />,
path: "login",
},
{
Expand Down
13 changes: 10 additions & 3 deletions src/components/EdpUnblock/EdpUnblock.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import AboutArrow from "../graphics/AboutArrow";

import "./EdpUnblock.css";
import { getZoomedBoudingClientRect } from "../../utils/zoom";
import BadgeCheck from "../graphics/BadgeCheck";


const browserLogosInfos = {
Expand Down Expand Up @@ -59,7 +60,7 @@ console.log("userOS:", userOS, "userBrowser:", userBrowser);

const compatibilityCondition = ((userOS === "iOS" && nonCompatibleIOSBrowsers.includes(userBrowser)) || (userOS === "Android" && nonCompatibleAndroidBrowsers.includes(userBrowser)) || (userOS === "MacOS" && userBrowser === "Safari"));

export default function EdpUnblock() {
export default function EdpUnblock({ isEDPUnblockActuallyInstalled }) {
const location = useLocation();

const aboutRef = useRef(null);
Expand Down Expand Up @@ -124,8 +125,14 @@ export default function EdpUnblock() {
{compatibilityCondition && (userOS !== "iOS" ? <><p>Malheureusement, l'extension Ecole Directe Plus Unblock n'est pas disponible sur votre navigateur. 😥</p><p>S'il vous plaît considérez l'usage d'un navigateur compatible comme le <a href={userOS === "iOS" ? "https://apps.apple.com/app/id1484498200" : "https://play.google.com/store/apps/details?id=org.mozilla.firefox"} className="suggested-browser" target="_blank">{userOS === "iOS" ? "navigateur Orion" : "navigateur Firefox"}</a>.</p></> : <p>Malheureusement, l'extension Ecole Directe Plus Unblock n'est pas compatible avec les navigateurs sur iOS et iPadOS. S'il vous plaît, considérez l'usage d'un autre appareil avec un système d'exploitation compatible comme un ordinateur sous Windows ou Linux, ou un appareil mobile sous Android.</p>) }
<a href={browserLogosInfos[userBrowser] && browserLogosInfos[userBrowser].url} target={userBrowser === "Firefox" ? "_self" : "_blank"} className={`edpu-download-link ${compatibilityCondition ? "disabled" : ""} ${browserLogosInfos[userBrowser] && browserLogosInfos[userBrowser].available ? "available" : "unavailable"}`}>
{browserLogosInfos[userBrowser] && browserLogosInfos[userBrowser].logo}
{compatibilityCondition ? <span>Navigateur incompatible</span> : <span>Ajouter l’extension</span>}
{compatibilityCondition ? <div className="download-unavailable"></div> : <DownloadIcon />}
{isEDPUnblockActuallyInstalled
? <span>Extension installée</span>
: (compatibilityCondition ? <span>Navigateur incompatible</span> : <span>Ajouter l’extension</span>)
}
{isEDPUnblockActuallyInstalled
? <BadgeCheck />
: (compatibilityCondition ? <div className="download-unavailable"></div> : <DownloadIcon />)
}
</a>
</div>
<Link ref={aboutButtonRef} to="#about" className="edpu-about-link" replace onClick={() => { location.hash === "#about" && scrollToAbout() }}>
Expand Down
Loading

0 comments on commit 3366296

Please sign in to comment.