package com.tt.honeyDue.platform

import android.content.Intent
import androidx.compose.runtime.Composable
import androidx.compose.ui.platform.LocalContext
import com.tt.honeyDue.models.Contractor
import com.tt.honeyDue.sharing.ContractorSharingManager
import com.tt.honeyDue.analytics.PostHogAnalytics
import com.tt.honeyDue.analytics.AnalyticsEvents

@Composable
actual fun rememberShareContractor(): (Contractor) -> Unit {
    val context = LocalContext.current

    return { contractor: Contractor ->
        val intent = ContractorSharingManager.createShareIntent(context, contractor)
        if (intent != null) {
            // Track contractor shared event
            PostHogAnalytics.capture(AnalyticsEvents.CONTRACTOR_SHARED)
            context.startActivity(Intent.createChooser(intent, "Share Contractor"))
        }
    }
}
