| @@ -100,6 +100,7 @@ const BigProfileCard = (props) => { | |||
| )} | |||
| {deleteOrEditModal.show && ( | |||
| <DeleteCategory | |||
| customId={props.profile._id} | |||
| setOpenedDeleteModal={closeModalHandler} | |||
| type={deleteOrEditModal.type} | |||
| customLabeledCard={<UserLabeledCard user={props.profile} />} | |||
| @@ -1,18 +1,6 @@ | |||
| import { Box } from "@mui/material"; | |||
| import styled, { keyframes } from "styled-components"; | |||
| import selectedTheme from "../../../../themes"; | |||
| const skeletonAnimation = keyframes` | |||
| 0% { | |||
| opacity: 1; | |||
| } | |||
| 50% { | |||
| opacity: 0.63; | |||
| } | |||
| 100% { | |||
| opacity: 1 | |||
| } | |||
| `; | |||
| const skeletonBackgroundAnimation = keyframes` | |||
| 0% { | |||
| opacity: 1; | |||
| @@ -27,7 +15,7 @@ const skeletonBackgroundAnimation = keyframes` | |||
| export const SkeletonItemBackgroundColor = styled(Box)` | |||
| background-color: ${selectedTheme.colors.filterSkeletonItems}; | |||
| animation: ${skeletonAnimation} 1.2s infinite; | |||
| animation: ${skeletonBackgroundAnimation} 1.2s infinite; | |||
| `; | |||
| export const SkeletonBackgroundColor = styled(Box)` | |||
| background-color: ${selectedTheme.colors.filterSkeletonBackground}; | |||
| @@ -39,7 +39,7 @@ const DeleteCategory = (props) => { | |||
| type: props.type, | |||
| method: DELETE_TYPE, | |||
| name: props.category?.name, | |||
| id: props.category?._id, | |||
| id: props.customId || props.category?._id, | |||
| categoryId: props.categoryId, | |||
| handleApiResponseSuccess, | |||
| }) | |||
| @@ -96,6 +96,7 @@ DeleteCategory.propTypes = { | |||
| customLabeledCardHeight: PropTypes.string, | |||
| customLabeledCardIcon: PropTypes.node, | |||
| categoryId: PropTypes.string, | |||
| customId: PropTypes.string, | |||
| }; | |||
| export default DeleteCategory; | |||
| @@ -3,3 +3,5 @@ export const SUBCATEGORIES_TYPE = "subcategories"; | |||
| export const USERS_TYPE = "users"; | |||
| export const LOCATIONS_TYPE = "locations"; | |||
| export const REVIEW_TYPE = "reviews"; | |||
| export const USERS_BLOCK_TYPE = "blockUser"; | |||
| export const USERS_DELETE_TYPE = "deleteUser" | |||
| @@ -123,6 +123,8 @@ export default { | |||
| editProfileAsAdmin: "admin/users/{userId}", | |||
| getAllProfiles: "users", | |||
| getAllProfilesAsAdmin: "admin/users", | |||
| deleteProfileAsAdmin: "admin/users/{userId}", | |||
| blockProfileAsAdmin: "admin/users/{userId}/block", | |||
| }, | |||
| applications: { | |||
| application: "/applications/{applicationUid}", | |||
| @@ -1,4 +1,10 @@ | |||
| import { getRequest, putRequest, replaceInUrl } from "."; | |||
| import { | |||
| deleteRequest, | |||
| getRequest, | |||
| patchRequest, | |||
| putRequest, | |||
| replaceInUrl, | |||
| } from "."; | |||
| import apiEndpoints from "./apiEndpoints"; | |||
| export const attemptFetchProfile = (payload) => | |||
| @@ -16,3 +22,15 @@ export const attemptEditProfileAsAdmin = (payload, requestData) => | |||
| replaceInUrl(apiEndpoints.users.editProfileAsAdmin, { userId: payload }), | |||
| requestData | |||
| ); | |||
| export const attemptDeleteProfileAsAdmin = (payload) => | |||
| deleteRequest( | |||
| replaceInUrl(apiEndpoints.users.deleteProfileAsAdmin, { | |||
| userId: payload.userId, | |||
| }) | |||
| ); | |||
| export const attemptBlockProfileAsAdmin = (payload) => | |||
| patchRequest( | |||
| replaceInUrl(apiEndpoints.users.blockProfileAsAdmin, { | |||
| userId: payload.userId, | |||
| }) | |||
| ); | |||
| @@ -8,6 +8,8 @@ import { | |||
| CATEGORIES_TYPE, | |||
| LOCATIONS_TYPE, | |||
| SUBCATEGORIES_TYPE, | |||
| USERS_BLOCK_TYPE, | |||
| USERS_DELETE_TYPE, | |||
| } from "../../constants/adminTypeConstants"; | |||
| import { | |||
| attemptAddNewCategory, | |||
| @@ -22,6 +24,7 @@ import { | |||
| attemptDeleteLocation, | |||
| attemptEditLocation, | |||
| } from "../../request/locationsRequest"; | |||
| import { attemptBlockProfileAsAdmin, attemptDeleteProfileAsAdmin } from "../../request/profileRequest"; | |||
| // import { attemptAddNewCategory } from "../../request/categoriesRequest"; | |||
| import { ADMIN_FETCH } from "../actions/admin/adminActionConstants"; | |||
| import { | |||
| @@ -30,6 +33,7 @@ import { | |||
| } from "../actions/admin/adminActions"; | |||
| import { fetchCategories } from "../actions/categories/categoriesActions"; | |||
| import { fetchLocations } from "../actions/locations/locationsActions"; | |||
| import { fetchAllProfilesAsAdmin } from "../actions/profile/profileActions"; | |||
| function* editCategory(payload) { | |||
| try { | |||
| @@ -137,6 +141,22 @@ function* deleteLocation(payload) { | |||
| yield call(console.log, e); | |||
| } | |||
| } | |||
| function* deleteUser(payload) { | |||
| try { | |||
| yield call(attemptDeleteProfileAsAdmin, { userId: payload.id }); | |||
| yield put(fetchAllProfilesAsAdmin()); | |||
| } catch (e) { | |||
| yield call(console.log, e); | |||
| } | |||
| } | |||
| function* blockUser(payload) { | |||
| try { | |||
| yield call(attemptBlockProfileAsAdmin, { userId: payload.id }); | |||
| yield put(fetchAllProfilesAsAdmin()); | |||
| } catch (e) { | |||
| yield call(console.log, e); | |||
| } | |||
| } | |||
| function* fetchAdminMethod({ payload }) { | |||
| try { | |||
| @@ -180,6 +200,10 @@ function* fetchAdminMethod({ payload }) { | |||
| yield call(deleteLocation, { | |||
| id: payload.id, | |||
| }); | |||
| } else if (payload.type === USERS_DELETE_TYPE) { | |||
| yield call(deleteUser, { id: payload.id }); | |||
| } else if (payload.type === USERS_BLOCK_TYPE) { | |||
| yield call(blockUser, { id: payload.id }); | |||
| } | |||
| if (payload.handleApiResponseSuccess) | |||
| yield call(payload.handleApiResponseSuccess); | |||