Skip to content

Commit

Permalink
Standardize the width of identity views (#151)
Browse files Browse the repository at this point in the history
  • Loading branch information
byn9826 authored Sep 12, 2024
1 parent 5848d93 commit 962cab6
Show file tree
Hide file tree
Showing 9 changed files with 132 additions and 124 deletions.
39 changes: 19 additions & 20 deletions server/src/views/AuthorizeAccount.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,15 @@ const AuthorizeAccount = ({
<Layout
locales={locales}
logoUrl={logoUrl}
locale={queryDto.locale}>
locale={queryDto.locale}
>
<Title title={localeConfig.authorizeAccount.title[queryDto.locale]} />
<SubmitError />
<form
autocomplete='on'
onsubmit='return handleSubmit(event)'
>
<section class='flex-col gap-4'>
<section class='flex-col gap-2'>
<Field
label={localeConfig.authorizeAccount.email[queryDto.locale]}
type='email'
Expand All @@ -64,9 +66,7 @@ const AuthorizeAccount = ({
name='confirmPassword'
/>
{enableNames && (
<section
id='row-names'
class='flex-row gap-4'>
<>
<Field
label={localeConfig.authorizeAccount.firstName[queryDto.locale]}
type='text'
Expand All @@ -79,9 +79,8 @@ const AuthorizeAccount = ({
required={namesIsRequired}
name='lastName'
/>
</section>
</>
)}
<SubmitError />
<SubmitButton
title={localeConfig.authorizeAccount.signUp[queryDto.locale]}
/>
Expand Down Expand Up @@ -118,7 +117,7 @@ const AuthorizeAccount = ({
</section>
</form>
<a
class='button-text mt-4'
class='button-text'
href={`${routeConfig.InternalRoute.Identity}/authorize-password?${queryString}`}
>
{localeConfig.authorizeAccount.signIn[queryDto.locale]}
Expand All @@ -138,18 +137,18 @@ const AuthorizeAccount = ({
${enableNames && namesIsRequired ? validateScript.firstName(queryDto.locale) : ''}
${enableNames && namesIsRequired ? validateScript.lastName(queryDto.locale) : ''}
fetch('${routeConfig.InternalRoute.Identity}/authorize-account', {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify({
firstName: document.getElementById('form-firstName') ? document.getElementById('form-firstName').value : undefined,
lastName: document.getElementById('form-lastName') ? document.getElementById('form-lastName').value : undefined,
email: document.getElementById('form-email').value,
password: document.getElementById('form-password').value,
${requestScript.parseAuthorizeBaseValues(queryDto)}
})
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify({
firstName: document.getElementById('form-firstName') ? document.getElementById('form-firstName').value : undefined,
lastName: document.getElementById('form-lastName') ? document.getElementById('form-lastName').value : undefined,
email: document.getElementById('form-email').value,
password: document.getElementById('form-password').value,
${requestScript.parseAuthorizeBaseValues(queryDto)}
})
})
.then((response) => {
${responseScript.parseRes()}
Expand Down
2 changes: 1 addition & 1 deletion server/src/views/AuthorizeEmailMfa.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const AuthorizeEmailMfa = ({
locale={queryDto.locale}
>
<h1 class='w-text text-center'>{localeConfig.authorizeEmailMfa.title[queryDto.locale]}</h1>
<SubmitError />
<form
onsubmit='return handleSubmit(event)'
>
Expand All @@ -45,7 +46,6 @@ const AuthorizeEmailMfa = ({
>
{localeConfig.authorizeEmailMfa.resend[queryDto.locale]}
</button>
<SubmitError />
<SubmitButton
title={localeConfig.authorizeEmailMfa.verify[queryDto.locale]}
/>
Expand Down
32 changes: 17 additions & 15 deletions server/src/views/AuthorizeMfaEnroll.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,37 +23,39 @@ const AuthorizeMfaEnroll = ({
locale={queryDto.locale}
>
<Title title={localeConfig.authorizeMfaEnroll.title[queryDto.locale]} />
<SubmitError />
<section class='flex-row justify-around w-full gap-8 mt-4'>
<button
class='button w-half'
type='button'
onclick='handleSelect("email")'>
onclick='handleSelect("email")'
>
{localeConfig.authorizeMfaEnroll.email[queryDto.locale]}
</button>
<button
class='button w-half'
type='button'
onclick='handleSelect("otp")'>
onclick='handleSelect("otp")'
>
{localeConfig.authorizeMfaEnroll.otp[queryDto.locale]}
</button>
</section>
<SubmitError />
{html`
<script>
function handleSelect(type) {
fetch('${routeConfig.InternalRoute.Identity}/authorize-mfa-enroll', {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify({
state: "${queryDto.state}",
code: "${queryDto.code}",
redirectUri: "${queryDto.redirectUri}",
locale: "${queryDto.locale}",
type
})
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify({
state: "${queryDto.state}",
code: "${queryDto.code}",
redirectUri: "${queryDto.redirectUri}",
locale: "${queryDto.locale}",
type
})
})
.then((response) => {
${responseScript.parseRes()}
Expand Down
26 changes: 13 additions & 13 deletions server/src/views/AuthorizeOtpMfa.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ const AuthorizeOtpMfa = ({
<canvas id='qr-code' />
</>
)}
<SubmitError />
<form
onsubmit='return handleSubmit(event)'
>
Expand All @@ -56,7 +57,6 @@ const AuthorizeOtpMfa = ({
{localeConfig.authorizeOtpMfa.switchToEmail[queryDto.locale]}
</button>
)}
<SubmitError />
<SubmitButton
title={localeConfig.authorizeOtpMfa.verify[queryDto.locale]}
/>
Expand All @@ -76,18 +76,18 @@ const AuthorizeOtpMfa = ({
e.preventDefault();
${validateScript.verificationOtp(queryDto.locale)}
fetch('${routeConfig.InternalRoute.Identity}/authorize-otp-mfa', {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify({
state: "${queryDto.state}",
code: "${queryDto.code}",
locale: "${queryDto.locale}",
redirectUri: "${queryDto.redirectUri}",
mfaCode: document.getElementById('form-otp').value,
})
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify({
state: "${queryDto.state}",
code: "${queryDto.code}",
locale: "${queryDto.locale}",
redirectUri: "${queryDto.redirectUri}",
mfaCode: document.getElementById('form-otp').value,
})
})
.then((response) => {
${responseScript.parseRes()}
Expand Down
44 changes: 22 additions & 22 deletions server/src/views/AuthorizePassword.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,12 @@ const AuthorizePassword = ({
</script>
)}
<Title title={localeConfig.authorizePassword.title[queryDto.locale]} />
<SubmitError />
<form
autocomplete='on'
onsubmit='return handleSubmit(event)'
>
<section class='flex-col gap-4'>
<section class='flex-col gap-2'>
{enablePasswordSignIn && (
<>
<Field
Expand All @@ -64,7 +65,6 @@ const AuthorizePassword = ({
/>
</>
)}
<SubmitError />
{enablePasswordSignIn && (
<SubmitButton
title={localeConfig.authorizePassword.submit[queryDto.locale]}
Expand Down Expand Up @@ -95,7 +95,7 @@ const AuthorizePassword = ({
</section>
</form>
{(enableSignUp || enablePasswordReset) && (
<section class='flex-col gap-2 mt-4'>
<section class='flex-col gap-4'>
{enableSignUp && (
<a
class='button-text'
Expand All @@ -121,15 +121,15 @@ const AuthorizePassword = ({
function handleGoogleSignIn (response) {
if (!response.credential) return false;
fetch('${routeConfig.InternalRoute.Identity}/authorize-google', {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify({
credential: response.credential,
${requestScript.parseAuthorizeBaseValues(queryDto)}
})
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify({
credential: response.credential,
${requestScript.parseAuthorizeBaseValues(queryDto)}
})
})
.then((response) => {
${responseScript.parseRes()}
Expand All @@ -146,16 +146,16 @@ const AuthorizePassword = ({
${validateScript.email(queryDto.locale)}
${validateScript.password(queryDto.locale)}
fetch('${routeConfig.InternalRoute.Identity}/authorize-password', {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify({
email: document.getElementById('form-email').value,
password: document.getElementById('form-password').value,
${requestScript.parseAuthorizeBaseValues(queryDto)}
})
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify({
email: document.getElementById('form-email').value,
password: document.getElementById('form-password').value,
${requestScript.parseAuthorizeBaseValues(queryDto)}
})
})
.then((response) => {
${responseScript.parseRes()}
Expand Down
17 changes: 7 additions & 10 deletions server/src/views/AuthorizeReset.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
import Title from 'views/components/Title'
import Field from 'views/components/Field'
import { oauthDto } from 'dtos'
import SubmitButton from 'views/components/SubmitButton'

const AuthorizeReset = ({
logoUrl, queryString, queryDto, locales,
Expand Down Expand Up @@ -45,6 +46,7 @@ const AuthorizeReset = ({
>
<Title title={localeConfig.authorizeReset.title[queryDto.locale]} />
<p class='mb-4 text-center w-text'>{localeConfig.authorizeReset.desc[queryDto.locale]}</p>
<SubmitError />
<form
onsubmit='return handleSubmit(event)'
>
Expand Down Expand Up @@ -84,18 +86,13 @@ const AuthorizeReset = ({
name='confirmPassword'
className='hidden'
/>
<SubmitError />
<button
id='submit-btn'
class='button mt-4'
type='submit'
>
{localeConfig.authorizeReset.send[queryDto.locale]}
</button>
<SubmitButton
title={localeConfig.authorizeReset.send[queryDto.locale]}
/>
</section>
</form>
<a
class='button-text mt-4'
class='button-text'
href={`${routeConfig.InternalRoute.Identity}/authorize-password?${queryString}`}
>
{localeConfig.authorizeReset.backSignIn[queryDto.locale]}
Expand Down Expand Up @@ -163,7 +160,7 @@ const AuthorizeReset = ({
document.getElementById('resend-btn').classList.remove('hidden');
document.getElementById('password-row').classList.remove('hidden');
document.getElementById('confirmPassword-row').classList.remove('hidden');
document.getElementById('submit-btn').innerHTML = '${localeConfig.authorizeReset.reset[queryDto.locale]}'
document.getElementById('submit-button').innerHTML = '${localeConfig.authorizeReset.reset[queryDto.locale]}'
})
.catch((error) => {
${responseScript.handleSubmitError(queryDto.locale)}
Expand Down
24 changes: 12 additions & 12 deletions server/src/views/VerifyEmail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,17 @@ const VerifyEmail = ({
class='flex-col items-center gap-4'
>
<Title title={localeConfig.verifyEmail.title[queryDto.locale]} />
<p class='mb-4 w-text text-center'>{localeConfig.verifyEmail.desc[queryDto.locale]}</p>
<p class='mb-2 w-text text-center'>{localeConfig.verifyEmail.desc[queryDto.locale]}</p>
<SubmitError />
<form
onsubmit='return handleSubmit(event)'
>
<section class='flex-col gap-4'>
<section class='flex-col gap-2'>
<Field
type='text'
required={false}
name='code'
/>
<SubmitError />
<SubmitButton
title={localeConfig.verifyEmail.verify[queryDto.locale]}
/>
Expand All @@ -62,15 +62,15 @@ const VerifyEmail = ({
e.preventDefault();
${validateScript.verificationCode(queryDto.locale)}
fetch('${routeConfig.InternalRoute.Identity}/verify-email', {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify({
code: document.getElementById('form-code').value,
id: '${queryDto.id}',
})
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify({
code: document.getElementById('form-code').value,
id: '${queryDto.id}',
})
})
.then((response) => {
${responseScript.parseRes()}
Expand Down
Loading

0 comments on commit 962cab6

Please sign in to comment.