feat: integrate agent edit profile screen as an embedded tab in profile settings and restrict agent connection actions to non-agent users

This commit is contained in:
pradeepkumar
2026-04-30 11:31:59 +05:30
parent a1e3fcdb92
commit 004e3caa6e
3 changed files with 47 additions and 24 deletions

View File

@@ -257,6 +257,9 @@ class _AgentDetailScreenState extends ConsumerState<AgentDetailScreen> {
final agent = state.agent!;
final isAvailable = agent.isAvailable;
final connState = state.connectionState;
// Hide the Connect/Pending/Unlink button when the viewer is an AGENT —
// the platform does not support agent-to-agent connections.
final viewerIsAgent = ref.watch(authProvider).user?.role == 'AGENT';
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 38),
@@ -302,18 +305,20 @@ class _AgentDetailScreenState extends ConsumerState<AgentDetailScreen> {
),
),
const Spacer(),
// Connect/Pending/Unlink button
_buildConnectButton(
connState,
isAvailable,
() => _handleConnect(state),
),
const SizedBox(width: 4),
// Connect/Pending/Unlink button — hidden for agent viewers
if (!viewerIsAgent) ...[
_buildConnectButton(
connState,
isAvailable,
() => _handleConnect(state),
),
const SizedBox(width: 4),
],
],
),
),
// Start Message button when connected
if (connState == 'accepted') ...[
// Start Message button when connected (only for non-agent viewers)
if (!viewerIsAgent && connState == 'accepted') ...[
const SizedBox(height: 12),
_buildStartMessageButton(agent),
],

View File

@@ -71,7 +71,11 @@ class _EditProfileData {
// ---------------------------------------------------------------------------
class AgentEditProfileScreen extends ConsumerStatefulWidget {
const AgentEditProfileScreen({super.key});
/// When true, omits the in-screen back button + title row so this widget can
/// be embedded inside another shell (e.g. a tab in ProfileSettingsScreen).
final bool embedded;
const AgentEditProfileScreen({super.key, this.embedded = false});
@override
ConsumerState<AgentEditProfileScreen> createState() =>
@@ -433,6 +437,10 @@ class _AgentEditProfileScreenState
Widget build(BuildContext context) {
final asyncData = ref.watch(_editProfileDataProvider);
if (widget.embedded) {
return _buildBody(asyncData);
}
return Column(
children: [
// Header with back button