import 'package:auto_route/auto_route.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:krow/core/presentation/gen/assets.gen.dart';
import 'package:krow/core/presentation/styles/kw_box_decorations.dart';
import 'package:krow/core/presentation/styles/kw_text_styles.dart';
import 'package:krow/features/profile/wages_forms/domain/bloc/wages_form_bloc.dart';
import 'package:krow/features/profile/wages_forms/domain/entities/wage_form_entity.dart';

class FormItemWidget extends StatelessWidget {
  const FormItemWidget({
    super.key,
    required this.formRoute,
    required this.label,
    required this.wageForm,
  });

  final PageRouteInfo<Object?> formRoute;
  final WageFormEntity wageForm;
  final String label;

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: () {
        context.pushRoute(formRoute);

        context.read<WagesFormBloc>().add(SetActiveForm(form: wageForm));
      },
      child: Container(
        height: 56,
        decoration: KwBoxDecorations.primaryLight8,
        margin: const EdgeInsets.only(bottom: 8),
        padding: const EdgeInsetsDirectional.fromSTEB(12, 16, 12, 16),
        child: Row(
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
          children: [
            Text(
              label,
              style: AppTextStyles.headingH3,
            ),
            Assets.images.icons.caretRight.svg(width: 24, height: 24)
          ],
        ),
      ),
    );
  }
}
