import { createSlice } from '@reduxjs/toolkit'

const userSlice = createSlice({
	name: 'user',
	initialState: { name: '-', unit: '', user_id: '', user_role: '' },
	reducers: {
		UPDATE_NAME(state, action) {
			state.name = action.payload
		},
		UPDATE_UNIT(state, action) {
			state.unit = action.payload
		},
		UPDATE_USER_ID(state, action) {
			state.user_id = action.payload
		},
		UPDATE_USER_ROLE(state, action) {
			state.user_role = action.payload
		},
	},
})

export const { UPDATE_NAME, UPDATE_UNIT, UPDATE_USER_ID, UPDATE_USER_ROLE } = userSlice.actions

export default userSlice.reducer
