Merge branch 'dev' into 538-be-assign-a-hub-manager-to-an-order

This commit is contained in:
Achintha Isuru
2026-02-26 11:58:14 -05:00
13 changed files with 108 additions and 320 deletions

View File

@@ -0,0 +1,3 @@
description: This file stores settings for Dart & Flutter DevTools.
documentation: https://docs.flutter.dev/tools/devtools/extensions#configure-extension-enablement-states
extensions:

View File

@@ -56,10 +56,31 @@ class ClientHubsPage extends StatelessWidget {
}, },
builder: (BuildContext context, ClientHubsState state) { builder: (BuildContext context, ClientHubsState state) {
return Scaffold( return Scaffold(
backgroundColor: UiColors.bgMenu, appBar: UiAppBar(
title: t.client_hubs.title,
subtitle: t.client_hubs.subtitle,
showBackButton: true,
actions: <Widget>[
Padding(
padding: const EdgeInsets.only(right: UiConstants.space5),
child: UiButton.primary(
onPressed: () async {
final bool? success = await Modular.to.toEditHub();
if (success == true && context.mounted) {
BlocProvider.of<ClientHubsBloc>(
context,
).add(const ClientHubsFetched());
}
},
text: t.client_hubs.add_hub,
leadingIcon: UiIcons.add,
size: UiButtonSize.small,
),
),
],
),
body: CustomScrollView( body: CustomScrollView(
slivers: <Widget>[ slivers: <Widget>[
_buildAppBar(context),
SliverPadding( SliverPadding(
padding: const EdgeInsets.symmetric( padding: const EdgeInsets.symmetric(
horizontal: UiConstants.space5, horizontal: UiConstants.space5,
@@ -112,81 +133,4 @@ class ClientHubsPage extends StatelessWidget {
), ),
); );
} }
Widget _buildAppBar(BuildContext context) {
return SliverAppBar(
backgroundColor: UiColors.foreground,
automaticallyImplyLeading: false,
expandedHeight: 140,
pinned: true,
flexibleSpace: FlexibleSpaceBar(
background: Container(
color: UiColors.foreground,
padding: const EdgeInsets.fromLTRB(
UiConstants.space5,
UiConstants.space12,
UiConstants.space5,
0,
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
GestureDetector(
onTap: () => Modular.to.toClientHome(),
child: Container(
width: 40,
height: 40,
decoration: BoxDecoration(
color: UiColors.white.withValues(alpha: 0.2),
shape: BoxShape.circle,
),
child: const Icon(
UiIcons.arrowLeft,
color: UiColors.white,
size: 20,
),
),
),
const SizedBox(height: UiConstants.space4),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
t.client_hubs.title,
style: UiTypography.headline1m.white,
),
Text(
t.client_hubs.subtitle,
style: UiTypography.body2r.copyWith(
color: UiColors.switchInactive,
),
),
],
),
),
UiButton.primary(
onPressed: () async {
final bool? success = await Modular.to.toEditHub();
if (success == true && context.mounted) {
BlocProvider.of<ClientHubsBloc>(
context,
).add(const ClientHubsFetched());
}
},
text: t.client_hubs.add_hub,
leadingIcon: UiIcons.add,
size: UiButtonSize.small,
),
],
),
],
),
),
),
);
}
} }

View File

@@ -44,10 +44,7 @@ class ClientSettingsPage extends StatelessWidget {
child: const Scaffold( child: const Scaffold(
backgroundColor: UiColors.bgMenu, backgroundColor: UiColors.bgMenu,
body: CustomScrollView( body: CustomScrollView(
slivers: <Widget>[ slivers: <Widget>[SettingsProfileHeader(), SettingsActions()],
SettingsProfileHeader(),
SettingsActions(),
],
), ),
), ),
), ),

View File

