<div id="append_generic_price" class="row">
	@include('Admin.Shop.Articles.partials.generic_prices.list-generic_prices')
</div>

<div class="row mt-3">
	<div class="col-6">
		@include('components.form.selects.select-tree', ['name' => "article_price_generic_id", 'id_name' => "article_price_generic_id", 'value' => $price['article_price_generic_id'] ?? null, 'list' => $price_generics ?? null, 'required' => false, 'class' => 'form-control-sm w-100'])
	</div>
	<div class="col-6">
		<button type="button" class="btn btn-sm btn-primary" id="add-new-generic_price">Associer un tarif générique <i class="fa fa-plus"></i></button>
	</div>
</div>

@push('js')
	<script>

		function append_generic_price() {
			$('.select2').select2();
			handleAddGeneric();
		}

		function handleAddGeneric() {
			$('#add-new-generic_price').click(function() {
				var id = $('#article_price_generic_id').val();
				var content = $.get("{{ route('Admin.Shop.PriceGenerics.getPrice') }}/" + id, function(data) {
					$('#append_generic_price').html(data);
					handleDeleteGenericPrice();
				});
			});
		}

		function handleDeleteGenericPrice() {
			$('.delete-generic_price-btn').off().click(function(e) {
				console.log('ici');
				e.preventDefault();
				// $('#append_generic_price').html('');

				/*
				confirm_delete(id, "{## route('Admin.Shop.GenericPrices.destroy') }}", function() {
					$selector.remove();
				});
				*/
			});
		}

		$(function() {
			append_generic_price();
		});

	</script>
@endpush
