266 lines
11 KiB
Vue
266 lines
11 KiB
Vue
<script setup lang="ts">
|
|
import Chat from '@/components/Chat.vue';
|
|
import { Head, Link, useForm } from '@inertiajs/vue3';
|
|
import { route } from 'ziggy-js';
|
|
|
|
const props = defineProps<{
|
|
dynamic: {
|
|
id: number;
|
|
name: string;
|
|
rules: string;
|
|
chat: any;
|
|
participants: Array<{ id: number; name: string }>;
|
|
ledgers: Array<{
|
|
id: number;
|
|
name: string;
|
|
score: number;
|
|
media?: Array<{ id: number; url: string; mime_type: string }>;
|
|
}>;
|
|
};
|
|
}>();
|
|
|
|
const breadcrumbs = [
|
|
{
|
|
name: 'Dynamics',
|
|
href: route('dynamics.index'),
|
|
},
|
|
{
|
|
name: props.dynamic.name,
|
|
href: route('dynamics.show', props.dynamic.id),
|
|
},
|
|
];
|
|
|
|
const form = useForm({
|
|
name: '',
|
|
rules: '',
|
|
media: [] as File[],
|
|
});
|
|
|
|
function handleLedgerFileChange(event: Event) {
|
|
const files = (event.target as HTMLInputElement).files;
|
|
if (files) {
|
|
for (let i = 0; i < files.length; i++) {
|
|
form.media.push(files[i]);
|
|
}
|
|
}
|
|
}
|
|
|
|
function removeLedgerFile(index: number) {
|
|
form.media.splice(index, 1);
|
|
}
|
|
|
|
function submit() {
|
|
form.post(route('dynamics.ledgers.store', props.dynamic.id), {
|
|
onSuccess: () => form.reset(),
|
|
});
|
|
}
|
|
</script>
|
|
|
|
<template>
|
|
<Head :title="dynamic.name" />
|
|
|
|
<div class="py-12">
|
|
<div class="mx-auto max-w-7xl sm:px-6 lg:px-8">
|
|
<div
|
|
class="overflow-hidden bg-white shadow-sm sm:rounded-lg dark:bg-gray-800"
|
|
>
|
|
<div class="p-6 text-gray-900 dark:text-gray-100">
|
|
<h3 class="text-lg font-medium">{{ dynamic.name }}</h3>
|
|
<p class="mt-2 text-sm text-gray-600 dark:text-gray-400">
|
|
{{ dynamic.rules }}
|
|
</p>
|
|
</div>
|
|
</div>
|
|
|
|
<Chat :chat="dynamic.chat" />
|
|
|
|
<div class="mt-8">
|
|
<h4
|
|
class="text-lg font-medium text-gray-900 dark:text-gray-100"
|
|
>
|
|
Participants
|
|
</h4>
|
|
<ul
|
|
class="mt-4 grid grid-cols-1 gap-6 md:grid-cols-2 lg:grid-cols-3"
|
|
>
|
|
<li
|
|
v-for="participant in dynamic.participants"
|
|
:key="participant.id"
|
|
class="overflow-hidden bg-white p-4 shadow-sm sm:rounded-lg dark:bg-gray-800"
|
|
>
|
|
{{ participant.name }}
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
|
|
<div class="mt-8">
|
|
<div class="mb-6 flex items-center justify-between">
|
|
<h4
|
|
class="text-lg font-medium text-gray-900 dark:text-gray-100"
|
|
>
|
|
Ledgers
|
|
</h4>
|
|
</div>
|
|
<ul
|
|
class="mt-4 grid grid-cols-1 gap-6 md:grid-cols-2 lg:grid-cols-3"
|
|
>
|
|
<li
|
|
v-for="ledger in dynamic.ledgers"
|
|
:key="ledger.id"
|
|
class="border-b border-gray-200 bg-white p-6 dark:border-gray-600 dark:bg-gray-700"
|
|
>
|
|
<Link
|
|
:href="
|
|
route('dynamics.ledgers.show', {
|
|
dynamic: dynamic.id,
|
|
ledger: ledger.id,
|
|
})
|
|
"
|
|
>
|
|
<h5 class="text-lg font-semibold">
|
|
{{ ledger.name }}
|
|
</h5>
|
|
<p
|
|
class="mt-2 text-sm text-gray-600 dark:text-gray-400"
|
|
>
|
|
Score: {{ ledger.score }}
|
|
</p>
|
|
|
|
<!-- Ledger Media Thumbnails -->
|
|
<div
|
|
v-if="ledger.media && ledger.media.length > 0"
|
|
class="mt-2 flex flex-wrap gap-1"
|
|
>
|
|
<div
|
|
v-for="item in ledger.media"
|
|
:key="item.id"
|
|
class="relative size-8 overflow-hidden rounded border border-gray-300 bg-black dark:border-gray-600"
|
|
>
|
|
<img
|
|
v-if="
|
|
item.mime_type.startsWith('image/')
|
|
"
|
|
:src="item.url"
|
|
class="size-full object-cover"
|
|
/>
|
|
<video
|
|
v-else-if="
|
|
item.mime_type.startsWith('video/')
|
|
"
|
|
:src="item.url"
|
|
class="size-full object-cover"
|
|
/>
|
|
</div>
|
|
</div>
|
|
</Link>
|
|
</li>
|
|
</ul>
|
|
<div
|
|
v-if="dynamic.ledgers.length === 0"
|
|
class="mt-4 text-gray-500"
|
|
>
|
|
No ledgers found for this dynamic.
|
|
</div>
|
|
</div>
|
|
|
|
<div class="mt-8">
|
|
<div
|
|
class="overflow-hidden bg-white shadow-sm sm:rounded-lg dark:bg-gray-800"
|
|
>
|
|
<div class="p-6 text-gray-900 dark:text-gray-100">
|
|
<h3 class="text-lg font-medium">Create a New Ledger</h3>
|
|
|
|
<form @submit.prevent="submit" class="mt-6 space-y-6">
|
|
<div>
|
|
<label
|
|
for="name"
|
|
class="block text-sm font-medium text-gray-700 dark:text-gray-300"
|
|
>Name</label
|
|
>
|
|
<input
|
|
v-model="form.name"
|
|
id="name"
|
|
type="text"
|
|
class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 dark:border-gray-700 dark:bg-gray-900 dark:text-gray-300 dark:focus:border-indigo-600 dark:focus:ring-indigo-600"
|
|
/>
|
|
<div
|
|
v-if="form.errors.name"
|
|
class="text-sm text-red-600"
|
|
>
|
|
{{ form.errors.name }}
|
|
</div>
|
|
</div>
|
|
|
|
<div>
|
|
<label
|
|
for="rules"
|
|
class="block text-sm font-medium text-gray-700 dark:text-gray-300"
|
|
>Rules</label
|
|
>
|
|
<textarea
|
|
v-model="form.rules"
|
|
id="rules"
|
|
rows="4"
|
|
class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 dark:border-gray-700 dark:bg-gray-900 dark:text-gray-300 dark:focus:border-indigo-600 dark:focus:ring-indigo-600"
|
|
></textarea>
|
|
<div
|
|
v-if="form.errors.rules"
|
|
class="text-sm text-red-600"
|
|
>
|
|
{{ form.errors.rules }}
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Media Uploads for Ledgers -->
|
|
<div>
|
|
<label
|
|
class="block text-sm font-medium text-gray-700 dark:text-gray-300"
|
|
>Attach Cover/Rules Media</label
|
|
>
|
|
<input
|
|
type="file"
|
|
multiple
|
|
accept="image/*,video/*"
|
|
@change="handleLedgerFileChange"
|
|
class="mt-1 block w-full text-sm text-neutral-500 file:mr-4 file:rounded-md file:border-0 file:bg-indigo-50 file:px-4 file:py-2 file:text-xs file:font-semibold file:text-indigo-700 hover:file:bg-indigo-100"
|
|
/>
|
|
<div
|
|
v-if="form.media.length > 0"
|
|
class="mt-2 flex flex-wrap gap-2"
|
|
>
|
|
<div
|
|
v-for="(file, index) in form.media"
|
|
:key="index"
|
|
class="relative inline-flex items-center gap-2 rounded border border-neutral-200 bg-neutral-100 p-1.5 pr-8 text-xs dark:border-neutral-700 dark:bg-neutral-800"
|
|
>
|
|
<span class="max-w-[150px] truncate">{{
|
|
file.name
|
|
}}</span>
|
|
<button
|
|
type="button"
|
|
@click="removeLedgerFile(index)"
|
|
class="absolute top-1.5 right-1.5 cursor-pointer text-[10px] text-neutral-400 hover:text-red-500"
|
|
>
|
|
✕
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="flex items-center gap-4">
|
|
<button
|
|
type="submit"
|
|
:disabled="form.processing"
|
|
class="inline-flex items-center rounded-md border border-transparent bg-gray-800 px-4 py-2 text-xs font-semibold tracking-widest text-white uppercase transition duration-150 ease-in-out hover:bg-gray-700 focus:bg-gray-700 focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 focus:outline-none active:bg-gray-900 dark:bg-gray-200 dark:text-gray-800 dark:hover:bg-white dark:focus:bg-white dark:focus:ring-offset-gray-800 dark:active:bg-gray-300"
|
|
>
|
|
Create Ledger
|
|
</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</template>
|