@@ -24,36 +24,6 @@ class SettingsActions extends StatelessWidget {
delegate: SliverChildListDelegate(<Widget>[ delegate: SliverChildListDelegate(<Widget>[
const SizedBox(height: UiConstants.space5), const SizedBox(height: UiConstants.space5),
// Edit Profile button (Yellow)
UiButton.primary(
text: labels.edit_profile,
fullWidth: true,
style: ElevatedButton.styleFrom(
backgroundColor: UiColors.accent,
foregroundColor: UiColors.accentForeground,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(UiConstants.radiusBase * 2),
),
),
onPressed: () => Modular.to.toClientEditProfile(),
),
const SizedBox(height: UiConstants.space4),
// Hubs button (Yellow)
UiButton.primary(
text: labels.hubs,
fullWidth: true,
style: ElevatedButton.styleFrom(
backgroundColor: UiColors.accent,
foregroundColor: UiColors.accentForeground,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(UiConstants.radiusBase * 2),
),
),
onPressed: () => Modular.to.toClientHubs(),
),
const SizedBox(height: UiConstants.space5),
// Quick Links card // Quick Links card
_QuickLinksCard(labels: labels), _QuickLinksCard(labels: labels),
const SizedBox(height: UiConstants.space5), const SizedBox(height: UiConstants.space5),
@@ -67,7 +37,9 @@ class SettingsActions extends StatelessWidget {
style: OutlinedButton.styleFrom( style: OutlinedButton.styleFrom(
side: const BorderSide(color: UiColors.black), side: const BorderSide(color: UiColors.black),
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(UiConstants.radiusBase * 2), borderRadius: BorderRadius.circular(
UiConstants.radiusBase * 2,
),
), ),
), ),
onPressed: state is ClientSettingsLoading onPressed: state is ClientSettingsLoading

View File

@@ -1,37 +1,29 @@
# ----------------------------------------------------------
# CREATE COST CENTER
# ----------------------------------------------------------
mutation createCostCenter( mutation createCostCenter(
$name: String! $name: String!
$createdBy: String $businessId: UUID!
) @auth(level: USER) { ) @auth(level: USER) {
costCenter_insert( costCenter_insert(
data: { data: {
name: $name name: $name
createdBy: $createdBy businessId: $businessId
} }
) )
} }
# ----------------------------------------------------------
# UPDATE COST CENTER
# ----------------------------------------------------------
mutation updateCostCenter( mutation updateCostCenter(
$id: UUID! $id: UUID!
$name: String $name: String
$businessId: UUID
) @auth(level: USER) { ) @auth(level: USER) {
costCenter_update( costCenter_update(
id: $id id: $id,
data: { data: {
name: $name name: $name
businessId: $businessId
} }
) )
} }
# ----------------------------------------------------------
# DELETE COST CENTER
# ----------------------------------------------------------
mutation deleteCostCenter($id: UUID!) @auth(level: USER) { mutation deleteCostCenter($id: UUID!) @auth(level: USER) {
costCenter_delete(id: $id) costCenter_delete(id: $id)
} }

View File

@@ -1,47 +1,30 @@
query listCostCenters @auth(level: USER) {
# ---------------------------------------------------------- costCenters {
# LIST ALL COST CENTERS
# ----------------------------------------------------------
query listCostCenters(
$offset: Int
$limit: Int
) @auth(level: USER) {
costCenters(offset: $offset, limit: $limit) {
id id
name name
createdAt businessId
updatedAt
createdBy
} }
} }
# ----------------------------------------------------------
# GET BY ID
# ----------------------------------------------------------
query getCostCenterById($id: UUID!) @auth(level: USER) { query getCostCenterById($id: UUID!) @auth(level: USER) {
costCenter(id: $id) { costCenter(id: $id) {
id id
name name
createdAt businessId
updatedAt
createdBy
} }
} }
# ---------------------------------------------------------- query filterCostCenters(
# GET COST CENTER LINKED TO A SPECIFIC HUB $name: String,
# ---------------------------------------------------------- $businessId: UUID
query getCostCenterByHubId($hubId: UUID!) @auth(level: USER) { ) @auth(level: USER) {
hubs(where: { id: { eq: $hubId } }) { costCenters(
where: {
name: { eq: $name },
businessId: { eq: $businessId }
}) {
id id
name name
costCenterId businessId
costCenter {
id
name
createdAt
updatedAt
createdBy
}
} }
} }

View File

@@ -1,62 +0,0 @@
mutation createHub(
$name: String!
$locationName: String
$address: String
$nfcTagId: String
$ownerId: UUID!
) @auth(level: USER) {
hub_insert(
data: {
name: $name
locationName: $locationName
address: $address
nfcTagId: $nfcTagId
ownerId: $ownerId
}
)
}
mutation updateHub(
$id: UUID!
$name: String
$locationName: String
$address: String
$nfcTagId: String
$ownerId: UUID
) @auth(level: USER) {
hub_update(
id: $id
data: {
name: $name
locationName: $locationName
address: $address
nfcTagId: $nfcTagId
ownerId: $ownerId
}
)
}
mutation deleteHub($id: UUID!) @auth(level: USER) {
hub_delete(id: $id)
}
mutation assignCostCenterToHub(
$hubId: UUID!
$costCenterId: UUID!
) @auth(level: USER) {
hub_update(
id: $hubId
data: {
costCenterId: $costCenterId
}
)
}
mutation removeCostCenterFromHub($hubId: UUID!) @auth(level: USER) {
hub_update(
id: $hubId
data: {
costCenterId: null
}
)
}

View File

@@ -1,82 +0,0 @@
query listHubs @auth(level: USER) {
hubs {
id
name
locationName
address
nfcTagId
ownerId
costCenterId
costCenter {
id
name
}
createdAt
updatedAt
createdBy
}
}
query getHubById($id: UUID!) @auth(level: USER) {
hub(id: $id) {
id
name
locationName
address
nfcTagId
ownerId
costCenterId
costCenter {
id
name
}
createdAt
updatedAt
createdBy
}
}
query getHubsByOwnerId($ownerId: UUID!) @auth(level: USER) {
hubs(where: { ownerId: { eq: $ownerId } }) {
id
name
locationName
address
nfcTagId
ownerId
costCenterId
costCenter {
id
name
}
createdAt
updatedAt
createdBy
}
}
query filterHubs(
$ownerId: UUID
$name: String
$nfcTagId: String
) @auth(level: USER) {
hubs(
where: {
ownerId: { eq: $ownerId }
name: { eq: $name }
nfcTagId: { eq: $nfcTagId }
}
) {
id
name
locationName
address
nfcTagId
ownerId
costCenterId
costCenter {
id
name
}
}
}

