Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preprod #2

Merged
merged 7 commits into from
Mar 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ jobs:
with:
node-version: 20
- run: npm ci --force
- run: npm run build
- run: npm run build:$(git branch --show-current)
- run: tar -czvf wce-portail.tar.gz -C dist .
- run: npx semantic-release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
77 changes: 44 additions & 33 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
import Home from './pages/home/Home';
import Layout from './components/layout/Layout';
import { useState, useEffect, ReactNode } from 'react';
import { Routes, Route, useNavigate, Navigate, useParams } from 'react-router-dom';
import {
Routes,
Route,
useNavigate,
Navigate,
useParams,
} from 'react-router-dom';
import FAQ from './pages/FAQ/FAQ.md';
import DonneesPerso from './pages/DonneesPerso/DonneesPerso.md';
import Contact from './pages/Contact/Contact.md';
Expand Down Expand Up @@ -47,9 +53,9 @@ function App() {
const [participantsNumber, setparticipantsNumber] = useState(0);
const [msg, setMsg] = useState<ReactNode>(<></>);

const sendEmail = (room: string) => {
const sendEmail = (roomName: string) => {
api
.post('conference/create/byemail', { conference: room, email: email })
.post('conference/create/byemail', { roomName, email: email })
.then(res => {
if (res.data.error) {
setError({
Expand Down Expand Up @@ -184,47 +190,44 @@ function App() {

const Wrapper = () => {
const { roomName } = useParams();

if (isAlphanumeric(roomName)) {
return <Jitsi_meet
joinConference={joinConference}
setError={setError}
setMsg={setMsg}
setRoomName={setRoomName}
/>;
}
// else {
return (
<Jitsi_meet
joinConference={joinConference}
setError={setError}
setMsg={setMsg}
setRoomName={setRoomName}
/>
);
}
// else {
// return <Navigate to={`/${roomName}`} />;
// }
return <></>
return <></>;
};

const OtherRoutes = () => {
api
.get(`/backend/${window.location.href}`)
.then(res => {
<Navigate to={`/${roomName}`} replace={true} />;
// window.location.href = `/${roomName}`;
return window.location.reload();
})
.catch(res => {
<Navigate to={`/error`} replace={true} />;
// window.location.href = `/error`;
return window.location.reload();
})
.get(`/backend/${window.location.href}`)
.then(res => {
<Navigate to={`/${roomName}`} replace={true} />;
// window.location.href = `/${roomName}`;
return window.location.reload();
})
.catch(res => {
<Navigate to={`/error`} replace={true} />;
// window.location.href = `/error`;
return window.location.reload();
});

return <></>
return <></>;
};

return (
<MuiDsfrThemeProvider>
<Routes>
<Route
path=":roomName"
element={
<Wrapper/>
}
/>
<Route path=":roomName" element={<Wrapper />} />
<Route
path="login_callback"
element={
Expand Down Expand Up @@ -269,7 +272,15 @@ function App() {
/>
}
/>
<Route path="/wce-api/*" element={<Navigate to={`/${import.meta.env.VITE_BASE_URL}`} replace={true} />} />
<Route
path="/wce-api/*"
element={
<Navigate
to={`/${import.meta.env.VITE_BASE_URL}`}
replace={true}
/>
}
/>
<Route path="error" element={<Error error={error} />} />
<Route path="feedback" element={<Feedback setError={setError} />} />
<Route path="browser_test" element={<BrowserTest />} />
Expand Down
78 changes: 44 additions & 34 deletions src/components/header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,40 +25,50 @@ function HeaderComponent({
const [msg, setMsg] = useState<any>();

const logOut = () => {
api
.get('/auth/logout')
.then(res => {
if (res.data.error) {
localStorage.setItem('auth', 'false');
setAuthenticated(false);
navigate('/');
} else {
open(res.data, '_self');
}
})
.catch(error => {
if (error.response) {
setMsg(
<Badge noIcon severity="error">
une erreur est survenue lors de la déconnexion
</Badge>
);
} else {
if (error.request) {
setError({
message: 'une erreur est survenue lors de la déconnexion',
error: { status: '', stack: '' },
});
navigate('/error');
} else {
setError({
message: 'une erreur est survenue lors de la déconnexion',
error: { status: '', stack: '' },
});
navigate('/error');
}
}
});
fetch(`${import.meta.env.VITE_BASE_URL}/authentication/logout`, {
redirect: 'manual',
}).then(res => {
if (res.type === 'opaqueredirect') {
window.location.href = res.url;
} else {
// handle normally / pass on to next handler
window.location.href = res.url;
}
});
// api
// .get('/authentication/logout')
// .then(res => {
// if (res.data.error) {
// localStorage.setItem('auth', 'false');
// setAuthenticated(false);
// navigate('/');
// } else {
// open(res.data, '_self');
// }
// })
// .catch(error => {
// if (error.response) {
// setMsg(
// <Badge noIcon severity="error">
// une erreur est survenue lors de la déconnexion
// </Badge>
// );
// } else {
// if (error.request) {
// setError({
// message: 'une erreur est survenue lors de la déconnexion',
// error: { status: '', stack: '' },
// });
// navigate('/error');
// } else {
// setError({
// message: 'une erreur est survenue lors de la déconnexion',
// error: { status: '', stack: '' },
// });
// navigate('/error');
// }
// }
// });
};
return (
<div className={styles.parent}>
Expand Down
Loading
Loading