import ComponentLibrary
import ComposableArchitecture
import Localization
import SwiftUI

@Reducer
public struct InviteFriendsBanner {
    @ObservableState
    public struct State: Equatable {
        public init() {}
    }

    public enum Action {
        case delegate(Delegate)

        public enum Delegate {
            case bannerTapped
            case dismissTapped
        }
    }

    public init() {}

    public var body: some ReducerOf<Self> {
        Reduce { _, action in
            switch action {
            case .delegate:
                // Catch-all
                return .none
            }
        }

        Analytics()
    }
}

public struct InviteFriendsBannerView: View {
    @Bindable var store: StoreOf<InviteFriendsBanner>

    public init(store: StoreOf<InviteFriendsBanner>) {
        self.store = store
    }

    public var body: some View {
        CTABanner(
            title: L10n.FeatureSocial.inviteFriendsBannerTitle,
            subtitle: L10n.FeatureSocial.inviteFriendsBannerSubtitle,
            icon: { Image.Icon.follow },
            background: { Image.Assets.inviteFriendsBannerBackground },
            action: { store.send(.delegate(.bannerTapped)) },
            dismissAction: { store.send(.delegate(.dismissTapped)) }
        )
    }
}