View File

@@ -1,5 +1,6 @@
mutation createTeamHub( mutation createTeamHub(
$teamId: UUID! $teamId: UUID!
$costCenterId: UUID
$hubName: String! $hubName: String!
$address: String! $address: String!
@@ -20,6 +21,7 @@ mutation createTeamHub(
teamHub_insert( teamHub_insert(
data: { data: {
teamId: $teamId teamId: $teamId
costCenterId: $costCenterId
hubName: $hubName hubName: $hubName
address: $address address: $address
@@ -45,6 +47,7 @@ mutation updateTeamHub(
$id: UUID! $id: UUID!
$teamId: UUID $teamId: UUID
$costCenterId: UUID
$hubName: String $hubName: String
$address: String $address: String
@@ -67,6 +70,7 @@ mutation updateTeamHub(
id: $id id: $id
data: { data: {
teamId: $teamId teamId: $teamId
costCenterId: $costCenterId
hubName: $hubName hubName: $hubName
address: $address address: $address
@@ -91,3 +95,24 @@ mutation updateTeamHub(
mutation deleteTeamHub($id: UUID!) @auth(level: USER) { mutation deleteTeamHub($id: UUID!) @auth(level: USER) {
teamHub_delete(id: $id) teamHub_delete(id: $id)
} }
mutation assignCostCenterToTeamHub(
$id: UUID!
$costCenterId: UUID!
) @auth(level: USER) {
teamHub_update(
id: $id
data: {
costCenterId: $costCenterId
}
)
}
mutation removeCostCenterFromTeamHub($id: UUID!) @auth(level: USER) {
teamHub_update(
id: $id
data: {
costCenterId: null
}
)
}

View File

@@ -8,6 +8,7 @@ query listTeamHubs($offset: Int, $limit: Int) @auth(level: USER) {
teamHubs(offset: $offset, limit: $limit, orderBy: { createdAt: DESC }) { teamHubs(offset: $offset, limit: $limit, orderBy: { createdAt: DESC }) {
id id
teamId teamId
costCenterId
hubName hubName
address address
@@ -24,6 +25,11 @@ query listTeamHubs($offset: Int, $limit: Int) @auth(level: USER) {
managerName managerName
isActive isActive
departments departments
costCenter {
id
name
businessId
}
} }
} }
@@ -32,6 +38,7 @@ query getTeamHubById($id: UUID!) @auth(level: USER) {
teamHub(id: $id) { teamHub(id: $id) {
id id
teamId teamId
costCenterId
hubName hubName
address address
@@ -48,6 +55,11 @@ query getTeamHubById($id: UUID!) @auth(level: USER) {
managerName managerName
isActive isActive
departments departments
costCenter {
id
name
businessId
}
} }
} }
@@ -65,6 +77,7 @@ query getTeamHubsByTeamId(
) { ) {
id id
teamId teamId
costCenterId
hubName hubName
address address
@@ -81,6 +94,11 @@ query getTeamHubsByTeamId(
managerName managerName
isActive isActive
departments departments
costCenter {
id
name
businessId
}
} }
} }
@@ -105,6 +123,7 @@ query listTeamHubsByOwnerId(
) { ) {
id id
teamId teamId
costCenterId
hubName hubName
address address
@@ -121,6 +140,11 @@ query listTeamHubsByOwnerId(
managerName managerName
isActive isActive
departments departments
costCenter {
id
name
businessId
}
} }
} }

View File

@@ -1,6 +1,8 @@
type CostCenter @table(name: "cost_centers") { type CostCenter @table(name: "cost_centers") {
id: UUID! @default(expr: "uuidV4()") id: UUID! @default(expr: "uuidV4()")
name: String! name: String!
businessId: UUID!
createdAt: Timestamp @default(expr: "request.time") createdAt: Timestamp @default(expr: "request.time")
updatedAt: Timestamp @default(expr: "request.time") updatedAt: Timestamp @default(expr: "request.time")
createdBy: String createdBy: String

View File

@@ -1,13 +0,0 @@
type Hub @table(name: "hubs") {
id: UUID! @default(expr: "uuidV4()")
name: String!
locationName: String
address: String
nfcTagId: String
ownerId: UUID!
costCenterId: UUID
costCenter: CostCenter @ref(fields: "costCenterId", references: "id")
createdAt: Timestamp @default(expr: "request.time")
updatedAt: Timestamp @default(expr: "request.time")
createdBy: String
}

View File

@@ -4,6 +4,9 @@ type TeamHub @table(name: "team_hubs") {
teamId: UUID! teamId: UUID!
team: Team! @ref(fields: "teamId", references: "id") team: Team! @ref(fields: "teamId", references: "id")
costCenterId: UUID
costCenter: CostCenter @ref(fields: "costCenterId", references: "id")
hubName: String! hubName: String!
address: String! address: String!