farhantock
3 months ago
6 changed files with 226 additions and 34 deletions
@ -1,22 +1,7 @@ |
|||||||
/* |
// user actions
|
||||||
* All actions should be import and exported first |
export * from './modules/user/actions'; |
||||||
* to make components / pages are easy to use |
|
||||||
*/ |
|
||||||
|
|
||||||
import { |
// theme actions
|
||||||
setIsLogin, |
export * from './modules/theme/actions'; |
||||||
setUser, |
|
||||||
setFcmToken, |
|
||||||
setChosenLanguage, |
|
||||||
setRegister |
|
||||||
} from './modules/user/actions'; |
|
||||||
|
|
||||||
|
export * from './modules/incidentReport/actions' |
||||||
|
|
||||||
export { |
|
||||||
setIsLogin, |
|
||||||
setUser, |
|
||||||
setFcmToken, |
|
||||||
setChosenLanguage, |
|
||||||
setRegister |
|
||||||
} |
|
||||||
|
@ -0,0 +1,115 @@ |
|||||||
|
// Action Types
|
||||||
|
export const SET_INCIDENT_DATE = 'SET_INCIDENT_DATE'; |
||||||
|
export const SET_INCIDENT_TIME = 'SET_INCIDENT_TIME'; |
||||||
|
export const SET_REPORT_DATE = 'SET_REPORT_DATE'; |
||||||
|
export const SET_REPORT_TIME = 'SET_REPORT_TIME'; |
||||||
|
export const SET_AREA = 'SET_AREA'; |
||||||
|
export const SET_DATA_RECEPIENT = 'SET_DATA_RECEPIENT'; |
||||||
|
export const SET_DATA_REPORTER = 'SET_DATA_REPORTER'; |
||||||
|
export const SET_INCIDENT_LOCATION = 'SET_INCIDENT_LOCATION'; |
||||||
|
export const SET_REPORT_LOCATION = 'SET_REPORT_LOCATION'; |
||||||
|
export const SET_DATA_INCIDENT = 'SET_DATA_INCIDENT'; |
||||||
|
export const SET_DATA_ACHIEVEMENT = 'SET_DATA_ACHIEVEMENT'; |
||||||
|
export const SET_DATA_TYPE_RISK = 'SET_DATA_TYPE_RISK'; |
||||||
|
export const SET_INCIDENT_RISK_POTENTIAL = 'SET_INCIDENT_RISK_POTENTIAL'; |
||||||
|
export const SET_RISK_LEVEL = 'SET_RISK_LEVEL'; |
||||||
|
export const SET_ROOT_CASE = 'SET_ROOT_CASE'; |
||||||
|
export const SET_CHRONOLOGY = 'SET_CHRONOLOGY'; |
||||||
|
export const SET_DATA_PREVENTION = 'SET_DATA_PREVENTION'; |
||||||
|
export const SET_DATA_IMAGES = 'SET_DATA_IMAGES'; |
||||||
|
export const RESET_INCIDENT_REPORT = 'RESET_INCIDENT_REPORT'; |
||||||
|
// Action Creators
|
||||||
|
export const setIncidentDate = (date) => ({ |
||||||
|
type: SET_INCIDENT_DATE, |
||||||
|
payload: date, |
||||||
|
}); |
||||||
|
|
||||||
|
export const setIncidentTime = (time) => ({ |
||||||
|
type: SET_INCIDENT_TIME, |
||||||
|
payload: time, |
||||||
|
}); |
||||||
|
|
||||||
|
export const setReportDate = (date) => ({ |
||||||
|
type: SET_REPORT_DATE, |
||||||
|
payload: date, |
||||||
|
}); |
||||||
|
|
||||||
|
export const setReportTime = (time) => ({ |
||||||
|
type: SET_REPORT_TIME, |
||||||
|
payload: time, |
||||||
|
}); |
||||||
|
|
||||||
|
export const setArea = (area) => ({ |
||||||
|
type: SET_AREA, |
||||||
|
payload: area, |
||||||
|
}); |
||||||
|
|
||||||
|
export const setDataRecepient = (data) => ({ |
||||||
|
type: SET_DATA_RECEPIENT, |
||||||
|
payload: data, |
||||||
|
}); |
||||||
|
|
||||||
|
export const setDataReporter = (data) => ({ |
||||||
|
type: SET_DATA_REPORTER, |
||||||
|
payload: data, |
||||||
|
}); |
||||||
|
|
||||||
|
export const setIncidentLocation = (location) => ({ |
||||||
|
type: SET_INCIDENT_LOCATION, |
||||||
|
payload: location, |
||||||
|
}); |
||||||
|
|
||||||
|
export const setReportLocation = (location) => ({ |
||||||
|
type: SET_REPORT_LOCATION, |
||||||
|
payload: location, |
||||||
|
}); |
||||||
|
|
||||||
|
export const setDataIncident = (data) => ({ |
||||||
|
type: SET_DATA_INCIDENT, |
||||||
|
payload: data, |
||||||
|
}); |
||||||
|
|
||||||
|
export const setDataAchievement = (data) => ({ |
||||||
|
type: SET_DATA_ACHIEVEMENT, |
||||||
|
payload: data, |
||||||
|
}); |
||||||
|
|
||||||
|
export const setDataTypeRisk = (data) => ({ |
||||||
|
type: SET_DATA_TYPE_RISK, |
||||||
|
payload: data, |
||||||
|
}); |
||||||
|
|
||||||
|
export const setIncidentRiskPotential = (data) => ({ |
||||||
|
type: SET_INCIDENT_RISK_POTENTIAL, |
||||||
|
payload: data, |
||||||
|
}); |
||||||
|
|
||||||
|
export const setRiskLevel = (data) => ({ |
||||||
|
type: SET_RISK_LEVEL, |
||||||
|
payload: data, |
||||||
|
}); |
||||||
|
|
||||||
|
export const setChronology = (data) => ({ |
||||||
|
type: SET_CHRONOLOGY, |
||||||
|
payload: data, |
||||||
|
}); |
||||||
|
|
||||||
|
export const setRootCase = (data) => ({ |
||||||
|
type: SET_ROOT_CASE, |
||||||
|
payload: data, |
||||||
|
}); |
||||||
|
|
||||||
|
export const setDataPrevention = (data) => ({ |
||||||
|
type: SET_DATA_PREVENTION, |
||||||
|
payload: data, |
||||||
|
}); |
||||||
|
|
||||||
|
export const setImages = (images) => ({ |
||||||
|
type: SET_DATA_IMAGES, |
||||||
|
payload: images, |
||||||
|
}); |
||||||
|
|
||||||
|
|
||||||
|
export const resetIncidentReport = () => ({ |
||||||
|
type: RESET_INCIDENT_REPORT, |
||||||
|
}); |
@ -0,0 +1,89 @@ |
|||||||
|
import { |
||||||
|
SET_INCIDENT_DATE, |
||||||
|
SET_INCIDENT_TIME, |
||||||
|
SET_REPORT_DATE, |
||||||
|
SET_REPORT_TIME, |
||||||
|
SET_AREA, |
||||||
|
SET_DATA_RECEPIENT, |
||||||
|
SET_DATA_REPORTER, |
||||||
|
SET_INCIDENT_LOCATION, |
||||||
|
SET_REPORT_LOCATION, |
||||||
|
SET_DATA_INCIDENT, |
||||||
|
SET_DATA_ACHIEVEMENT, |
||||||
|
SET_DATA_TYPE_RISK, |
||||||
|
RESET_INCIDENT_REPORT, |
||||||
|
SET_CHRONOLOGY, |
||||||
|
SET_ROOT_CASE, |
||||||
|
SET_INCIDENT_RISK_POTENTIAL, |
||||||
|
SET_RISK_LEVEL, |
||||||
|
SET_DATA_PREVENTION, |
||||||
|
SET_DATA_IMAGES |
||||||
|
} from './actions'; |
||||||
|
|
||||||
|
const initialState = { |
||||||
|
area: { external: false, internal: false }, |
||||||
|
chronology: null, |
||||||
|
dataAchievement: [], |
||||||
|
dataIncidentReport: [], |
||||||
|
dataPrevention: [], |
||||||
|
dataRecipient: { name: "", noContact: "", position: "" }, |
||||||
|
dataReporter: { name: "", noContact: "", position: "" }, |
||||||
|
incidentDate: null, |
||||||
|
incidentLocation: { location: "", subLocation: "" }, |
||||||
|
incidentRiskPotential: { impact: "", impactDescription: "", likelihood: "", likelihoodDescription: "", value: "" }, |
||||||
|
incidentTime: null, |
||||||
|
dataImage: [], |
||||||
|
reportDate: null, |
||||||
|
reportLocation: { projectLocation: "", reportLocation: "", subLocation: "" }, |
||||||
|
reportTime: null, |
||||||
|
riskLevel: { backgroundColor: "", color: "", level: "" }, |
||||||
|
rootCase: null, |
||||||
|
typeRiskIncident: null, |
||||||
|
}; |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
export default function incidentReportReducer(state = initialState, action) { |
||||||
|
switch (action.type) { |
||||||
|
case SET_INCIDENT_DATE: |
||||||
|
return { ...state, incidentDate: action.payload }; |
||||||
|
case SET_INCIDENT_TIME: |
||||||
|
return { ...state, incidentTime: action.payload }; |
||||||
|
case SET_REPORT_DATE: |
||||||
|
return { ...state, reportDate: action.payload }; |
||||||
|
case SET_REPORT_TIME: |
||||||
|
return { ...state, reportTime: action.payload }; |
||||||
|
case SET_AREA: |
||||||
|
return { ...state, area: action.payload }; |
||||||
|
case SET_DATA_RECEPIENT: |
||||||
|
return { ...state, dataRecipient: { ...state.dataRecipient, ...action.payload } }; |
||||||
|
case SET_DATA_REPORTER: |
||||||
|
return { ...state, dataReporter: { ...state.dataReporter, ...action.payload } }; |
||||||
|
case SET_INCIDENT_LOCATION: |
||||||
|
return { ...state, incidentLocation: { ...state.incidentLocation, ...action.payload } }; |
||||||
|
case SET_REPORT_LOCATION: |
||||||
|
return { ...state, reportLocation: { ...state.reportLocation, ...action.payload } }; |
||||||
|
case SET_DATA_INCIDENT: |
||||||
|
return { ...state, dataIncidentReport: action.payload }; |
||||||
|
case SET_DATA_ACHIEVEMENT: |
||||||
|
return { ...state, dataAchievement: action.payload }; |
||||||
|
case SET_DATA_TYPE_RISK: |
||||||
|
return { ...state, typeRiskIncident: action.payload }; |
||||||
|
case SET_INCIDENT_RISK_POTENTIAL: |
||||||
|
return { ...state, incidentRiskPotential: action.payload }; |
||||||
|
case SET_RISK_LEVEL: |
||||||
|
return { ...state, riskLevel: action.payload }; |
||||||
|
case SET_CHRONOLOGY: |
||||||
|
return { ...state, chronology: action.payload }; |
||||||
|
case SET_ROOT_CASE: |
||||||
|
return { ...state, rootCase: action.payload }; |
||||||
|
case SET_DATA_PREVENTION: |
||||||
|
return { ...state, dataPrevention: action.payload }; |
||||||
|
case SET_DATA_IMAGES: |
||||||
|
return { ...state, dataImage: action.payload }; |
||||||
|
case RESET_INCIDENT_REPORT: |
||||||
|
return initialState; |
||||||
|
default: |
||||||
|
return state; |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue