-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
VKT(Frontend): Persist parts of PublicEnrollmentContactState into ses…
…sion storage for improved UX over page reloads [deploy]
- Loading branch information
Showing
4 changed files
with
37 additions
and
5 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
frontend/packages/vkt/src/redux/persist/transforms/PublicEnrollmentContactTransform.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { createTransform } from 'reduxjs-toolkit-persist'; | ||
|
||
import { | ||
initialState, | ||
PublicEnrollmentContactState, | ||
} from 'redux/reducers/publicEnrollmentContact'; | ||
|
||
type OutboundState = PublicEnrollmentContactState; | ||
|
||
export const PublicEnrollmentContactTransform = createTransform( | ||
// transform state on its way to being serialized and persisted: | ||
// retain details provided by user (enrollment details) as well as important inferred details (contacted examiners), | ||
// discard rest | ||
( | ||
inboundState: PublicEnrollmentContactState, | ||
): Partial<PublicEnrollmentContactState> => { | ||
return { | ||
enrollment: inboundState.enrollment, | ||
contactedExaminers: inboundState.contactedExaminers, | ||
}; | ||
}, | ||
// transform state being rehydrated | ||
(outboundState: OutboundState) => { | ||
return { | ||
...initialState, | ||
...outboundState, | ||
}; | ||
}, | ||
// define which reducers this transform gets called for. | ||
{ whitelist: ['publicEnrollmentContact'] }, | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters