refactor: Update reorder suggestions to fetch and display completed orders with aggregated totals instead of individual shift roles.

This commit is contained in:
Achintha Isuru
2026-02-21 22:44:26 -05:00
parent 2c6cd9cd45
commit c5e48ffbc6
4 changed files with 160 additions and 33 deletions

View File

@@ -433,3 +433,98 @@ query listOrdersByBusinessAndTeamHub(
createdBy
}
}
# ------------------------------------------------------------
# GET COMPLETED ORDERS BY BUSINESS AND DATE RANGE
# ------------------------------------------------------------
query listCompletedOrdersByBusinessAndDateRange(
$businessId: UUID!
$start: Timestamp!
$end: Timestamp!
$offset: Int
$limit: Int
) @auth(level: USER) {
orders(
where: {
businessId: { eq: $businessId }
status: { eq: COMPLETED }
date: { ge: $start, le: $end }
}
offset: $offset
limit: $limit
orderBy: { createdAt: DESC }
) {
id
eventName
vendorId
businessId
orderType
status
date
startDate
endDate
duration
lunchBreak
total
assignedStaff
requested
recurringDays
permanentDays
poReference
notes
createdAt
business {
id
businessName
email
contactName
}
vendor {
id
companyName
}
teamHub {
address
placeId
hubName
}
# Assigned shifts and their roles
shifts_on_order {
id
title
date
startTime
endTime
hours
cost
location
locationAddress
status
workersNeeded
filled
shiftRoles_on_shift {
id
roleId
count
assigned
startTime
endTime
hours
totalValue
role {
id
name
costPerHour
}
}
}
}
}