-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1b032b0
commit c282800
Showing
5 changed files
with
14 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 10 additions & 57 deletions
67
app/layout/project/sidebar/project/inventory-panel/cost-surfaces/bulk-action-menu/utils.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 }))); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.