From 3f60d432181866a8ee1709f3f84c66537427e13b Mon Sep 17 00:00:00 2001
From: monocle
Date: Mon, 9 Jan 2023 12:14:17 -0800
Subject: [PATCH] Fix routing to demo bug. Closes #1472
* Separate Demo from RecordSearch
* Update DemoInfo:
- Remove stop demo state management
- Use Link instead of button for OECI log in
* Add stop demo state management to RecordSearch
* Use history.replace instead of history.push in checkOeciRedirect(). This allows browser back button to work properly.
---
src/frontend/src/components/App/index.tsx | 7 +-
.../{RecordSearch => }/Demo/DemoInfo.tsx | 81 ++++++++++---------
src/frontend/src/components/Demo/index.tsx | 42 ++++++++++
.../RecordSearch/Assumptions/index.tsx | 32 ++++++++
.../components/RecordSearch/Demo/index.tsx | 19 -----
.../src/components/RecordSearch/index.tsx | 65 ++++-----------
src/frontend/src/service/cookie-service.ts | 2 +-
7 files changed, 138 insertions(+), 110 deletions(-)
rename src/frontend/src/components/{RecordSearch => }/Demo/DemoInfo.tsx (74%)
create mode 100644 src/frontend/src/components/Demo/index.tsx
create mode 100644 src/frontend/src/components/RecordSearch/Assumptions/index.tsx
delete mode 100644 src/frontend/src/components/RecordSearch/Demo/index.tsx
diff --git a/src/frontend/src/components/App/index.tsx b/src/frontend/src/components/App/index.tsx
index 18976b0ed..00146413b 100644
--- a/src/frontend/src/components/App/index.tsx
+++ b/src/frontend/src/components/App/index.tsx
@@ -5,7 +5,7 @@ import history from "../../service/history";
import Footer from "../Footer";
import Header from "../Header";
import RecordSearch from "../RecordSearch";
-import Demo from "../RecordSearch/Demo";
+import Demo from "../Demo";
import OeciLogin from "../OeciLogin";
import Landing from "../Landing";
import Manual from "../Manual";
@@ -36,7 +36,10 @@ class App extends React.Component {
-
+
diff --git a/src/frontend/src/components/RecordSearch/Demo/DemoInfo.tsx b/src/frontend/src/components/Demo/DemoInfo.tsx
similarity index 74%
rename from src/frontend/src/components/RecordSearch/Demo/DemoInfo.tsx
rename to src/frontend/src/components/Demo/DemoInfo.tsx
index 4ef09c24b..16e314796 100644
--- a/src/frontend/src/components/RecordSearch/Demo/DemoInfo.tsx
+++ b/src/frontend/src/components/Demo/DemoInfo.tsx
@@ -1,19 +1,13 @@
import React from "react";
import { Link } from "react-router-dom";
-import { connect } from "react-redux";
-import { stopDemo } from "../../../redux/search/actions";
-import history from "../../../service/history";
-import store from "../../../redux/store";
-interface Props {
- stopDemo: Function;
-}
-class DemoInfo extends React.Component {
- toOeci = () => {
- store.dispatch(this.props.stopDemo());
- history.push("/oeci");
- };
- formattedInfo = (firstName: string, lastName: string, description: string[], dateOfBirth: string) => {
+class DemoInfo extends React.Component {
+ formattedInfo = (
+ firstName: string,
+ lastName: string,
+ description: string[],
+ dateOfBirth: string
+ ) => {
return (
@@ -25,19 +19,19 @@ class DemoInfo extends React.Component {
Last Name
{lastName}
- {
- dateOfBirth && (
-
-
Date of Birth
-
{dateOfBirth}
-
- )
- }
+ {dateOfBirth && (
+
+
Date of Birth
+
{dateOfBirth}
+
+ )}
- {description.map((line: string) =>
{line}
)}
+ {description.map((line: string) => (
+
{line}
+ ))}
);
- }
+ };
render() {
const examplesData = [
@@ -45,7 +39,9 @@ class DemoInfo extends React.Component {
name: "Single Conviction",
firstName: "Single",
lastName: "Conviction",
- description: ["As a simple example, if a person's record has only a single convicted charge, it is eligible after three years."]
+ description: [
+ "As a simple example, if a person's record has only a single convicted charge, it is eligible after three years.",
+ ],
},
{
name: "Multiple Charges",
@@ -53,8 +49,8 @@ class DemoInfo extends React.Component {
lastName: "Charges",
description: [
"If a record has more than one case, the time restrictions quickly get more complex, as this example demonstrates. Eligibility dates depend on whether dismissals are on the same or a different case as a conviction. Searching OECI will also reveal traffic violations, which are always ineligible.",
- "This record also includes a case with an outstanding balance due for fines, which is indicated in both the record summary and on the case itself."
- ]
+ "This record also includes a case with an outstanding balance due for fines, which is indicated in both the record summary and on the case itself.",
+ ],
},
{
name: "John Common",
@@ -62,7 +58,7 @@ class DemoInfo extends React.Component {
lastName: "Common",
description: [
"Searching for a common name will often bring up records that belong to different individuals, leading to an incorrect analysis for the set of resulting cases. Another source of confusion is that each case may or may not incude a birth year, as well as middle name or initial.",
- "It is thus always recommended to provide a birth date in the search. You can also use the Enable Editing feature to remove cases or charges from the resulting record, and these charges will be excluded in the eligibility analysis."
+ "It is thus always recommended to provide a birth date in the search. You can also use the Enable Editing feature to remove cases or charges from the resulting record, and these charges will be excluded in the eligibility analysis.",
],
},
{
@@ -70,20 +66,19 @@ class DemoInfo extends React.Component {
firstName: "John",
lastName: "Common",
description: [
- "Most charges that are eligible are also subject to the same set of time restrictions. There are some exceptions to this, notably Class B Felonies, and possession of less than an ounce of marijuana."
+ "Most charges that are eligible are also subject to the same set of time restrictions. There are some exceptions to this, notably Class B Felonies, and possession of less than an ounce of marijuana.",
],
- dateOfBirth: "1/1/1970"
+ dateOfBirth: "1/1/1970",
},
{
name: "John Common – Needs More Analysis",
firstName: "John",
lastName: "Common",
description: [
- "Some charges cannot be evaluated for eligibility until the user provides some follow-up information about the charge. RecordSponge deals with this ambiguity by showing the different possible outcomes for eligibility, and by asking the user for the required extra information in order to determine an exact analysis."
+ "Some charges cannot be evaluated for eligibility until the user provides some follow-up information about the charge. RecordSponge deals with this ambiguity by showing the different possible outcomes for eligibility, and by asking the user for the required extra information in order to determine an exact analysis.",
],
- dateOfBirth: "2/2/1985"
+ dateOfBirth: "2/2/1985",
},
-
];
return (
@@ -117,19 +112,26 @@ class DemoInfo extends React.Component {