203 lines
12 KiB
PHP
203 lines
12 KiB
PHP
<div class="space-y-6">
|
|
@include('helpdesk::partials.page-header', [
|
|
'eyebrow' => 'Helpdesk',
|
|
'title' => 'Create Ticket',
|
|
'subtitle' => 'Raise a new support request with priority, project, category, team and full details.',
|
|
])
|
|
|
|
<form
|
|
method="POST"
|
|
action="{{ route('helpdesk.tickets.store') }}"
|
|
enctype="multipart/form-data"
|
|
class="space-y-6"
|
|
x-data="{
|
|
body: @js(old('body', $body ?? '')),
|
|
syncBody() {
|
|
this.body = this.$refs.bodyEditor.innerHTML;
|
|
this.$refs.bodyInput.value = this.body;
|
|
},
|
|
command(action, value = null) {
|
|
this.$refs.bodyEditor.focus();
|
|
document.execCommand(action, false, value);
|
|
this.syncBody();
|
|
},
|
|
init() {
|
|
this.$refs.bodyEditor.innerHTML = this.body || '';
|
|
this.$refs.bodyInput.value = this.body || '';
|
|
}
|
|
}"
|
|
>
|
|
@csrf
|
|
|
|
<div class="rounded-2xl border border-zinc-200 bg-white shadow-sm dark:border-zinc-700 dark:bg-zinc-900">
|
|
<div class="border-b border-zinc-200 px-6 py-4 dark:border-zinc-700">
|
|
<h2 class="text-lg font-semibold text-zinc-900 dark:text-zinc-100">Ticket details</h2>
|
|
<p class="mt-1 text-sm text-zinc-500 dark:text-zinc-400">Capture the request clearly so the support workflow can route and notify correctly.</p>
|
|
</div>
|
|
|
|
<div class="grid gap-6 p-6 lg:grid-cols-2">
|
|
<div class="lg:col-span-2">
|
|
<label class="block text-sm font-semibold text-zinc-700 dark:text-zinc-200" for="subject">Subject</label>
|
|
<input
|
|
id="subject"
|
|
name="subject"
|
|
type="text"
|
|
value="{{ old('subject', $subject ?? '') }}"
|
|
class="mt-2 block w-full rounded-xl border-zinc-300 shadow-sm focus:border-blue-500 focus:ring-blue-500 dark:border-zinc-700 dark:bg-zinc-950 dark:text-zinc-100"
|
|
data-dusk="ticket-subject"
|
|
>
|
|
@error('subject') <p class="mt-2 text-sm text-red-600">{{ $message }}</p> @enderror
|
|
</div>
|
|
|
|
@if($companies->isNotEmpty())
|
|
<div>
|
|
<label class="block text-sm font-semibold text-zinc-700 dark:text-zinc-200" for="company_id">Company</label>
|
|
<select
|
|
id="company_id"
|
|
name="company_id"
|
|
class="mt-2 block w-full rounded-xl border-zinc-300 shadow-sm focus:border-blue-500 focus:ring-blue-500 dark:border-zinc-700 dark:bg-zinc-950 dark:text-zinc-100"
|
|
>
|
|
<option value="">Select company</option>
|
|
@foreach ($companies as $company)
|
|
<option value="{{ $company->id }}" @selected((string) old('company_id', $company_id ?? '') === (string) $company->id)>
|
|
{{ $company->name }}
|
|
</option>
|
|
@endforeach
|
|
</select>
|
|
@error('company_id') <p class="mt-2 text-sm text-red-600">{{ $message }}</p> @enderror
|
|
</div>
|
|
@endif
|
|
|
|
<div>
|
|
<label class="block text-sm font-semibold text-zinc-700 dark:text-zinc-200" for="priority_id">Priority</label>
|
|
<select
|
|
id="priority_id"
|
|
name="priority_id"
|
|
class="mt-2 block w-full rounded-xl border-zinc-300 shadow-sm focus:border-blue-500 focus:ring-blue-500 dark:border-zinc-700 dark:bg-zinc-950 dark:text-zinc-100"
|
|
data-dusk="ticket-priority"
|
|
>
|
|
<option value="">Select priority</option>
|
|
@foreach ($priorities as $priority)
|
|
<option value="{{ $priority->id }}" @selected((string) old('priority_id', $priority_id ?? '') === (string) $priority->id)>
|
|
{{ $priority->name }}
|
|
</option>
|
|
@endforeach
|
|
</select>
|
|
@error('priority_id') <p class="mt-2 text-sm text-red-600">{{ $message }}</p> @enderror
|
|
</div>
|
|
|
|
<div>
|
|
<label class="block text-sm font-semibold text-zinc-700 dark:text-zinc-200" for="category_id">Category</label>
|
|
<select
|
|
id="category_id"
|
|
name="category_id"
|
|
class="mt-2 block w-full rounded-xl border-zinc-300 shadow-sm focus:border-blue-500 focus:ring-blue-500 dark:border-zinc-700 dark:bg-zinc-950 dark:text-zinc-100"
|
|
>
|
|
<option value="">Select category</option>
|
|
@foreach ($categories as $category)
|
|
<option value="{{ $category->id }}" @selected((string) old('category_id', $category_id ?? '') === (string) $category->id)>
|
|
{{ $category->name }}
|
|
</option>
|
|
@endforeach
|
|
</select>
|
|
@error('category_id') <p class="mt-2 text-sm text-red-600">{{ $message }}</p> @enderror
|
|
</div>
|
|
|
|
<div>
|
|
<label class="block text-sm font-semibold text-zinc-700 dark:text-zinc-200" for="project_id">Project</label>
|
|
<select
|
|
id="project_id"
|
|
name="project_id"
|
|
class="mt-2 block w-full rounded-xl border-zinc-300 shadow-sm focus:border-blue-500 focus:ring-blue-500 dark:border-zinc-700 dark:bg-zinc-950 dark:text-zinc-100"
|
|
>
|
|
<option value="">Select project</option>
|
|
@foreach ($projects as $project)
|
|
<option value="{{ $project->id }}" @selected((string) old('project_id', $project_id ?? '') === (string) $project->id)>
|
|
{{ $project->title ?? $project->name }}
|
|
</option>
|
|
@endforeach
|
|
</select>
|
|
@error('project_id') <p class="mt-2 text-sm text-red-600">{{ $message }}</p> @enderror
|
|
</div>
|
|
|
|
<div>
|
|
<label class="block text-sm font-semibold text-zinc-700 dark:text-zinc-200" for="team_id">Team</label>
|
|
<select
|
|
id="team_id"
|
|
name="team_id"
|
|
class="mt-2 block w-full rounded-xl border-zinc-300 shadow-sm focus:border-blue-500 focus:ring-blue-500 dark:border-zinc-700 dark:bg-zinc-950 dark:text-zinc-100"
|
|
>
|
|
<option value="">Select team</option>
|
|
@foreach ($teams as $team)
|
|
<option value="{{ $team->id }}" @selected((string) old('team_id', $team_id ?? '') === (string) $team->id)>
|
|
{{ $team->name }}
|
|
</option>
|
|
@endforeach
|
|
</select>
|
|
@error('team_id') <p class="mt-2 text-sm text-red-600">{{ $message }}</p> @enderror
|
|
</div>
|
|
|
|
<div>
|
|
<label class="block text-sm font-semibold text-zinc-700 dark:text-zinc-200" for="due_at">Due date</label>
|
|
<input
|
|
id="due_at"
|
|
name="due_at"
|
|
type="date"
|
|
value="{{ old('due_at', $due_at ?? '') }}"
|
|
class="mt-2 block w-full rounded-xl border-zinc-300 shadow-sm focus:border-blue-500 focus:ring-blue-500 dark:border-zinc-700 dark:bg-zinc-950 dark:text-zinc-100"
|
|
>
|
|
@error('due_at') <p class="mt-2 text-sm text-red-600">{{ $message }}</p> @enderror
|
|
</div>
|
|
|
|
<div class="lg:col-span-2">
|
|
<label class="block text-sm font-semibold text-zinc-700 dark:text-zinc-200">Details</label>
|
|
|
|
<div class="mt-2 overflow-hidden rounded-xl border border-zinc-300 bg-white shadow-sm dark:border-zinc-700 dark:bg-zinc-950">
|
|
<div class="flex flex-wrap gap-1 border-b border-zinc-200 bg-zinc-50 p-2 dark:border-zinc-800 dark:bg-zinc-900">
|
|
<button type="button" x-on:click="command('bold')" class="rounded-lg px-2 py-1 text-sm font-bold hover:bg-zinc-200 dark:hover:bg-zinc-800">B</button>
|
|
<button type="button" x-on:click="command('italic')" class="rounded-lg px-2 py-1 text-sm italic hover:bg-zinc-200 dark:hover:bg-zinc-800">I</button>
|
|
<button type="button" x-on:click="command('underline')" class="rounded-lg px-2 py-1 text-sm underline hover:bg-zinc-200 dark:hover:bg-zinc-800">U</button>
|
|
<button type="button" x-on:click="command('insertUnorderedList')" class="rounded-lg px-2 py-1 text-sm hover:bg-zinc-200 dark:hover:bg-zinc-800">• List</button>
|
|
<button type="button" x-on:click="command('insertOrderedList')" class="rounded-lg px-2 py-1 text-sm hover:bg-zinc-200 dark:hover:bg-zinc-800">1. List</button>
|
|
<button type="button" x-on:click="command('formatBlock', 'blockquote')" class="rounded-lg px-2 py-1 text-sm hover:bg-zinc-200 dark:hover:bg-zinc-800">Quote</button>
|
|
<button type="button" x-on:click="const url = prompt('URL'); if (url) command('createLink', url)" class="rounded-lg px-2 py-1 text-sm hover:bg-zinc-200 dark:hover:bg-zinc-800">Link</button>
|
|
<button type="button" x-on:click="command('removeFormat')" class="rounded-lg px-2 py-1 text-sm hover:bg-zinc-200 dark:hover:bg-zinc-800">Clear</button>
|
|
</div>
|
|
|
|
<div
|
|
x-ref="bodyEditor"
|
|
contenteditable="true"
|
|
x-on:input.debounce.200ms="syncBody"
|
|
x-on:blur="syncBody"
|
|
class="prose prose-sm min-h-[280px] max-w-none bg-white p-4 text-sm text-zinc-900 outline-none dark:prose-invert dark:bg-zinc-950 dark:text-zinc-100"
|
|
data-dusk="ticket-body-editor"
|
|
></div>
|
|
</div>
|
|
|
|
<input x-ref="bodyInput" type="hidden" name="body" value="{{ old('body', $body ?? '') }}">
|
|
|
|
@error('body') <p class="mt-2 text-sm text-red-600">{{ $message }}</p> @enderror
|
|
</div>
|
|
|
|
<div class="lg:col-span-2">
|
|
<label class="block text-sm font-semibold text-zinc-700 dark:text-zinc-200" for="attachments">Attachments</label>
|
|
<input
|
|
id="attachments"
|
|
name="attachments[]"
|
|
type="file"
|
|
multiple
|
|
class="mt-2 block w-full rounded-xl border border-zinc-300 bg-white px-3 py-2 text-sm shadow-sm dark:border-zinc-700 dark:bg-zinc-950 dark:text-zinc-100"
|
|
>
|
|
@error('attachments') <p class="mt-2 text-sm text-red-600">{{ $message }}</p> @enderror
|
|
@error('attachments.*') <p class="mt-2 text-sm text-red-600">{{ $message }}</p> @enderror
|
|
</div>
|
|
</div>
|
|
|
|
<div class="flex items-center justify-end gap-3 border-t border-zinc-200 px-6 py-4 dark:border-zinc-700">
|
|
<a href="{{ route('helpdesk.tickets.index') }}" wire:navigate class="rounded-xl border border-zinc-300 px-4 py-2 text-sm font-semibold text-zinc-700 hover:bg-zinc-50 dark:border-zinc-700 dark:text-zinc-200 dark:hover:bg-zinc-800">Cancel</a>
|
|
<button type="submit" x-on:click="syncBody" class="rounded-xl bg-blue-600 px-5 py-2 text-sm font-semibold text-white shadow-sm hover:bg-blue-700" data-dusk="ticket-create-submit">Create Ticket</button>
|
|
</div>
|
|
</div>
|
|
</form>
|
|
</div>
|