update cart view

This commit is contained in:
pbao9
2025-07-29 08:53:41 +07:00
parent 5ea42105f9
commit 980c9468fc
18 changed files with 893 additions and 409 deletions
@@ -0,0 +1,45 @@
<div class="bg-white rounded-lg border border-gray-200 p-6" x-data="{ loading: true }" data-skeleton-id="domain-input">
<h3 class="text-lg font-semibold text-gray-800 mb-4">{{ __('Domain') }}</h3>
<!-- Skeleton Loading -->
<template x-if="loading">
<div class="space-y-4 animate-pulse">
<div class="h-12 bg-gray-200 rounded-lg"></div>
<div class="h-4 bg-gray-200 rounded w-3/4"></div>
</div>
</template>
<!-- Actual Content -->
<template x-if="!loading">
<div x-data="{ serverName: '', isValid: true }">
<flux:input
name="server_name"
placeholder="{{ __('Nhập tên domain') }}"
x-model="serverName"
@input="isValid = /^[a-zA-Z0-9.-]+$/.test(serverName)"
>
<x-slot name="iconTrailing">
<flux:button
size="sm"
variant="subtle"
icon="x-mark"
class="-mr-1"
@click="serverName = ''; isValid = true"
type="button"
/>
</x-slot>
</flux:input>
<template x-if="!isValid">
<div class="p-4 my-4 text-sm text-red-800 rounded-lg bg-red-50" role="alert">
{{ __('Tên server không hợp lệ. Chỉ được dùng chữ, số, dấu chấm và dấu gạch ngang.') }}
<b>{{ __('VD: tenmiencuaban.com.vn') }}</b>
</div>
</template>
<p class="text-xs text-red-600 mt-2">
{{ __('Lưu ý: Quý khách chỉ ghi tên Domain, không cần ghi đầy đủ tiền tố http:// hoặc https://') }}
</p>
</div>
</template>
</div>
@@ -0,0 +1,34 @@
<div class="text-center py-16" x-data="{ loading: true }">
<!-- Skeleton Loading -->
<template x-if="loading">
<div class="animate-pulse">
<div class="w-24 h-24 bg-gray-200 rounded-full mx-auto mb-6"></div>
<div class="h-6 bg-gray-200 rounded w-48 mx-auto mb-2"></div>
<div class="h-4 bg-gray-200 rounded w-64 mx-auto mb-6"></div>
<div class="h-12 bg-gray-200 rounded w-32 mx-auto"></div>
</div>
</template>
<!-- Actual Empty Cart Content -->
<template x-if="!loading">
<div>
<div class="w-24 h-24 bg-gray-100 rounded-full flex items-center justify-center mx-auto mb-6">
<svg class="w-12 h-12 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
d="M3 3h2l.4 2M7 13h10l4-8H5.4m0 0L7 13m0 0l-2.5 5M7 13l2.5 5m6-5v6a2 2 0 01-2 2H9a2 2 0 01-2-2v-6m8 0V9a2 2 0 00-2-2H9a2 2 0 00-2 2v4.01">
</path>
</svg>
</div>
<h3 class="text-xl font-semibold text-gray-800 mb-2">{{ __('Giỏ hàng trống') }}</h3>
<p class="text-gray-600 mb-6">{{ __('Bạn chưa có sản phẩm nào trong giỏ hàng.') }}</p>
<a href="{{ route('shop') }}"
class="inline-flex items-center px-6 py-3 bg-blue-600 text-white font-medium rounded-lg hover:bg-blue-700 transition-colors">
<svg class="w-5 h-5 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
d="M12 6v6m0 0v6m0-6h6m-6 0H6"></path>
</svg>
{{ __('Mua sản phẩm') }}
</a>
</div>
</template>
</div>
@@ -0,0 +1,99 @@
<div class="bg-white rounded-lg border border-gray-200 p-6" x-cloak x-data="{ selectedOs: null, showOsDetails: false, loading: true }" data-skeleton-id="os-selection">
<h3 class="text-lg font-semibold text-gray-800 mb-4">{{ __('Hệ điều hành') }}</h3>
<!-- Skeleton Loading -->
<template x-if="loading">
<div class="space-y-6 animate-pulse">
<!-- OS Group Skeleton -->
<div class="space-y-4">
<div class="flex items-center gap-2 mb-2">
<div class="w-6 h-6 bg-gray-200 rounded"></div>
<div class="h-4 bg-gray-200 rounded w-24"></div>
</div>
<div class="grid grid-cols-2 sm:grid-cols-3 gap-3">
<div class="h-20 bg-gray-200 rounded-xl"></div>
<div class="h-20 bg-gray-200 rounded-xl"></div>
<div class="h-20 bg-gray-200 rounded-xl"></div>
</div>
</div>
<!-- Second OS Group Skeleton -->
<div class="space-y-4">
<div class="flex items-center gap-2 mb-2">
<div class="w-6 h-6 bg-gray-200 rounded"></div>
<div class="h-4 bg-gray-200 rounded w-20"></div>
</div>
<div class="grid grid-cols-2 sm:grid-cols-3 gap-3">
<div class="h-20 bg-gray-200 rounded-xl"></div>
<div class="h-20 bg-gray-200 rounded-xl"></div>
</div>
</div>
</div>
</template>
<!-- Actual Content -->
<template x-if="!loading">
<div class="space-y-4">
@foreach ($item['os_group'] as $group)
<div>
<div class="flex items-center gap-2 mb-2">
<img src="{{ $group->thumbnail }}" alt="{{ $group->name }}" class="w-6 h-6 rounded" />
<span class="font-medium text-gray-700">{{ $group->name }}</span>
</div>
<div class="grid grid-cols-2 sm:grid-cols-3 gap-3">
@foreach ($group->os as $os)
<div class="relative">
<button type="button"
@click="selectedOs = {{ $os->id }}; $dispatch('os-changed', {{ $os->id }}); showOsDetails = true"
:class="{
'border-orange-500 ring-2 ring-orange-400 bg-orange-50 text-orange-700': selectedOs ===
{{ $os->id }},
'border-gray-200 bg-white text-gray-700 hover:bg-gray-50': selectedOs !==
{{ $os->id }}
}"
class="border rounded-xl p-3 text-sm font-medium transition-all text-left flex items-center gap-3 w-full relative">
<img src="{{ $os->thumbnail ?? $group->thumbnail }}" alt="{{ $os->version }}"
class="w-8 h-8 rounded object-cover" />
<div>
<div class="font-semibold">{{ $group->name }}</div>
<div class="text-xs text-gray-500">{{ __('Version') }}:
{{ $os->version }}</div>
</div>
<div x-show="selectedOs === {{ $os->id }}"
class="absolute top-1 right-1 bg-orange-500 text-white rounded-full p-0.5">
<svg class="w-4 h-4" fill="none" stroke="currentColor" stroke-width="2"
viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" d="M5 13l4 4L19 7" />
</svg>
</div>
</button>
</div>
@endforeach
</div>
</div>
@endforeach
</div>
</template>
<!-- OS Details Panel -->
<div x-show="showOsDetails && selectedOs" x-transition:enter="transition ease-out duration-300"
x-transition:enter-start="opacity-0 transform scale-95" x-transition:enter-end="opacity-100 transform scale-100"
x-transition:leave="transition ease-in duration-200" x-transition:leave-start="opacity-100 transform scale-100"
x-transition:leave-end="opacity-0 transform scale-95"
class="mt-4 p-4 bg-orange-50 rounded-lg border border-orange-200">
<div class="flex items-center justify-between mb-2">
<h5 class="font-semibold text-orange-800">{{ __('Thông tin hệ điều hành') }}</h5>
<flux:button size="sm" variant="subtle" icon="x-mark" @click="showOsDetails = false" type="button" />
</div>
<p class="text-sm text-orange-700">
{{ __('Bạn đã chọn hệ điều hành. Hệ điều hành sẽ được cài đặt tự động khi máy chủ được tạo.') }}
</p>
</div>
<input type="hidden" name="os_id" x-bind:value="selectedOs"
wire:model.defer="selectedOsList.{{ $index }}">
</div>
@@ -0,0 +1,70 @@
<div class="bg-white rounded-lg border border-gray-200 p-6" x-data="{ loading: true }" data-skeleton-id="product-details">
<input type="hidden" name="product_id" value="{{ $product->id }}" />
<input type="hidden" name="product_type" value="{{ $item['product_type'] }}" />
<!-- Skeleton Loading -->
<template x-if="loading">
<div class="animate-pulse">
<div class="flex items-center justify-between mb-4">
<div class="h-6 bg-gray-200 rounded w-1/3"></div>
<div class="h-6 bg-gray-200 rounded w-1/4"></div>
</div>
<div class="space-y-3">
<div class="h-4 bg-gray-200 rounded w-full"></div>
<div class="h-4 bg-gray-200 rounded w-5/6"></div>
<div class="h-4 bg-gray-200 rounded w-4/6"></div>
<div class="h-4 bg-gray-200 rounded w-3/4"></div>
</div>
</div>
</template>
<!-- Actual Content -->
<template x-if="!loading">
<div>
<div class="flex items-center justify-between mb-4">
<h2 class="text-xl font-semibold text-gray-800 border-b-2 border-blue-500 pb-2">
{{ $product->name }}
@if ($item['product_type'] == 4)
<span class="text-sm text-gray-500">(VPS)</span>
@elseif ($item['product_type'] == 3)
<span class="text-sm text-gray-500">(Hosting)</span>
@endif
</h2>
<div class="text-right">
@if ($product->price_sale && $product->price_sale < $product->price)
<div class="text-lg font-bold text-red-600">
{{ format_price($product->price_sale) }}/{{ __('tháng') }}
</div>
<div class="text-sm text-gray-400 line-through">
{{ format_price($product->price) }}/{{ __('tháng') }}
</div>
@else
<div class="text-lg font-bold text-gray-800">
{{ format_price($product->price) }}/{{ __('tháng') }}
</div>
@endif
</div>
</div>
<!-- Product Features -->
<div class="space-y-2 text-sm text-gray-700">
@if ($item['product_type'] == 3)
<!-- Hosting Features -->
<div>• {{ number_format($product->disk ?? 2000) }} MB {{ __('dung lượng SSD') }}.</div>
<div>• 1 {{ __('Addon domain') }}.</div>
<div>• 10 {{ __('Sub-domains') }}.</div>
<div>• {{ __('Không giới hạn Alias Domain') }}.</div>
<div>• {{ __('Không giới hạn Database') }}.</div>
<div>• {{ __('Không giới hạn tài khoản FTP') }}.</div>
<div>• {{ __('Control Panel') }}: Cpanel.</div>
@else
<!-- VPS Features -->
@include('frontend.cart.partials.vps-features', [
'product' => $product,
'parentLoading' => 'loading'
])
@endif
</div>
</div>
</template>
</div>
@@ -0,0 +1,28 @@
@props(['type' => 'default', 'lines' => 3, 'height' => 'h-4'])
@php
$skeletonTypes = [
'text' => 'h-4 bg-gray-200 rounded',
'title' => 'h-6 bg-gray-200 rounded',
'button' => 'h-10 bg-gray-200 rounded-lg',
'input' => 'h-12 bg-gray-200 rounded-lg',
'card' => 'h-32 bg-gray-200 rounded-lg',
'avatar' => 'w-8 h-8 bg-gray-200 rounded-full',
'icon' => 'w-5 h-5 bg-gray-200 rounded',
'image' => 'w-8 h-8 bg-gray-200 rounded object-cover',
];
$skeletonClass = $skeletonTypes[$type] ?? $skeletonTypes['text'];
@endphp
<div class="animate-pulse">
@if ($type === 'card')
<div class="{{ $skeletonClass }}"></div>
@elseif ($type === 'avatar' || $type === 'icon' || $type === 'image')
<div class="{{ $skeletonClass }}"></div>
@else
@for ($i = 0; $i < $lines; $i++)
<div class="{{ $skeletonClass }} {{ $i === $lines - 1 ? 'w-3/4' : 'w-full' }} {{ $i > 0 ? 'mt-2' : '' }}"></div>
@endfor
@endif
</div>
@@ -0,0 +1,49 @@
@php
$features = [
'cpu' => ['icon' => 'cpu.svg', 'label' => 'CPU', 'unit' => 'vCore'],
'ram' => ['icon' => 'ram.svg', 'label' => 'RAM', 'unit' => 'GB'],
'disk' => ['icon' => 'storage.svg', 'label' => 'Disk', 'unit' => 'GB'],
'gpu' => ['icon' => 'video.svg', 'label' => 'GPU', 'unit' => 'GB'],
'ip' => ['icon' => 'network.svg', 'label' => 'IP Public', 'unit' => 'IP'],
'bandwidth' => ['icon' => 'bandwidth.svg', 'label' => 'Băng thông', 'unit' => 'GB']
];
@endphp
<div x-data="{ loading: true }" data-skeleton-id="vps-features">
<!-- Skeleton Loading for VPS Features -->
<template x-if="loading">
<div class="space-y-3 animate-pulse">
@foreach (range(1, 6) as $i)
<div class="flex items-center space-x-3">
<div class="w-5 h-5 bg-gray-200 rounded"></div>
<div class="flex items-center gap-2">
<div class="h-4 bg-gray-200 rounded w-16"></div>
<div class="h-4 bg-gray-200 rounded w-12"></div>
</div>
</div>
@endforeach
</div>
</template>
<!-- Actual VPS Features -->
<template x-if="!loading">
<div>
@foreach ($features as $key => $feature)
@if ($product->$key)
<div class="flex items-center space-x-3">
<div class="flex-shrink-0">
<img src="{{ asset('/icon/' . $feature['icon']) }}" alt="{{ $feature['label'] }}" class="w-5 h-5">
</div>
<div class="flex items-center gap-2">
<span class="text-md font-semibold">{{ $feature['label'] }}:</span>
<div class="font-semibold text-blue-800 h-4">
<span>{{ $product->$key }}</span>
<span class="text-xs text-blue-600">{{ $feature['unit'] }}</span>
</div>
</div>
</div>
@endif
@endforeach
</div>
</template>
</div>