@@ -105,6 +106,7 @@ const AppRouter: React.FC = () => {
} />
} />
} />
+
} />
diff --git a/src/store/features/admin/adminService.tsx b/src/store/features/admin/adminService.tsx
index 8c109788..3d380e2c 100644
--- a/src/store/features/admin/adminService.tsx
+++ b/src/store/features/admin/adminService.tsx
@@ -30,6 +30,10 @@ 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 getAllRequests = async () => {
const response = await axiosInstance.get(`/api/user/admin-get-users-request`);
return response.data;
@@ -49,6 +53,32 @@ const acceptOrRejectRequest = async (userRequestId:string , requestStatus:string
const response = await axiosInstance.put(`/api/user/admin-accept-or-reject-request/${userRequestId}`, {requestStatus});
return response.data;
}
+const getPasswordExpiration = async () => {
+ const response = await axiosInstance.get('/api/user/admin-get-password-expiration');
+ return response.data;
+};
+const getTerms = async () => {
+ const response = await axiosInstance.get('/api/user/user-get-terms');
+ return response.data;
+}
+const setTerms = async (type:string,content:string) => {
+ const response = await axiosInstance.post('/api/user/admin-set-terms',{type,content});
+ return response.data;
+}
+
+const getTerm = async (id:string) => {
+ const response = await axiosInstance.get(`/api/user/admin-get-terms/${id}`);
+ return response.data;
+}
+const updateTerm = async (id:string,type:string,content:string) =>{
+ const response = await axiosInstance.put(`/api/user/admin-update-terms/${id}`,{type,content});
+ return response.data;
+}
+
+const deleteTerm = async (id:string) =>{
+ const response = await axiosInstance.delete(`/api/user/admin-delete-terms/${id}`);
+ return response.data;
+}
const adminService = {
getAllUsers,
@@ -57,10 +87,17 @@ const adminService = {
updateUserStatus,
getOrderHistory,
getAllShops,
+ updatePasswordExpiration,
+ getPasswordExpiration,
getAllRequests,
deleteUserRequest,
getRequest,
- acceptOrRejectRequest
+ acceptOrRejectRequest,
+ getTerms,
+ setTerms,
+ getTerm,
+ updateTerm,
+ deleteTerm,
}
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 7b5518cc..570f1341 100644
--- a/src/store/features/admin/adminSlice.tsx
+++ b/src/store/features/admin/adminSlice.tsx
@@ -2,284 +2,591 @@
import { createSlice, createAsyncThunk, PayloadAction } from "@reduxjs/toolkit";
import adminService from "./adminService";
import { getErrorMessage } from "../../../utils/axios/axiosInstance";
-import { AdminReponse, IAdminInitialResponse } from "../../../utils/types/store";
+import {
+ AdminReponse,
+ IAdminInitialResponse,
+} from "../../../utils/types/store";
import { toast } from "react-toastify";
const initialState: IAdminInitialResponse = {
- message: "",
- users: null,
- requests: null,
- request:null,
- isError: false,
- isLoading: false,
- isSuccess: false,
+ message: "",
+ users: null,
+ requests: null,
+ request: null,
+ isError: false,
+ isLoading: false,
+ isSuccess: false,
+ passwordExpiration: null,
+ terms: null,
+ term: null,
};
-export const getAllUsers = createAsyncThunk('admin/getAllUsers', async (_, thunkApi) => {
+export const getAllUsers = createAsyncThunk(
+ "admin/getAllUsers",
+ async (_, thunkApi) => {
try {
- const response = await adminService.getAllUsers();
- return response;
+ const response = await adminService.getAllUsers();
+ return response;
} catch (error) {
- return thunkApi.rejectWithValue(getErrorMessage(error));
+ return thunkApi.rejectWithValue(getErrorMessage(error));
}
-})
+ }
+);
-export const getUserById = createAsyncThunk('admin/getUserById', async (userId: string, thunkApi) => {
+export const getUserById = createAsyncThunk(
+ "admin/getUserById",
+ async (userId: string, thunkApi) => {
try {
- const response = await adminService.getUserById(userId);
- return response.data;
+ const response = await adminService.getUserById(userId);
+ return response.data;
} catch (error) {
- return thunkApi.rejectWithValue(getErrorMessage(error));
+ return thunkApi.rejectWithValue(getErrorMessage(error));
}
-})
+ }
+);
-export const updateUserRole = createAsyncThunk('admin/updateUser', async ({ userId, role }: { userId: string, role: string }, thunkApi) => {
+export const updateUserRole = createAsyncThunk(
+ "admin/updateUser",
+ async ({ userId, role }: { userId: string; role: string }, thunkApi) => {
try {
- const response = await adminService.updateUserRole(userId, role);
- return response;
+ const response = await adminService.updateUserRole(userId, role);
+ return response;
} catch (error) {
- return thunkApi.rejectWithValue(getErrorMessage(error));
+ return thunkApi.rejectWithValue(getErrorMessage(error));
}
-});
+ }
+);
-export const updateUserStatus = createAsyncThunk('admin/updateUserStatus',async({ userId, status }: { userId: string, status: string}, thunkApi) => {
+export const updateUserStatus = createAsyncThunk(
+ "admin/updateUserStatus",
+ async ({ userId, status }: { userId: string; status: string }, thunkApi) => {
try {
- const response = await adminService.updateUserStatus(userId, status);
- return response;
+ const response = await adminService.updateUserStatus(userId, status);
+ return response;
} catch (error) {
- return thunkApi.rejectWithValue(getErrorMessage(error));
+ return thunkApi.rejectWithValue(getErrorMessage(error));
}
-});
-export const getOrderHistory = createAsyncThunk('admin/getOrderHistory', async (_, thunkApi) => {
+ }
+);
+export const getOrderHistory = createAsyncThunk(
+ "admin/getOrderHistory",
+ async (_, thunkApi) => {
try {
- const response = await adminService.getOrderHistory();
- return response;
+ const response = await adminService.getOrderHistory();
+ return response;
} catch (error) {
- return thunkApi.rejectWithValue(getErrorMessage(error));
+ return thunkApi.rejectWithValue(getErrorMessage(error));
}
-});
-export const getAllShops = createAsyncThunk('admin/admin-get-shops', async (_, thunkApi) => {
+ }
+);
+export const getAllShops = createAsyncThunk(
+ "admin/admin-get-shops",
+ async (_, thunkApi) => {
try {
- const response = await adminService.getAllShops();
- return response;
+ const response = await adminService.getAllShops();
+ return response;
} catch (error) {
- return thunkApi.rejectWithValue(getErrorMessage(error));
+ return thunkApi.rejectWithValue(getErrorMessage(error));
}
-});
+ }
+);
-export const getAllRequests = createAsyncThunk('admin/admin-get-requests', async (_,thunkApi)=>{
+export const getAllRequests = createAsyncThunk(
+ "admin/admin-get-requests",
+ async (_, thunkApi) => {
try {
- const response = await adminService.getAllRequests();
- return response;
+ const response = await adminService.getAllRequests();
+ return response;
} catch (error) {
- return thunkApi.rejectWithValue(getErrorMessage(error));
+ return thunkApi.rejectWithValue(getErrorMessage(error));
}
-});
+ }
+);
-export const deleteUserRequest = createAsyncThunk('admin/admin-delete-request', async ({userRequestId,requestId}:{userRequestId:string,requestId:string},thunkApi) => {
+export const deleteUserRequest = createAsyncThunk(
+ "admin/admin-delete-request",
+ async (
+ { userRequestId, requestId }: { userRequestId: string; requestId: string },
+ thunkApi
+ ) => {
try {
- const response = await adminService.deleteUserRequest(userRequestId,requestId);
- return response;
+ const response = await adminService.deleteUserRequest(
+ userRequestId,
+ requestId
+ );
+ return response;
} catch (error) {
- return thunkApi.rejectWithValue(getErrorMessage(error));
+ return thunkApi.rejectWithValue(getErrorMessage(error));
}
-});
+ }
+);
-export const getRequest = createAsyncThunk('admin/admin-get-request', async(userRequestId:string ,thunkApi)=>{
+export const getRequest = createAsyncThunk(
+ "admin/admin-get-request",
+ async (userRequestId: string, thunkApi) => {
try {
- const response = await adminService.getRequest(userRequestId);
- return response
+ const response = await adminService.getRequest(userRequestId);
+ return response;
} catch (error) {
- return thunkApi.rejectWithValue(getErrorMessage(error));
+ return thunkApi.rejectWithValue(getErrorMessage(error));
}
-});
+ }
+);
-export const acceptOrRejectRequest = createAsyncThunk('admin/admin-accept-or-reject-request', async({userRequestId, requestStatus}:{userRequestId:string, requestStatus:string},thunkApi)=>{
+export const acceptOrRejectRequest = createAsyncThunk(
+ "admin/admin-accept-or-reject-request",
+ async (
+ {
+ userRequestId,
+ requestStatus,
+ }: { userRequestId: string; requestStatus: string },
+ thunkApi
+ ) => {
try {
- const response = await adminService.acceptOrRejectRequest(userRequestId, requestStatus);
- return response;
+ const response = await adminService.acceptOrRejectRequest(
+ userRequestId,
+ requestStatus
+ );
+ return response;
} catch (error) {
- return thunkApi.rejectWithValue(getErrorMessage(error));
+ return thunkApi.rejectWithValue(getErrorMessage(error));
}
-})
+ }
+);
-const adminSlice = createSlice({
- name: 'admin',
- initialState,
- reducers: {},
- extraReducers: (builder) => {
- builder
- .addCase(getAllUsers.pending, (state) => {
- state.isLoading = true;
- state.isError = false;
- state.isSuccess = false;
- })
- .addCase(getAllUsers.fulfilled, (state, action:PayloadAction
) => {
- state.isLoading = false;
- state.isError = false;
- state.isSuccess = true;
- state.users = action.payload.data.user;
- state.message = action.payload.message;
+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));
+ }
+ }
+);
- })
- .addCase(getAllUsers.rejected, (state, action:PayloadAction) => {
- state.isLoading = false;
- state.isError = true;
- state.message = action.payload || action.payload.message;
- })
- .addCase(updateUserRole.pending, (state) => {
- state.isLoading = true;
- })
- .addCase(updateUserRole.fulfilled, (state, action:PayloadAction) => {
- const { id, role } = action.payload.data.user;
- const user = state.users.find((user) => user.id === id);
- if (user) {
- user.role = role;
- }
- state.isSuccess = true;
- state.isLoading = false;
- state.message = action.payload.message;
- toast.success(state.message);
- })
- .addCase(updateUserRole.rejected, (state, action:PayloadAction) => {
- state.isLoading = false;
- state.message = action.payload.message;
- toast.error(state.message);
- })
- .addCase(updateUserStatus.pending, (state) => {
- state.isLoading = true;
- })
- .addCase(updateUserStatus.fulfilled, (state, action:PayloadAction) => {
- const { id, status } = action.payload.data.user;
- const user = state.users.find((user) => user.id === id);
- if (user) {
- user.status = status;
- }
- state.isSuccess = true;
- state.isLoading = false;
- state.message = action.payload.message;
- toast.success(state.message);
- })
- .addCase(updateUserStatus.rejected, (state, action:PayloadAction) => {
- state.isLoading = false;
- state.message = action.payload.message;
- toast.error(state.message);
- })
- .addCase(getOrderHistory.pending, (state) => {
- state.isLoading = true;
- state.isError = false;
- state.isSuccess = false;
- })
- .addCase(getOrderHistory.fulfilled, (state, action:PayloadAction) => {
- state.isLoading = false;
- state.isError = false;
- state.isSuccess = true;
- state.users = action.payload.data.user;
- state.message = action.payload.message;
+export const fetchPasswordExpiration = createAsyncThunk(
+ "admin/fetchPasswordExpiration",
+ async (_, thunkApi) => {
+ try {
+ const response = await adminService.getPasswordExpiration();
+ return response.minutes;
+ } catch (error) {
+ return thunkApi.rejectWithValue(getErrorMessage(error));
+ }
+ }
+);
+export const getAllTerms = createAsyncThunk(
+ "admin/getAllTerms",
+ async (_, thunkApi) => {
+ try {
+ const response = await adminService.getTerms();
+ return response;
+ } catch (error) {
+ return thunkApi.rejectWithValue(getErrorMessage(error));
+ }
+ }
+);
+
+export const setTerms = createAsyncThunk(
+ "admin/setTerms",
+ async (
+ { termType, termContent }: { termType: string; termContent: string },
+ thunkApi
+ ) => {
+ try {
+ const response = await adminService.setTerms(termType, termContent);
+ return response;
+ } catch (error) {
+ return thunkApi.rejectWithValue(getErrorMessage(error));
+ }
+ }
+);
+
+export const getTerm = createAsyncThunk(
+ "admin/get-single-term",
+ async (id: string, thunkApi) => {
+ try {
+ const response = await adminService.getTerm(id);
+ return response;
+ } catch (error) {
+ return thunkApi.rejectWithValue(getErrorMessage(error));
+ }
+ }
+);
+export const updateTerm = createAsyncThunk(
+ "admin/update-term",
+ async (
+ {
+ id,
+ termType,
+ termContent,
+ }: { id: string; termType: string; termContent: string },
+ thunkApi
+ ) => {
+ try {
+ const response = await adminService.updateTerm(id, termType, termContent);
+ return response;
+ } catch (error) {
+ return thunkApi.rejectWithValue(getErrorMessage(error));
+ }
+ }
+);
+export const deleteTerm = createAsyncThunk(
+ "admin/delete-term",
+ async (id: string, thunkApi) => {
+ try {
+ const response = await adminService.deleteTerm(id);
+ return response;
+ } catch (error) {
+ return thunkApi.rejectWithValue(getErrorMessage(error));
+ }
+ }
+);
+
+const adminSlice = createSlice({
+ name: "admin",
+ initialState,
+ reducers: {},
+ extraReducers: (builder) => {
+ builder
+ .addCase(getAllUsers.pending, (state) => {
+ state.isLoading = true;
+ state.isError = false;
+ state.isSuccess = false;
+ })
+ .addCase(
+ getAllUsers.fulfilled,
+ (state, action: PayloadAction) => {
+ state.isLoading = false;
+ state.isError = false;
+ state.isSuccess = true;
+ state.users = action.payload.data.user;
+ state.message = action.payload.message;
+ }
+ )
+ .addCase(getAllUsers.rejected, (state, action: PayloadAction) => {
+ state.isLoading = false;
+ state.isError = true;
+ state.message = action.payload || action.payload.message;
+ })
+ .addCase(updateUserRole.pending, (state) => {
+ state.isLoading = true;
+ })
+ .addCase(
+ updateUserRole.fulfilled,
+ (state, action: PayloadAction) => {
+ const { id, role } = action.payload.data.user;
+ const user = state.users.find((user) => user.id === id);
+ if (user) {
+ user.role = role;
+ }
+ state.isSuccess = true;
+ state.isLoading = false;
+ state.message = action.payload.message;
+ toast.success(state.message);
+ }
+ )
+ .addCase(
+ updateUserRole.rejected,
+ (state, action: PayloadAction) => {
+ state.isLoading = false;
+ state.message = action.payload.message;
+ toast.error(state.message);
+ }
+ )
+ .addCase(updateUserStatus.pending, (state) => {
+ state.isLoading = true;
+ })
+ .addCase(
+ updateUserStatus.fulfilled,
+ (state, action: PayloadAction) => {
+ const { id, status } = action.payload.data.user;
+ const user = state.users.find((user) => user.id === id);
+ if (user) {
+ user.status = status;
+ }
+ state.isSuccess = true;
+ state.isLoading = false;
+ state.message = action.payload.message;
+ toast.success(state.message);
+ }
+ )
+ .addCase(
+ updateUserStatus.rejected,
+ (state, action: PayloadAction) => {
+ state.isLoading = false;
+ state.message = action.payload.message;
+ toast.error(state.message);
+ }
+ )
+ .addCase(getOrderHistory.pending, (state) => {
+ state.isLoading = true;
+ state.isError = false;
+ state.isSuccess = false;
+ })
+ .addCase(
+ getOrderHistory.fulfilled,
+ (state, action: PayloadAction) => {
+ state.isLoading = false;
+ state.isError = false;
+ state.isSuccess = true;
+ state.users = action.payload.data.user;
+ state.message = action.payload.message;
+ }
+ )
+ .addCase(
+ getOrderHistory.rejected,
+ (state, action: PayloadAction) => {
+ state.isLoading = false;
+ state.isError = true;
+ state.message = action.payload || action.payload.message;
+ }
+ )
+ .addCase(getAllShops.pending, (state) => {
+ state.isLoading = true;
+ state.isError = false;
+ state.isSuccess = false;
+ })
+ .addCase(
+ getAllShops.fulfilled,
+ (state, action: PayloadAction) => {
+ state.isLoading = false;
+ state.isError = false;
+ state.isSuccess = true;
+ state.users = action.payload.data.user;
+ state.message = action.payload.message;
+ }
+ )
+ .addCase(getAllShops.rejected, (state, action: PayloadAction) => {
+ state.isLoading = false;
+ state.isError = true;
+ state.message = action.payload || action.payload.message;
+ })
+ .addCase(getAllRequests.pending, (state) => {
+ state.isLoading = true;
+ state.isError = false;
+ state.isSuccess = false;
+ })
+ .addCase(
+ getAllRequests.fulfilled,
+ (state, action: PayloadAction) => {
+ state.isLoading = false;
+ state.isError = false;
+ state.isSuccess = true;
+ state.requests = action.payload.data.sellerProfiles;
+ state.message = action.payload.message;
+ toast.success(state.message);
+ }
+ )
+ .addCase(getAllRequests.rejected, (state, action: PayloadAction) => {
+ state.isLoading = false;
+ state.isError = true;
+ state.message = action.payload;
+ toast.error(state.message);
+ })
+ .addCase(deleteUserRequest.pending, (state) => {
+ state.isLoading = true;
+ state.isError = false;
+ state.isSuccess = false;
+ })
+ .addCase(
+ deleteUserRequest.fulfilled,
+ (state, action: PayloadAction) => {
+ state.isLoading = false;
+ state.isError = false;
+ state.isSuccess = true;
+ state.message = action.payload.message;
+ toast.success(state.message);
+ }
+ )
+ .addCase(
+ deleteUserRequest.rejected,
+ (state, action: PayloadAction) => {
+ state.isLoading = false;
+ state.isError = true;
+ state.message = action.payload;
+ }
+ )
+ .addCase(getRequest.pending, (state) => {
+ state.isLoading = true;
+ state.isError = false;
+ state.isSuccess = false;
+ })
+ .addCase(
+ getRequest.fulfilled,
+ (state, action: PayloadAction) => {
+ state.isLoading = false;
+ state.isError = false;
+ state.isSuccess = true;
+ state.request = action.payload.data.sellerRequest;
+ state.message = action.payload.message;
+ toast.success(state.message);
+ }
+ )
+ .addCase(getRequest.rejected, (state, action: PayloadAction) => {
+ state.isLoading = false;
+ state.isError = true;
+ state.message = action.payload;
+ })
+ .addCase(acceptOrRejectRequest.pending, (state) => {
+ state.isLoading = true;
+ state.isError = false;
+ state.isSuccess = false;
+ })
+ .addCase(
+ acceptOrRejectRequest.fulfilled,
+ (state, action: PayloadAction) => {
+ state.isLoading = false;
+ state.isError = false;
+ state.isSuccess = true;
+ state.request = action.payload.data.sellerRequest;
+ state.message = action.payload.message;
+ toast.success(state.message);
+ console.log(state.request);
+ }
+ )
+ .addCase(
+ acceptOrRejectRequest.rejected,
+ (state, action: PayloadAction) => {
+ state.isLoading = false;
+ state.isError = true;
+ state.message = action.payload;
+ toast.error(state.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(getOrderHistory.rejected, (state, action:PayloadAction) => {
- state.isLoading = false;
- state.isError = true;
- state.message = action.payload || action.payload.message;
- })
- .addCase(getAllShops.pending, (state) => {
- state.isLoading = true;
- state.isError = false;
- state.isSuccess = false;
- })
- .addCase(getAllShops.fulfilled, (state, action:PayloadAction) => {
- state.isLoading = false;
- state.isError = false;
- state.isSuccess = true;
- state.users = action.payload.data.user;
- state.message = action.payload.message;
+ .addCase(
+ fetchPasswordExpiration.rejected,
+ (state, action: PayloadAction) => {
+ state.isLoading = false;
+ state.isError = true;
+ state.message = action.payload;
+ toast.error(state.message);
+ }
+ )
+ .addCase(getAllTerms.pending, (state) => {
+ state.isLoading = true;
+ })
+ .addCase(getAllTerms.fulfilled, (state, action: PayloadAction) => {
+ state.isLoading = false;
+ state.isSuccess = true;
+ state.message = action.payload.message;
+ state.terms = action.payload.data.termsAndCondition;
+ state.isError = false;
+ toast(state.message);
+ })
- })
- .addCase(getAllShops.rejected, (state, action:PayloadAction) => {
- state.isLoading = false;
- state.isError = true;
- state.message = action.payload || action.payload.message;
- })
- .addCase(getAllRequests.pending, (state) => {
- state.isLoading = true;
- state.isError = false;
- state.isSuccess = false;
- })
- .addCase(getAllRequests.fulfilled, (state, action:PayloadAction) => {
- state.isLoading = false;
- state.isError = false;
- state.isSuccess = true;
- state.requests = action.payload.data.sellerProfiles;
- state.message = action.payload.message;
- toast.success(state.message);
+ .addCase(getAllTerms.rejected, (state, action: PayloadAction) => {
+ state.isLoading = false;
+ state.isError = true;
+ state.message = action.payload;
+ })
+ .addCase(setTerms.pending, (state) => {
+ state.isLoading = true;
+ })
+ .addCase(setTerms.fulfilled, (state, action: PayloadAction) => {
+ state.isLoading = false;
+ state.isSuccess = true;
+ state.message = action.payload.message;
+ state.terms = action.payload.data.termsAndCondition;
+ state.isError = false;
+ toast.success(state.message);
+ })
- })
- .addCase(getAllRequests.rejected, (state, action:PayloadAction) => {
- state.isLoading = false;
- state.isError = true;
- state.message = action.payload;
- toast.error(state.message)
- })
- .addCase(deleteUserRequest.pending, (state) => {
- state.isLoading = true;
- state.isError = false;
- state.isSuccess = false;
- })
- .addCase(deleteUserRequest.fulfilled, (state, action:PayloadAction) => {
- state.isLoading = false;
- state.isError = false;
- state.isSuccess = true;
- state.message = action.payload.message;
- toast.success(state.message);
+ .addCase(setTerms.rejected, (state, action: PayloadAction) => {
+ state.isLoading = false;
+ state.isError = true;
+ state.message = action.payload;
+ toast.error(state.message);
+ })
+ .addCase(getTerm.pending, (state) => {
+ state.isLoading = true;
+ })
+ .addCase(getTerm.fulfilled, (state, action: PayloadAction) => {
+ state.isLoading = false;
+ state.isSuccess = true;
+ state.message = action.payload.message;
+ state.term = action.payload.data.termsAndCondition;
+ state.isError = false;
+ toast(state.message);
+ })
- })
- .addCase(deleteUserRequest.rejected, (state, action:PayloadAction) => {
- state.isLoading = false;
- state.isError = true;
- state.message = action.payload;
- })
- .addCase(getRequest.pending, (state) => {
- state.isLoading = true;
- state.isError = false;
- state.isSuccess = false;
- })
- .addCase(getRequest.fulfilled, (state, action:PayloadAction) => {
- state.isLoading = false;
- state.isError = false;
- state.isSuccess = true;
- state.request = action.payload.data.sellerRequest;
- state.message = action.payload.message;
- toast.success(state.message);
+ .addCase(getTerm.rejected, (state, action: PayloadAction) => {
+ state.isLoading = false;
+ state.isError = true;
+ state.message = action.payload;
+ toast.error(state.message);
+ })
+ .addCase(updateTerm.pending, (state) => {
+ state.isLoading = true;
+ })
+ .addCase(updateTerm.fulfilled, (state, action: PayloadAction) => {
+ state.isLoading = false;
+ state.isSuccess = true;
+ state.message = action.payload.message;
+ state.term = action.payload.data.termsAndCondition;
+ state.isError = false;
+ toast.success(state.message);
+ })
- })
- .addCase(getRequest.rejected, (state, action:PayloadAction) => {
- state.isLoading = false;
- state.isError = true;
- state.message = action.payload;
- })
- .addCase(acceptOrRejectRequest.pending, (state) => {
- state.isLoading = true;
- state.isError = false;
- state.isSuccess = false;
- })
- .addCase(acceptOrRejectRequest.fulfilled, (state, action:PayloadAction) => {
- state.isLoading = false;
- state.isError = false;
- state.isSuccess = true;
- state.request = action.payload.data.sellerRequest;
- state.message = action.payload.message;
- toast.success(state.message);
- console.log(state.request);
+ .addCase(updateTerm.rejected, (state, action: PayloadAction) => {
+ state.isLoading = false;
+ state.isError = true;
+ state.message = action.payload;
+ toast.error(state.message);
+ })
+ .addCase(deleteTerm.pending, (state) => {
+ state.isLoading = true;
+ })
+ .addCase(deleteTerm.fulfilled, (state, action: PayloadAction) => {
+ state.isLoading = false;
+ state.isSuccess = true;
+ state.message = action.payload.message;
+ state.isError = false;
+ toast.success(state.message);
+ })
- })
- .addCase(acceptOrRejectRequest.rejected, (state, action:PayloadAction) => {
- state.isLoading = false;
- state.isError = true;
- state.message = action.payload;
- toast.error(state.message);
- })
-},
+ .addCase(deleteTerm.rejected, (state, action: PayloadAction) => {
+ state.isLoading = false;
+ state.isError = true;
+ state.message = action.payload;
+ toast.error(state.message);
+ });
+ },
});
-export default adminSlice.reducer;
\ No newline at end of file
+export default adminSlice.reducer;
diff --git a/src/utils/axios/axiosInstance.ts b/src/utils/axios/axiosInstance.ts
index 0860e069..6d550dca 100644
--- a/src/utils/axios/axiosInstance.ts
+++ b/src/utils/axios/axiosInstance.ts
@@ -1,7 +1,7 @@
/* eslint-disable */
import axios from "axios";
-// export const URL = "https://e-commerce-ninjas-platform-backend.onrender.com";
-export const URL = "http://localhost:5001";
+export const URL = "https://e-commerce-ninjas-platform-backend.onrender.com";
+// export const URL = "http://localhost:5001";
const axiosInstance = axios.create({
baseURL: `${URL}`,
headers: {
diff --git a/src/utils/text/truncateString.ts b/src/utils/text/truncateString.ts
index 34c8b2db..444998d6 100644
--- a/src/utils/text/truncateString.ts
+++ b/src/utils/text/truncateString.ts
@@ -1,5 +1,5 @@
/* eslint-disable */
-function truncateString(str: string , maxLength: number): string {
+export function truncateString(str: string , maxLength: number): string {
if (str.length <= maxLength) {
return str;
} else {
@@ -7,4 +7,25 @@ function truncateString(str: string , maxLength: number): string {
}
}
-export default truncateString;
\ No newline at end of file
+
+
+export function formatTextToParagraph(text) {
+ const maxCharLimit = 200;
+ let paragraphs = [];
+ const words = text.split(' ');
+
+ let currentParagraph = '';
+
+ words.forEach((word) => {
+ if ((currentParagraph + word).length > maxCharLimit) {
+ paragraphs.push(currentParagraph.trim());
+ currentParagraph = `${word} `;
+ } else {
+ currentParagraph += `${word} `;
+ }
+ });
+ if (currentParagraph.trim()) {
+ paragraphs.push(currentParagraph.trim());
+ }
+ return paragraphs.join('\n\n');
+ }
diff --git a/src/utils/types/store.d.ts b/src/utils/types/store.d.ts
index f06481fa..cb0f0860 100644
--- a/src/utils/types/store.d.ts
+++ b/src/utils/types/store.d.ts
@@ -215,6 +215,9 @@ export interface IAdminInitialResponse {
isSuccess: boolean;
isLoading: boolean;
message: string | null;
+ passwordExpiration:null;
+ terms:null;
+ term:null;
}
export interface ISingleProductResponse {