Skip to content

Conversation

@reunefe
Copy link
Contributor

@reunefe reunefe commented Jan 9, 2026

Continues on #572

'Set the status of the material request to pending when a maintainer has viewed the request',
})
@RequireAnyPermissions(Permission.VIEW_ANY_MATERIAL_REQUESTS)
public async processMaterialRequest(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public async processMaterialRequest(
public async setMaterialRequestStatusToPending(

) {
update_app_material_requests(
where: { id: { _eq: $materialRequestId }, profile_id: { _eq: $userProfileId } }
where: { id: { _eq: $materialRequestId } }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this extra check on profile id, is to make sure users can only update their own material request
if you remove that here, you need to manually check in the controller if the current user should be allowed to modify this material request.

}

public async updateMaterialRequestStatus(
currentRequest: MaterialRequest,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doesn't it make more sense to only pass the currentRequest.id
and then set the updateMaterialRequest specific date based on the desired status?

const updateMaterialRequest = {
	materialRequestId: currentRequest.id,
	updated_at: new Date().toISOString(),
};
if (status === status === Lookup_App_Material_Request_Status_Enum.Cancelled) {
	updateMaterialRequest.cancelled_at = new Date().toISOString();
}
if (status === status === Lookup_App_Material_Request_Status_Enum.Approved) {
	updateMaterialRequest.approved_at = new Date().toISOString();
}
if (status === status === Lookup_App_Material_Request_Status_Enum.Denied) {
	updateMaterialRequest.denied_at = new Date().toISOString();
}

const updateMaterialRequestStatusResponse = await this.dataService.execute<
			UpdateMaterialRequestStatusMutation,
			UpdateMaterialRequestStatusMutationVariables
		>(UpdateMaterialRequestStatusDocument, {
			materialRequestId: currentRequestId,
			updateMaterialRequest,
		});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants