Skip to content

Commit b39dc41

Browse files
committed
Add attestation checkbox
1 parent 0e85a85 commit b39dc41

File tree

3 files changed

+42
-2
lines changed

3 files changed

+42
-2
lines changed

frontend/src/screens/App/screens/Corrections/components/SelectAlternates.less

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,11 @@
7272
.linkButton();
7373
margin-top: 1rem;
7474
}
75+
76+
.attestedLabel {
77+
margin-top: 1rem;
78+
display: block;
79+
input {
80+
margin-right: 0.5rem;
81+
}
82+
}

frontend/src/screens/App/screens/Corrections/components/SelectAlternates.tsx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ export default function SelectAlternates({
2222
toggleAlternateSelection,
2323
selectAllAlternates,
2424
deselectAllAlternates,
25+
alternatesAttested,
26+
setAlternatesAttested,
2527
} = useCorrectionsStore();
2628
const { isLoginValidated } = useLoginStore();
2729

@@ -31,6 +33,10 @@ export default function SelectAlternates({
3133
toggleAlternateSelection(identifier);
3234
};
3335

36+
const handleAttestedChange = (): void => {
37+
setAlternatesAttested(!alternatesAttested);
38+
};
39+
3440
return (
3541
<div>
3642
{!isEmpty(alternatesSelections) ? (
@@ -85,6 +91,19 @@ export default function SelectAlternates({
8591
Deselect All
8692
</button>
8793
</div>
94+
<label className={stylesheet.attestedLabel}>
95+
<input
96+
type="checkbox"
97+
id="attested"
98+
name="attested"
99+
checked={alternatesAttested}
100+
onChange={handleAttestedChange}
101+
disabled={!isLoginValidated}
102+
required
103+
/>
104+
I&rsquo;ve reviewed these other photos and selected any of the
105+
same place
106+
</label>
88107
</div>
89108
</FieldSet>
90109
) : (

frontend/src/screens/App/screens/Corrections/stores/CorrectionsStore.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import create from 'zustand';
22
import { immer } from 'zustand/middleware/immer';
33

4+
import { isEmpty } from 'lodash';
45
import useLoginStore from 'shared/stores/LoginStore';
56
import { getAlternatePhotos, getPhoto, Photo } from 'shared/utils/photosApi';
67
import {
@@ -14,6 +15,7 @@ interface State {
1415
photoId: string | null;
1516
photo: Photo | null;
1617
alternatesSelections: Record<string, boolean>;
18+
alternatesAttested: boolean;
1719

1820
isMapOpen: boolean;
1921
correctedLng: number | null;
@@ -34,6 +36,7 @@ interface Actions {
3436
toggleAlternateSelection: (identifier: string) => void;
3537
selectAllAlternates: () => void;
3638
deselectAllAlternates: () => void;
39+
setAlternatesAttested: (attested: boolean) => void;
3740
openMap: () => void;
3841
closeMap: () => void;
3942
setCorrectedLngLat: (lng: number, lat: number) => void;
@@ -49,6 +52,7 @@ const useCorrectionsStore = create(
4952
photoId: null,
5053
photo: null,
5154
alternatesSelections: {},
55+
alternatesAttested: false,
5256
isMapOpen: false,
5357
correctedLng: null,
5458
correctedLat: null,
@@ -124,6 +128,12 @@ const useCorrectionsStore = create(
124128
});
125129
},
126130

131+
setAlternatesAttested: (attested: boolean) => {
132+
set((draft) => {
133+
draft.alternatesAttested = attested;
134+
});
135+
},
136+
127137
openMap: () => {
128138
set((draft) => {
129139
draft.isMapOpen = true;
@@ -196,17 +206,20 @@ export function useCorrectionsStoreComputeds(): ComputedState {
196206
correctedLat,
197207
correctedLng,
198208
correctionType,
209+
alternatesSelections,
210+
alternatesAttested,
199211
} = useCorrectionsStore();
200212
const defaultGeocode = photo?.effectiveGeocode;
201213
return {
202214
previousLng: defaultGeocode?.lngLat.lng ?? null,
203215
previousLat: defaultGeocode?.lngLat.lat ?? null,
204216
previousAddress: photo?.address ?? null,
205217
canSubmit:
206-
(correctionType === 'geocode' &&
218+
(alternatesAttested || isEmpty(alternatesSelections)) &&
219+
((correctionType === 'geocode' &&
207220
correctedLat !== null &&
208221
correctedLng !== null) ||
209-
(correctionType === 'address' && correctedAddress !== null),
222+
(correctionType === 'address' && correctedAddress !== null)),
210223
};
211224
}
212225

0 commit comments

Comments
 (0)