diff --git a/app/layout/project/sidebar/project/inventory-panel/constants.ts b/app/layout/project/sidebar/project/inventory-panel/constants.ts index 1e730c61c8..eb66ee3b1a 100644 --- a/app/layout/project/sidebar/project/inventory-panel/constants.ts +++ b/app/layout/project/sidebar/project/inventory-panel/constants.ts @@ -5,9 +5,9 @@ import CostSurfaceInfo from './cost-surfaces/info'; import FeaturesTable from './features'; import FeaturesInfo from './features/info'; import FeatureUploadModal from './features/modals/upload'; -import ProtectedAreasTable from './protected-areas'; -import ProtectedAreasFooter from './protected-areas/footer'; import { InventoryPanel } from './types'; +import ProtectedAreasTable from './wdpas'; +import ProtectedAreasFooter from './wdpas/footer'; export const INVENTORY_TABS = { 'protected-areas': { diff --git a/app/layout/project/sidebar/project/inventory-panel/cost-surfaces/bulk-action-menu/utils.ts b/app/layout/project/sidebar/project/inventory-panel/cost-surfaces/bulk-action-menu/utils.ts index e0cba8e243..d458ead34d 100644 --- a/app/layout/project/sidebar/project/inventory-panel/cost-surfaces/bulk-action-menu/utils.ts +++ b/app/layout/project/sidebar/project/inventory-panel/cost-surfaces/bulk-action-menu/utils.ts @@ -1,75 +1,28 @@ import { Session } from 'next-auth'; -import { Feature } from 'types/api/feature'; +import { CostSurface } from 'types/api/cost-surface'; import { Project } from 'types/api/project'; import PROJECTS from 'services/projects'; -export function bulkDeleteFeatureFromProject( +export function bulkDeleteCostSurfaceFromProject( pid: Project['id'], - fids: Feature['id'][], + csids: CostSurface['id'][], session: Session ) { - const deleteFeatureFromProject = ({ pid, fid }: { pid: Project['id']; fid: Feature['id'] }) => { - return PROJECTS.delete(`/${pid}/features/${fid}`, { - headers: { - Authorization: `Bearer ${session.accessToken}`, - }, - }); - }; - - return Promise.all(fids.map((fid) => deleteFeatureFromProject({ pid, fid }))); -} - -export function editFeaturesTagsBulk( - projectId: Project['id'], - featureIds: Feature['id'][], - session: Session, - data: { - tagName: string; - } -) { - const editFeatureTag = ({ - featureId, - projectId, - data, - }: { - featureId: Feature['id']; - projectId: Project['id']; - data: { - tagName: string; - }; - }) => { - return PROJECTS.request({ - method: 'PATCH', - url: `/${projectId}/features/${featureId}/tags`, - data, - headers: { - Authorization: `Bearer ${session.accessToken}`, - }, - }); - }; - return Promise.all(featureIds.map((featureId) => editFeatureTag({ projectId, featureId, data }))); -} - -export function deleteFeaturesTagsBulk( - projectId: Project['id'], - featureIds: Feature['id'][], - session: Session -) { - const deleteFeatureTags = ({ - projectId, - featureId, + const deleteCostSurfaceFromProject = ({ + pid, + csid, }: { - projectId: Project['id']; - featureId: Feature['id']; + pid: Project['id']; + csid: CostSurface['id']; }) => { - return PROJECTS.delete(`/${projectId}/features/${featureId}/tags`, { + return PROJECTS.delete(`/${pid}/cost-surfaces/${csid}`, { headers: { Authorization: `Bearer ${session.accessToken}`, }, }); }; - return Promise.all(featureIds.map((featureId) => deleteFeatureTags({ projectId, featureId }))); + return Promise.all(csids.map((csid) => deleteCostSurfaceFromProject({ pid, csid }))); } diff --git a/app/layout/project/sidebar/project/inventory-panel/cost-surfaces/modals/delete/index.tsx b/app/layout/project/sidebar/project/inventory-panel/cost-surfaces/modals/delete/index.tsx index 0c242180f0..095c5bc7c4 100644 --- a/app/layout/project/sidebar/project/inventory-panel/cost-surfaces/modals/delete/index.tsx +++ b/app/layout/project/sidebar/project/inventory-panel/cost-surfaces/modals/delete/index.tsx @@ -12,9 +12,8 @@ import { useToasts } from 'hooks/toast'; import { Button } from 'components/button/component'; import Icon from 'components/icon/component'; import { ModalProps } from 'components/modal'; -import { bulkDeleteFeatureFromProject } from 'layout/project/sidebar/project/inventory-panel/features/bulk-action-menu/utils'; +import { bulkDeleteCostSurfaceFromProject } from 'layout/project/sidebar/project/inventory-panel/cost-surfaces/bulk-action-menu/utils'; import { CostSurface } from 'types/api/cost-surface'; -import { Pagination } from 'types/api/meta'; import ALERT_SVG from 'svgs/ui/new-layout/alert.svg?sprite'; @@ -48,7 +47,7 @@ const DeleteModal = ({ const handleBulkDelete = useCallback(() => { const deletableFeatureIds = selectedCostSurfaces.map(({ id }) => id); - bulkDeleteFeatureFromProject(pid, deletableFeatureIds, session) + bulkDeleteCostSurfaceFromProject(pid, deletableFeatureIds, session) .then(async () => { await queryClient.invalidateQueries(['cost-surfaces', pid]); diff --git a/app/layout/project/sidebar/project/inventory-panel/protected-areas/footer/index.tsx b/app/layout/project/sidebar/project/inventory-panel/wdpas/footer/index.tsx similarity index 100% rename from app/layout/project/sidebar/project/inventory-panel/protected-areas/footer/index.tsx rename to app/layout/project/sidebar/project/inventory-panel/wdpas/footer/index.tsx diff --git a/app/layout/project/sidebar/project/inventory-panel/protected-areas/index.tsx b/app/layout/project/sidebar/project/inventory-panel/wdpas/index.tsx similarity index 100% rename from app/layout/project/sidebar/project/inventory-panel/protected-areas/index.tsx rename to app/layout/project/sidebar/project/inventory-panel/wdpas/index.tsx