Misc No-Op Buttons — Wired to Live Actions (feat/misc-no-ops)

Branch: feat/misc-no-ops


Background

Several interactive elements in the app were no-ops — they displayed to users but performed no action when tapped. This document covers all fixes shipped in feat/misc-no-ops.


Fixes

1. SocialInviteCard — “INVITA ORA”

File: lib/shared/widgets/feed_interruption_widgets.dart

The “INVITA ORA” button now calls ShareService().shareAppInvitation(), which triggers the native share sheet with an app install link.

ElevatedButton(
  onPressed: () => ShareService().shareAppInvitation(),
  ...
)

2. VendorDashboardScreen — “Vedi tutto”

File: lib/features/dashboard/screens/vendor_dashboard_screen.dart

The “Vedi tutto” TextButton next to “Feedback Recente (7g)” now navigates to the vendor’s event list:

TextButton(
  onPressed: () => context.push('/home/my-events'),
  child: const Text('Vedi tutto'),
)

3. SquadDetailSheet — “Apri Chat Squad”

Files: lib/shared/widgets/squad_detail_sheet.dart, lib/shared/models/squad_model.dart, lib/features/social/services/squad_service.dart

Problem: The “Apri Chat Squad” button only closed the bottom sheet. The Squad model had no chatId field, so there was no chat to navigate to.

Solution — three coordinated changes:

a) Squad model — chatId field

class Squad {
  // ...
  final String? chatId; // null for squads created before this feature
 
  factory Squad.fromJson(Map<String, dynamic> json) => Squad(
    // ...
    chatId: json['chat_id'] as String?,
  );
}

b) SquadService — auto-create chat on squad creation

createSquad() now:

  1. Inserts the squad row as before.
  2. Inserts a group type row into the chats table with metadata: { squad_id }.
  3. Adds the creator as owner in chat_participants.
  4. Updates squads.chat_id with the new chat ID.
  5. Returns the squad with chatId populated.

Step 2–4 are wrapped in a try/catch — a chat creation failure does not fail squad creation.

c) Squad detail sheet — navigate or show fallback

void _openSquadChat(BuildContext context) {
  final chatId = widget.squad.chatId;
  if (chatId == null) {
    // Show snackbar: "Chat non ancora disponibile"
    return;
  }
  Navigator.pop(context);
  context.push('/social/chat/$chatId');
}

Database Migration

supabase/migrations/20260318000003_squad_chat.sql

ALTER TABLE public.squads
  ADD COLUMN IF NOT EXISTS chat_id UUID REFERENCES public.chats(id) ON DELETE SET NULL;
 
CREATE POLICY "Squad members can access squad chat"
  ON public.chats FOR SELECT TO authenticated
  USING (
    id IN (
      SELECT s.chat_id FROM public.squads s
      JOIN public.squad_members sm ON sm.squad_id = s.id
      WHERE sm.user_id = auth.uid() AND s.chat_id IS NOT NULL
    )
  );

Apply with: supabase db push or Supabase dashboard SQL editor.


Notes

  • Old squads (before this migration) will have chat_id = NULL. The “Apri Chat Squad” button shows a graceful snackbar in this case.
  • New squads created after this migration will always have a linked group chat, automatically created at squad creation time.