Skip to content

Commit

Permalink
feat: Merge pull request #2 from DISIC/preprod
Browse files Browse the repository at this point in the history
Preprod
  • Loading branch information
HamzaKhait authored Mar 19, 2024
2 parents cb98047 + 71f1e7a commit bdc2e36
Show file tree
Hide file tree
Showing 6 changed files with 345 additions and 71 deletions.
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

0 comments on commit bdc2e36

Please sign in to comment.