feat: add quick-create functionality for client categories in the schedule form
This commit is contained in:
@@ -62,7 +62,7 @@
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-sm font-semibold text-gray-700 mb-1">Target Date</label>
|
||||
<input type="date" name="target_date" value="{{ old('target_date') }}" class="input-soft">
|
||||
<input type="date" name="target_date" value="{{ old('target_date') }}" class="input-soft" @change="checkContract()">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -116,7 +116,8 @@
|
||||
|
||||
<div class="flex flex-col sm:flex-row gap-3 pt-1">
|
||||
<button type="submit" class="btn-sakura flex-1 py-3"
|
||||
:class="{ 'opacity-50 cursor-not-allowed': contractWarning }">🎬 Create Brief</button>
|
||||
:class="{ 'opacity-50 cursor-not-allowed': contractWarning }"
|
||||
:disabled="contractWarning">🎬 Create Brief</button>
|
||||
<a href="{{ route('content.index') }}"
|
||||
class="flex-1 py-3 text-center rounded-full border border-pink-200 text-gray-600 hover:bg-pink-50 font-semibold text-sm">
|
||||
Cancel
|
||||
@@ -135,13 +136,32 @@ function contractCheck(checkUrl) {
|
||||
contractMessage: '',
|
||||
async checkContract() {
|
||||
if (!this.categoryId) { this.contractWarning = false; return; }
|
||||
const params = new URLSearchParams({ category_id: this.categoryId, client_id: this.clientId || '' });
|
||||
const res = await fetch(checkUrl + '?' + params);
|
||||
const data = await res.json();
|
||||
if (data) {
|
||||
this.contractWarning = true;
|
||||
this.contractMessage = `"${data.title}" — ${data.client_name} holds exclusive rights in the ${data.category} category until ${data.end_date} (${data.days_left} days left).`;
|
||||
} else {
|
||||
let dateVal = '';
|
||||
const targetDateEl = document.querySelector('input[name="target_date"]');
|
||||
if (targetDateEl && targetDateEl.value) {
|
||||
dateVal = targetDateEl.value;
|
||||
}
|
||||
if (!dateVal) {
|
||||
this.contractWarning = false;
|
||||
return;
|
||||
}
|
||||
const params = new URLSearchParams({
|
||||
category_id: this.categoryId,
|
||||
client_id: this.clientId || '',
|
||||
date: dateVal
|
||||
});
|
||||
try {
|
||||
const res = await fetch(checkUrl + '?' + params);
|
||||
if (!res.ok) throw new Error('Network error');
|
||||
const data = await res.json();
|
||||
if (data && data.title) {
|
||||
this.contractWarning = true;
|
||||
this.contractMessage = `"${data.title}" — ${data.client_name} holds exclusive rights in the ${data.category} category until ${data.end_date} (${data.days_left} days left).`;
|
||||
} else {
|
||||
this.contractWarning = false;
|
||||
this.contractMessage = '';
|
||||
}
|
||||
} catch (e) {
|
||||
this.contractWarning = false;
|
||||
this.contractMessage = '';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user