-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #55 from Spaces-Place/dusqo
bookingdata 전역상태관리로 변경
- Loading branch information
Showing
6 changed files
with
206 additions
and
29 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,55 @@ | ||
import { createSlice } from '@reduxjs/toolkit'; | ||
import { initialBookingData } from '../constants/bookingIndex'; | ||
|
||
const bookingSlice = createSlice({ | ||
name: 'booking', | ||
initialState: { | ||
bookingData: initialBookingData, | ||
bookingInfo: null, | ||
totalPrice: 0, | ||
step: 1, | ||
usageUnit: null | ||
}, | ||
reducers: { | ||
saveBookingData: (state, action) => { | ||
state.bookingData = action.payload.bookingData; | ||
state.bookingInfo = action.payload.bookingInfo; | ||
state.totalPrice = action.payload.totalPrice; | ||
state.usageUnit = action.payload.usageUnit; | ||
}, | ||
updateBookingData: (state, action) => { | ||
state.bookingData = { | ||
...state.bookingData, | ||
[action.payload.name]: action.payload.value | ||
}; | ||
}, | ||
setBookingInfo: (state, action) => { | ||
state.bookingInfo = action.payload; | ||
state.usageUnit = action.payload.usageUnit; | ||
}, | ||
setTotalPrice: (state, action) => { | ||
state.totalPrice = action.payload; | ||
}, | ||
setStep: (state, action) => { | ||
state.step = action.payload; | ||
}, | ||
resetBooking: (state) => { | ||
state.bookingData = initialBookingData; | ||
state.bookingInfo = null; | ||
state.totalPrice = 0; | ||
state.step = 1; | ||
state.usageUnit = null; | ||
} | ||
} | ||
}); | ||
|
||
export const { | ||
saveBookingData, | ||
updateBookingData, | ||
setBookingInfo, | ||
setTotalPrice, | ||
setStep, | ||
resetBooking | ||
} = bookingSlice.actions; | ||
|
||
export default bookingSlice.reducer; |
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,11 @@ | ||
// store/index.js | ||
import { configureStore } from '@reduxjs/toolkit'; | ||
import bookingReducer from './bookingSlice'; | ||
|
||
export const store = configureStore({ | ||
reducer: { | ||
booking: bookingReducer | ||
} | ||
}); | ||
|
||
export default store; |