validation if a hug has orders
This commit is contained in:
@@ -94,6 +94,25 @@ class HubRepositoryImpl implements HubRepositoryInterface {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Future<void> deleteHub(String id) async {
|
Future<void> deleteHub(String id) async {
|
||||||
|
final String? businessId = dc.ClientSessionStore.instance.session?.business?.id;
|
||||||
|
if (businessId == null || businessId.isEmpty) {
|
||||||
|
await _firebaseAuth.signOut();
|
||||||
|
throw Exception('Business is missing. Please sign in again.');
|
||||||
|
}
|
||||||
|
|
||||||
|
final QueryResult<
|
||||||
|
dc.ListOrdersByBusinessAndTeamHubData,
|
||||||
|
dc.ListOrdersByBusinessAndTeamHubVariables> result = await _dataConnect
|
||||||
|
.listOrdersByBusinessAndTeamHub(
|
||||||
|
businessId: businessId,
|
||||||
|
teamHubId: id,
|
||||||
|
)
|
||||||
|
.execute();
|
||||||
|
|
||||||
|
if (result.data.orders.isNotEmpty) {
|
||||||
|
throw Exception("Sorry this hub has orders, it can't be deleted.");
|
||||||
|
}
|
||||||
|
|
||||||
await _dataConnect.deleteTeamHub(id: id).execute();
|
await _dataConnect.deleteTeamHub(id: id).execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -404,6 +404,7 @@ query listOrdersByBusinessAndTeamHub(
|
|||||||
where: {
|
where: {
|
||||||
businessId: { eq: $businessId }
|
businessId: { eq: $businessId }
|
||||||
teamHubId: { eq: $teamHubId }
|
teamHubId: { eq: $teamHubId }
|
||||||
|
#status: {in: [ DRAFT POSTED FILLED PENDING FULLY_STAFFED PARTIAL_STAFFED ] }
|
||||||
}
|
}
|
||||||
offset: $offset
|
offset: $offset
|
||||||
limit: $limit
|
limit: $limit
|
||||||
|
|||||||
Reference in New Issue
Block a user