Persist the state of the support form
Summary: This diff migrates the current state variables of the support form to the redux store, so that they can be persisted. This change will make them exportable and also solve the bug, where user navigates away from the form and comes back to see the support form's data vanished. Right now the videos are not persisted, as its uploading bit is a work in progress. Reviewed By: passy Differential Revision: D18531674 fbshipit-source-id: b1e824377da55cf531312920ff1bb5b862a12010
This commit is contained in:
committed by
Facebook Github Bot
parent
d97675f2e6
commit
f1aeb947b7
@@ -8,12 +8,25 @@
|
||||
*/
|
||||
|
||||
import {Actions} from './';
|
||||
export type SupportFormV2State = {
|
||||
title: string;
|
||||
description: string;
|
||||
commitHash: string;
|
||||
appName: string;
|
||||
};
|
||||
|
||||
export type State = {
|
||||
webState: NTUsersFormData | null;
|
||||
supportFormV2: SupportFormV2State;
|
||||
};
|
||||
export type Action = {
|
||||
export type Action =
|
||||
| {
|
||||
type: 'SET_SUPPORT_FORM_STATE';
|
||||
payload: NTUsersFormData | null;
|
||||
}
|
||||
| {
|
||||
type: 'SET_SUPPORT_FORM_V2_STATE';
|
||||
payload: SupportFormV2State;
|
||||
};
|
||||
|
||||
export type NTUsersFormData = {
|
||||
@@ -22,6 +35,21 @@ export type NTUsersFormData = {
|
||||
|
||||
export const initialState: () => State = () => ({
|
||||
webState: null,
|
||||
supportFormV2: {
|
||||
title: '',
|
||||
description: [
|
||||
'## Context',
|
||||
'What are you trying to accomplish at a high level? Feel free to include mocks and tasks.',
|
||||
'',
|
||||
'## Problem',
|
||||
"What's blocking you?",
|
||||
'',
|
||||
"## Workarounds I've Tried",
|
||||
'',
|
||||
].join('\n'),
|
||||
commitHash: '',
|
||||
appName: '',
|
||||
},
|
||||
});
|
||||
export default function reducer(
|
||||
state: State | undefined,
|
||||
@@ -33,6 +61,11 @@ export default function reducer(
|
||||
...state,
|
||||
webState: action.payload,
|
||||
};
|
||||
} else if (action.type === 'SET_SUPPORT_FORM_V2_STATE') {
|
||||
return {
|
||||
...state,
|
||||
supportFormV2: action.payload,
|
||||
};
|
||||
} else {
|
||||
return state;
|
||||
}
|
||||
@@ -44,3 +77,8 @@ export const setSupportFormState = (
|
||||
type: 'SET_SUPPORT_FORM_STATE',
|
||||
payload,
|
||||
});
|
||||
|
||||
export const setSupportFormV2State = (payload: SupportFormV2State): Action => ({
|
||||
type: 'SET_SUPPORT_FORM_V2_STATE',
|
||||
payload,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user