summaryrefslogtreecommitdiff
path: root/extension/react-app/src/redux/slices/configSlice.ts
blob: a6a641e66ff7f8323fb00cc6b9e4d3cac81afd2c (plain)
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
34
35
36
37
38
39
40
41
42
43
44
45
import { createSlice } from "@reduxjs/toolkit";
import { RootStore } from "../store";

export const configSlice = createSlice({
  name: "config",
  initialState: {
    apiUrl: "http://localhost:8000",
  } as RootStore["config"],
  reducers: {
    setWorkspacePath: (
      state: RootStore["config"],
      action: { type: string; payload: string }
    ) => {
      return {
        ...state,
        workspacePath: action.payload,
      };
    },
    setApiUrl: (
      state: RootStore["config"],
      action: { type: string; payload: string }
    ) => ({
      ...state,
      apiUrl: action.payload,
    }),
    setVscMachineId: (
      state: RootStore["config"],
      action: { type: string; payload: string }
    ) => ({
      ...state,
      vscMachineId: action.payload,
    }),
    setSessionId: (
      state: RootStore["config"],
      action: { type: string; payload: string }
    ) => ({
      ...state,
      sessionId: action.payload,
    }),
  },
});

export const { setVscMachineId, setApiUrl, setWorkspacePath, setSessionId } =
  configSlice.actions;
export default configSlice.reducer;