import ComponentLibrary
import ComposableArchitecture
import Localization
import SwiftUI

@Reducer
public struct FeaturedArtistBanner {
    @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 FeaturedArtistBannerView: View {
    @Bindable var store: StoreOf<FeaturedArtistBanner>

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

    public var body: some View {
        CTABanner(
            title: L10n.FeatureSocial.featuredArtistBannerTitle,
            subtitle: L10n.FeatureSocial.featuredArtistBannerSubtitle,
            icon: { Image.Assets.timbalandAvatar },
            background: { Image.Assets.featuredArtistBannerBackground },
            action: { store.send(.delegate(.bannerTapped)) },
            dismissAction: { store.send(.delegate(.dismissTapped)) }
        )
        .overlay(
            RoundedRectangle(cornerRadius: 8)
                .inset(by: 0.5)
                .stroke(.white.opacity(0.15), lineWidth: 1)
        )
    }
}
