Skip to content

Commit ed760b9

Browse files
committed
feat: add roomId selector and hook for common UI state management
1 parent 64cf7ac commit ed760b9

4 files changed

Lines changed: 16 additions & 1 deletion

File tree

src/store/apiSlice.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { createApi } from "@reduxjs/toolkit/query/react";
22

33
import { axiosBaseQuery } from "../services/httpService";
44

5-
const programId = import.meta.env.VITE_PROGRAM_ID || "app02";
5+
const programId = import.meta.env.VITE_PROGRAM_ID || "app01";
66
console.log("programId == ", programId);
77
const baseApiPath = `/cws/${programId}/api`;
88

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { useSelector } from 'react-redux';
2+
import { selectRoomId } from './commonUiSelectors';
3+
4+
export const useRoomId = () => {
5+
return useSelector(selectRoomId);
6+
};
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { createSelector } from '@reduxjs/toolkit';
2+
import { RootState } from '../store';
3+
4+
5+
export const selectRoomId = createSelector(
6+
(state: RootState) => state.commonUI,
7+
(commonUI) => commonUI.roomId
8+
);

src/store/commonUi/commonUiSlice.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const commonUiSlice = createSlice({
99
state.roomId = action.payload;
1010
},
1111

12+
1213
// resetState: () => {
1314
// // This is here in order to provide an action name to trigger store reset
1415
// // in root store reducer

0 commit comments

Comments
 (0)