added media, mutation events, agent instructions
This commit is contained in:
+11
-1
@@ -8,8 +8,18 @@ import { configureEcho } from '@laravel/echo-vue';
|
||||
|
||||
configureEcho({
|
||||
broadcaster: 'reverb',
|
||||
key: import.meta.env.VITE_REVERB_APP_KEY || 'mock-key',
|
||||
wsHost: import.meta.env.VITE_REVERB_HOST || 'localhost',
|
||||
wsPort: import.meta.env.VITE_REVERB_PORT
|
||||
? Number(import.meta.env.VITE_REVERB_PORT)
|
||||
: 8080,
|
||||
wssPort: import.meta.env.VITE_REVERB_PORT
|
||||
? Number(import.meta.env.VITE_REVERB_PORT)
|
||||
: 8080,
|
||||
forceTLS: false,
|
||||
enabledTransports: ['ws', 'wss'],
|
||||
});
|
||||
|
||||
(window as any).echoConfigured = true;
|
||||
|
||||
const appName = import.meta.env.VITE_APP_NAME || 'Laravel';
|
||||
|
||||
|
||||
@@ -18,11 +18,15 @@ const className = computed(() => props.class);
|
||||
<SidebarInset v-if="props.variant === 'sidebar'" :class="className">
|
||||
<slot />
|
||||
</SidebarInset>
|
||||
<main
|
||||
v-else
|
||||
class="mx-auto flex h-full w-full max-w-7xl flex-1 flex-col gap-4 rounded-xl"
|
||||
:class="className"
|
||||
>
|
||||
<main v-else class="app-content" :class="className">
|
||||
<slot />
|
||||
</main>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
@reference "../../css/app.css";
|
||||
|
||||
.app-content {
|
||||
@apply mx-auto flex h-full w-full max-w-7xl flex-1 flex-col gap-4 rounded-xl;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -3,14 +3,30 @@ import AppLogoIcon from '@/components/AppLogoIcon.vue';
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
class="flex aspect-square size-8 items-center justify-center rounded-md bg-sidebar-primary text-sidebar-primary-foreground"
|
||||
>
|
||||
<AppLogoIcon class="size-5 fill-current text-white dark:text-black" />
|
||||
<div class="app-logo__icon-container">
|
||||
<AppLogoIcon class="app-logo__icon" />
|
||||
</div>
|
||||
<div class="ml-1 grid flex-1 text-left text-sm">
|
||||
<span class="mb-0.5 truncate leading-tight font-semibold"
|
||||
>Laravel Starter Kit</span
|
||||
>
|
||||
<div class="app-logo__text-container">
|
||||
<span class="app-logo__text">Laravel Starter Kit</span>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
@reference "../../css/app.css";
|
||||
|
||||
.app-logo__icon-container {
|
||||
@apply flex aspect-square size-8 items-center justify-center rounded-md bg-sidebar-primary text-sidebar-primary-foreground;
|
||||
}
|
||||
|
||||
.app-logo__icon {
|
||||
@apply size-5 fill-current text-white dark:text-black;
|
||||
}
|
||||
|
||||
.app-logo__text-container {
|
||||
@apply ml-1 grid flex-1 text-left text-sm;
|
||||
}
|
||||
|
||||
.app-logo__text {
|
||||
@apply mb-0.5 truncate leading-tight font-semibold;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -14,10 +14,8 @@ withDefaults(
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<header
|
||||
class="flex h-16 shrink-0 items-center gap-2 border-b border-sidebar-border/70 px-6 transition-[width,height] ease-linear group-has-data-[collapsible=icon]/sidebar-wrapper:h-12 md:px-4"
|
||||
>
|
||||
<div class="flex items-center gap-2">
|
||||
<header class="sidebar-header">
|
||||
<div class="sidebar-header__inner">
|
||||
<SidebarTrigger class="-ml-1" />
|
||||
<template v-if="breadcrumbs && breadcrumbs.length > 0">
|
||||
<Breadcrumbs :breadcrumbs="breadcrumbs" />
|
||||
@@ -25,3 +23,15 @@ withDefaults(
|
||||
</div>
|
||||
</header>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
@reference "../../css/app.css";
|
||||
|
||||
.sidebar-header {
|
||||
@apply flex h-16 shrink-0 items-center gap-2 border-b border-sidebar-border/70 px-6 transition-[width,height] ease-linear group-has-data-[collapsible=icon]/sidebar-wrapper:h-12 md:px-4;
|
||||
}
|
||||
|
||||
.sidebar-header__inner {
|
||||
@apply flex items-center gap-2;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -12,22 +12,42 @@ const tabs = [
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
class="inline-flex gap-1 rounded-lg bg-neutral-100 p-1 dark:bg-neutral-800"
|
||||
>
|
||||
<div class="appearance-tabs">
|
||||
<button
|
||||
v-for="{ value, Icon, label } in tabs"
|
||||
:key="value"
|
||||
@click="updateAppearance(value)"
|
||||
:class="[
|
||||
'flex items-center rounded-md px-3.5 py-1.5 transition-colors',
|
||||
appearance === value
|
||||
? 'bg-white shadow-xs dark:bg-neutral-700 dark:text-neutral-100'
|
||||
: 'text-neutral-500 hover:bg-neutral-200/60 hover:text-black dark:text-neutral-400 dark:hover:bg-neutral-700/60',
|
||||
'appearance-tabs__tab',
|
||||
{ 'appearance-tabs__tab--active': appearance === value },
|
||||
]"
|
||||
>
|
||||
<component :is="Icon" class="-ml-1 h-4 w-4" />
|
||||
<span class="ml-1.5 text-sm">{{ label }}</span>
|
||||
<component :is="Icon" class="appearance-tabs__icon" />
|
||||
<span class="appearance-tabs__label">{{ label }}</span>
|
||||
</button>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
@reference "../../css/app.css";
|
||||
|
||||
.appearance-tabs {
|
||||
@apply inline-flex gap-1 rounded-lg bg-neutral-100 p-1 dark:bg-neutral-800;
|
||||
}
|
||||
|
||||
.appearance-tabs__tab {
|
||||
@apply flex items-center rounded-md px-3.5 py-1.5 text-neutral-500 transition-colors hover:bg-neutral-200/60 hover:text-black dark:text-neutral-400 dark:hover:bg-neutral-700/60;
|
||||
}
|
||||
|
||||
.appearance-tabs__tab--active {
|
||||
@apply bg-white shadow-xs hover:bg-white dark:bg-neutral-700 dark:text-neutral-100 dark:hover:bg-neutral-700;
|
||||
}
|
||||
|
||||
.appearance-tabs__icon {
|
||||
@apply -ml-1 h-4 w-4;
|
||||
}
|
||||
|
||||
.appearance-tabs__label {
|
||||
@apply ml-1.5 text-sm;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,59 +1,377 @@
|
||||
<script setup>
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue';
|
||||
import { useForm } from '@inertiajs/vue3';
|
||||
import { useEcho, echoIsConfigured, configureEcho } from '@laravel/echo-vue';
|
||||
import { route } from 'ziggy-js';
|
||||
import { onMounted } from 'vue';
|
||||
import { useEcho } from '@laravel/echo-vue';
|
||||
import { Paperclip } from '@lucide/vue';
|
||||
|
||||
const props = defineProps({
|
||||
chat: Object,
|
||||
});
|
||||
const props = defineProps<{
|
||||
chat: {
|
||||
id: number;
|
||||
messages: Array<{
|
||||
id: number;
|
||||
user: { name: string };
|
||||
content: string;
|
||||
created_at: string;
|
||||
media?: Array<{
|
||||
id: number;
|
||||
url: string;
|
||||
file_name: string;
|
||||
mime_type: string;
|
||||
}>;
|
||||
}>;
|
||||
};
|
||||
}>();
|
||||
|
||||
if (!echoIsConfigured()) {
|
||||
configureEcho({
|
||||
broadcaster: 'reverb',
|
||||
key: import.meta.env.VITE_REVERB_APP_KEY || 'mock-key',
|
||||
wsHost: import.meta.env.VITE_REVERB_HOST || 'localhost',
|
||||
wsPort: import.meta.env.VITE_REVERB_PORT
|
||||
? Number(import.meta.env.VITE_REVERB_PORT)
|
||||
: 8080,
|
||||
wssPort: import.meta.env.VITE_REVERB_PORT
|
||||
? Number(import.meta.env.VITE_REVERB_PORT)
|
||||
: 8080,
|
||||
forceTLS: false,
|
||||
enabledTransports: ['ws', 'wss'],
|
||||
});
|
||||
}
|
||||
|
||||
const fileInput = ref<HTMLInputElement | null>(null);
|
||||
|
||||
const form = useForm({
|
||||
content: '',
|
||||
media: [] as File[],
|
||||
});
|
||||
|
||||
const echo = useEcho();
|
||||
|
||||
onMounted(() => {
|
||||
echo.private(`chats.${props.chat.id}`)
|
||||
.listen('MessageSent', (e) => {
|
||||
props.chat.messages.push(e.message);
|
||||
});
|
||||
useEcho(`chats.${props.chat.id}`, 'MessageSent', (e: any) => {
|
||||
props.chat.messages.push(e.message);
|
||||
});
|
||||
|
||||
function handleFileChange(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 removeFile(index: number) {
|
||||
form.media.splice(index, 1);
|
||||
}
|
||||
|
||||
function submit() {
|
||||
form.post(route('chats.messages.store', props.chat.id), {
|
||||
onSuccess: () => form.reset(),
|
||||
onSuccess: () => {
|
||||
form.reset();
|
||||
if (fileInput.value) {
|
||||
fileInput.value.value = '';
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
// Lightbox Modal state
|
||||
const activeLightboxUrl = ref<string | null>(null);
|
||||
const activeLightboxType = ref<'image' | 'video' | null>(null);
|
||||
|
||||
function openLightbox(url: string, mimeType: string) {
|
||||
activeLightboxUrl.value = url;
|
||||
activeLightboxType.value = mimeType.startsWith('image/')
|
||||
? 'image'
|
||||
: 'video';
|
||||
}
|
||||
|
||||
function closeLightbox() {
|
||||
activeLightboxUrl.value = null;
|
||||
activeLightboxType.value = null;
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="mt-8">
|
||||
<h4 class="text-lg font-medium text-gray-900 dark:text-gray-100">Chat</h4>
|
||||
<div class="mt-4 space-y-4">
|
||||
<div v-for="message in chat.messages" :key="message.id" class="p-4 bg-white dark:bg-gray-800 overflow-hidden shadow-sm sm:rounded-lg">
|
||||
<div class="flex justify-between">
|
||||
<span class="font-semibold">{{ message.user.name }}</span>
|
||||
<span class="text-xs text-gray-500">{{ new Date(message.created_at).toLocaleString() }}</span>
|
||||
<div class="c-chat">
|
||||
<h4 class="c-chat__title">Chat</h4>
|
||||
<div class="c-chat__list">
|
||||
<div
|
||||
v-for="message in chat.messages"
|
||||
:key="message.id"
|
||||
class="c-chat__message"
|
||||
>
|
||||
<div class="c-chat__message-header">
|
||||
<span class="c-chat__message-author">{{
|
||||
message.user.name
|
||||
}}</span>
|
||||
<span class="c-chat__message-time">{{
|
||||
new Date(message.created_at).toLocaleString()
|
||||
}}</span>
|
||||
</div>
|
||||
<p class="c-chat__message-text">
|
||||
{{ message.content }}
|
||||
</p>
|
||||
|
||||
<!-- Attached Media Display -->
|
||||
<div
|
||||
v-if="message.media && message.media.length > 0"
|
||||
class="c-chat__message-media"
|
||||
>
|
||||
<div
|
||||
v-for="item in message.media"
|
||||
:key="item.id"
|
||||
class="c-chat__media-item"
|
||||
>
|
||||
<img
|
||||
v-if="item.mime_type.startsWith('image/')"
|
||||
:src="item.url"
|
||||
:alt="item.file_name"
|
||||
class="c-chat__image cursor-pointer transition-opacity hover:opacity-90"
|
||||
@click="openLightbox(item.url, item.mime_type)"
|
||||
/>
|
||||
<div
|
||||
v-else-if="item.mime_type.startsWith('video/')"
|
||||
class="relative cursor-pointer transition-opacity hover:opacity-90"
|
||||
@click="openLightbox(item.url, item.mime_type)"
|
||||
>
|
||||
<video
|
||||
:src="item.url"
|
||||
class="c-chat__video"
|
||||
></video>
|
||||
<div class="c-chat__play-overlay">▶</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<p class="mt-2 text-sm text-gray-600 dark:text-gray-400">{{ message.content }}</p>
|
||||
</div>
|
||||
<div v-if="chat.messages.length === 0" class="text-gray-500">
|
||||
<div v-if="chat.messages.length === 0" class="c-chat__empty">
|
||||
No messages yet.
|
||||
</div>
|
||||
</div>
|
||||
<form @submit.prevent="submit" class="mt-6 space-y-6">
|
||||
<div>
|
||||
<label for="content" class="block text-sm font-medium text-gray-700 dark:text-gray-300">Message</label>
|
||||
<textarea v-model="form.content" id="content" rows="3" class="mt-1 block w-full border-gray-300 dark:border-gray-700 dark:bg-gray-900 dark:text-gray-300 focus:border-indigo-500 dark:focus:border-indigo-600 focus:ring-indigo-500 dark:focus:ring-indigo-600 rounded-md shadow-sm"></textarea>
|
||||
<div v-if="form.errors.content" class="text-sm text-red-600">{{ form.errors.content }}</div>
|
||||
<form @submit.prevent="submit" class="c-chat__form">
|
||||
<div class="c-chat__form-group">
|
||||
<label for="content" class="c-chat__label">Message</label>
|
||||
<textarea
|
||||
v-model="form.content"
|
||||
id="content"
|
||||
rows="3"
|
||||
class="c-chat__textarea"
|
||||
placeholder="Type a message..."
|
||||
></textarea>
|
||||
<div v-if="form.errors.content" class="c-chat__error">
|
||||
{{ form.errors.content }}
|
||||
</div>
|
||||
|
||||
<!-- Attachment Button & Hidden Input -->
|
||||
<div class="c-chat__attachment-container">
|
||||
<button
|
||||
type="button"
|
||||
@click="fileInput?.click()"
|
||||
class="c-chat__attach-btn"
|
||||
>
|
||||
<Paperclip class="c-chat__attach-icon" />
|
||||
Attach Photos/Videos
|
||||
</button>
|
||||
<input
|
||||
ref="fileInput"
|
||||
type="file"
|
||||
multiple
|
||||
accept="image/*,video/*"
|
||||
class="hidden"
|
||||
@change="handleFileChange"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<!-- Previews List -->
|
||||
<div v-if="form.media.length > 0" class="c-chat__preview-list">
|
||||
<div
|
||||
v-for="(file, index) in form.media"
|
||||
:key="index"
|
||||
class="c-chat__preview-item"
|
||||
>
|
||||
<span class="c-chat__preview-name">{{
|
||||
file.name
|
||||
}}</span>
|
||||
<button
|
||||
type="button"
|
||||
@click="removeFile(index)"
|
||||
class="c-chat__preview-remove"
|
||||
>
|
||||
✕
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex items-center gap-4">
|
||||
<button type="submit" :disabled="form.processing" class="inline-flex items-center px-4 py-2 bg-gray-800 dark:bg-gray-200 border border-transparent rounded-md font-semibold text-xs text-white dark:text-gray-800 uppercase tracking-widest hover:bg-gray-700 dark:hover:bg-white focus:bg-gray-700 dark:focus:bg-white active:bg-gray-900 dark:active:bg-gray-300 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 dark:focus:ring-offset-gray-800 transition ease-in-out duration-150">
|
||||
<div class="c-chat__submit-box">
|
||||
<button
|
||||
type="submit"
|
||||
:disabled="form.processing"
|
||||
class="c-chat__button"
|
||||
>
|
||||
Send
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<!-- Gorgeous Dark Lightbox Modal -->
|
||||
<div
|
||||
v-if="activeLightboxUrl"
|
||||
class="c-chat__lightbox"
|
||||
@click="closeLightbox"
|
||||
>
|
||||
<button @click="closeLightbox" class="c-chat__lightbox-close">
|
||||
✕
|
||||
</button>
|
||||
<div class="c-chat__lightbox-content" @click.stop>
|
||||
<img
|
||||
v-if="activeLightboxType === 'image'"
|
||||
:src="activeLightboxUrl"
|
||||
class="c-chat__lightbox-image"
|
||||
/>
|
||||
<video
|
||||
v-else-if="activeLightboxType === 'video'"
|
||||
:src="activeLightboxUrl"
|
||||
controls
|
||||
autoplay
|
||||
class="c-chat__lightbox-video"
|
||||
></video>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
@reference "../../css/app.css";
|
||||
|
||||
.c-chat {
|
||||
@apply mt-8;
|
||||
}
|
||||
|
||||
.c-chat__title {
|
||||
@apply text-lg font-medium text-gray-900 dark:text-gray-100;
|
||||
}
|
||||
|
||||
.c-chat__list {
|
||||
@apply mt-4 space-y-4;
|
||||
}
|
||||
|
||||
.c-chat__message {
|
||||
@apply overflow-hidden bg-white p-4 shadow-sm sm:rounded-lg dark:bg-gray-800;
|
||||
}
|
||||
|
||||
.c-chat__message-header {
|
||||
@apply flex justify-between;
|
||||
}
|
||||
|
||||
.c-chat__message-author {
|
||||
@apply font-semibold;
|
||||
}
|
||||
|
||||
.c-chat__message-time {
|
||||
@apply text-xs text-gray-500;
|
||||
}
|
||||
|
||||
.c-chat__message-text {
|
||||
@apply mt-2 text-sm text-gray-600 dark:text-gray-400;
|
||||
}
|
||||
|
||||
.c-chat__message-media {
|
||||
@apply mt-3 flex flex-wrap gap-2;
|
||||
}
|
||||
|
||||
.c-chat__media-item {
|
||||
@apply relative max-w-[240px] overflow-hidden rounded-md border border-neutral-200 bg-black dark:border-neutral-700;
|
||||
}
|
||||
|
||||
.c-chat__image {
|
||||
@apply h-auto max-h-[180px] w-full object-cover;
|
||||
}
|
||||
|
||||
.c-chat__video {
|
||||
@apply h-auto max-h-[180px] w-full;
|
||||
}
|
||||
|
||||
.c-chat__play-overlay {
|
||||
@apply absolute inset-0 flex items-center justify-center bg-black/40 text-2xl font-bold text-white;
|
||||
}
|
||||
|
||||
.c-chat__empty {
|
||||
@apply text-gray-500;
|
||||
}
|
||||
|
||||
.c-chat__form {
|
||||
@apply mt-6 space-y-6;
|
||||
}
|
||||
|
||||
.c-chat__form-group {
|
||||
@apply space-y-2;
|
||||
}
|
||||
|
||||
.c-chat__label {
|
||||
@apply block text-sm font-medium text-gray-700 dark:text-gray-300;
|
||||
}
|
||||
|
||||
.c-chat__textarea {
|
||||
@apply 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;
|
||||
}
|
||||
|
||||
.c-chat__error {
|
||||
@apply text-sm text-red-600;
|
||||
}
|
||||
|
||||
.c-chat__attachment-container {
|
||||
@apply mt-2 flex items-center;
|
||||
}
|
||||
|
||||
.c-chat__attach-btn {
|
||||
@apply inline-flex cursor-pointer items-center gap-1.5 text-xs text-neutral-500 transition-colors hover:text-foreground;
|
||||
}
|
||||
|
||||
.c-chat__attach-icon {
|
||||
@apply size-3.5;
|
||||
}
|
||||
|
||||
.c-chat__preview-list {
|
||||
@apply mt-2 flex flex-wrap gap-2;
|
||||
}
|
||||
|
||||
.c-chat__preview-item {
|
||||
@apply 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;
|
||||
}
|
||||
|
||||
.c-chat__preview-name {
|
||||
@apply max-w-[150px] truncate;
|
||||
}
|
||||
|
||||
.c-chat__preview-remove {
|
||||
@apply absolute top-1.5 right-1.5 cursor-pointer text-[10px] text-neutral-400 hover:text-red-500;
|
||||
}
|
||||
|
||||
.c-chat__submit-box {
|
||||
@apply flex items-center gap-4;
|
||||
}
|
||||
|
||||
.c-chat__button {
|
||||
@apply 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;
|
||||
}
|
||||
|
||||
/* Lightbox Styling */
|
||||
.c-chat__lightbox {
|
||||
@apply fixed inset-0 z-50 flex items-center justify-center bg-black/95 p-4;
|
||||
}
|
||||
|
||||
.c-chat__lightbox-close {
|
||||
@apply absolute top-6 right-6 cursor-pointer text-3xl text-white transition-colors duration-200 hover:text-red-500;
|
||||
}
|
||||
|
||||
.c-chat__lightbox-content {
|
||||
@apply max-h-full max-w-full;
|
||||
}
|
||||
|
||||
.c-chat__lightbox-image {
|
||||
@apply max-h-[90vh] max-w-full rounded object-contain shadow-lg;
|
||||
}
|
||||
|
||||
.c-chat__lightbox-video {
|
||||
@apply max-h-[90vh] max-w-full rounded shadow-lg;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -11,18 +11,36 @@ withDefaults(defineProps<Props>(), {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<header :class="variant === 'small' ? '' : 'mb-8 space-y-0.5'">
|
||||
<h2
|
||||
:class="
|
||||
variant === 'small'
|
||||
? 'mb-0.5 text-base font-medium'
|
||||
: 'text-xl font-semibold tracking-tight'
|
||||
"
|
||||
>
|
||||
<header :class="['c-heading', { 'c-heading--small': variant === 'small' }]">
|
||||
<h2 class="c-heading__title">
|
||||
{{ title }}
|
||||
</h2>
|
||||
<p v-if="description" class="text-sm text-muted-foreground">
|
||||
<p v-if="description" class="c-heading__description">
|
||||
{{ description }}
|
||||
</p>
|
||||
</header>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
@reference "../../css/app.css";
|
||||
|
||||
.c-heading {
|
||||
@apply mb-8 space-y-0.5;
|
||||
}
|
||||
|
||||
.c-heading--small {
|
||||
@apply mb-0 space-y-0;
|
||||
}
|
||||
|
||||
.c-heading__title {
|
||||
@apply text-xl font-semibold tracking-tight;
|
||||
}
|
||||
|
||||
.c-heading--small .c-heading__title {
|
||||
@apply mb-0.5 text-base font-medium tracking-normal;
|
||||
}
|
||||
|
||||
.c-heading__description {
|
||||
@apply text-sm text-muted-foreground;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -5,9 +5,17 @@ defineProps<{
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div v-show="message">
|
||||
<p class="text-sm text-red-600 dark:text-red-500">
|
||||
<div v-show="message" class="c-input-error">
|
||||
<p class="c-input-error__message">
|
||||
{{ message }}
|
||||
</p>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
@reference "../../css/app.css";
|
||||
|
||||
.c-input-error__message {
|
||||
@apply text-sm text-red-600 dark:text-red-500;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -21,26 +21,42 @@ defineExpose({
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="relative">
|
||||
<div class="password-input">
|
||||
<Input
|
||||
ref="inputRef"
|
||||
:type="showPassword ? 'text' : 'password'"
|
||||
:class="cn('pr-10', props.class)"
|
||||
:class="cn('password-input__field', props.class)"
|
||||
v-bind="$attrs"
|
||||
/>
|
||||
<button
|
||||
type="button"
|
||||
@click="showPassword = !showPassword"
|
||||
:class="
|
||||
cn(
|
||||
'absolute inset-y-0 right-0 flex items-center rounded-r-md px-3 text-muted-foreground hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring focus-visible:outline-none',
|
||||
)
|
||||
"
|
||||
class="password-input__toggle"
|
||||
:aria-label="showPassword ? 'Hide password' : 'Show password'"
|
||||
:tabindex="-1"
|
||||
>
|
||||
<EyeOff v-if="showPassword" class="size-4" />
|
||||
<Eye v-else class="size-4" />
|
||||
<EyeOff v-if="showPassword" class="password-input__icon" />
|
||||
<Eye v-else class="password-input__icon" />
|
||||
</button>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
@reference "../../css/app.css";
|
||||
|
||||
.password-input {
|
||||
@apply relative;
|
||||
}
|
||||
|
||||
:deep(.password-input__field) {
|
||||
@apply pr-10;
|
||||
}
|
||||
|
||||
.password-input__toggle {
|
||||
@apply absolute inset-y-0 right-0 flex items-center rounded-r-md px-3 text-muted-foreground hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring focus-visible:outline-none;
|
||||
}
|
||||
|
||||
.password-input__icon {
|
||||
@apply size-4;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -18,8 +18,16 @@ defineProps<Props>();
|
||||
:tabindex="tabindex"
|
||||
:method="method"
|
||||
:as="as"
|
||||
class="text-foreground underline decoration-neutral-300 underline-offset-4 transition-colors duration-300 ease-out hover:decoration-current! dark:decoration-neutral-500"
|
||||
class="c-text-link"
|
||||
>
|
||||
<slot />
|
||||
</Link>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
@reference "../../css/app.css";
|
||||
|
||||
.c-text-link {
|
||||
@apply text-foreground underline decoration-neutral-300 underline-offset-4 transition-colors duration-300 ease-out hover:decoration-current! dark:decoration-neutral-500;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -22,17 +22,35 @@ const showAvatar = computed(
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Avatar class="h-8 w-8 overflow-hidden rounded-lg">
|
||||
<Avatar class="user-info__avatar">
|
||||
<AvatarImage v-if="showAvatar" :src="user.avatar!" :alt="user.name" />
|
||||
<AvatarFallback class="rounded-lg text-black dark:text-white">
|
||||
{{ getInitials(user.name) }}
|
||||
</AvatarFallback>
|
||||
</Avatar>
|
||||
|
||||
<div class="grid flex-1 text-left text-sm leading-tight">
|
||||
<span class="truncate font-medium">{{ user.name }}</span>
|
||||
<span v-if="showEmail" class="truncate text-xs text-muted-foreground">{{
|
||||
user.email
|
||||
}}</span>
|
||||
<div class="user-info__details">
|
||||
<span class="user-info__name">{{ user.name }}</span>
|
||||
<span v-if="showEmail" class="user-info__email">{{ user.email }}</span>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
@reference "../../css/app.css";
|
||||
|
||||
.user-info__avatar {
|
||||
@apply h-8 w-8 overflow-hidden rounded-lg;
|
||||
}
|
||||
|
||||
.user-info__details {
|
||||
@apply grid flex-1 text-left text-sm leading-tight;
|
||||
}
|
||||
|
||||
.user-info__name {
|
||||
@apply truncate font-medium;
|
||||
}
|
||||
|
||||
.user-info__email {
|
||||
@apply truncate text-xs text-muted-foreground;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -10,28 +10,19 @@ defineProps<{
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
class="flex min-h-svh flex-col items-center justify-center gap-6 bg-background p-6 md:p-10"
|
||||
>
|
||||
<div class="w-full max-w-sm">
|
||||
<div class="flex flex-col gap-8">
|
||||
<div class="flex flex-col items-center gap-4">
|
||||
<Link
|
||||
:href="home()"
|
||||
class="flex flex-col items-center gap-2 font-medium"
|
||||
>
|
||||
<div
|
||||
class="mb-1 flex h-9 w-9 items-center justify-center rounded-md"
|
||||
>
|
||||
<AppLogoIcon
|
||||
class="size-9 fill-current text-[var(--foreground)] dark:text-white"
|
||||
/>
|
||||
<div class="auth-layout">
|
||||
<div class="auth-layout__container">
|
||||
<div class="auth-layout__inner">
|
||||
<div class="auth-layout__header">
|
||||
<Link :href="home()" class="auth-layout__logo-link">
|
||||
<div class="auth-layout__logo-box">
|
||||
<AppLogoIcon class="auth-layout__logo" />
|
||||
</div>
|
||||
<span class="sr-only">{{ title }}</span>
|
||||
</Link>
|
||||
<div class="space-y-2 text-center">
|
||||
<h1 class="text-xl font-medium">{{ title }}</h1>
|
||||
<p class="text-center text-sm text-muted-foreground">
|
||||
<div class="auth-layout__title-box">
|
||||
<h1 class="auth-layout__title">{{ title }}</h1>
|
||||
<p class="auth-layout__description">
|
||||
{{ description }}
|
||||
</p>
|
||||
</div>
|
||||
@@ -41,3 +32,47 @@ defineProps<{
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
@reference "../../../css/app.css";
|
||||
|
||||
.auth-layout {
|
||||
@apply flex min-h-svh flex-col items-center justify-center gap-6 bg-background p-6 md:p-10;
|
||||
}
|
||||
|
||||
.auth-layout__container {
|
||||
@apply w-full max-w-sm;
|
||||
}
|
||||
|
||||
.auth-layout__inner {
|
||||
@apply flex flex-col gap-8;
|
||||
}
|
||||
|
||||
.auth-layout__header {
|
||||
@apply flex flex-col items-center gap-4;
|
||||
}
|
||||
|
||||
.auth-layout__logo-link {
|
||||
@apply flex flex-col items-center gap-2 font-medium;
|
||||
}
|
||||
|
||||
.auth-layout__logo-box {
|
||||
@apply mb-1 flex h-9 w-9 items-center justify-center rounded-md;
|
||||
}
|
||||
|
||||
.auth-layout__logo {
|
||||
@apply size-9 fill-current text-[var(--foreground)] dark:text-white;
|
||||
}
|
||||
|
||||
.auth-layout__title-box {
|
||||
@apply space-y-2 text-center;
|
||||
}
|
||||
|
||||
.auth-layout__title {
|
||||
@apply text-xl font-medium;
|
||||
}
|
||||
|
||||
.auth-layout__description {
|
||||
@apply text-center text-sm text-muted-foreground;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -26,33 +26,67 @@ function submit() {
|
||||
<template>
|
||||
<Head title="Create Dynamic" />
|
||||
|
||||
<div class="py-12">
|
||||
<div class="max-w-7xl mx-auto sm:px-6 lg:px-8">
|
||||
<div class="bg-white dark:bg-gray-800 overflow-hidden shadow-sm sm:rounded-lg">
|
||||
<div class="p-6 text-gray-900 dark:text-gray-100">
|
||||
<h3 class="text-lg font-medium">Create a New Dynamic</h3>
|
||||
<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">Create a New Dynamic</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 border-gray-300 dark:border-gray-700 dark:bg-gray-900 dark:text-gray-300 focus:border-indigo-500 dark:focus:border-indigo-600 focus:ring-indigo-500 dark:focus:ring-indigo-600 rounded-md shadow-sm" />
|
||||
<div v-if="form.errors.name" class="text-sm text-red-600">{{ form.errors.name }}</div>
|
||||
<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 border-gray-300 dark:border-gray-700 dark:bg-gray-900 dark:text-gray-300 focus:border-indigo-500 dark:focus:border-indigo-600 focus:ring-indigo-500 dark:focus:ring-indigo-600 rounded-md shadow-sm"></textarea>
|
||||
<div v-if="form.errors.rules" class="text-sm text-red-600">{{ form.errors.rules }}</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>
|
||||
|
||||
<div class="flex items-center gap-4">
|
||||
<button type="submit" :disabled="form.processing" class="inline-flex items-center px-4 py-2 bg-gray-800 dark:bg-gray-200 border border-transparent rounded-md font-semibold text-xs text-white dark:text-gray-800 uppercase tracking-widest hover:bg-gray-700 dark:hover:bg-white focus:bg-gray-700 dark:focus:bg-white active:bg-gray-900 dark:active:bg-gray-300 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 dark:focus:ring-offset-gray-800 transition ease-in-out duration-150">
|
||||
Create
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</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
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -17,30 +17,48 @@ const breadcrumbs = [
|
||||
<template>
|
||||
<Head title="Dynamics" />
|
||||
|
||||
<div class="py-12">
|
||||
<div class="max-w-7xl mx-auto sm:px-6 lg:px-8">
|
||||
<div class="bg-white dark:bg-gray-800 overflow-hidden shadow-sm sm:rounded-lg">
|
||||
<div class="p-6 text-gray-900 dark:text-gray-100">
|
||||
<div class="flex justify-between items-center mb-6">
|
||||
<h3 class="text-lg font-medium">Your Dynamics</h3>
|
||||
<Link :href="route('dynamics.create')" class="inline-flex items-center px-4 py-2 bg-gray-800 dark:bg-gray-200 border border-transparent rounded-md font-semibold text-xs text-white dark:text-gray-800 uppercase tracking-widest hover:bg-gray-700 dark:hover:bg-white focus:bg-gray-700 dark:focus:bg-white active:bg-gray-900 dark:active:bg-gray-300 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 dark:focus:ring-offset-gray-800 transition ease-in-out duration-150">
|
||||
Create Dynamic
|
||||
</Link>
|
||||
</div>
|
||||
<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">
|
||||
<div class="mb-6 flex items-center justify-between">
|
||||
<h3 class="text-lg font-medium">Your Dynamics</h3>
|
||||
<Link
|
||||
:href="route('dynamics.create')"
|
||||
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 Dynamic
|
||||
</Link>
|
||||
</div>
|
||||
|
||||
<div v-if="dynamics.length > 0" class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
|
||||
<div v-for="dynamic in dynamics" :key="dynamic.id" class="p-6 bg-white dark:bg-gray-700 border-b border-gray-200 dark:border-gray-600">
|
||||
<Link :href="route('dynamics.show', dynamic.id)">
|
||||
<h4 class="text-lg font-semibold">{{ dynamic.name }}</h4>
|
||||
</Link>
|
||||
<p class="mt-2 text-sm text-gray-600 dark:text-gray-400">{{ dynamic.rules }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else>
|
||||
<p>You don't have any dynamics yet.</p>
|
||||
<div
|
||||
v-if="dynamics.length > 0"
|
||||
class="grid grid-cols-1 gap-6 md:grid-cols-2 lg:grid-cols-3"
|
||||
>
|
||||
<div
|
||||
v-for="dynamic in dynamics"
|
||||
:key="dynamic.id"
|
||||
class="border-b border-gray-200 bg-white p-6 dark:border-gray-600 dark:bg-gray-700"
|
||||
>
|
||||
<Link :href="route('dynamics.show', dynamic.id)">
|
||||
<h4 class="text-lg font-semibold">
|
||||
{{ dynamic.name }}
|
||||
</h4>
|
||||
</Link>
|
||||
<p
|
||||
class="mt-2 text-sm text-gray-600 dark:text-gray-400"
|
||||
>
|
||||
{{ dynamic.rules }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else>
|
||||
<p>You don't have any dynamics yet.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -1,11 +1,23 @@
|
||||
<script setup>
|
||||
<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: Object,
|
||||
});
|
||||
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 = [
|
||||
{
|
||||
@@ -21,8 +33,22 @@ const breadcrumbs = [
|
||||
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(),
|
||||
@@ -33,70 +59,207 @@ function submit() {
|
||||
<template>
|
||||
<Head :title="dynamic.name" />
|
||||
|
||||
<div class="py-12">
|
||||
<div class="max-w-7xl mx-auto sm:px-6 lg:px-8">
|
||||
<div class="bg-white dark:bg-gray-800 overflow-hidden shadow-sm sm:rounded-lg">
|
||||
<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">{{ dynamic.name }}</h3>
|
||||
<p class="mt-2 text-sm text-gray-600 dark:text-gray-400">{{ dynamic.rules }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<h3 class="text-lg font-medium">Create a New Ledger</h3>
|
||||
|
||||
<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 md:grid-cols-2 lg:grid-cols-3 gap-6">
|
||||
<li v-for="participant in dynamic.participants" :key="participant.id" class="p-4 bg-white dark:bg-gray-800 overflow-hidden shadow-sm sm:rounded-lg">
|
||||
{{ participant.name }}
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="mt-8">
|
||||
<div class="flex justify-between items-center mb-6">
|
||||
<h4 class="text-lg font-medium text-gray-900 dark:text-gray-100">Ledgers</h4>
|
||||
</div>
|
||||
<ul class="mt-4 grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
|
||||
<li v-for="ledger in dynamic.ledgers" :key="ledger.id" class="p-6 bg-white dark:bg-gray-700 border-b border-gray-200 dark:border-gray-600">
|
||||
<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>
|
||||
</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="bg-white dark:bg-gray-800 overflow-hidden shadow-sm sm:rounded-lg">
|
||||
<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 border-gray-300 dark:border-gray-700 dark:bg-gray-900 dark:text-gray-300 focus:border-indigo-500 dark:focus:border-indigo-600 focus:ring-indigo-500 dark:focus:ring-indigo-600 rounded-md shadow-sm" />
|
||||
<div v-if="form.errors.name" class="text-sm text-red-600">{{ form.errors.name }}</div>
|
||||
<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 border-gray-300 dark:border-gray-700 dark:bg-gray-900 dark:text-gray-300 focus:border-indigo-500 dark:focus:border-indigo-600 focus:ring-indigo-500 dark:focus:ring-indigo-600 rounded-md shadow-sm"></textarea>
|
||||
<div v-if="form.errors.rules" class="text-sm text-red-600">{{ form.errors.rules }}</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>
|
||||
|
||||
<div class="flex items-center gap-4">
|
||||
<button type="submit" :disabled="form.processing" class="inline-flex items-center px-4 py-2 bg-gray-800 dark:bg-gray-200 border border-transparent rounded-md font-semibold text-xs text-white dark:text-gray-800 uppercase tracking-widest hover:bg-gray-700 dark:hover:bg-white focus:bg-gray-700 dark:focus:bg-white active:bg-gray-900 dark:active:bg-gray-300 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 dark:focus:ring-offset-gray-800 transition ease-in-out duration-150">
|
||||
Create Ledger
|
||||
</button>
|
||||
<!-- 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>
|
||||
</form>
|
||||
</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>
|
||||
|
||||
@@ -1,12 +1,41 @@
|
||||
<script setup>
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue';
|
||||
import Chat from '@/components/Chat.vue';
|
||||
import { Head, useForm } from '@inertiajs/vue3';
|
||||
import { route } from 'ziggy-js';
|
||||
import { useEcho } from '@laravel/echo-vue';
|
||||
|
||||
const props = defineProps({
|
||||
dynamic: Object,
|
||||
ledger: Object,
|
||||
});
|
||||
const props = defineProps<{
|
||||
dynamic: {
|
||||
id: number;
|
||||
name: string;
|
||||
chat: { id: number };
|
||||
participants?: Array<{
|
||||
id: number;
|
||||
name: string;
|
||||
pivot?: { role: string };
|
||||
}>;
|
||||
};
|
||||
ledger: {
|
||||
id: number;
|
||||
name: string;
|
||||
score: number;
|
||||
rules: string;
|
||||
media?: Array<{ id: number; url: string; mime_type: string }>;
|
||||
mutations: Array<{
|
||||
id: number;
|
||||
user_id: number;
|
||||
user: { name: string };
|
||||
amount: number;
|
||||
description: string;
|
||||
status: string;
|
||||
created_at: string;
|
||||
chat: any;
|
||||
media?: Array<{ id: number; url: string; mime_type: string }>;
|
||||
}>;
|
||||
};
|
||||
isOwner: boolean;
|
||||
}>();
|
||||
|
||||
const breadcrumbs = [
|
||||
{
|
||||
@@ -19,78 +48,460 @@ const breadcrumbs = [
|
||||
},
|
||||
{
|
||||
name: props.ledger.name,
|
||||
href: route('dynamics.ledgers.show', { dynamic: props.dynamic.id, ledger: props.ledger.id }),
|
||||
href: route('dynamics.ledgers.show', {
|
||||
dynamic: props.dynamic.id,
|
||||
ledger: props.ledger.id,
|
||||
}),
|
||||
},
|
||||
];
|
||||
|
||||
const form = useForm({
|
||||
amount: 0,
|
||||
description: '',
|
||||
media: [] as File[],
|
||||
});
|
||||
|
||||
function handleMutationFileChange(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 removeMutationFile(index: number) {
|
||||
form.media.splice(index, 1);
|
||||
}
|
||||
|
||||
function submit() {
|
||||
form.post(route('dynamics.ledgers.mutations.store', { dynamic: props.dynamic.id, ledger: props.ledger.id }), {
|
||||
onSuccess: () => form.reset(),
|
||||
});
|
||||
form.post(
|
||||
route('dynamics.ledgers.mutations.store', {
|
||||
dynamic: props.dynamic.id,
|
||||
ledger: props.ledger.id,
|
||||
}),
|
||||
{
|
||||
onSuccess: () => form.reset(),
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
// Lightbox Modal state
|
||||
const activeLightboxUrl = ref<string | null>(null);
|
||||
const activeLightboxType = ref<'image' | 'video' | null>(null);
|
||||
|
||||
function openLightbox(url: string, mimeType: string) {
|
||||
activeLightboxUrl.value = url;
|
||||
activeLightboxType.value = mimeType.startsWith('image/')
|
||||
? 'image'
|
||||
: 'video';
|
||||
}
|
||||
|
||||
function closeLightbox() {
|
||||
activeLightboxUrl.value = null;
|
||||
activeLightboxType.value = null;
|
||||
}
|
||||
|
||||
// Toast System
|
||||
const toasts = ref<Array<{ id: number; message: string }>>([]);
|
||||
let toastCount = 0;
|
||||
|
||||
function showToast(message: string) {
|
||||
const id = toastCount++;
|
||||
toasts.value.push({ id, message });
|
||||
setTimeout(() => {
|
||||
toasts.value = toasts.value.filter((t) => t.id !== id);
|
||||
}, 6000);
|
||||
}
|
||||
|
||||
// Real-time Mutation Event Listeners
|
||||
useEcho(`chats.${props.dynamic.chat.id}`, 'MutationCreated', (e: any) => {
|
||||
if (e.mutation.ledger_id === props.ledger.id) {
|
||||
// Prevent duplicate mutations
|
||||
if (!props.ledger.mutations.some((m) => m.id === e.mutation.id)) {
|
||||
props.ledger.mutations.unshift(e.mutation);
|
||||
}
|
||||
// Auto-update score if already approved (e.g. submitted by owner)
|
||||
if (e.mutation.status === 'approved') {
|
||||
props.ledger.score += e.mutation.amount;
|
||||
}
|
||||
showToast(
|
||||
`New ${e.mutation.status} ledger entry added by ${e.mutation.user.name}: "${e.mutation.description}"`,
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
useEcho(`chats.${props.dynamic.chat.id}`, 'MutationUpdated', (e: any) => {
|
||||
if (e.mutation.ledger_id === props.ledger.id) {
|
||||
const index = props.ledger.mutations.findIndex(
|
||||
(m) => m.id === e.mutation.id,
|
||||
);
|
||||
if (index !== -1) {
|
||||
const oldStatus = props.ledger.mutations[index].status;
|
||||
const newStatus = e.mutation.status;
|
||||
|
||||
// Update status in-place
|
||||
props.ledger.mutations[index].status = newStatus;
|
||||
|
||||
// Transition ledger score based on status update
|
||||
if (oldStatus !== 'approved' && newStatus === 'approved') {
|
||||
props.ledger.score += e.mutation.amount;
|
||||
} else if (oldStatus === 'approved' && newStatus !== 'approved') {
|
||||
props.ledger.score -= e.mutation.amount;
|
||||
}
|
||||
|
||||
showToast(
|
||||
`Chore entry "${e.mutation.description}" status updated to ${newStatus.toUpperCase()}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
function updateStatus(mutationId: number, status: 'approved' | 'rejected') {
|
||||
useForm({ status }).put(
|
||||
route('dynamics.ledgers.mutations.update', {
|
||||
dynamic: props.dynamic.id,
|
||||
ledger: props.ledger.id,
|
||||
mutation: mutationId,
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
// Check if user is an owner in the dynamic
|
||||
function isOwnerUser(userId: number): boolean {
|
||||
const participant = props.dynamic.participants?.find(
|
||||
(p) => p.id === userId,
|
||||
);
|
||||
return participant?.pivot?.role === 'owner';
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Head :title="ledger.name" />
|
||||
|
||||
<div class="py-12">
|
||||
<div class="max-w-7xl mx-auto sm:px-6 lg:px-8">
|
||||
<div class="bg-white dark:bg-gray-800 overflow-hidden shadow-sm sm:rounded-lg">
|
||||
<div class="p-6 text-gray-900 dark:text-gray-100">
|
||||
<h3 class="text-lg font-medium">{{ ledger.name }}</h3>
|
||||
<p class="mt-2 text-sm text-gray-600 dark:text-gray-400">Score: {{ ledger.score }}</p>
|
||||
<p class="mt-2 text-sm text-gray-600 dark:text-gray-400">{{ ledger.rules }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Floating Toast Notifications -->
|
||||
<div
|
||||
class="pointer-events-none fixed top-6 right-6 z-50 flex max-w-sm flex-col gap-3"
|
||||
>
|
||||
<div
|
||||
v-for="toast in toasts"
|
||||
:key="toast.id"
|
||||
class="pointer-events-auto flex items-center justify-between gap-4 rounded-lg border border-neutral-700/50 bg-neutral-900 px-4 py-3 text-sm text-white shadow-xl"
|
||||
>
|
||||
<span>{{ toast.message }}</span>
|
||||
<button
|
||||
@click="toasts = toasts.filter((t) => t.id !== toast.id)"
|
||||
class="cursor-pointer text-neutral-400 hover:text-white"
|
||||
>
|
||||
✕
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mt-8">
|
||||
<h4 class="text-lg font-medium text-gray-900 dark:text-gray-100">Add Mutation</h4>
|
||||
<form @submit.prevent="submit" class="mt-6 space-y-6 bg-white dark:bg-gray-800 overflow-hidden shadow-sm sm:rounded-lg p-6">
|
||||
<div>
|
||||
<label for="amount" class="block text-sm font-medium text-gray-700 dark:text-gray-300">Amount</label>
|
||||
<input v-model="form.amount" id="amount" type="number" class="mt-1 block w-full border-gray-300 dark:border-gray-700 dark:bg-gray-900 dark:text-gray-300 focus:border-indigo-500 dark:focus:border-indigo-600 focus:ring-indigo-500 dark:focus:ring-indigo-600 rounded-md shadow-sm" />
|
||||
<div v-if="form.errors.amount" class="text-sm text-red-600">{{ form.errors.amount }}</div>
|
||||
</div>
|
||||
<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">{{ ledger.name }}</h3>
|
||||
<p class="mt-2 text-sm text-gray-600 dark:text-gray-400">
|
||||
Score: {{ ledger.score }}
|
||||
</p>
|
||||
<p class="mt-2 text-sm text-gray-600 dark:text-gray-400">
|
||||
{{ ledger.rules }}
|
||||
</p>
|
||||
|
||||
<div>
|
||||
<label for="description" class="block text-sm font-medium text-gray-700 dark:text-gray-300">Description</label>
|
||||
<textarea v-model="form.description" id="description" rows="4" class="mt-1 block w-full border-gray-300 dark:border-gray-700 dark:bg-gray-900 dark:text-gray-300 focus:border-indigo-500 dark:focus:border-indigo-600 focus:ring-indigo-500 dark:focus:ring-indigo-600 rounded-md shadow-sm"></textarea>
|
||||
<div v-if="form.errors.description" class="text-sm text-red-600">{{ form.errors.description }}</div>
|
||||
</div>
|
||||
|
||||
<div class="flex items-center gap-4">
|
||||
<button type="submit" :disabled="form.processing" class="inline-flex items-center px-4 py-2 bg-gray-800 dark:bg-gray-200 border border-transparent rounded-md font-semibold text-xs text-white dark:text-gray-800 uppercase tracking-widest hover:bg-gray-700 dark:hover:bg-white focus:bg-gray-700 dark:focus:bg-white active:bg-gray-900 dark:active:bg-gray-300 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 dark:focus:ring-offset-gray-800 transition ease-in-out duration-150">
|
||||
Add Mutation
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div class="mt-8">
|
||||
<h4 class="text-lg font-medium text-gray-900 dark:text-gray-100">Mutations</h4>
|
||||
<ul class="mt-4 space-y-4">
|
||||
<li v-for="mutation in ledger.mutations" :key="mutation.id" class="p-4 bg-white dark:bg-gray-800 overflow-hidden shadow-sm sm:rounded-lg">
|
||||
<div class="flex justify-between">
|
||||
<span class="font-semibold">{{ mutation.user.name }}</span>
|
||||
<span :class="{
|
||||
'text-green-500': mutation.amount > 0,
|
||||
'text-red-500': mutation.amount < 0,
|
||||
}">{{ mutation.amount > 0 ? '+' : '' }}{{ mutation.amount }}</span>
|
||||
<!-- Ledger Descriptive Media -->
|
||||
<div
|
||||
v-if="ledger.media && ledger.media.length > 0"
|
||||
class="mt-4 flex flex-wrap gap-3"
|
||||
>
|
||||
<div
|
||||
v-for="item in ledger.media"
|
||||
:key="item.id"
|
||||
class="max-w-[320px] overflow-hidden rounded-md border border-neutral-200 bg-black dark:border-neutral-700"
|
||||
>
|
||||
<img
|
||||
v-if="item.mime_type.startsWith('image/')"
|
||||
:src="item.url"
|
||||
class="h-auto max-h-[200px] w-full cursor-pointer object-cover transition-opacity hover:opacity-90"
|
||||
@click="openLightbox(item.url, item.mime_type)"
|
||||
/>
|
||||
<div
|
||||
v-else-if="item.mime_type.startsWith('video/')"
|
||||
class="relative cursor-pointer transition-opacity hover:opacity-90"
|
||||
@click="openLightbox(item.url, item.mime_type)"
|
||||
>
|
||||
<video
|
||||
:src="item.url"
|
||||
class="h-auto max-h-[200px] w-full"
|
||||
></video>
|
||||
<div
|
||||
class="absolute inset-0 flex items-center justify-center bg-black/40 text-2xl font-bold text-white"
|
||||
>
|
||||
▶
|
||||
</div>
|
||||
</div>
|
||||
<p class="mt-2 text-sm text-gray-600 dark:text-gray-400">{{ mutation.description }}</p>
|
||||
<div class="mt-2 text-xs text-gray-500">{{ new Date(mutation.created_at).toLocaleString() }}</div>
|
||||
<Chat :chat="mutation.chat" />
|
||||
</li>
|
||||
</ul>
|
||||
<div v-if="ledger.mutations.length === 0" class="mt-4 text-gray-500">
|
||||
No mutations found for this ledger.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mt-8">
|
||||
<h4
|
||||
class="text-lg font-medium text-gray-900 dark:text-gray-100"
|
||||
>
|
||||
Add Mutation
|
||||
</h4>
|
||||
<form
|
||||
@submit.prevent="submit"
|
||||
class="mt-6 space-y-6 overflow-hidden bg-white p-6 shadow-sm sm:rounded-lg dark:bg-gray-800"
|
||||
>
|
||||
<div>
|
||||
<label
|
||||
for="amount"
|
||||
class="block text-sm font-medium text-gray-700 dark:text-gray-300"
|
||||
>Amount</label
|
||||
>
|
||||
<input
|
||||
v-model="form.amount"
|
||||
id="amount"
|
||||
type="number"
|
||||
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.amount"
|
||||
class="text-sm text-red-600"
|
||||
>
|
||||
{{ form.errors.amount }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label
|
||||
for="description"
|
||||
class="block text-sm font-medium text-gray-700 dark:text-gray-300"
|
||||
>Description</label
|
||||
>
|
||||
<textarea
|
||||
v-model="form.description"
|
||||
id="description"
|
||||
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.description"
|
||||
class="text-sm text-red-600"
|
||||
>
|
||||
{{ form.errors.description }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Media Uploads for Mutations -->
|
||||
<div>
|
||||
<label
|
||||
class="block text-sm font-medium text-gray-700 dark:text-gray-300"
|
||||
>Attach Proof Media (Photos/Videos)</label
|
||||
>
|
||||
<input
|
||||
type="file"
|
||||
multiple
|
||||
accept="image/*,video/*"
|
||||
@change="handleMutationFileChange"
|
||||
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="removeMutationFile(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"
|
||||
>
|
||||
Add Mutation
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div class="mt-8">
|
||||
<h4
|
||||
class="text-lg font-medium text-gray-900 dark:text-gray-100"
|
||||
>
|
||||
Mutations
|
||||
</h4>
|
||||
<ul class="mt-4 space-y-4">
|
||||
<li
|
||||
v-for="mutation in ledger.mutations"
|
||||
:key="mutation.id"
|
||||
class="overflow-hidden bg-white p-4 shadow-sm sm:rounded-lg dark:bg-gray-800"
|
||||
>
|
||||
<div class="flex items-start justify-between">
|
||||
<div>
|
||||
<span class="font-semibold">{{
|
||||
mutation.user.name
|
||||
}}</span>
|
||||
<div class="mt-1 flex items-center gap-2">
|
||||
<span
|
||||
:class="{
|
||||
'text-green-500':
|
||||
mutation.amount > 0,
|
||||
'text-red-500': mutation.amount < 0,
|
||||
}"
|
||||
class="text-sm font-bold"
|
||||
>{{ mutation.amount > 0 ? '+' : ''
|
||||
}}{{ mutation.amount }}</span
|
||||
>
|
||||
<!-- Only show status badge if mutation was NOT auto-approved by an owner -->
|
||||
<span
|
||||
v-if="!isOwnerUser(mutation.user_id)"
|
||||
:class="{
|
||||
'bg-yellow-100 text-yellow-800 dark:bg-yellow-900/30 dark:text-yellow-400':
|
||||
mutation.status === 'pending',
|
||||
'bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-400':
|
||||
mutation.status === 'approved',
|
||||
'bg-red-100 text-red-800 dark:bg-red-900/30 dark:text-red-400':
|
||||
mutation.status === 'rejected',
|
||||
}"
|
||||
class="rounded px-1.5 py-0.5 text-[10px] font-medium tracking-wider uppercase"
|
||||
>
|
||||
{{ mutation.status }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="text-xs text-gray-500">
|
||||
{{
|
||||
new Date(
|
||||
mutation.created_at,
|
||||
).toLocaleString()
|
||||
}}
|
||||
</div>
|
||||
</div>
|
||||
<p
|
||||
class="mt-3 text-sm text-gray-600 dark:text-gray-400"
|
||||
>
|
||||
{{ mutation.description }}
|
||||
</p>
|
||||
|
||||
<!-- Attached Mutation Proof Media -->
|
||||
<div
|
||||
v-if="mutation.media && mutation.media.length > 0"
|
||||
class="mt-3 flex flex-wrap gap-2"
|
||||
>
|
||||
<div
|
||||
v-for="item in mutation.media"
|
||||
:key="item.id"
|
||||
class="max-w-[200px] overflow-hidden rounded-md border border-neutral-200 bg-black dark:border-neutral-700"
|
||||
>
|
||||
<img
|
||||
v-if="item.mime_type.startsWith('image/')"
|
||||
:src="item.url"
|
||||
class="h-auto max-h-[150px] w-full cursor-pointer object-cover transition-opacity hover:opacity-90"
|
||||
@click="
|
||||
openLightbox(item.url, item.mime_type)
|
||||
"
|
||||
/>
|
||||
<div
|
||||
v-else-if="
|
||||
item.mime_type.startsWith('video/')
|
||||
"
|
||||
class="relative cursor-pointer transition-opacity hover:opacity-90"
|
||||
@click="
|
||||
openLightbox(item.url, item.mime_type)
|
||||
"
|
||||
>
|
||||
<video
|
||||
:src="item.url"
|
||||
class="h-auto max-h-[150px] w-full"
|
||||
></video>
|
||||
<div
|
||||
class="absolute inset-0 flex items-center justify-center bg-black/40 text-2xl font-bold text-white"
|
||||
>
|
||||
▶
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Owner Approve/Reject Actions -->
|
||||
<div
|
||||
v-if="isOwner && mutation.status === 'pending'"
|
||||
class="mt-3 flex gap-2 border-t border-neutral-100 pt-3 dark:border-neutral-700"
|
||||
>
|
||||
<button
|
||||
@click="updateStatus(mutation.id, 'approved')"
|
||||
class="inline-flex cursor-pointer items-center rounded bg-green-600 px-3 py-1.5 text-xs font-semibold text-white hover:bg-green-500"
|
||||
>
|
||||
Approve
|
||||
</button>
|
||||
<button
|
||||
@click="updateStatus(mutation.id, 'rejected')"
|
||||
class="inline-flex cursor-pointer items-center rounded bg-red-600 px-3 py-1.5 text-xs font-semibold text-white hover:bg-red-500"
|
||||
>
|
||||
Reject
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<Chat :chat="mutation.chat" />
|
||||
</li>
|
||||
</ul>
|
||||
<div
|
||||
v-if="ledger.mutations.length === 0"
|
||||
class="mt-4 text-gray-500"
|
||||
>
|
||||
No mutations found for this ledger.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Lightbox Modal -->
|
||||
<div
|
||||
v-if="activeLightboxUrl"
|
||||
class="fixed inset-0 z-50 flex items-center justify-center bg-black/95 p-4"
|
||||
@click="closeLightbox"
|
||||
>
|
||||
<button
|
||||
@click="closeLightbox"
|
||||
class="absolute top-6 right-6 cursor-pointer text-3xl text-white transition-colors duration-200 hover:text-red-500"
|
||||
>
|
||||
✕
|
||||
</button>
|
||||
<div class="max-h-full max-w-full" @click.stop>
|
||||
<img
|
||||
v-if="activeLightboxType === 'image'"
|
||||
:src="activeLightboxUrl"
|
||||
class="max-h-[90vh] max-w-full rounded object-contain shadow-lg"
|
||||
/>
|
||||
<video
|
||||
v-else-if="activeLightboxType === 'video'"
|
||||
:src="activeLightboxUrl"
|
||||
controls
|
||||
autoplay
|
||||
class="max-h-[90vh] max-w-full rounded shadow-lg"
|
||||
></video>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
Reference in New Issue
Block a user