@extends('layouts.admin', ['title' => __('Industries').' | Nivex'])

@section('content')
    <h1 class="section-title text-4xl">{{ $industry->exists ? __('Edit') : __('Create New') }} {{ __('Industries') }}</h1>
    <form method="POST" enctype="multipart/form-data" action="{{ $industry->exists ? route('admin.industries.update', $industry) : route('admin.industries.store') }}" class="mt-8 grid gap-5 lg:grid-cols-2">
        @csrf
        @if($industry->exists) @method('PUT') @endif
        <div><label class="label">English title</label><input name="title_en" class="field" value="{{ old('title_en', data_get($industry->title, 'en')) }}"></div>
        <div><label class="label">Arabic title</label><input name="title_ar" class="field" value="{{ old('title_ar', data_get($industry->title, 'ar')) }}"></div>
        <div><label class="label">English description</label><textarea name="description_en" class="field" rows="5">{{ old('description_en', data_get($industry->description, 'en')) }}</textarea></div>
        <div><label class="label">Arabic description</label><textarea name="description_ar" class="field" rows="5">{{ old('description_ar', data_get($industry->description, 'ar')) }}</textarea></div>
        <div>
            <label class="label">Image</label>
            <input type="file" name="image" accept="image/*" class="field">
            @if ($industry->image_path)
                <img src="{{ asset('storage/'.$industry->image_path) }}" alt="{{ $industry->translate('title', 'en') }}" class="mt-3 h-20 w-20 rounded-2xl object-cover">
                <label class="mt-3 flex items-center gap-3 text-sm font-semibold">
                    <input type="checkbox" name="remove_image" value="1">
                    Remove current image
                </label>
            @endif
        </div>
        <div><label class="label">Order</label><input name="sort_order" type="number" class="field" value="{{ old('sort_order', $industry->sort_order ?? 0) }}"></div>
        <label class="flex items-center gap-3 text-sm font-semibold"><input type="checkbox" name="is_active" value="1" {{ old('is_active', $industry->is_active ?? true) ? 'checked' : '' }}>Active</label>
        <div class="lg:col-span-2"><button class="btn-primary">{{ __('Save Changes') }}</button></div>
    </form>
@endsection