clientid works
This commit is contained in:
@ -11,11 +11,13 @@ import { NewsApi } from "../slice/NewsApi";
|
||||
|
||||
export type AuthDataType = {
|
||||
token: string | null;
|
||||
clientId: string | null;
|
||||
user: { name: string | null; username: string } | null;
|
||||
};
|
||||
|
||||
const initialAuthDataState: AuthDataType = {
|
||||
token: null,
|
||||
clientId: null,
|
||||
user: null,
|
||||
};
|
||||
|
||||
@ -35,6 +37,8 @@ export type StorePrototype = {
|
||||
|
||||
export const updateToken = createAction<string>("auth/updateToken");
|
||||
export const getLocalToken = createAction("auth/getLocalToken");
|
||||
export const updateClient = createAction<string>("auth/updateClient");
|
||||
export const getLocalClient = createAction("auth/getLocalClient");
|
||||
export const updateUser = createAction<User>("auth/updateUser");
|
||||
export const logOut = createAction("auth/logOut");
|
||||
|
||||
@ -58,6 +62,16 @@ export const store = configureStore({
|
||||
state.token = token;
|
||||
}
|
||||
});
|
||||
builder.addCase(updateClient, (state, action) => {
|
||||
state.clientId = action.payload;
|
||||
localStorage.setItem("clientId", action.payload);
|
||||
});
|
||||
builder.addCase(getLocalClient, (state) => {
|
||||
const clientId: string | null = localStorage.getItem("clientId");
|
||||
if (clientId) {
|
||||
state.clientId = clientId;
|
||||
}
|
||||
});
|
||||
builder.addCase(updateUser, (state, action) => {
|
||||
state.user = action.payload;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user