Fix Personal button - create separate button instead of fake Organization object
This commit is contained in:
@@ -74,7 +74,7 @@ class OrganizationBloc extends Bloc<OrganizationEvent, OrganizationState> {
|
||||
final currentState = state;
|
||||
if (currentState is OrganizationLoaded) {
|
||||
Organization? selected;
|
||||
|
||||
|
||||
if (event.orgId.isEmpty) {
|
||||
// Personal workspace - set to null to indicate no org selected
|
||||
selected = null;
|
||||
@@ -84,7 +84,7 @@ class OrganizationBloc extends Bloc<OrganizationEvent, OrganizationState> {
|
||||
orElse: () => currentState.selectedOrg!,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
emit(
|
||||
OrganizationLoaded(
|
||||
organizations: currentState.organizations,
|
||||
|
||||
@@ -192,15 +192,11 @@ class _HomePageState extends State<HomePage> with TickerProviderStateMixin {
|
||||
Row(
|
||||
children: [
|
||||
// Personal workspace button (always show when logged in)
|
||||
_buildOrgButton(
|
||||
Organization(id: '', name: 'Personal'),
|
||||
selectedOrg == null,
|
||||
() {
|
||||
context.read<OrganizationBloc>().add(
|
||||
SelectOrganization(''),
|
||||
);
|
||||
},
|
||||
),
|
||||
_buildPersonalButton(selectedOrg == null, () {
|
||||
context.read<OrganizationBloc>().add(
|
||||
SelectOrganization(''),
|
||||
);
|
||||
}),
|
||||
const SizedBox(width: 16),
|
||||
// Organization tabs
|
||||
...orgs.map(
|
||||
@@ -252,6 +248,21 @@ class _HomePageState extends State<HomePage> with TickerProviderStateMixin {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildPersonalButton(bool selected, VoidCallback onTap) {
|
||||
final highlightColor = const Color.fromARGB(255, 100, 200, 255);
|
||||
final defaultColor = AppTheme.secondaryText;
|
||||
return TextButton(
|
||||
onPressed: onTap,
|
||||
child: Text(
|
||||
'Personal',
|
||||
style: TextStyle(
|
||||
color: selected ? highlightColor : defaultColor,
|
||||
fontWeight: selected ? FontWeight.bold : FontWeight.normal,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildAddButton(VoidCallback onTap) {
|
||||
final defaultColor = AppTheme.secondaryText;
|
||||
return TextButton(
|
||||
|
||||
@@ -123,14 +123,14 @@ class ApiClient {
|
||||
// Only try to extract code/message if data is a Map
|
||||
String code = 'UNKNOWN';
|
||||
String message = 'Unknown error';
|
||||
|
||||
|
||||
if (data is Map<String, dynamic>) {
|
||||
code = data['code'] ?? 'UNKNOWN';
|
||||
message = data['message'] ?? 'Unknown error';
|
||||
} else if (data != null) {
|
||||
message = data.toString();
|
||||
}
|
||||
|
||||
|
||||
return ApiError(code: code, message: message, status: status);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user