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