-
- Suggest Change To Test Center Information
-
+
Suggest Change to Test Center Information
Last update: {updatedAt.toLocaleString()}
diff --git a/src/constants/add-test-center.constants.js b/src/constants/add-test-center.constants.js
index 6c796894..1d7372b3 100644
--- a/src/constants/add-test-center.constants.js
+++ b/src/constants/add-test-center.constants.js
@@ -34,31 +34,37 @@ export const OFFERINGS = [
displayName: 'Antibody Test',
icon: DiagnosticTest,
key: 'ii',
+ value: false
},
{
displayName: 'Nasal Swab Test',
icon: Swab,
key: 'rp',
+ value: false
},
{
displayName: 'Drivethrough',
icon: Car,
key: 'driveThru',
+ value: false
},
{
displayName: 'Plasma Donation',
icon: Donate,
key: 'canDonatePlasma',
+ value: false
},
{
displayName: 'Free or Low-Cost Testing',
icon: DollarSign,
key: 'freeOrLowCost',
+ value: false
},
{
displayName: 'Online Scheduling',
icon: Monitor,
- key: 'teleScreeningAvailable',
+ key: 'telescreeningAvailable',
+ value: false
},
];
@@ -67,31 +73,37 @@ export const SCREENING_METHODS = [
displayName: 'Accepts Insurance',
icon: InsuranceCard,
key: 'acceptsInsurance',
+ value: false
},
{
displayName: 'Government ID Required',
icon: Id,
key: 'governmentIdRequired',
+ value: false
},
{
displayName: 'Referral Required',
icon: Users,
key: 'referralRequired',
+ value: false
},
{
displayName: 'Appointment Required',
icon: Calendar,
key: 'appointmentRequired',
+ value: false
},
{
displayName: 'First Responders Prioritized',
icon: Transportation,
key: 'firstResponderFriendly',
+ value: false
},
{
displayName: 'Minimum Age',
icon: AlertTriangle,
key: 'minimumAge',
+ value: false
},
];
diff --git a/src/constants/experiences.constants.js b/src/constants/experiences.constants.js
index b242d389..3d4e232a 100644
--- a/src/constants/experiences.constants.js
+++ b/src/constants/experiences.constants.js
@@ -132,38 +132,38 @@ export const NEGATIVE_TAGS = [
{
id: 'ph',
name: 'Poor Hygiene',
- icon:
,
- whiteIcon:
+ icon:
,
+ whiteIcon:
},
{
id: 'su',
name: 'Seemed Understaffed',
- icon: ,
- whiteIcon:
+ icon: ,
+ whiteIcon:
},
{
id: 'ct',
name: 'Could Not Get Tested',
- icon: ,
- whiteIcon:
+ icon: ,
+ whiteIcon:
},
{
id: 'lt',
name: 'Long Wait Time',
- icon: ,
- whiteIcon:
+ icon: ,
+ whiteIcon:
},
{
id: 'ca',
name: 'Confusing Process',
- icon: ,
- whiteIcon:
+ icon: ,
+ whiteIcon:
},
{
id: 'oc',
name: 'Overly Crowded',
- icon: ,
- whiteIcon:
+ icon: ,
+ whiteIcon:
},
];
@@ -171,37 +171,37 @@ export const NEGATIVE_TAGS = [
{
id: 'st',
name: 'Short Wait Time',
- icon: ,
- whiteIcon:
+ icon: ,
+ whiteIcon:
},
{
id: 'gh',
name: 'Good Hygiene',
- icon: ,
- whiteIcon:
+ icon: ,
+ whiteIcon:
},
{
id: 'fs',
name: 'Friendly Staff',
- icon: ,
- whiteIcon:
+ icon: ,
+ whiteIcon:
},
{
id: 'pp',
name: 'PPE Provided',
- icon: ,
- whiteIcon:
+ icon: ,
+ whiteIcon:
},
{
id: 'se',
name: 'Social Distancing',
- icon: ,
- whiteIcon:
+ icon: ,
+ whiteIcon:
},
{
id: 'gm',
name: 'Good Bedside Manner',
- icon: ,
- whiteIcon:
+ icon: ,
+ whiteIcon:
},
];
\ No newline at end of file
diff --git a/src/pages/add-test-center.page.js b/src/pages/add-test-center.page.js
index e901d5ea..ec672995 100644
--- a/src/pages/add-test-center.page.js
+++ b/src/pages/add-test-center.page.js
@@ -2,17 +2,6 @@ import React, { Component } from 'react';
import { bindAll, cloneDeep } from 'lodash';
import styled from 'styled-components';
-import {
- Container,
- TextField,
- MenuItem,
- Select,
- RadioGroup,
- Radio,
- FormControlLabel,
- FormControl,
-} from '@material-ui/core';
-
import { AppContext } from '@contexts/app.context';
import {
GOT_TESTED_OPTIONS,
@@ -20,12 +9,11 @@ import {
SCREENING_METHODS,
POST_DATA_STATE,
} from '@constants/add-test-center.constants';
-import Header from '@general/headers/header';
-import PrimaryButton from '@general/buttons/primary-button';
-import SnackbarMessage from '@general/alerts/snackbar-message';
import TypesService from '@services/types.service.js';
import FacilitateService from '@services/facilitate.service.js';
+import TestCenterUpdate from '@components/general/test-center-update';
+
export default class AddTestCenterPage extends Component {
static contextType = AppContext;
@@ -137,159 +125,27 @@ export default class AddTestCenterPage extends Component {
this.setState({ snackbarOpen: false });
}
+ onChange(item, value) {
+ this.setState({ postData: { ...this.state.postData, [item]: value } });
+ }
+
render() {
return (
- <>
-
- Submit New Test Center
-
- Complete the following form to propose a new test center within AllClear. All submissions will be reviewed
- by the AllClear team within 24 hours.
-
-
-
-
-
+ this.onCheckboxSelected.bind(this, option)}
+ handleSnackbarClose={() => this.handleSnackbarClose}
+ handleSubmit={(e) => this.handleSubmit(e)}
+ onCancelClicked={() => this.onCancelClicked}
+ onChange={(item, value) => this.onChange(item, value)}
+ />
-
- >
);
}
}
@@ -303,102 +159,3 @@ const Section = styled.section`
color: #fff;
}
`;
-
-const H3 = styled.h3`
- margin-bottom: 20px;
- font-size: 24px;
-`;
-
-const H4 = styled.h4`
- margin-bottom: 20px;
- font-size: 16px;
-`;
-
-const StyledHeader = styled(Header)`
- .color-block {
- display: none;
- }
-`;
-
-const Article = styled.article`
- padding: 44px 0;
- color: #fff;
-
- &:first-child {
- border-bottom: 1px solid rgba(255, 255, 255, 0.4);
- }
-
- > * {
- width: 100%;
- &:not(:last-child) {
- margin-bottom: 20px;
- }
- }
-`;
-
-const Checkboxes = styled.section`
- display: grid;
- grid-template-columns: repeat(auto-fill, minmax(172px, 1fr));
- column-gap: 17px;
- row-gap: 17px;
- margin-bottom: 40px;
-`;
-
-const Checkbox = styled.div`
- display: flex;
- flex-direction: column;
- justify-content: space-between;
- align-items: center;
- min-height: 122.78px;
- text-align: center;
- border-radius: 10px;
- border: 1px solid rgba(255, 255, 255, 0.5);
- transition: background-color ease 0.5s;
- cursor: pointer;
-
- * {
- cursor: inherit;
- }
-
- &:hover {
- background-color: rgba(0, 0, 0, 0.1);
- }
-
- &.checked {
- border-color: ${(props) => props.theme.palette.secondary.main};
- background-color: ${(props) => props.theme.palette.secondary.main};
- }
-`;
-
-const StyledRadio = styled(Radio)`
- color: #fff;
- &.Mui-checked {
- color: #fff;
- }
-`;
-
-const ButtonContainer = styled.div`
- display: grid;
- grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
- column-gap: 32px;
- row-gap: 32px;
- margin-bottom: 61px;
-
- button {
- font-size: 17px;
- }
-`;
-
-const CancelButton = styled(PrimaryButton)`
- color: #fff;
- background-color: rgba(255, 255, 255, 0.1);
-`;
-
-const SubmitButton = styled(PrimaryButton)`
- color: ${(props) => props.theme.palette.primary.main};
- background-color: #fff;
-
- &:hover {
- background-color: #e1efff;
- }
-`;
diff --git a/src/pages/edit-test-center.page.js b/src/pages/edit-test-center.page.js
new file mode 100644
index 00000000..88a91c8c
--- /dev/null
+++ b/src/pages/edit-test-center.page.js
@@ -0,0 +1,230 @@
+import React, { Component } from 'react';
+import { bindAll, cloneDeep } from 'lodash';
+import styled from 'styled-components';
+
+import FacilityService from '@services/facility.service.js';
+
+import { AppContext } from '@contexts/app.context';
+import {
+ GOT_TESTED_OPTIONS,
+ OFFERINGS,
+ SCREENING_METHODS,
+ POST_DATA_STATE,
+} from '@constants/add-test-center.constants';
+import TypesService from '@services/types.service.js';
+import FacilitateService from '@services/facilitate.service.js';
+import TestCenterUpdate from '@components/general/test-center-update';
+
+export default class EditTestCenterPage extends Component {
+ static contextType = AppContext;
+
+ initialState = {
+ postData: POST_DATA_STATE,
+ gotTested: GOT_TESTED_OPTIONS,
+ offerings: OFFERINGS,
+ screening: SCREENING_METHODS,
+ snackbarOpen: false,
+ snackbarSeverity: '',
+ snackbarMessage: '',
+ };
+
+ constructor(props) {
+ super(props);
+ bindAll(this, ['onCheckboxSelected', 'onCancelClicked', 'handleSubmit', 'handleSnackbarClose']);
+ this.typesService = TypesService.getInstance();
+ this.facilitateService = FacilitateService.getInstance();
+ this.facilityService = FacilityService.getInstance();
+ this.state = cloneDeep(this.initialState);
+ this.id = props.match.params.id;
+ }
+
+ async componentDidMount() {
+
+ try {
+ const testCenterTypes = await this.typesService.getFacilities();
+ const testCenterDetails = await this.facilityService.getFacility(this.id);
+
+ if (testCenterTypes?.length) {
+ this.setState({ testCenterTypes });
+ }
+
+ let allTestTypes = [];
+ if(testCenterDetails.data.testTypes) {
+ testCenterDetails.data.testTypes.map((testType) => {
+ allTestTypes.push({id: testType.id});
+ });
+ }
+
+ this.setState((prevState) => {
+ const offeringsArr = prevState.offerings.map((item, j) => {
+ if(allTestTypes.some((e) => e.id === item.key) || testCenterDetails.data[item.key]){
+ item.value= true;
+ }
+ return item;
+ });
+
+ const screeningArr = prevState.screening.map((item, j) => {
+ if(testCenterDetails.data[item.key]){
+ item.value=true;
+ }
+ return item;
+ });
+ return {
+ ...prevState,
+ postData: {
+ id: this.id,
+ name: testCenterDetails.data.name,
+ address: testCenterDetails.data.address,
+ driveThru: testCenterDetails.data.driveThru,
+ telescreeningAvailable: testCenterDetails.data.telescreeningAvailable,
+ freeOrLowCost: testCenterDetails.data.freeOrLowCost,
+ acceptsInsurance: testCenterDetails.data.acceptsInsurance,
+ governmentIdRequired: testCenterDetails.data.governmentIdRequired,
+ referralRequired: testCenterDetails.data.referralRequired,
+ firstResponderFriendly: testCenterDetails.data.firstResponderFriendly,
+ canDonatePlasma: testCenterDetails.data.canDonatePlasma,
+ appointmentRequired: testCenterDetails.data.appointmentRequired,
+ notes: '',
+ gotTested: undefined,
+ type: testCenterDetails.data.typeId ? { id: testCenterDetails.data.typeId } : { id: 'none' },
+ testTypes: allTestTypes,
+ minimumAge: testCenterDetails.data.minimumAge ? '18' : undefined,
+ },
+ offerings: offeringsArr,
+ screening: screeningArr
+ };
+ });
+ } catch(err) {
+ // display error if test center id is invalid
+ this.setState({
+ ...this.initialState,
+ snackbarMessage: 'Test Center does not exist.',
+ snackbarSeverity: 'error',
+ snackbarOpen: true,
+ });
+ }
+ }
+
+ onCheckboxSelected(selected) {
+ selected.value = !selected.value;
+ if (selected.key === 'ii' || selected.key === 'rp') {
+ if (selected.value) {
+ // add to testTypes array
+ this.setState((prevState) => ({
+ postData: {
+ ...prevState.postData,
+ testTypes: [...prevState.postData.testTypes, { id: selected.key }],
+ },
+ }));
+ } else {
+ // remove from testTypes array
+ this.setState((prevState) => ({
+ postData: {
+ ...prevState.postData,
+ testTypes: prevState.postData.testTypes.filter((key) => key.id !== selected.key),
+ },
+ }));
+ }
+ } else if (selected.key === 'minimumAge') {
+ if (selected.value) {
+ // converting minimumAge boolean to actual minimum age value
+ this.setState((prevState) => ({
+ postData: { ...prevState.postData, [selected.key]: 18 },
+ }));
+ } else {
+ this.setState((prevState) => ({
+ postData: { ...prevState.postData, [selected.key]: undefined },
+ }));
+ }
+ } else {
+ this.setState((prevState) => ({
+ postData: { ...prevState.postData, [selected.key]: selected.value },
+ }));
+ }
+ }
+
+ onCancelClicked() {
+ this.setState(cloneDeep(this.initialState), () => {
+ if (this.props.history.length > 2) {
+ // if history is not empty, go back:
+ this.props.history.goBack();
+ } else {
+ // else go to Map page
+ this.props.history.push(`/map/selection=${this.id}`);
+ }
+ });
+ }
+
+ async handleSubmit(e) {
+ e.preventDefault();
+
+ if (!this.state.postData.name || !this.state.postData.address) {
+ this.setState({
+ snackbarMessage: 'Please complete required fields',
+ snackbarSeverity: 'error',
+ snackbarOpen: true,
+ });
+ } else {
+ const response = await this.facilitateService.changeFacilityByCitizen({ value: this.state.postData });
+ if (response.error) {
+ this.setState({
+ snackbarMessage: 'An error occured. Please try again later.',
+ snackbarSeverity: 'error',
+ snackbarOpen: true,
+ });
+ } else {
+ this.setState((prevState) => ({
+ ...prevState,
+ snackbarMessage: 'Success! The edited Test Center has been submitted',
+ snackbarSeverity: 'success',
+ snackbarOpen: true,
+ }));
+ }
+ }
+ }
+
+ handleSnackbarClose() {
+ this.setState({ snackbarOpen: false });
+
+ // return to map if test center is invalid
+ if(this.state.snackbarMessage === 'Test Center does not exist.'){
+ this.onCancelClicked();
+ }
+ }
+
+ onChange(item, value) {
+ this.setState({ postData: { ...this.state.postData, [item]: value } });
+ }
+
+ render() {
+ return (
+ <>
+
+ this.onCheckboxSelected.bind(this, option)}
+ handleSnackbarClose={() => this.handleSnackbarClose}
+ handleSubmit={(e) => this.handleSubmit(e)}
+ onCancelClicked={() => this.onCancelClicked}
+ onChange={(item, value) => this.onChange(item, value)}
+ />
+
+ >
+ );
+ }
+}
+
+const Section = styled.section`
+ background: ${(props) => props.theme.palette.gradient.mobile};
+ ${(props) => props.theme.breakpoints.up('md')} {
+ background: ${(props) => props.theme.palette.gradient.desktop};
+ }
+ svg {
+ color: #fff;
+ }
+`;
diff --git a/src/pages/test-center.page.js b/src/pages/test-center.page.js
index f348d5d1..bfad901a 100644
--- a/src/pages/test-center.page.js
+++ b/src/pages/test-center.page.js
@@ -5,6 +5,7 @@ import { withRouter } from 'react-router';
import { Container, Button } from '@material-ui/core';
import PhoneIcon from '@material-ui/icons/Phone';
import KeyboardArrowLeftIcon from '@material-ui/icons/KeyboardArrowLeft';
+import { Link } from 'react-router-dom';
// components
import LinkButton from '@general/buttons/link-button';
@@ -20,7 +21,6 @@ import { triggerShareAction, getShareActionSnackbar } from '@util/social.helpers
import {
getFacilityDetailsMap,
convertToReadableDate,
- getFeedbackButtonURL,
isTaggableLocation,
applyCovidTag
} from '@util/general.helpers';
@@ -63,7 +63,6 @@ class TestCenterPage extends Component {
const facility = res.data;
this.loading = false;
this.facilityDetailsMap = getFacilityDetailsMap(facility);
- this.feedbackURL = getFeedbackButtonURL(facility);
facility.lastUpdated = convertToReadableDate(facility.updatedAt);
return facility;
})
@@ -213,7 +212,7 @@ class TestCenterPage extends Component {
>
)}
diff --git a/src/services/experience.service.js b/src/services/experience.service.js
index ad97de83..ba238c3c 100644
--- a/src/services/experience.service.js
+++ b/src/services/experience.service.js
@@ -47,4 +47,13 @@ export default class ExperienceService {
params: {facilityId}
});
}
+
+ limit(sessionId, facilityId){
+ return Axios({
+ method: 'GET',
+ url:`${this.baseURL}/limit`,
+ headers: { 'X-AllClear-SessionID': sessionId },
+ params: {facilityId}
+ });
+ }
}
diff --git a/src/services/facilitate.service.js b/src/services/facilitate.service.js
index e607dac8..be93b473 100644
--- a/src/services/facilitate.service.js
+++ b/src/services/facilitate.service.js
@@ -41,4 +41,21 @@ export default class FacilitateService {
return error;
}
}
+
+ async changeFacilityByCitizen(body) {
+ try {
+ const response = await Axios({
+ method: 'PUT',
+ url: `${this.baseURL}/citizen`,
+ data: body,
+ });
+ return response;
+ } catch (e) {
+ const error = {
+ error: true,
+ ...e.response,
+ };
+ return error;
+ }
+ }
}
diff --git a/src/util/general.helpers.js b/src/util/general.helpers.js
index 69c43923..e346a64d 100644
--- a/src/util/general.helpers.js
+++ b/src/util/general.helpers.js
@@ -141,16 +141,6 @@ export function convertToReadableDate(dateStr) {
return `${date.getMonth() + 1}/${date.getDate()}/${date.getFullYear()}`;
}
-export function getFeedbackButtonURL(facility) {
- return `
- https://airtable.com/shrVJrPQs4qQkcW4o?prefill_Name=${facility.name || facility.title || ''}
- &prefill_Phone number=${facility.phone || ''}
- &prefill_Hours=${facility.service_time === undefined ? '' : facility.service_time}
- &prefill_This location was drive through=${(facility.driveThru.toString() === 'true' ? 'Drive Through' : '')}
- &prefill_This location required an appointment=${boolToEng(facility.appointmentRequired) || ''}
- &prefill_Address=${facility.description || facility.address || ''}`;
-}
-
export function applyCovidTag({name, city, state, address, lastUpdated, text, url, type}) {
const tag = {
'@context': 'https://schema.org',
@@ -185,4 +175,14 @@ export function sortExperiencesTags(tagA, tagB){
} else {
return tagB.count - tagA.count;
}
-}
\ No newline at end of file
+}
+
+/*export function getFeedbackButtonURL(facility) {
+ return `
+ https://airtable.com/shrVJrPQs4qQkcW4o?prefill_Name=${facility.name || facility.title || ''}
+ &prefill_Phone number=${facility.phone || ''}
+ &prefill_Hours=${facility.service_time === undefined ? '' : facility.service_time}
+ &prefill_This location was drive through=${(facility.driveThru.toString() === 'true' ? 'Drive Through' : '')}
+ &prefill_This location required an appointment=${boolToEng(facility.appointmentRequired) || ''}
+ &prefill_Address=${facility.description || facility.address || ''}`;
+}*/
\ No newline at end of file