Files
Kol-Manager/resources/views/rate-cards/profile.blade.php

374 lines
25 KiB
PHP

@extends('layouts.app')
@section('title', 'Rate Card Profile')
@section('page-title', '🎨 Rate Card Profile')
@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'))
<div x-data="{ show: true }" x-show="show" x-init="setTimeout(() => show = false, 4000)"
class="flex items-center justify-between gap-3 bg-green-50 border border-green-200 rounded-2xl px-4 py-3 text-sm text-green-700">
<span>{{ session('success') }}</span>
<button @click="show = false" class="text-green-500 hover:text-green-700 text-lg leading-none">✕</button>
</div>
@endif
<form action="{{ route('rate-cards.profile.update') }}" method="POST" enctype="multipart/form-data"
class="space-y-5">
@csrf
{{-- Identity --}}
<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">Identity</h2>
</div>
<div class="p-5 grid grid-cols-1 sm:grid-cols-2 gap-4">
<div>
<label class="block text-xs font-semibold text-gray-600 mb-1">Display Name <span
class="text-pink-400">*</span></label>
<input type="text" name="owner_name" required value="{{ old('owner_name', $profile->owner_name) }}"
class="input-soft" placeholder="e.g. Sakura KOL">
</div>
<div>
<label class="block text-xs font-semibold text-gray-600 mb-1">Tagline</label>
<input type="text" name="tagline" value="{{ old('tagline', $profile->tagline) }}" class="input-soft"
placeholder="e.g. Lifestyle & Beauty Creator">
</div>
<div>
<label class="block text-xs font-semibold text-gray-600 mb-1">Email</label>
<input type="email" name="email" value="{{ old('email', $profile->email) }}" class="input-soft"
placeholder="hi@example.com">
</div>
<div>
<label class="block text-xs font-semibold text-gray-600 mb-1">WhatsApp Number</label>
<input type="text" name="whatsapp" value="{{ old('whatsapp', $profile->whatsapp) }}"
class="input-soft" placeholder="+6012-345-6789">
</div>
<div>
<label class="block text-xs font-semibold text-gray-600 mb-1">Instagram Handle</label>
<div class="relative">
<span
class="absolute left-3 top-1/2 -translate-y-1/2 text-gray-400 text-sm pointer-events-none"></span>
<input type="text" name="ig_handle" value="{{ old('ig_handle', $profile->ig_handle) }}"
class="input-soft pl-7" placeholder="@yourhandle">
</div>
</div>
<div>
<label class="block text-xs font-semibold text-gray-600 mb-1">TikTok Handle</label>
<div class="relative">
<span
class="absolute left-3 top-1/2 -translate-y-1/2 text-gray-400 text-sm pointer-events-none"></span>
<input type="text" name="tiktok_handle"
value="{{ old('tiktok_handle', $profile->tiktok_handle) }}" class="input-soft pl-7"
placeholder="@yourhandle">
</div>
</div>
<div class="sm:col-span-2">
<label class="block text-xs font-semibold text-gray-600 mb-1">YouTube Handle / Channel</label>
<input type="text" name="youtube_handle"
value="{{ old('youtube_handle', $profile->youtube_handle) }}" class="input-soft"
placeholder="@yourchannel">
</div>
</div>
</div>
{{-- Appearance --}}
<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">Appearance</h2>
</div>
<div class="p-5 grid grid-cols-1 sm:grid-cols-2 gap-4">
<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>
<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>
</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>
<label class="block text-xs font-semibold text-gray-600 mb-1">Background Color</label>
<div class="flex items-center gap-2">
<input type="color" name="bg_color" value="{{ old('bg_color', $profile->bg_color) }}"
class="h-10 w-16 rounded-2xl border border-pink-200 cursor-pointer p-1 bg-white shrink-0"
oninput="document.getElementById('bg_text').value=this.value">
<input type="text" id="bg_text" value="{{ old('bg_color', $profile->bg_color) }}"
class="input-soft text-sm flex-1" readonly>
</div>
</div>
<div>
<label class="block text-xs font-semibold text-gray-600 mb-1">Accent Color</label>
<div class="flex items-center gap-2">
<input type="color" name="accent_color"
value="{{ old('accent_color', $profile->accent_color) }}"
class="h-10 w-16 rounded-2xl border border-pink-200 cursor-pointer p-1 bg-white shrink-0"
oninput="document.getElementById('accent_text').value=this.value">
<input type="text" id="accent_text" value="{{ old('accent_color', $profile->accent_color) }}"
class="input-soft text-sm flex-1" readonly>
</div>
</div>
<div>
<label class="block text-xs font-semibold text-gray-600 mb-1">Text Color</label>
<div class="flex items-center gap-2">
<input type="color" name="text_color" value="{{ old('text_color', $profile->text_color) }}"
class="h-10 w-16 rounded-2xl border border-pink-200 cursor-pointer p-1 bg-white shrink-0"
oninput="document.getElementById('text_text').value=this.value">
<input type="text" id="text_text" value="{{ old('text_color', $profile->text_color) }}"
class="input-soft text-sm flex-1" readonly>
</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">
</div>
<div class="sm:col-span-2">
<label class="flex items-start gap-3 cursor-pointer">
<input type="checkbox" name="show_prices" value="1"
class="w-4 h-4 accent-pink-400 mt-0.5 shrink-0" {{ old('show_prices', $profile->show_prices) ? 'checked' : '' }}>
<div>
<span class="text-sm font-medium text-gray-700">Show prices publicly</span>
<p class="text-xs text-gray-400">Uncheck to show "On Request" instead of actual prices</p>
</div>
</label>
</div>
</div>
</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>
<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-2 w-full">
<button type="submit" class="btn-sakura text-xs sm:text-sm shrink-0 px-4 py-2 sm:px-6 sm:py-2.5">💾 Save Profile</button>
<a href="{{ route('rate-cards.public') }}" target="_blank"
class="bg-white text-xs sm:text-sm px-3 py-1.5 sm:px-4 sm:py-2 rounded-full border border-pink-200 text-pink-600 hover:bg-pink-50 shadow-sm shrink-0">
👁️ Preview
</a>
<a href="{{ route('rate-cards.pdf') }}"
class="bg-white text-xs sm:text-sm px-3 py-1.5 sm:px-4 sm:py-2 rounded-full border border-blue-200 text-blue-600 hover:bg-blue-50 shadow-sm shrink-0">
📄 Download PDF
</a>
<a href="{{ route('rate-cards.index') }}"
class="bg-white text-xs sm:text-sm px-3 py-1.5 sm:px-4 sm:py-2 rounded-full border border-gray-200 text-gray-600 hover:bg-gray-50 shadow-sm shrink-0">
← Back
</a>
</div>
</form>
</div>
@endsection