All files / src/entities/line/model slice.ts

85.71% Statements 6/7
100% Branches 0/0
66.66% Functions 2/3
85.71% Lines 6/7

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33                  13x           13x         2x     1x           13x   13x  
import { createSlice, type PayloadAction } from '@reduxjs/toolkit';
import { TOOLS } from '@/shared/constants';
 
export interface LineState {
	active: boolean;
	color: string;
	thickness: number;
}
 
const initialState: LineState = {
	active: false,
	color: '#000000',
	thickness: 2,
};
 
const lineSlice = createSlice({
	name: TOOLS.LINE,
	initialState,
	reducers: {
		setLineColor(state, action: PayloadAction<string>) {
			state.color = action.payload;
		},
		setLineThickness(state, action: PayloadAction<number>) {
			state.thickness = action.payload;
		},
		resetLineState: () => initialState,
	},
});
 
export const { setLineColor, setLineThickness, resetLineState } = lineSlice.actions;
 
export const lineReducer = lineSlice.reducer;