@@ -98,6 +99,7 @@ const AppRouter: React.FC = () => {
>
} />
} />
+
} />
diff --git a/src/store/features/admin/adminService.tsx b/src/store/features/admin/adminService.tsx
index 5bf1eba0..32564065 100644
--- a/src/store/features/admin/adminService.tsx
+++ b/src/store/features/admin/adminService.tsx
@@ -30,8 +30,15 @@ const getAllShops = async () => {
return response.data;
}
+const updatePasswordExpiration = async (minutes: number) => {
+ const response = await axiosInstance.put('/api/user/admin-update-password-expiration', { minutes });
+ return response.data;
+};
-
+const getPasswordExpiration = async () => {
+ const response = await axiosInstance.get('/api/user/admin-get-password-expiration');
+ return response.data;
+};
const adminService = {
getAllUsers,
@@ -39,7 +46,9 @@ const adminService = {
updateUserRole,
updateUserStatus,
getOrderHistory,
- getAllShops
+ getAllShops,
+ updatePasswordExpiration,
+ getPasswordExpiration,
}
export default adminService;
\ No newline at end of file
diff --git a/src/store/features/admin/adminSlice.tsx b/src/store/features/admin/adminSlice.tsx
index 8f106688..746f112e 100644
--- a/src/store/features/admin/adminSlice.tsx
+++ b/src/store/features/admin/adminSlice.tsx
@@ -11,6 +11,7 @@ const initialState: IAdminInitialResponse = {
isError: false,
isLoading: false,
isSuccess: false,
+ passwordExpiration:null
};
export const getAllUsers = createAsyncThunk('admin/getAllUsers', async (_, thunkApi) => {
@@ -65,6 +66,27 @@ export const getAllShops = createAsyncThunk('admin/admin-get-shops', async (_, t
}
})
+export const updateUserPasswordExpiration = createAsyncThunk(
+ 'admin/updateUserPasswordExpiration',
+ async ({ minutes }: { minutes: number }, thunkApi) => {
+ try {
+ const response = await adminService.updatePasswordExpiration(minutes);
+ return response;
+ } catch (error) {
+ return thunkApi.rejectWithValue(getErrorMessage(error));
+ }
+ }
+);
+
+export const fetchPasswordExpiration = createAsyncThunk('admin/fetchPasswordExpiration', async (_, thunkApi) => {
+ try {
+ const response = await adminService.getPasswordExpiration();
+ return response.minutes;
+ } catch (error) {
+ return thunkApi.rejectWithValue(getErrorMessage(error));
+ }
+});
+
const adminSlice = createSlice({
name: 'admin',
initialState,
@@ -163,6 +185,36 @@ const adminSlice = createSlice({
state.isError = true;
state.message = action.payload || action.payload.message;
})
+ .addCase(updateUserPasswordExpiration.pending, (state) => {
+ state.isLoading = true;
+ })
+ .addCase(updateUserPasswordExpiration.fulfilled, (state, action: PayloadAction
) => {
+ state.isLoading = false;
+ state.isSuccess = true;
+ state.isError = false;
+ state.message = action.payload.message;
+ toast.success(state.message);
+ })
+ .addCase(updateUserPasswordExpiration.rejected, (state, action: PayloadAction) => {
+ state.isLoading = false;
+ state.isError = true;
+ state.message = action.payload || action.payload.message;
+ toast.error(state.message);
+ })
+ .addCase(fetchPasswordExpiration.pending, (state) => {
+ state.isLoading = true;
+ })
+ .addCase(fetchPasswordExpiration.fulfilled, (state, action: PayloadAction) => {
+ state.isLoading = false;
+ state.passwordExpiration = action.payload;
+ })
+
+ .addCase(fetchPasswordExpiration.rejected, (state, action: PayloadAction) => {
+ state.isLoading = false;
+ state.isError = true;
+ state.message = action.payload;
+ toast.error(state.message);
+ })
},
});
diff --git a/src/utils/types/store.d.ts b/src/utils/types/store.d.ts
index c003b4f0..005f7b16 100644
--- a/src/utils/types/store.d.ts
+++ b/src/utils/types/store.d.ts
@@ -187,6 +187,7 @@ export interface IAdminInitialResponse {
isSuccess: boolean;
isLoading: boolean;
message: string | null;
+ passwordExpiration:null;
}
export interface ISingleProductResponse {