-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #324 from recogito/develop
Merge to main
- Loading branch information
Showing
208 changed files
with
7,233 additions
and
2,896 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
.accept-org-invite h1 { | ||
margin-top: 0; | ||
} | ||
|
||
.accept-org-invite .input-wrapper + .input-wrapper { | ||
margin-left: 0; | ||
margin-top: 1em; | ||
} | ||
|
||
.accept-org-invite :is(button, a.button) { | ||
margin-top: 2em; | ||
} | ||
|
||
.accept-org-invite .error { | ||
font-size: var(--font-tiny); | ||
color: var(--red-500); | ||
} | ||
|
||
.accept-org-invite .success { | ||
text-align: center; | ||
} | ||
|
||
.accept-org-invite .success p { | ||
font-size: var(--font-small); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
import { useState } from 'react'; | ||
import { WarningOctagon } from '@phosphor-icons/react'; | ||
import { TextInput } from '@components/TextInput'; | ||
import type { ApiAcceptOrgInvite, Translations } from 'src/Types'; | ||
import { Button } from '@components/Button'; | ||
import { supabase } from '@backend/supabaseBrowserClient'; | ||
import { AnimatedCheck } from '@components/AnimatedIcons'; | ||
|
||
import './AcceptOrgInvite.css'; | ||
|
||
interface AcceptOrgInviteProps { | ||
i18n: Translations; | ||
token: string; | ||
} | ||
|
||
export const AcceptOrgInviteComponent = (props: AcceptOrgInviteProps) => { | ||
const { t } = props.i18n; | ||
|
||
const [password, setPassword] = useState(''); | ||
|
||
const [email, setEmail] = useState(''); | ||
|
||
const [verification, setVerification] = useState(''); | ||
|
||
const [busy, setBusy] = useState(false); | ||
|
||
const [error, setError] = useState(''); | ||
|
||
const [success, setSuccess] = useState(false); | ||
|
||
const onAcceptOrgInvite = (evt: React.MouseEvent) => { | ||
evt.preventDefault(); | ||
|
||
if (password !== verification) { | ||
setError(t["Passwords don't match"]); | ||
} else { | ||
setBusy(true); | ||
|
||
const payload: ApiAcceptOrgInvite = { | ||
email, | ||
password, | ||
token: props.token, | ||
}; | ||
|
||
console.log(props.token); | ||
|
||
fetch('/api/accept-new-user', { | ||
method: 'POST', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
body: JSON.stringify(payload), | ||
}).then((response) => { | ||
if (!response.ok) { | ||
console.error(response.status); | ||
setError(t['Could not set new password']); | ||
} else { | ||
setSuccess(true); | ||
} | ||
setBusy(false); | ||
}); | ||
} | ||
}; | ||
|
||
return ( | ||
<div className='accept-org-invite'> | ||
{success ? ( | ||
<main> | ||
<div className='success'> | ||
<AnimatedCheck size={38} /> | ||
<p> | ||
{t['Credentials updated.']}{' '} | ||
<a href={`/${props.i18n.lang}/sign-in`}>{t['Login']}</a> | ||
</p> | ||
</div> | ||
</main> | ||
) : ( | ||
<main> | ||
<h1>{t['Set Password']}</h1> | ||
<form className='login'> | ||
<TextInput | ||
type='text' | ||
autoComplete={false} | ||
id='email' | ||
name='email' | ||
label={t['Your email address']} | ||
className='lg w-full' | ||
onChange={setEmail} | ||
/> | ||
<TextInput | ||
type='password' | ||
autoComplete={false} | ||
id='password' | ||
name='password' | ||
label={t['Enter new password']} | ||
className='lg w-full' | ||
onChange={setPassword} | ||
/> | ||
|
||
<TextInput | ||
type='password' | ||
autoComplete={false} | ||
id='verification' | ||
name='verification' | ||
label={t['Confirm password']} | ||
className='lg w-full' | ||
error={Boolean(error)} | ||
onChange={setVerification} | ||
/> | ||
|
||
{error && ( | ||
<p className='error'> | ||
<WarningOctagon | ||
className='icon text-bottom' | ||
size={18} | ||
weight='fill' | ||
/>{' '} | ||
{error} | ||
</p> | ||
)} | ||
|
||
<Button | ||
busy={busy} | ||
className='primary lg w-full' | ||
onClick={onAcceptOrgInvite} | ||
> | ||
<span>{t['Set Password']}</span> | ||
</Button> | ||
</form> | ||
</main> | ||
)} | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './AcceptOrgInvite'; |
Oops, something went wrong.