Skip to content

Commit

Permalink
Merge pull request #415 from HarperDB/stage
Browse files Browse the repository at this point in the history
Auth Flow Fixes
  • Loading branch information
BboyAkers authored Nov 13, 2024
2 parents ae010b2 + 178866b commit 244afa3
Show file tree
Hide file tree
Showing 9 changed files with 62 additions and 57 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "harperdb-studio",
"version": "4.7.0",
"version": "4.7.1",
"description": "A UI for HarperDB",
"deploymentUrl": "studio.harperdb.io",
"private": true,
Expand Down
3 changes: 3 additions & 0 deletions src/assets/styles/components/_error-boundary.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
.w-400 {
width: 400px;
}
.error-boundary {
font-size: $font-size-small;
overflow: hidden;
Expand Down
4 changes: 4 additions & 0 deletions src/assets/styles/pages/_auth.scss
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@
}
}

.auth-centered-container {
height: calc(100% - 135px);
}

.auth-form-container {
background-color: $color-darkpurple;
}
Expand Down
1 change: 1 addition & 0 deletions src/components/auth/ResetPassword.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ function ResetPassword() {
className="border-0 rounded-pill btn-gradient-blue"
title="Send Password Reset Email"
block
type="submit"
color="purple"
>
Send Password Reset Email
Expand Down
2 changes: 1 addition & 1 deletion src/components/auth/SignIn.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ function SignIn() {
placeholder="password"
/>
</Label>
<Button id="signIn" className="border-0 rounded-pill btn-gradient-blue" onClick={submit} title="Sign In My Account" block disabled={formState.submitted}>
<Button id="signIn" type="submit" className="border-0 rounded-pill btn-gradient-blue" onClick={submit} title="Sign In My Account" block disabled={formState.submitted}>
Sign In
</Button>
</Form>
Expand Down
1 change: 1 addition & 0 deletions src/components/auth/SignUp.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ function SignUp() {
<Button
id="sign-up"
block
type="submit"
className="border-0 rounded-pill btn-gradient-blue"
disabled={formState.submitted} onClick={() => setFormState({ submitted: true })}
>
Expand Down
52 changes: 21 additions & 31 deletions src/components/auth/UpdatePassword.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useEffect, useState } from 'react';
import { Card, CardBody, Input, Button } from 'reactstrap';
import { Label, Input, Button } from 'reactstrap';
import { useNavigate } from 'react-router-dom';
import { useStoreState } from 'pullstate';

Expand All @@ -18,7 +18,7 @@ function UpdatePassword() {

const setPasswordError = () => {
setFormData({});
setTimeout(() => setFormState({ error: '8 char min., 1 lower case, 1 upper case, 1 number, 1 special char.' }), 0);
setFormState({ error: true });
};

// NOTE: Marketing requested to send a conversion event when this page is
Expand Down Expand Up @@ -51,44 +51,34 @@ function UpdatePassword() {
}
};

// eslint-disable-next-line
useEffect(() => !formState.submitted && setFormState({}), [formData]);

return (
<div id="login-form">
{formState.processing ? (
<Loader header="setting account password" spinner relative />
) : (
<>
<Card className="mb-3">
<CardBody onKeyDown={(e) => e.keyCode !== 13 || submit()}>
<div className="instructions">
Add an account password
<br />
<br />
{formState.error ? (
<i className="text-small text-danger text-bold">{formState.error}</i>
) : (
<i className="text-small text-bold">8 char min., 1 lower case, 1 upper case, 1 number, 1 special char.</i>
)}
</div>
<div className="d-flex justify-content-center align-items-center auth-centered-container">
<div className="login-form">
{formState.processing ? (
<Loader header="setting account password" spinner relative />
) : (
<>
<h2 className="mb-2 instructions">Add an account password</h2>
<span className={`text-small text-bold d-inline-block my-2 ${formState.error ? 'text-danger' : ''}`}>
<i>8 char min., 1 lower case, 1 upper case, 1 number, 1 special char.</i>
</span>
<Label className="mb-4 d-block">
<Input
id="password1"
onChange={(e) => setFormData({ ...formData, password: e.target.value })}
disabled={formState.submitted}
className="mb-2 text-center"
type="password"
title="password"
placeholder="add password"
placeholder="Add Password"
/>
<Button id="updateMyPassword" onClick={submit} disabled={formState.submitted} title="Add Account Password" block color="purple">
Add Account Password
</Button>
</CardBody>
</Card>
<div className="login-nav-link">&nbsp;</div>
</>
)}
</Label>
<Button type="submit" id="updateMyPassword" className="border-0 rounded-pill btn-gradient-blue" block onClick={submit} disabled={formState.submitted || formData.processing} title="Add Account Password">
Submit Account Password
</Button>
</>
)}
</div>
</div>
);
}
Expand Down
6 changes: 5 additions & 1 deletion src/components/layouts/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,11 @@ function App() {
) : loggedIn ? (
<main id="app-container">
<ErrorBoundary FallbackComponent={ErrorFallback}>
<Suspense fallback={<Loader header=" " spinner />}>
<Suspense fallback={
<div className="auth-centered-container">
<Loader header=" " spinner />
</div>
}>
{/* can we put instance routes in here, each in a suspense tag (since they're lazily loaded) */}
<Routes>
<Route element={isMaintenance ? <Maintenance /> : <UpdatePassword />} path="/update-password" />
Expand Down
48 changes: 25 additions & 23 deletions src/components/shared/ErrorFallback.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,31 @@ import { Button, Card, CardBody, Col, Row } from 'reactstrap';

function ErrorFallback({ error, componentStack, resetErrorBoundary, extraClass = undefined }) {
return (
<Card className={`error-boundary mb-3 ${extraClass}`}>
<CardBody>
<b>Component Error {new Date().toLocaleTimeString()}</b>
<hr className="my-1" />
<div className="error-message">{error.message}</div>
<hr className="my-1" />
<div className="stack-trace">
<pre>{componentStack}</pre>
</div>
<Row>
<Col>
<Button color="danger" block href="https://harperdbhelp.zendesk.com/hc/en-us/requests/new" target="_blank" rel="noopener noreferrer">
Create A Support Ticket
</Button>
</Col>
<Col>
<Button color="success" block onClick={resetErrorBoundary}>
Retry Component Load
</Button>
</Col>
</Row>
</CardBody>
</Card>
<div className="d-flex justify-content-center align-items-center auth-centered-container">
<Card className={`error-boundary mb-3 w-400 ${extraClass}`}>
<CardBody>
<b>Component Error {new Date().toLocaleTimeString()}</b>
<hr className="my-1" />
<div className="error-message">{error.message}</div>
<hr className="my-1" />
<div className="stack-trace">
<pre>{componentStack}</pre>
</div>
<Row>
<Col>
<Button color="danger" block href="https://harperdbhelp.zendesk.com/hc/en-us/requests/new" target="_blank" rel="noopener noreferrer">
Create A Support Ticket
</Button>
</Col>
<Col>
<Button color="success" block onClick={resetErrorBoundary}>
Retry Component Load
</Button>
</Col>
</Row>
</CardBody>
</Card>
</div>
);
}

Expand Down

0 comments on commit 244afa3

Please sign in to comment.