Skip to content

Commit

Permalink
current iapp site state + url tweak, add drafts to default recordsets
Browse files Browse the repository at this point in the history
  • Loading branch information
micheal-w-wells committed Oct 16, 2023
1 parent e4dd3ab commit 24f1995
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 6 deletions.
2 changes: 1 addition & 1 deletion appv2/src/UI/Header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ const IAPPTabMemo = React.memo((props) => {
return (
<Tab
key={'tab4'}
path={'/Records/IAPP:' + activeIAPP}
path={'/Records/IAPP/' + activeIAPP + '/summary'}
label="Current IAPP"
loggedInOnly={true}
panelOpen={true}
Expand Down
2 changes: 1 addition & 1 deletion appv2/src/UI/Overlay/Records/Records.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ export const Records = (props) => {
</div>

{userSettingsState?.recordSets?.[set]?.recordSetName === 'All InvasivesBC Activities' ||
userSettingsState?.recordSets?.[set]?.recordSetName === 'All IAPP Records' ? (
userSettingsState?.recordSets?.[set]?.recordSetName === 'All IAPP Records' || userSettingsState.recordSets?.[set]?.recordSetName === 'My Drafts' ? (
<></>
) : (
<Button onClick={(e) => onClickDeleteRecordSet(set, e)} variant="outlined">
Expand Down
8 changes: 4 additions & 4 deletions appv2/src/rjsf/business-rules/customValidation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -840,19 +840,19 @@ export function getPestManagementPlanValidator(): rjsfValidator {
formData.activity_subtype_data.Treatment_ChemicalPlant_Information;

if (!pest_management_plan && !pmp_not_in_dropdown) {
errors['activity_subtype_data']['Treatment_ChemicalPlant_Information']['pest_management_plan'].addError(
errors['activity_subtype_data']['Treatment_ChemicalPlant_Information']['pest_management_plan']?.addError(
'Either Pest Management Plan or Unlisted Drop Down field has to be filled.'
);
errors['activity_subtype_data']['Treatment_ChemicalPlant_Information']['pmp_not_in_dropdown'].addError(
errors['activity_subtype_data']['Treatment_ChemicalPlant_Information']['pmp_not_in_dropdown']?.addError(
'Either Pest Management Plan or Unlisted Drop Down field has to be filled.'
);
}

if (pest_management_plan && pmp_not_in_dropdown) {
errors['activity_subtype_data']['Treatment_ChemicalPlant_Information']['pest_management_plan'].addError(
errors['activity_subtype_data']['Treatment_ChemicalPlant_Information']['pest_management_plan']?.addError(
'You must only fill either Pest Management Plan or Unlisted Drop Down field.'
);
errors['activity_subtype_data']['Treatment_ChemicalPlant_Information']['pmp_not_in_dropdown'].addError(
errors['activity_subtype_data']['Treatment_ChemicalPlant_Information']['pmp_not_in_dropdown']?.addError(
'You must only fill either Pest Management Plan or Unlisted Drop Down field.'
);
}
Expand Down
7 changes: 7 additions & 0 deletions appv2/src/state/reducers/userSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
ACTIVITY_GET_REQUEST,
CLOSE_NEW_RECORD_MENU,
GET_API_DOC_SUCCESS,
IAPP_GET_SUCCESS,
MAP_TOGGLE_WHATS_HERE,
OPEN_NEW_RECORD_MENU,
RECORDSET_ADD_FILTER,
Expand Down Expand Up @@ -149,6 +150,12 @@ function createUserSettingsReducer(configuration: AppConfig): (UserSettingsState
newRecordDialogueOpen: true
}
}
case IAPP_GET_SUCCESS : {
return {
...state,
activeIAPP: action.payload.iapp?.site_id
}
}
case ACTIVITY_CREATE_SUCCESS: {
return {
...state,
Expand Down
21 changes: 21 additions & 0 deletions appv2/src/state/sagas/iappsite/dataAccess.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,32 @@ import {
import {selectActivity} from "../../reducers/activity";
import centroid from "@turf/centroid";
import {selectIAPPSite} from "../../reducers/iappsite";
import { selectUserSettings } from "state/reducers/userSettings";

export function* handle_IAPP_GET_REQUEST(action) {
try {
// if mobile or web

const idFromURL = action.payload.iappID;
if(idFromURL !== undefined) {
yield put({type: IAPP_GET_NETWORK_REQUEST, payload: {iappID: action.payload.iappID}});
}

const userSettingsState = yield select(selectUserSettings)
const activeIAPP = userSettingsState.activeIAPP;

if(activeIAPP !== undefined) {
yield put({type: IAPP_GET_NETWORK_REQUEST, payload: {iappID: activeIAPP}});
}
else
{
// dispatch alert to user that there is no active iapp site

//yield put({ type: Notif})
}



} catch (e) {
console.error(e);
yield put({type: IAPP_GET_FAILURE});
Expand Down

0 comments on commit 24f1995

Please sign in to comment.