Skip to content

Commit

Permalink
release 0.0.4 (#10)
Browse files Browse the repository at this point in the history
* feat: add backend routes for discussions and messages (#8)

* feat: add backend routes for discussions and messages

* feat: controller description && added handleDatabaseOperation

* feat: email invitation && register with invitation (#9)
  • Loading branch information
SchneiderNicolas authored Sep 21, 2023
1 parent 70f9c3c commit e2a5035
Show file tree
Hide file tree
Showing 34 changed files with 1,117 additions and 194 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.DS_Store
6 changes: 4 additions & 2 deletions front/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import SignUp from './pages/SignUp';
import ProtectedRoute from './components/ProtectedRoute';
import Sidebar from './components/Sidebar';
import Settings from './pages/Settings';
import AcceptInvitationPage from './pages/AcceptInvitationPage';

const App = () => {
return (
Expand All @@ -16,6 +17,7 @@ const App = () => {
<Routes>
<Route path="/signin" element={<SignIn />} />
<Route path="/signup" element={<SignUp />} />
<Route path="/register" element={<AcceptInvitationPage />} />
<Route path="/" element={<ProtectedRoute />}>
<Route index element={<Home />} />
<Route path="settings" element={<Settings />} />
Expand All @@ -29,9 +31,9 @@ const App = () => {

const ConditionalSidebar = () => {
const location = useLocation();
const path = location.pathname;
const path = location.pathname.toLowerCase();

if (path === '/signin' || path === '/signup') {
if (path === '/signin' || path === '/signup' || path === '/register') {
return null;
}

Expand Down
1 change: 0 additions & 1 deletion front/src/components/TopBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ export type TopBarProps = {
};

export const TopBar = ({ toggle, isMobile }: TopBarProps) => {
// Function to handle the click event
const handleNewDiscussionClick = () => {
console.log('new discussion');
};
Expand Down
99 changes: 99 additions & 0 deletions front/src/pages/AcceptInvitationPage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
import React, { useState, useEffect } from 'react';
import { useNavigate, useLocation } from 'react-router-dom';
import Button from '../components/Button';
import Input from '../components/Input';
import config from '../config/config';

const AcceptInvitationPage = () => {
const [userName, setUserName] = useState('');
const [pass, setPass] = useState('');
const [confirmPass, setConfirmPass] = useState('');
const [signUpError, setSignUpError] = useState('');
const [email, setEmail] = useState('');
const [inviteCode, setInviteCode] = useState('');

const navigate = useNavigate();
const location = useLocation();

useEffect(() => {
const queryParams = new URLSearchParams(location.search);
setEmail(queryParams.get('email') || '');
setInviteCode(queryParams.get('inviteCode') || '');
}, [location.search]);

const onSubmit = async () => {
if (pass !== confirmPass) {
setSignUpError('Passwords do not match.');
return;
}
const response = await fetch(
`${config.API_BASE_URL}/auth/register-invite`,
{
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
inviteCode: inviteCode,
name: userName,
password: pass,
}),
},
);

const data = await response.json();

if (!response.ok) {
setSignUpError(data.message);
return;
} else {
navigate('/signin');
}
};

return (
<div className="flex flex-col justify-center items-center h-screen">
<div className="px-12 py-12 shadow bg-white rounded-md flex flex-col gap-6">
<h1 className="text-2xl font-bold text-gray-600 text-center mb-2">
Complete Your Registration
</h1>
<p className="text-md text-gray-600 text-center mb-4">{email}</p>
<Input
placeholder="Username"
onChange={(e) => {
setUserName(e.target.value);
}}
id="input_username"
/>
<Input
placeholder="Password"
type="password"
onChange={(e) => {
setPass(e.target.value);
}}
id="input_password"
/>
<Input
placeholder="Confirm Password"
type="password"
onChange={(e) => {
setConfirmPass(e.target.value);
}}
id="input_confirm_password"
/>
<p
className={`text-red-600 text-center text-sm -mt-2 capitalize ${
signUpError ? 'animate-shake' : 'invisible'
}`}
>
{signUpError || 'invisible'}
</p>
<Button type="button" className="-mt-2" onClick={onSubmit}>
Confirm
</Button>
</div>
</div>
);
};

export default AcceptInvitationPage;
14 changes: 7 additions & 7 deletions front/src/pages/SignIn.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,17 @@ const SignIn = () => {
<div className="flex flex-col justify-center items-center h-screen">
<div className="px-12 py-12 shadow bg-white rounded-md flex flex-col gap-6">
<h1 className="text-2xl font-bold text-gray-600 text-center mb-4">
Connectez-vous à votre compte
Sign in to your account
</h1>
<Input
placeholder="E-mail"
placeholder="Email"
onChange={(e) => {
setEmail(e.target.value);
}}
id="input_email"
/>
<Input
placeholder="Mot de passe"
placeholder="Password"
type="password"
onChange={(e) => {
setPass(e.target.value);
Expand All @@ -62,15 +62,15 @@ const SignIn = () => {
loginError ? 'animate-shake' : 'invisible'
}`}
>
Identifiants incorrects. Veuillez réessayer.
Incorrect credentials. Please try again.
</p>
<Button type="button" className="-mt-2" onClick={onSubmit}>
Connexion
Login
</Button>
<p className="mt-1 text-sm text-center text-gray-400">
Vous n&apos;avez pas de compte ?{' '}
Don't have an account?{' '}
<a href="/signup" className="text-violet-500 underline">
Créez-en un ici
Create one here
</a>
.
</p>
Expand Down
18 changes: 9 additions & 9 deletions front/src/pages/SignUp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,56 +43,56 @@ const SignUpPage = () => {
<div className="flex flex-col justify-center items-center h-screen">
<div className="px-12 py-12 shadow bg-white rounded-md flex flex-col gap-6">
<h1 className="text-2xl font-bold text-gray-600 text-center mb-4">
Créez votre compte
Create your account
</h1>
<Input
placeholder="Nom d'utilisateur"
placeholder="Username"
onChange={(e) => {
setUserName(e.target.value);
}}
id="input_username"
/>
<Input
placeholder="E-mail"
placeholder="Email"
onChange={(e) => {
setUserEmail(e.target.value);
}}
id="input_email"
type="email"
/>
<Input
placeholder="Mot de passe"
placeholder="Password"
type="password"
onChange={(e) => {
setPass(e.target.value);
}}
id="input_password"
/>
<Input
placeholder="Confirmez le mot de passe"
placeholder="Confirm password"
type="password"
onChange={(e) => {
setConfirmPass(e.target.value);
}}
id="input_confirm_password"
/>
<p
className={`text-red-600 text-center text-sm -mt-2 capitalize ${
className={`text-red-600 text-center text-sm -mt-2 ${
signUpError ? 'animate-shake' : 'invisible'
}`}
>
{signUpError || 'invisible'}
</p>
<Button type="button" className="-mt-2" onClick={onSubmit}>
Inscription
Sign Up
</Button>
<p className="mt-1 text-sm text-center text-gray-400">
Vous avez déjà un compte ?{' '}
Already have an account?{' '}
<a
href="/signin"
className="text-violet-500 underline cursor-pointer"
>
Connectez-vous ici
Sign in here
</a>
.
</p>
Expand Down
71 changes: 71 additions & 0 deletions server/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit e2a5035

Please sign in to comment.