feat: extend rate card profiles with brands, terms, and custom HTML, and remove search bar from search index view
This commit is contained in:
@@ -4,6 +4,8 @@
|
||||
@section('page-subtitle', 'Customise your public rate card page')
|
||||
|
||||
@section('content')
|
||||
<link href="https://cdn.quilljs.com/1.3.6/quill.snow.css" rel="stylesheet">
|
||||
<script src="https://cdn.quilljs.com/1.3.6/quill.min.js"></script>
|
||||
<div class="max-w-3xl mx-auto space-y-5">
|
||||
|
||||
@if(session('success'))
|
||||
@@ -81,20 +83,79 @@
|
||||
<h2 class="font-bold text-gray-700">Appearance</h2>
|
||||
</div>
|
||||
<div class="p-5 grid grid-cols-1 sm:grid-cols-2 gap-4">
|
||||
<div class="sm:col-span-2">
|
||||
<div class="sm:col-span-2" x-data="{
|
||||
uploading: false,
|
||||
errorMsg: '',
|
||||
logoUrl: '{{ $profile->logo_path ? route('files.serve-profile-logo') : '' }}',
|
||||
|
||||
async pickFile(input) {
|
||||
if (!input.files.length) return;
|
||||
this.uploading = true;
|
||||
this.errorMsg = '';
|
||||
const fd = new FormData();
|
||||
fd.append('logo', input.files[0]);
|
||||
fd.append('_token', document.querySelector('meta[name=csrf-token]').content);
|
||||
try {
|
||||
const res = await fetch('{{ route('rate-cards.profile.upload-logo', [], false) }}', {
|
||||
method: 'POST',
|
||||
body: fd,
|
||||
headers: {
|
||||
'Accept': 'application/json'
|
||||
}
|
||||
});
|
||||
const data = await res.json();
|
||||
if (res.ok) {
|
||||
this.logoUrl = data.url + '?t=' + Date.now();
|
||||
} else {
|
||||
this.errorMsg = data.message ?? 'Upload failed.';
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
this.errorMsg = 'Network error. Please try again.';
|
||||
}
|
||||
this.uploading = false;
|
||||
input.value = '';
|
||||
},
|
||||
|
||||
async removeLogo() {
|
||||
if (!confirm('Remove this logo?')) return;
|
||||
const fd = new FormData();
|
||||
fd.append('_token', document.querySelector('meta[name=csrf-token]').content);
|
||||
fd.append('_method', 'DELETE');
|
||||
await fetch('{{ route('rate-cards.profile.delete-logo', [], false) }}', {
|
||||
method: 'POST',
|
||||
body: fd,
|
||||
headers: { 'Accept': 'application/json' }
|
||||
});
|
||||
this.logoUrl = '';
|
||||
}
|
||||
}">
|
||||
<label class="block text-xs font-semibold text-gray-600 mb-1">Logo / Profile Image</label>
|
||||
@if($profile->logo_path)
|
||||
<div class="flex items-center gap-3 mb-2">
|
||||
<img src="{{ route('files.serve-profile-logo') }}" alt="Logo"
|
||||
class="w-16 h-16 object-cover rounded-2xl border border-pink-100">
|
||||
<span class="text-xs text-gray-400">Current logo</span>
|
||||
|
||||
<template x-if="logoUrl">
|
||||
<div class="flex items-center gap-3 mb-3">
|
||||
<img :src="logoUrl" alt="Logo"
|
||||
class="w-16 h-16 object-cover rounded-2xl border border-pink-100 shrink-0">
|
||||
<div class="flex-1 min-w-0">
|
||||
<p class="text-xs font-semibold text-gray-600">Current Logo</p>
|
||||
<p class="text-xs text-gray-400 mt-0.5">Choose a new file to replace it</p>
|
||||
</div>
|
||||
<button type="button" @click="removeLogo()"
|
||||
class="text-xs px-3 py-1.5 rounded-full border border-red-200 text-red-400 hover:bg-red-50 shrink-0">
|
||||
🗑️ Remove
|
||||
</button>
|
||||
</div>
|
||||
@endif
|
||||
<input type="file" name="logo" accept="image/*" class="w-full text-sm text-gray-600
|
||||
file:mr-3 file:py-2 file:px-4 file:rounded-full file:border-0
|
||||
file:text-xs file:font-semibold file:bg-pink-50 file:text-pink-600
|
||||
hover:file:bg-pink-100 cursor-pointer">
|
||||
<p class="text-xs text-gray-400 mt-1">Max 2MB. PNG/JPG/WebP.</p>
|
||||
</template>
|
||||
|
||||
<div class="relative">
|
||||
<input type="file" accept="image/*" @change="pickFile($event.target)" class="w-full text-sm text-gray-600
|
||||
file:mr-3 file:py-2 file:px-4 file:rounded-full file:border-0
|
||||
file:text-xs file:font-semibold file:bg-pink-50 file:text-pink-600
|
||||
hover:file:bg-pink-100 cursor-pointer" :disabled="uploading">
|
||||
<span x-show="uploading" class="text-xs text-pink-500 mt-1 block">Uploading…</span>
|
||||
<span x-show="errorMsg" x-text="errorMsg" class="text-xs text-red-500 mt-1 block"></span>
|
||||
</div>
|
||||
<p class="text-xs text-gray-400 mt-1">Max 2MB. Uploads immediately on file selection.</p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
@@ -128,7 +189,82 @@
|
||||
class="input-soft text-sm flex-1" readonly>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<div class="sm:col-span-2" x-data="{
|
||||
init() {
|
||||
var quill = new Quill(this.$refs.editor, {
|
||||
theme: 'snow',
|
||||
placeholder: 'e.g. 1. 50% down payment required. 2. Rates valid for 30 days.',
|
||||
modules: {
|
||||
toolbar: [
|
||||
[{ 'size': ['small', false, 'large', 'huge'] }],
|
||||
['bold', 'italic', 'underline', 'strike'],
|
||||
[{ 'color': [] }, { 'background': [] }],
|
||||
[{ 'list': 'ordered'}, { 'list': 'bullet' }],
|
||||
['clean']
|
||||
]
|
||||
}
|
||||
});
|
||||
quill.on('text-change', () => {
|
||||
this.$refs.input.value = quill.root.innerHTML;
|
||||
});
|
||||
}
|
||||
}">
|
||||
<label class="block text-xs font-semibold text-gray-600 mb-1">Terms & Conditions</label>
|
||||
<input type="hidden" name="terms_and_conditions" x-ref="input"
|
||||
value="{{ old('terms_and_conditions', $profile->terms_and_conditions) }}">
|
||||
<div class="bg-white rounded-lg border border-pink-200">
|
||||
<div x-ref="editor" style="min-height: 120px;">
|
||||
{!! old('terms_and_conditions', $profile->terms_and_conditions) !!}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sm:col-span-2" x-data="{
|
||||
init() {
|
||||
var quill = new Quill(this.$refs.editor, {
|
||||
theme: 'snow',
|
||||
placeholder: 'Customize your Contact Person Page formatting...',
|
||||
modules: {
|
||||
toolbar: [
|
||||
[{ 'size': ['small', false, 'large', 'huge'] }],
|
||||
['bold', 'italic', 'underline', 'strike'],
|
||||
[{ 'color': [] }, { 'background': [] }],
|
||||
[{ 'align': [] }],
|
||||
['clean']
|
||||
]
|
||||
}
|
||||
});
|
||||
quill.on('text-change', () => {
|
||||
this.$refs.input.value = quill.root.innerHTML;
|
||||
});
|
||||
}
|
||||
}">
|
||||
<label class="block text-xs font-semibold text-gray-600 mb-1">Contact Person Page (PDF)</label>
|
||||
@php
|
||||
$defaultContactHtml = '<div style="text-align: center; margin-top: 40px;">
|
||||
<h1 style="font-family: \'Comic Sans MS\', sans-serif; font-size: 32px; font-weight: 900; letter-spacing: 4px; color: #111827; margin-bottom: 30px; text-transform: uppercase;">CONTACT PERSON</h1>';
|
||||
if ($profile->whatsapp) {
|
||||
$defaultContactHtml .= '<div style="font-family: \'Comic Sans MS\', sans-serif; font-size: 36px; font-weight: 900; color: #14b8a6; margin-bottom: 5px;">' . $profile->whatsapp . '</div>
|
||||
<div style="font-family: \'Comic Sans MS\', sans-serif; font-size: 20px; font-weight: 800; color: #14b8a6; margin-bottom: 30px; letter-spacing: 2px;">(WHATS APP)</div>';
|
||||
}
|
||||
if ($profile->email) {
|
||||
$defaultContactHtml .= '<div style="font-family: \'Comic Sans MS\', sans-serif; font-size: 14px; font-weight: 800; color: #f97316; margin-bottom: 10px; letter-spacing: 2px;">EMAIL</div>
|
||||
<div style="font-family: \'Comic Sans MS\', sans-serif; font-size: 32px; font-weight: 900; color: #ef4444; margin-bottom: 40px; letter-spacing: 2px;">' . strtoupper($profile->email) . '</div>';
|
||||
}
|
||||
$defaultContactHtml .= '<div style="font-size: 11px; font-weight: 900; color: #111827; line-height: 1.5; max-width: 80%; margin: 0 auto; text-transform: uppercase;">
|
||||
Kami tidak bertanggung jawab atas segala bentuk kerjasama yg timbul dengan pihak selain dari kontak diatas
|
||||
</div>
|
||||
</div>';
|
||||
@endphp
|
||||
<input type="hidden" name="contact_person_html" x-ref="input"
|
||||
value="{{ old('contact_person_html', $profile->contact_person_html) }}">
|
||||
<div class="bg-white rounded-lg border border-pink-200">
|
||||
<div x-ref="editor" style="min-height: 120px;">
|
||||
{!! old('contact_person_html', $profile->contact_person_html ?: $defaultContactHtml) !!}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="sm:col-span-2">
|
||||
<label class="block text-xs font-semibold text-gray-600 mb-1">Custom Footer</label>
|
||||
<input type="text" name="custom_footer" value="{{ old('custom_footer', $profile->custom_footer) }}"
|
||||
class="input-soft" placeholder="e.g. Prices valid until Dec 2025 · DM for bundles">
|
||||
@@ -146,22 +282,95 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{-- Actions --}}
|
||||
<div class="flex flex-wrap items-center gap-3">
|
||||
<button type="submit" class="btn-sakura px-6 py-2.5">💾 Save Profile</button>
|
||||
<a href="{{ route('rate-cards.public') }}" target="_blank"
|
||||
class="btn-sakura text-sm px-4 py-2.5 rounded-full border border-pink-200 text-pink-500 hover:bg-pink-50">
|
||||
👁️ Preview
|
||||
</a>
|
||||
<a href="{{ route('rate-cards.pdf') }}"
|
||||
class="btn-sakura text-sm px-4 py-2.5 rounded-full border border-blue-200 text-blue-500 hover:bg-blue-50">
|
||||
📄 Download PDF
|
||||
</a>
|
||||
<a href="{{ route('rate-cards.index') }}"
|
||||
class="btn-sakura text-sm px-4 py-2.5 rounded-full border border-gray-200 text-gray-500 hover:bg-gray-50">
|
||||
← Back
|
||||
</a>
|
||||
</div>
|
||||
|
||||
{{-- Past Brands --}}
|
||||
<div class="cat-card overflow-hidden">
|
||||
<div class="flex items-center gap-3 px-5 py-4 border-b border-pink-50">
|
||||
<span class="text-xl"></span>
|
||||
<h2 class="font-bold text-gray-700">Brand Collaborations Logo</h2>
|
||||
</div>
|
||||
<div class="p-5" x-data="{
|
||||
uploading: false,
|
||||
brands: {{ Illuminate\Support\Js::from($profile->past_brands ?? []) }},
|
||||
async pickBrand(input) {
|
||||
if (!input.files.length) return;
|
||||
this.uploading = true;
|
||||
const fd = new FormData();
|
||||
for (let i = 0; i < input.files.length; i++) {
|
||||
fd.set('logo', input.files[i]);
|
||||
fd.set('_token', document.querySelector('meta[name=csrf-token]').content);
|
||||
try {
|
||||
const res = await fetch('{{ route('rate-cards.profile.upload-brand-logo', [], false) }}', { method: 'POST', body: fd, headers: { 'Accept': 'application/json' } });
|
||||
const data = await res.json();
|
||||
if (res.ok) this.brands.push(data.path);
|
||||
} catch (e) { console.error(e); }
|
||||
}
|
||||
this.uploading = false;
|
||||
input.value = '';
|
||||
},
|
||||
async removeBrand(path, index) {
|
||||
if(!confirm('Remove this brand?')) return;
|
||||
const fd = new FormData();
|
||||
fd.append('_token', document.querySelector('meta[name=csrf-token]').content);
|
||||
fd.append('_method', 'DELETE');
|
||||
fd.append('path', path);
|
||||
await fetch('{{ route('rate-cards.profile.delete-brand-logo', [], false) }}', { method: 'POST', body: fd, headers: {'Accept': 'application/json'} });
|
||||
this.brands.splice(index, 1);
|
||||
}
|
||||
}">
|
||||
<div class="flex items-center justify-between mb-2">
|
||||
<label class="block text-xs font-semibold text-gray-600">Brand Logos</label>
|
||||
<div class="flex items-center gap-2">
|
||||
<span class="text-[10px] text-gray-500 uppercase tracking-widest font-semibold">Display Size on PDF:</span>
|
||||
<select name="brand_logo_size" class="text-xs border-pink-200 rounded-md py-1 pr-8 pl-2 focus:ring-pink-500 focus:border-pink-500 bg-white">
|
||||
<option value="small" {{ old('brand_logo_size', $profile->brand_logo_size ?? 'medium') == 'small' ? 'selected' : '' }}>Small</option>
|
||||
<option value="medium" {{ old('brand_logo_size', $profile->brand_logo_size ?? 'medium') == 'medium' ? 'selected' : '' }}>Medium</option>
|
||||
<option value="large" {{ old('brand_logo_size', $profile->brand_logo_size ?? 'medium') == 'large' ? 'selected' : '' }}>Large</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<div class="flex flex-wrap gap-4 mb-3">
|
||||
<template x-for="(path, index) in brands" :key="index">
|
||||
<div
|
||||
class="relative rounded-2xl border border-pink-100 p-2 flex items-center justify-center bg-white group shrink-0"
|
||||
style="width: 100px; height: 100px;">
|
||||
<img :src="'/storage/' + path" class="max-w-full max-h-full object-contain">
|
||||
<button type="button" @click="removeBrand(path, index)"
|
||||
class="absolute -bottom-2 -right-2 bg-red-100 text-red-500 rounded-full w-6 h-6 flex items-center justify-center hover:bg-red-200 shadow text-[10px] z-10 transition-colors">🗑️</button>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<label
|
||||
class="rounded-2xl border-2 border-dashed border-pink-200 flex items-center justify-center text-pink-300 hover:bg-pink-50 hover:text-pink-400 cursor-pointer transition-colors shrink-0"
|
||||
style="width: 100px; height: 100px;"
|
||||
:class="{'opacity-50 pointer-events-none': uploading}">
|
||||
<span x-show="!uploading" class="text-2xl">+</span>
|
||||
<span x-show="uploading" class="text-xs">...</span>
|
||||
<input type="file" multiple accept="image/*" class="hidden" @change="pickBrand($event.target)">
|
||||
</label>
|
||||
</div>
|
||||
<p class="text-xs text-gray-400 mt-1">Upload brand logos you've worked with. They will be displayed on your rate
|
||||
cards.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{-- Actions --}}
|
||||
<div class="flex flex-wrap items-center gap-3">
|
||||
<button type="submit" class="btn-sakura px-6 py-2.5">💾 Save Profile</button>
|
||||
<a href="{{ route('rate-cards.public') }}" target="_blank"
|
||||
class="btn-sakura text-sm px-4 py-2.5 rounded-full border border-pink-200 text-pink-500 hover:bg-pink-50">
|
||||
👁️ Preview
|
||||
</a>
|
||||
<a href="{{ route('rate-cards.pdf') }}"
|
||||
class="btn-sakura text-sm px-4 py-2.5 rounded-full border border-blue-200 text-blue-500 hover:bg-blue-50">
|
||||
📄 Download PDF
|
||||
</a>
|
||||
<a href="{{ route('rate-cards.index') }}"
|
||||
class="btn-sakura text-sm px-4 py-2.5 rounded-full border border-gray-200 text-gray-500 hover:bg-gray-50">
|
||||
← Back
|
||||
</a>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
@endsection
|
||||
Reference in New Issue
Block a user