initial commit for welsh government planning appeals application
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
export const AccountDetailsDataActionTypes = {
|
||||
GETACCOUNTDETAILSDATA: "GETACCOUNTDETAILSDATA",
|
||||
SETACCOUNTDETAILSDATA: "SETACCOUNTDETAILSDATA",
|
||||
};
|
||||
|
||||
export const getAccountDetailsObj = () => (dispatch) => {
|
||||
return dispatch({
|
||||
type: AccountDetailsDataActionTypes.GETACCOUNTDETAILSDATA,
|
||||
});
|
||||
};
|
||||
|
||||
export const setAccountDetails = (accountDetails) => (dispatch) => {
|
||||
return dispatch({
|
||||
type: AccountDetailsDataActionTypes.SETACCOUNTDETAILSDATA,
|
||||
accountDetails: accountDetails,
|
||||
});
|
||||
};
|
||||
@@ -0,0 +1,20 @@
|
||||
import { AccountDetailsDataActionTypes } from "./action";
|
||||
|
||||
const AccountDetailsDataInitialState = {
|
||||
accountDetails: {},
|
||||
};
|
||||
|
||||
export default function reducer(
|
||||
state = AccountDetailsDataInitialState,
|
||||
action
|
||||
) {
|
||||
switch (action.type) {
|
||||
case AccountDetailsDataActionTypes.SETACCOUNTDETAILSDATA:
|
||||
return {
|
||||
...state,
|
||||
accountDetails: action.accountDetails,
|
||||
};
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
import { actionTypes } from "redux-form";
|
||||
|
||||
export const appealTypeDataActionTypes = {
|
||||
GETAPPEALTYPEDATA: "GETAPPEALTYPEDATA",
|
||||
SETAPPEALTYPEDATA: "SETAPPEALTYPEDATA",
|
||||
SETAPPEALTYPEIDDATA: "SETAPPEALTYPEIDDATA",
|
||||
SETAPPEALTYPETITLEDATA: "SETAPPEALTYPETITLEDATA",
|
||||
UPDATEAPPEALTYPEDATA: "UPDATEAPPEALTYPEDATA",
|
||||
SETCURRENTSECTION: "SETCURRENTSECTION",
|
||||
SETAPPEALLPA: "SETAPPEALLPA",
|
||||
SETCASEREFERENCE: "SETCASEREFERENCE",
|
||||
SETFORMCOMPLETE: "SETFORMCOMPLETE",
|
||||
};
|
||||
|
||||
export const getAppealTypeObj = () => (dispatch) => {
|
||||
return dispatch({
|
||||
type: appealTypeDataActionTypes.GETAPPEALTYPEDATA,
|
||||
});
|
||||
};
|
||||
|
||||
export const setAppealType = (appealTypeData) => (dispatch) => {
|
||||
return dispatch({
|
||||
type: appealTypeDataActionTypes.SETAPPEALTYPEDATA,
|
||||
appealTypeOptions: appealTypeData,
|
||||
});
|
||||
};
|
||||
|
||||
export const setAppealTypeTitle = (appealTypeData) => (dispatch) => {
|
||||
return dispatch({
|
||||
type: appealTypeDataActionTypes.SETAPPEALTYPETITLEDATA,
|
||||
appealTypeTitle: appealTypeData,
|
||||
});
|
||||
};
|
||||
|
||||
export const setAppealTypeID = (appealTypeData) => (dispatch) => {
|
||||
return dispatch({
|
||||
type: appealTypeDataActionTypes.SETAPPEALTYPEIDDATA,
|
||||
appealTypeID: appealTypeData,
|
||||
});
|
||||
};
|
||||
export const setCurrentSection = (currentSection) => (dispatch) => {
|
||||
return dispatch({
|
||||
type: appealTypeDataActionTypes.SETCURRENTSECTION,
|
||||
currentSection: currentSection,
|
||||
});
|
||||
};
|
||||
export const setAppealLPA = (appealLPA) => (dispatch) => {
|
||||
return dispatch({
|
||||
type: appealTypeDataActionTypes.SETAPPEALLPA,
|
||||
appealLPA: appealLPA,
|
||||
});
|
||||
};
|
||||
|
||||
export const setCaseReference = (caseReference) => (dispatch) => {
|
||||
return dispatch({
|
||||
type: appealTypeDataActionTypes.SETCASEREFERENCE,
|
||||
caseReference: caseReference,
|
||||
});
|
||||
};
|
||||
|
||||
export const setFormComplete = (formComplete) => (dispatch) => {
|
||||
return dispatch({
|
||||
type: appealTypeDataActionTypes.SETFORMCOMPLETE,
|
||||
formComplete: formComplete,
|
||||
});
|
||||
};
|
||||
@@ -0,0 +1,53 @@
|
||||
import { appealTypeDataActionTypes } from "./action";
|
||||
|
||||
const appealTypeDataInitialState = {
|
||||
appealTypeOptions: {},
|
||||
appealTypeTitle: {},
|
||||
appealTypeID: {},
|
||||
currentSection: 1,
|
||||
appealLPA: "",
|
||||
caseReference: "",
|
||||
formComplete: "false",
|
||||
};
|
||||
|
||||
export default function reducer(state = appealTypeDataInitialState, action) {
|
||||
switch (action.type) {
|
||||
case appealTypeDataActionTypes.SETAPPEALTYPEDATA:
|
||||
return {
|
||||
...state,
|
||||
appealTypeOptions: action.appealTypeOptions,
|
||||
};
|
||||
case appealTypeDataActionTypes.SETAPPEALTYPETITLEDATA:
|
||||
return {
|
||||
...state,
|
||||
appealTypeTitle: action.appealTypeTitle,
|
||||
};
|
||||
case appealTypeDataActionTypes.SETAPPEALTYPEIDDATA:
|
||||
return {
|
||||
...state,
|
||||
appealTypeID: action.appealTypeID,
|
||||
};
|
||||
case appealTypeDataActionTypes.SETCURRENTSECTION:
|
||||
return {
|
||||
...state,
|
||||
currentSection: action.currentSection,
|
||||
};
|
||||
case appealTypeDataActionTypes.SETAPPEALLPA:
|
||||
return {
|
||||
...state,
|
||||
appealLPA: action.appealLPA,
|
||||
};
|
||||
case appealTypeDataActionTypes.SETCASEREFERENCE:
|
||||
return {
|
||||
...state,
|
||||
caseReference: action.caseReference,
|
||||
};
|
||||
case appealTypeDataActionTypes.SETFORMCOMPLETE:
|
||||
return {
|
||||
...state,
|
||||
formComplete: action.formComplete,
|
||||
};
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
export const formDataActionTypes = {
|
||||
GETFORMDATA: "GETFORMDATA",
|
||||
SETFORMDATA: "SETFORMDATA",
|
||||
UPDATEFORMDATA: "UPDATEFORMDATA",
|
||||
};
|
||||
|
||||
export const getFormObj = () => (dispatch) => {
|
||||
return dispatch({
|
||||
type: formDataActionTypes.GETFORMDATA,
|
||||
});
|
||||
};
|
||||
|
||||
export const setForm = (formData) => (dispatch) => {
|
||||
return dispatch({
|
||||
type: formDataActionTypes.SETFORMDATA,
|
||||
formData: formData,
|
||||
});
|
||||
};
|
||||
@@ -0,0 +1,16 @@
|
||||
import { formDataActionTypes } from "./action";
|
||||
|
||||
const formDataInitialState = {
|
||||
formData: {},
|
||||
};
|
||||
|
||||
export default function reducer(state = formDataInitialState, action) {
|
||||
switch (action.type) {
|
||||
case formDataActionTypes.SETFORMDATA:
|
||||
return {
|
||||
formData: action.formData,
|
||||
};
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
import { actionTypes } from "redux-form";
|
||||
|
||||
export const LPADataActionTypes = {
|
||||
GETLPADATA: "GETLPADATA",
|
||||
SETLPADATA: "SETLPADATA",
|
||||
};
|
||||
|
||||
export const getLPAObj = () => (dispatch) => {
|
||||
return dispatch({
|
||||
type: LPADataActionTypes.GETLPADATA,
|
||||
});
|
||||
};
|
||||
|
||||
export const setLPA = (lpaData) => (dispatch) => {
|
||||
return dispatch({
|
||||
type: LPADataActionTypes.SETLPADATA,
|
||||
LPAData: lpaData,
|
||||
});
|
||||
};
|
||||
@@ -0,0 +1,17 @@
|
||||
import { LPADataActionTypes } from "./action";
|
||||
|
||||
const LPADataInitialState = {
|
||||
LPAData: {},
|
||||
};
|
||||
|
||||
export default function reducer(state = LPADataInitialState, action) {
|
||||
switch (action.type) {
|
||||
case LPADataActionTypes.SETLPADATA:
|
||||
return {
|
||||
...state,
|
||||
LPAData: action.LPAData,
|
||||
};
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
export const progressActionTypes = {
|
||||
GETPROGRESS: "GETPROGRESS",
|
||||
SETPROGRESS: "SETPROGRESS",
|
||||
UPDATEPROGRESS: "UPDATEPROGRESS",
|
||||
};
|
||||
|
||||
export const getProgressObj = () => (dispatch) => {
|
||||
return dispatch({
|
||||
type: progressActionTypes.GETPROGRESS,
|
||||
});
|
||||
};
|
||||
|
||||
export const setProgress = (progress) => (dispatch) => {
|
||||
return dispatch({
|
||||
type: progressActionTypes.SETPROGRESS,
|
||||
progressObj: progress,
|
||||
});
|
||||
};
|
||||
@@ -0,0 +1,16 @@
|
||||
import { progressActionTypes } from "./action";
|
||||
|
||||
const progressInitialState = {
|
||||
progress: {},
|
||||
};
|
||||
|
||||
export default function reducer(state = progressInitialState, action) {
|
||||
switch (action.type) {
|
||||
case progressActionTypes.SETPROGRESS:
|
||||
return {
|
||||
progressObj: action.progressObj,
|
||||
};
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
export const searchActionTypes = {
|
||||
GETSEARCH: "GETSEARCH",
|
||||
SETSEARCH: "SETSEARCH",
|
||||
UPDATESEARCH: "UPDATESEARCH",
|
||||
};
|
||||
|
||||
export const getSearchObj = () => (dispatch) => {
|
||||
return dispatch({
|
||||
type: searchActionTypes.GETSEARCH,
|
||||
});
|
||||
};
|
||||
|
||||
export const setSearch = (search) => (dispatch) => {
|
||||
return dispatch({
|
||||
type: searchActionTypes.SETSEARCH,
|
||||
searchString: search,
|
||||
});
|
||||
};
|
||||
@@ -0,0 +1,16 @@
|
||||
import { searchActionTypes } from "./action";
|
||||
|
||||
const searchInitialState = {
|
||||
search: {},
|
||||
};
|
||||
|
||||
export default function reducer(state = searchInitialState, action) {
|
||||
switch (action.type) {
|
||||
case searchActionTypes.SETSEARCH:
|
||||
return {
|
||||
searchString: action.searchString,
|
||||
};
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
export const searchResultsActionTypes = {
|
||||
GETSEARCHRESULTS: "GETSEARCHRESULTS",
|
||||
SETSEARCHRESULTS: "SETSEARCHRESULTS",
|
||||
UPDATESEARCHRESULTS: "UPDATESEARCHRESULTS",
|
||||
};
|
||||
|
||||
export const getSearchResultshObj = () => (dispatch) => {
|
||||
return dispatch({
|
||||
type: searchResultsActionTypes.GETSEARCHRESULTS,
|
||||
});
|
||||
};
|
||||
|
||||
export const setSearchResults = (searchResults) => (dispatch) => {
|
||||
return dispatch({
|
||||
type: searchResultsActionTypes.SETSEARCHRESULTS,
|
||||
searchResultsObj: searchResults,
|
||||
});
|
||||
};
|
||||
@@ -0,0 +1,16 @@
|
||||
import { searchResultsActionTypes } from "./action";
|
||||
|
||||
const searchResultsInitialState = {
|
||||
searchResultsObj: {},
|
||||
};
|
||||
|
||||
export default function reducer(state = searchResultsInitialState, action) {
|
||||
switch (action.type) {
|
||||
case searchResultsActionTypes.SETSEARCHRESULTS:
|
||||
return {
|
||||
searchResultsObj: action.searchResultsObj,
|
||||
};
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
}
|
||||
+111
@@ -0,0 +1,111 @@
|
||||
import { createStore, applyMiddleware, combineReducers } from "redux";
|
||||
import { createWrapper, HYDRATE } from "next-redux-wrapper";
|
||||
import thunkMiddleware from "redux-thunk";
|
||||
import search from "./search/reducer";
|
||||
import searchResultsObj from "./searchOutput/reducer";
|
||||
import formData from "./formData/reducer";
|
||||
import appealType from "./appealType/reducer";
|
||||
import LPAData from "./lpa/reducer";
|
||||
import accountDetails from "./accountDetails/reducer";
|
||||
import { reducer as formReducer } from "redux-form";
|
||||
import autoMergeLevel2 from "redux-persist/lib/stateReconciler/autoMergeLevel2";
|
||||
|
||||
//COMBINING ALL REDUCERS
|
||||
const combinedReducer = combineReducers({
|
||||
search,
|
||||
searchResultsObj,
|
||||
formData,
|
||||
appealType,
|
||||
LPAData,
|
||||
accountDetails,
|
||||
form: formReducer,
|
||||
});
|
||||
|
||||
const reducer = (state = {}, action) => {
|
||||
switch (action.type) {
|
||||
case HYDRATE:
|
||||
return { ...state, ...action.payload };
|
||||
case "SERVER_ACTION":
|
||||
return {
|
||||
...state,
|
||||
server: {
|
||||
...state.server,
|
||||
progress: action.payload,
|
||||
},
|
||||
};
|
||||
case "CLIENT_ACTION":
|
||||
return {
|
||||
...state,
|
||||
client: {
|
||||
...state.client,
|
||||
progress: action.payload,
|
||||
},
|
||||
};
|
||||
case "GET_ITEMS":
|
||||
return {
|
||||
...state,
|
||||
items: action.payload,
|
||||
loading: false,
|
||||
};
|
||||
case "SET_ITEMS":
|
||||
return {
|
||||
...state,
|
||||
items: action.payload,
|
||||
loading: false,
|
||||
};
|
||||
default:
|
||||
return combinedReducer(state, action);
|
||||
}
|
||||
};
|
||||
|
||||
// BINDING MIDDLEWARE
|
||||
const bindMiddleware = (middleware) => {
|
||||
if (process.env.NODE_ENV !== "production") {
|
||||
const { composeWithDevTools } = require("redux-devtools-extension");
|
||||
return composeWithDevTools(applyMiddleware(...middleware));
|
||||
}
|
||||
return applyMiddleware(...middleware);
|
||||
};
|
||||
|
||||
const makeStore = ({ isServer }) => {
|
||||
if (isServer) {
|
||||
//If it's on server side, create a store
|
||||
return createStore(reducer, bindMiddleware([thunkMiddleware]));
|
||||
} else {
|
||||
//If it's on client side, create a store which will persist
|
||||
const { persistStore, persistReducer } = require("redux-persist");
|
||||
const storage = require("redux-persist/lib/storage").default;
|
||||
|
||||
const persistConfig = {
|
||||
key: "nextjs",
|
||||
whitelist: [
|
||||
"search",
|
||||
"searchResults",
|
||||
"formData",
|
||||
"appealType",
|
||||
"LPAData",
|
||||
"accountDetails",
|
||||
"form",
|
||||
],
|
||||
storage,
|
||||
stateReconciler: autoMergeLevel2, // if needed, use a safer storage
|
||||
};
|
||||
|
||||
const persistedReducer = persistReducer(persistConfig, reducer); // Create a new reducer with our existing reducer
|
||||
|
||||
const store = createStore(
|
||||
persistedReducer,
|
||||
bindMiddleware([thunkMiddleware])
|
||||
); // Creating the store again
|
||||
|
||||
store.__persistor = persistStore(store); // This creates a persistor object & push that persisted object to .__persistor, so that we can avail the persistability feature
|
||||
|
||||
return store;
|
||||
}
|
||||
};
|
||||
export const setClientState = (clientState) => ({
|
||||
type: SET_CLIENT_STATE,
|
||||
payload: clientState,
|
||||
});
|
||||
// Export the wrapper & wrap the pages/_app.js with this wrapper only
|
||||
export const wrapper = createWrapper(makeStore);
|
||||
Reference in New Issue
Block a user