2023-03-20 15:59:50 +00:00
|
|
|
import { createSlice, type PayloadAction } from "@reduxjs/toolkit";
|
|
|
|
import * as carrier from "./carrier.js";
|
2022-03-02 00:14:01 +00:00
|
|
|
|
2023-03-20 15:59:50 +00:00
|
|
|
const initialState = {
|
|
|
|
shipType: "",
|
|
|
|
shipClass: "",
|
|
|
|
isCarrier: false,
|
|
|
|
mass: 10,
|
|
|
|
};
|
2022-03-06 19:10:44 +00:00
|
|
|
|
2023-03-20 15:59:50 +00:00
|
|
|
const identification = createSlice({
|
|
|
|
name: "identification",
|
|
|
|
initialState,
|
|
|
|
reducers: {
|
|
|
|
setShipType(state, action: PayloadAction<string>) {
|
|
|
|
state.shipType = action.payload;
|
|
|
|
},
|
|
|
|
setShipClass(state, action: PayloadAction<string>) {
|
|
|
|
state.shipClass = action.payload;
|
|
|
|
},
|
2022-03-02 00:14:01 +00:00
|
|
|
},
|
2023-03-20 15:59:50 +00:00
|
|
|
extraReducers(builder) {
|
|
|
|
builder.addCase(
|
|
|
|
carrier.actions.setCarrierBays,
|
|
|
|
(state, action: PayloadAction<number>) => {
|
|
|
|
state.isCarrier = action.payload > 0;
|
|
|
|
}
|
|
|
|
);
|
2022-03-02 00:14:01 +00:00
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2023-03-20 15:59:50 +00:00
|
|
|
export const { actions, reducer } = identification;
|