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

@section('content')
    <h1 class="section-title text-4xl">{{ $service->exists ? __('Edit') : __('Create New') }} {{ __('Services') }}</h1>
    <form method="POST" enctype="multipart/form-data" action="{{ $service->exists ? route('admin.services.update', $service) : route('admin.services.store') }}" class="mt-8 grid gap-5 lg:grid-cols-2">
        @csrf
        @if($service->exists) @method('PUT') @endif
        <div><label class="label">English title</label><input name="title_en" class="field" value="{{ old('title_en', data_get($service->title, 'en')) }}"></div>
        <div><label class="label">Arabic title</label><input name="title_ar" class="field" value="{{ old('title_ar', data_get($service->title, 'ar')) }}"></div>
        <div><label class="label">English excerpt</label><textarea name="excerpt_en" class="field" rows="4">{{ old('excerpt_en', data_get($service->excerpt, 'en')) }}</textarea></div>
        <div><label class="label">Arabic excerpt</label><textarea name="excerpt_ar" class="field" rows="4">{{ old('excerpt_ar', data_get($service->excerpt, 'ar')) }}</textarea></div>
        <div><label class="label">English bullets</label><textarea name="bullets_en" class="field" rows="6">{{ old('bullets_en', implode(PHP_EOL, data_get($service->bullets, 'en', []))) }}</textarea></div>
        <div><label class="label">Arabic bullets</label><textarea name="bullets_ar" class="field" rows="6">{{ old('bullets_ar', implode(PHP_EOL, data_get($service->bullets, 'ar', []))) }}</textarea></div>
        <div>
            <label class="label">Image</label>
            <input type="file" name="image" accept="image/*" class="field">
            @if ($service->image_path)
                <img src="{{ asset('storage/'.$service->image_path) }}" alt="{{ $service->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', $service->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', $service->is_active ?? true) ? 'checked' : '' }}>Active</label>
        <div class="lg:col-span-2"><button class="btn-primary">{{ __('Save Changes') }}</button></div>
    </form>
@endsection