Skip to content

Commit

Permalink
Merge pull request #12982 from transcom/MAIN-B-19065-fix-current-bug-…
Browse files Browse the repository at this point in the history
…delete-docs

MAIN - B-19065 fix-current-bug-delete-docs
  • Loading branch information
taeJungCaci authored Jun 11, 2024
2 parents 9c0b4a0 + 9d52c4a commit ed55043
Show file tree
Hide file tree
Showing 10 changed files with 97 additions and 6 deletions.
14 changes: 14 additions & 0 deletions pkg/gen/internalapi/embedded_spec.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 13 additions & 2 deletions pkg/handlers/internalapi/uploads.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,17 @@ func (h DeleteUploadHandler) Handle(params uploadop.DeleteUploadParams) middlewa
return handlers.ResponseForError(appCtx.Logger(), err), err
}

var ppmShipmentStatus models.PPMShipmentStatus

if params.PpmID != nil {
ppmShipmentId, _ := uuid.FromString(params.PpmID.String())
ppmShipment, err := models.FetchPPMShipmentByPPMShipmentID(appCtx.DB(), ppmShipmentId)
if err != nil {
return handlers.ResponseForError(appCtx.Logger(), err), err
}
ppmShipmentStatus = ppmShipment.Status
}

if params.OrderID != nil {
orderID, _ := uuid.FromString(params.OrderID.String())
move, e := models.FetchMoveByOrderID(appCtx.DB(), orderID)
Expand Down Expand Up @@ -157,8 +168,8 @@ func (h DeleteUploadHandler) Handle(params uploadop.DeleteUploadParams) middlewa
appCtx.Logger().Error("error retrieving move associated with this upload", zap.Error(err))
}

//If move status is not DRAFT, upload cannot be deleted
if *uploadInformation.MoveStatus != models.MoveStatusDRAFT {
//If move status is not DRAFT and customer is not uploading ppm docs, upload cannot be deleted
if (*uploadInformation.MoveStatus != models.MoveStatusDRAFT) && (ppmShipmentStatus != models.PPMShipmentStatusWaitingOnCustomer) {
return uploadop.NewDeleteUploadForbidden(), fmt.Errorf("deletion not permitted Move is not in 'DRAFT' status")
}

Expand Down
2 changes: 1 addition & 1 deletion src/pages/MyMove/PPM/Closeout/Expenses/Expenses.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ const Expenses = () => {
};

const handleUploadDelete = (uploadId, fieldName, setFieldTouched, setFieldValue) => {
deleteUpload(uploadId)
deleteUpload(uploadId, null, mtoShipment?.ppmShipment?.id)
.then(() => {
const filteredUploads = mtoShipment.ppmShipment.movingExpenses[currentIndex][fieldName].uploads.filter(
(upload) => upload.id !== uploadId,
Expand Down
2 changes: 1 addition & 1 deletion src/pages/MyMove/PPM/Closeout/ProGear/ProGear.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ const ProGear = () => {
};

const handleUploadDelete = (uploadId, fieldName, setFieldTouched, setFieldValue) => {
deleteUpload(uploadId)
deleteUpload(uploadId, null, mtoShipment?.ppmShipment?.id)
.then(() => {
const filteredUploads = mtoShipment.ppmShipment.proGearWeightTickets[currentIndex][fieldName].uploads.filter(
(upload) => upload.id !== uploadId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ const WeightTickets = () => {
};

const handleUploadDelete = (uploadId, fieldName, setFieldTouched, setFieldValue) => {
deleteUpload(uploadId)
deleteUpload(uploadId, null, mtoShipment?.ppmShipment?.id)
.then(() => {
const filteredUploads = mtoShipment.ppmShipment.weightTickets[currentIndex][fieldName].uploads.filter(
(upload) => upload.id !== uploadId,
Expand Down
3 changes: 2 additions & 1 deletion src/services/internalApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,12 +248,13 @@ export async function createUploadForPPMDocument(ppmShipmentId, documentId, file
);
}

export async function deleteUpload(uploadId, orderId) {
export async function deleteUpload(uploadId, orderId, ppmId) {
return makeInternalRequest(
'uploads.deleteUpload',
{
uploadId,
orderId,
ppmId,
},
{
normalize: false,
Expand Down
5 changes: 5 additions & 0 deletions swagger-def/internal.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3075,6 +3075,11 @@ paths:
type: string
format: uuid
description: ID of the order that the upload belongs to
- in: query
name: ppmId
type: string
format: uuid
description: Optional PPM shipment ID related to the upload
responses:
"204":
description: deleted
Expand Down
5 changes: 5 additions & 0 deletions swagger/internal.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4371,6 +4371,11 @@ paths:
type: string
format: uuid
description: ID of the order that the upload belongs to
- in: query
name: ppmId
type: string
format: uuid
description: Optional PPM shipment ID related to the upload
responses:
'204':
description: deleted
Expand Down

0 comments on commit ed55043

Please sign in to comment.