feat: improvements design
This commit is contained in:
parent
1196551a26
commit
56c257dc7d
15 changed files with 393 additions and 357 deletions
|
|
@ -20,8 +20,6 @@ class AuthenticatedSessionController extends Controller
|
|||
public function create(Request $request): Response
|
||||
{
|
||||
return Inertia::render('auth/Login', [
|
||||
'canResetPassword' => true,
|
||||
'canRegister' => true,
|
||||
'status' => session('status'),
|
||||
'email' => $request->query('email'),
|
||||
'redirect' => $request->query('redirect'),
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
class PostController extends Controller
|
||||
{
|
||||
public function index(Request $request): Response|RedirectResponse
|
||||
public function index(Request $request, ?string $status = null): Response|RedirectResponse
|
||||
{
|
||||
$workspace = $request->user()->currentWorkspace;
|
||||
|
||||
|
|
@ -28,16 +28,25 @@ public function index(Request $request): Response|RedirectResponse
|
|||
|
||||
$this->authorize('view', $workspace);
|
||||
|
||||
$posts = $workspace->posts()
|
||||
$query = $workspace->posts()
|
||||
->with(['postPlatforms' => function ($query) {
|
||||
$query->where('enabled', true)->with('socialAccount');
|
||||
}, 'user'])
|
||||
->latest('scheduled_at')
|
||||
->paginate(20);
|
||||
}, 'user']);
|
||||
|
||||
// Apply status filter if provided
|
||||
if ($status) {
|
||||
$query = match ($status) {
|
||||
'draft' => $query->draft(),
|
||||
'scheduled' => $query->scheduled(),
|
||||
'published' => $query->published(),
|
||||
default => $query,
|
||||
};
|
||||
}
|
||||
|
||||
return Inertia::render('posts/Index', [
|
||||
'workspace' => $workspace,
|
||||
'posts' => $posts,
|
||||
'posts' => Inertia::scroll(fn () => $query->latest('scheduled_at')->paginate(15)),
|
||||
'currentStatus' => $status,
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -37,13 +37,25 @@ public function share(Request $request): array
|
|||
{
|
||||
$user = $request->user();
|
||||
|
||||
$currentWorkspace = $user?->currentWorkspace;
|
||||
$currentRole = null;
|
||||
|
||||
if ($user && $currentWorkspace) {
|
||||
$currentRole = $user->workspaces()
|
||||
->where('workspaces.id', $currentWorkspace->id)
|
||||
->first()
|
||||
?->pivot
|
||||
?->role;
|
||||
}
|
||||
|
||||
return [
|
||||
...parent::share($request),
|
||||
'name' => config('app.name'),
|
||||
'auth' => [
|
||||
'user' => $user,
|
||||
'role' => $currentRole,
|
||||
],
|
||||
'currentWorkspace' => $user?->currentWorkspace,
|
||||
'currentWorkspace' => $currentWorkspace,
|
||||
'workspaces' => $user ? $user->workspaces()->select('workspaces.id', 'workspaces.name')->get() : [],
|
||||
'sidebarOpen' => ! $request->hasCookie('sidebar_state') || $request->cookie('sidebar_state') === 'true',
|
||||
'flash' => $request->session()->get('flash', []),
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -1,6 +1,8 @@
|
|||
<script setup lang="ts">
|
||||
import { Link, router, usePage } from '@inertiajs/vue3';
|
||||
import { Calendar, Check, ChevronsUpDown, Hash, LogOut, Plus, Settings, Share2, Tag } from 'lucide-vue-next';
|
||||
import { IconCalendar, IconCheck, IconSelector, IconFileText, IconHash, IconLogout, IconPlus, IconSettings, IconShare2, IconPencil, IconFileCheck, IconTag, IconUser, IconClock, IconMessageCircle, IconGift, IconBell, IconBook, IconSun, IconMoon, IconDeviceDesktop } from '@tabler/icons-vue';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { create as createPost } from '@/actions/App/Http/Controllers/PostController';
|
||||
import { computed } from 'vue';
|
||||
|
||||
import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar';
|
||||
|
|
@ -10,13 +12,18 @@ import {
|
|||
DropdownMenuGroup,
|
||||
DropdownMenuItem,
|
||||
DropdownMenuLabel,
|
||||
DropdownMenuPortal,
|
||||
DropdownMenuRadioGroup,
|
||||
DropdownMenuRadioItem,
|
||||
DropdownMenuSeparator,
|
||||
DropdownMenuSub,
|
||||
DropdownMenuSubContent,
|
||||
DropdownMenuSubTrigger,
|
||||
DropdownMenuTrigger,
|
||||
} from '@/components/ui/dropdown-menu';
|
||||
import {
|
||||
Sidebar,
|
||||
SidebarContent,
|
||||
SidebarFooter,
|
||||
SidebarGroup,
|
||||
SidebarGroupContent,
|
||||
SidebarGroupLabel,
|
||||
|
|
@ -26,10 +33,12 @@ import {
|
|||
SidebarMenuItem,
|
||||
SidebarRail,
|
||||
} from '@/components/ui/sidebar';
|
||||
import { useAppearance } from '@/composables/useAppearance';
|
||||
import { useInitials } from '@/composables/useInitials';
|
||||
import { accounts, calendar, logout } from '@/routes';
|
||||
import { index as hashtags } from '@/routes/hashtags';
|
||||
import { index as labels } from '@/routes/labels';
|
||||
import { index as postsIndex } from '@/actions/App/Http/Controllers/PostController';
|
||||
import { edit as editProfile } from '@/routes/profile';
|
||||
import { settings as workspaceSettings } from '@/routes/workspace';
|
||||
import { create as createWorkspaceRoute, switchMethod } from '@/routes/workspaces';
|
||||
|
|
@ -50,32 +59,94 @@ const currentWorkspace = computed<Workspace | null>(() => page.props.currentWork
|
|||
const workspaces = computed<Workspace[]>(() => page.props.workspaces as Workspace[]);
|
||||
|
||||
const { getInitials } = useInitials();
|
||||
const { appearance, updateAppearance } = useAppearance();
|
||||
|
||||
const mainNavItems: NavItem[] = [
|
||||
const themeLabels: Record<string, string> = {
|
||||
light: 'Light',
|
||||
dark: 'Dark',
|
||||
system: 'System',
|
||||
};
|
||||
|
||||
const postsNavItems: NavItem[] = [
|
||||
{
|
||||
title: 'Calendar',
|
||||
href: calendar.url(),
|
||||
icon: Calendar,
|
||||
icon: IconCalendar,
|
||||
},
|
||||
{
|
||||
title: 'Accounts',
|
||||
href: accounts.url(),
|
||||
icon: Share2,
|
||||
title: 'All',
|
||||
href: postsIndex.url(),
|
||||
icon: IconFileText,
|
||||
},
|
||||
{
|
||||
title: 'Hashtags',
|
||||
href: hashtags.url(),
|
||||
icon: Hash,
|
||||
title: 'Scheduled',
|
||||
href: postsIndex.url('scheduled'),
|
||||
icon: IconClock,
|
||||
},
|
||||
{
|
||||
title: 'Labels',
|
||||
href: labels.url(),
|
||||
icon: Tag,
|
||||
title: 'Posted',
|
||||
href: postsIndex.url('published'),
|
||||
icon: IconFileCheck,
|
||||
},
|
||||
{
|
||||
title: 'Settings',
|
||||
href: workspaceSettings.url(),
|
||||
icon: Settings,
|
||||
title: 'Drafts',
|
||||
href: postsIndex.url('draft'),
|
||||
icon: IconPencil,
|
||||
},
|
||||
];
|
||||
|
||||
const canManageWorkspace = computed(() => auth.value.role !== 'member');
|
||||
|
||||
const configNavItems = computed(() => {
|
||||
const items: NavItem[] = [
|
||||
{
|
||||
title: 'Connections',
|
||||
href: accounts.url(),
|
||||
icon: IconShare2,
|
||||
},
|
||||
{
|
||||
title: 'Hashtags',
|
||||
href: hashtags.url(),
|
||||
icon: IconHash,
|
||||
},
|
||||
{
|
||||
title: 'Labels',
|
||||
href: labels.url(),
|
||||
icon: IconTag,
|
||||
},
|
||||
];
|
||||
|
||||
if (canManageWorkspace.value) {
|
||||
items.push({
|
||||
title: 'Settings',
|
||||
href: workspaceSettings.url(),
|
||||
icon: IconSettings,
|
||||
});
|
||||
}
|
||||
|
||||
return items;
|
||||
});
|
||||
|
||||
const supportNavItems: NavItem[] = [
|
||||
{
|
||||
title: 'Share feedback',
|
||||
href: 'mailto:support@trypost.it',
|
||||
icon: IconMessageCircle,
|
||||
},
|
||||
{
|
||||
title: 'Earn 30% referral',
|
||||
href: '/referral',
|
||||
icon: IconGift,
|
||||
},
|
||||
{
|
||||
title: 'Stay updated',
|
||||
href: 'https://x.com/trypostit',
|
||||
icon: IconBell,
|
||||
},
|
||||
{
|
||||
title: 'Docs',
|
||||
href: 'https://docs.trypost.it',
|
||||
icon: IconBook,
|
||||
},
|
||||
];
|
||||
|
||||
|
|
@ -105,51 +176,122 @@ function handleLogout() {
|
|||
<SidebarMenuItem>
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger as-child>
|
||||
<SidebarMenuButton
|
||||
size="lg"
|
||||
class="data-[state=open]:bg-sidebar-accent data-[state=open]:text-sidebar-accent-foreground"
|
||||
>
|
||||
<img
|
||||
:src="currentWorkspace?.logo.url"
|
||||
:alt="currentWorkspace?.name"
|
||||
class="size-8 rounded-full object-cover"
|
||||
/>
|
||||
<SidebarMenuButton size="lg"
|
||||
class="data-[state=open]:bg-sidebar-accent data-[state=open]:text-sidebar-accent-foreground">
|
||||
<Avatar class="h-9 w-9 rounded-full shrink-0">
|
||||
<AvatarImage v-if="auth.user.avatar?.url" :src="auth.user.avatar?.url"
|
||||
:alt="auth.user.name" />
|
||||
<AvatarFallback class="rounded-full text-xs">
|
||||
{{ getInitials(auth.user.name) }}
|
||||
</AvatarFallback>
|
||||
</Avatar>
|
||||
<div class="grid flex-1 text-left text-sm leading-tight">
|
||||
<span class="truncate font-semibold">{{ currentWorkspace?.name || 'Select workspace' }}</span>
|
||||
<span class="truncate text-xs text-muted-foreground">Workspace</span>
|
||||
<span class="truncate font-semibold">{{ auth.user.name }}</span>
|
||||
<span class="truncate text-xs text-muted-foreground">{{ currentWorkspace?.name ||
|
||||
'Select workspace' }}</span>
|
||||
</div>
|
||||
<ChevronsUpDown class="ml-auto size-4" />
|
||||
<IconSelector class="ml-auto size-4" />
|
||||
</SidebarMenuButton>
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent
|
||||
class="w-[--reka-dropdown-menu-trigger-width] min-w-56 rounded-lg"
|
||||
align="start"
|
||||
side="bottom"
|
||||
:side-offset="4"
|
||||
>
|
||||
<DropdownMenuLabel class="text-xs text-muted-foreground">
|
||||
Workspaces
|
||||
</DropdownMenuLabel>
|
||||
<DropdownMenuItem
|
||||
v-for="workspace in workspaces"
|
||||
:key="workspace.id"
|
||||
class="cursor-pointer gap-2 p-2"
|
||||
@click="switchWorkspace(workspace)"
|
||||
>
|
||||
<img
|
||||
:src="workspace.logo.url"
|
||||
:alt="workspace.name"
|
||||
class="size-6 rounded-sm object-cover"
|
||||
/>
|
||||
<span class="truncate">{{ workspace.name }}</span>
|
||||
<Check v-if="currentWorkspace?.id === workspace.id" class="ml-auto size-4" />
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuSeparator />
|
||||
<DropdownMenuItem class="cursor-pointer gap-2 p-2" @click="createWorkspace">
|
||||
<div class="flex size-6 items-center justify-center rounded-md border bg-background">
|
||||
<Plus class="size-4" />
|
||||
<DropdownMenuContent class="w-[--reka-dropdown-menu-trigger-width] min-w-56 rounded-lg"
|
||||
align="start" side="bottom" :side-offset="4">
|
||||
<!-- User Info -->
|
||||
<DropdownMenuLabel class="p-0 font-normal">
|
||||
<div class="flex items-center gap-2 px-2 py-2 text-left text-sm">
|
||||
<Avatar class="h-8 w-8 rounded-full">
|
||||
<AvatarImage v-if="auth.user.avatar?.url" :src="auth.user.avatar?.url"
|
||||
:alt="auth.user.name" />
|
||||
<AvatarFallback class="rounded-full">
|
||||
{{ getInitials(auth.user.name) }}
|
||||
</AvatarFallback>
|
||||
</Avatar>
|
||||
<div class="grid flex-1 text-left text-sm leading-tight">
|
||||
<span class="truncate font-semibold">{{ auth.user.name }}</span>
|
||||
<span class="truncate text-xs text-muted-foreground">{{ auth.user.email
|
||||
}}</span>
|
||||
</div>
|
||||
</div>
|
||||
<span class="font-medium">Create workspace</span>
|
||||
</DropdownMenuLabel>
|
||||
<DropdownMenuSeparator />
|
||||
|
||||
<!-- Workspaces -->
|
||||
<DropdownMenuSub>
|
||||
<DropdownMenuSubTrigger>
|
||||
<img v-if="currentWorkspace?.logo.url" :src="currentWorkspace.logo.url"
|
||||
:alt="currentWorkspace.name" class="mr-2 size-4 rounded-full object-cover" />
|
||||
<span>Workspace: {{ currentWorkspace?.name || 'Select' }}</span>
|
||||
</DropdownMenuSubTrigger>
|
||||
<DropdownMenuPortal>
|
||||
<DropdownMenuSubContent>
|
||||
<DropdownMenuRadioGroup :model-value="currentWorkspace?.id"
|
||||
@update:model-value="(id: string) => switchWorkspace(workspaces.find(w => w.id === id)!)">
|
||||
<DropdownMenuRadioItem v-for="workspace in workspaces" :key="workspace.id"
|
||||
:value="workspace.id">
|
||||
<img :src="workspace.logo.url" :alt="workspace.name"
|
||||
class="mr-2 size-4 rounded-full object-cover" />
|
||||
<span>{{ workspace.name }}</span>
|
||||
</DropdownMenuRadioItem>
|
||||
</DropdownMenuRadioGroup>
|
||||
<DropdownMenuSeparator />
|
||||
<DropdownMenuItem class="cursor-pointer gap-2" @click="createWorkspace">
|
||||
<IconPlus class="size-4" />
|
||||
<span>Create workspace</span>
|
||||
</DropdownMenuItem>
|
||||
</DropdownMenuSubContent>
|
||||
</DropdownMenuPortal>
|
||||
</DropdownMenuSub>
|
||||
|
||||
<DropdownMenuSeparator />
|
||||
|
||||
<!-- Theme -->
|
||||
<DropdownMenuSub>
|
||||
<DropdownMenuSubTrigger>
|
||||
<IconSun v-if="appearance === 'light'" class="mr-2 size-4" />
|
||||
<IconMoon v-else-if="appearance === 'dark'" class="mr-2 size-4" />
|
||||
<IconDeviceDesktop v-else class="mr-2 size-4" />
|
||||
<span>Theme: {{ themeLabels[appearance] }}</span>
|
||||
</DropdownMenuSubTrigger>
|
||||
<DropdownMenuPortal>
|
||||
<DropdownMenuSubContent>
|
||||
<DropdownMenuRadioGroup :model-value="appearance"
|
||||
@update:model-value="updateAppearance">
|
||||
<DropdownMenuRadioItem value="light">
|
||||
<IconSun class="mr-2 size-4" />
|
||||
<span>Light</span>
|
||||
</DropdownMenuRadioItem>
|
||||
<DropdownMenuRadioItem value="dark">
|
||||
<IconMoon class="mr-2 size-4" />
|
||||
<span>Dark</span>
|
||||
</DropdownMenuRadioItem>
|
||||
<DropdownMenuRadioItem value="system">
|
||||
<IconDeviceDesktop class="mr-2 size-4" />
|
||||
<span>System</span>
|
||||
</DropdownMenuRadioItem>
|
||||
</DropdownMenuRadioGroup>
|
||||
</DropdownMenuSubContent>
|
||||
</DropdownMenuPortal>
|
||||
</DropdownMenuSub>
|
||||
|
||||
<DropdownMenuSeparator />
|
||||
|
||||
<!-- User Actions -->
|
||||
<DropdownMenuGroup>
|
||||
<DropdownMenuItem as-child>
|
||||
<Link class="cursor-pointer" :href="editProfile()">
|
||||
<IconUser class="mr-2 size-4" />
|
||||
Profile
|
||||
</Link>
|
||||
</DropdownMenuItem>
|
||||
</DropdownMenuGroup>
|
||||
|
||||
<DropdownMenuSeparator />
|
||||
|
||||
|
||||
<DropdownMenuItem as-child>
|
||||
<Link class="w-full cursor-pointer" :href="logout()" @click="handleLogout" as="button">
|
||||
<IconLogout class="mr-2 size-4" />
|
||||
Log out
|
||||
</Link>
|
||||
</DropdownMenuItem>
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
|
|
@ -158,16 +300,23 @@ function handleLogout() {
|
|||
</SidebarHeader>
|
||||
|
||||
<SidebarContent>
|
||||
<!-- Create Post Button -->
|
||||
<div v-if="currentWorkspace" class="px-2 py-2">
|
||||
<Link :href="createPost.url()">
|
||||
<Button class="w-full">
|
||||
<IconPlus class="mr-2 size-4" />
|
||||
Create post
|
||||
</Button>
|
||||
</Link>
|
||||
</div>
|
||||
|
||||
<SidebarGroup v-if="currentWorkspace">
|
||||
<SidebarGroupLabel>Menu</SidebarGroupLabel>
|
||||
<SidebarGroupLabel>Posts</SidebarGroupLabel>
|
||||
<SidebarGroupContent>
|
||||
<SidebarMenu>
|
||||
<SidebarMenuItem v-for="item in mainNavItems" :key="item.title">
|
||||
<SidebarMenuButton
|
||||
as-child
|
||||
:tooltip="item.title"
|
||||
:is-active="isActive(item.href as string)"
|
||||
>
|
||||
<SidebarMenuItem v-for="item in postsNavItems" :key="item.title">
|
||||
<SidebarMenuButton as-child :tooltip="item.title"
|
||||
:is-active="isActive(item.href as string)">
|
||||
<Link :href="item.href">
|
||||
<component v-if="item.icon" :is="item.icon" />
|
||||
<span>{{ item.title }}</span>
|
||||
|
|
@ -177,77 +326,42 @@ function handleLogout() {
|
|||
</SidebarMenu>
|
||||
</SidebarGroupContent>
|
||||
</SidebarGroup>
|
||||
</SidebarContent>
|
||||
|
||||
<SidebarFooter>
|
||||
<SidebarMenu>
|
||||
<SidebarMenuItem>
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger as-child>
|
||||
<SidebarMenuButton
|
||||
size="lg"
|
||||
class="data-[state=open]:bg-sidebar-accent data-[state=open]:text-sidebar-accent-foreground"
|
||||
>
|
||||
<Avatar class="h-8 w-8 rounded-lg">
|
||||
<AvatarImage v-if="auth.user.avatar?.url" :src="auth.user.avatar?.url" :alt="auth.user.name" />
|
||||
<AvatarFallback class="rounded-lg">
|
||||
{{ getInitials(auth.user.name) }}
|
||||
</AvatarFallback>
|
||||
</Avatar>
|
||||
<div class="grid flex-1 text-left text-sm leading-tight">
|
||||
<span class="truncate font-semibold">{{ auth.user.name }}</span>
|
||||
<span class="truncate text-xs text-muted-foreground">{{ auth.user.email }}</span>
|
||||
</div>
|
||||
<ChevronsUpDown class="ml-auto size-4" />
|
||||
</SidebarMenuButton>
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent
|
||||
class="w-[--reka-dropdown-menu-trigger-width] min-w-56 rounded-lg"
|
||||
side="bottom"
|
||||
align="end"
|
||||
:side-offset="4"
|
||||
>
|
||||
<DropdownMenuLabel class="p-0 font-normal">
|
||||
<div class="flex items-center gap-2 px-1 py-1.5 text-left text-sm">
|
||||
<Avatar class="h-8 w-8 rounded-lg">
|
||||
<AvatarImage v-if="auth.user.avatar?.url" :src="auth.user.avatar?.url" :alt="auth.user.name" />
|
||||
<AvatarFallback class="rounded-lg">
|
||||
{{ getInitials(auth.user.name) }}
|
||||
</AvatarFallback>
|
||||
</Avatar>
|
||||
<div class="grid flex-1 text-left text-sm leading-tight">
|
||||
<span class="truncate font-semibold">{{ auth.user.name }}</span>
|
||||
<span class="truncate text-xs text-muted-foreground">{{ auth.user.email }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</DropdownMenuLabel>
|
||||
<DropdownMenuSeparator />
|
||||
<DropdownMenuGroup>
|
||||
<DropdownMenuItem as-child>
|
||||
<Link class="cursor-pointer" :href="editProfile()">
|
||||
<Settings class="mr-2 size-4" />
|
||||
Settings
|
||||
</Link>
|
||||
</DropdownMenuItem>
|
||||
</DropdownMenuGroup>
|
||||
<DropdownMenuSeparator />
|
||||
<DropdownMenuItem as-child>
|
||||
<Link
|
||||
class="cursor-pointer"
|
||||
:href="logout()"
|
||||
@click="handleLogout"
|
||||
as="button"
|
||||
>
|
||||
<LogOut class="mr-2 size-4" />
|
||||
Log out
|
||||
<SidebarGroup v-if="currentWorkspace">
|
||||
<SidebarGroupLabel>Configuration</SidebarGroupLabel>
|
||||
<SidebarGroupContent>
|
||||
<SidebarMenu>
|
||||
<SidebarMenuItem v-for="item in configNavItems" :key="item.title">
|
||||
<SidebarMenuButton as-child :tooltip="item.title"
|
||||
:is-active="isActive(item.href as string)">
|
||||
<Link :href="item.href">
|
||||
<component v-if="item.icon" :is="item.icon" />
|
||||
<span>{{ item.title }}</span>
|
||||
</Link>
|
||||
</DropdownMenuItem>
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
</SidebarMenuItem>
|
||||
</SidebarMenu>
|
||||
</SidebarFooter>
|
||||
</SidebarMenuButton>
|
||||
</SidebarMenuItem>
|
||||
</SidebarMenu>
|
||||
</SidebarGroupContent>
|
||||
</SidebarGroup>
|
||||
|
||||
<SidebarGroup v-if="currentWorkspace">
|
||||
<SidebarGroupLabel>Support</SidebarGroupLabel>
|
||||
<SidebarGroupContent>
|
||||
<SidebarMenu>
|
||||
<SidebarMenuItem v-for="item in supportNavItems" :key="item.title">
|
||||
<SidebarMenuButton as-child :tooltip="item.title">
|
||||
<a :href="item.href"
|
||||
:target="(item.href as string).startsWith('http') ? '_blank' : undefined">
|
||||
<component v-if="item.icon" :is="item.icon" />
|
||||
<span>{{ item.title }}</span>
|
||||
</a>
|
||||
</SidebarMenuButton>
|
||||
</SidebarMenuItem>
|
||||
</SidebarMenu>
|
||||
</SidebarGroupContent>
|
||||
</SidebarGroup>
|
||||
</SidebarContent>
|
||||
|
||||
<SidebarRail />
|
||||
</Sidebar>
|
||||
</template>
|
||||
</template>
|
||||
|
|
@ -1,34 +0,0 @@
|
|||
<script setup lang="ts">
|
||||
import { Monitor, Moon, Sun } from 'lucide-vue-next';
|
||||
|
||||
import { useAppearance } from '@/composables/useAppearance';
|
||||
|
||||
const { appearance, updateAppearance } = useAppearance();
|
||||
|
||||
const tabs = [
|
||||
{ value: 'light', Icon: Sun, label: 'Light' },
|
||||
{ value: 'dark', Icon: Moon, label: 'Dark' },
|
||||
{ value: 'system', Icon: Monitor, label: 'System' },
|
||||
] as const;
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
class="inline-flex gap-1 rounded-lg bg-neutral-100 p-1 dark:bg-neutral-800"
|
||||
>
|
||||
<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',
|
||||
]"
|
||||
>
|
||||
<component :is="Icon" class="-ml-1 h-4 w-4" />
|
||||
<span class="ml-1.5 text-sm">{{ label }}</span>
|
||||
</button>
|
||||
</div>
|
||||
</template>
|
||||
|
|
@ -6,7 +6,6 @@ import Heading from '@/components/Heading.vue';
|
|||
import { useActiveUrl } from '@/composables/useActiveUrl';
|
||||
import { toUrl } from '@/lib/utils';
|
||||
import { members } from '@/routes';
|
||||
import { edit as editAppearance } from '@/routes/appearance';
|
||||
import { index as billing } from '@/routes/billing';
|
||||
import { edit as editProfile } from '@/routes/profile';
|
||||
import { edit as editPassword } from '@/routes/user-password';
|
||||
|
|
@ -14,6 +13,8 @@ import { settings as workspaceSettings } from '@/routes/workspace';
|
|||
import { type NavItem, type SharedData } from '@/types';
|
||||
|
||||
const page = usePage<SharedData>();
|
||||
const auth = computed(() => page.props.auth);
|
||||
const canManageWorkspace = computed(() => auth.value.role !== 'member');
|
||||
|
||||
const navItems = computed<NavItem[]>(() => {
|
||||
const items: NavItem[] = [
|
||||
|
|
@ -25,25 +26,26 @@ const navItems = computed<NavItem[]>(() => {
|
|||
title: 'Password',
|
||||
href: editPassword(),
|
||||
},
|
||||
{
|
||||
title: 'Appearance',
|
||||
href: editAppearance(),
|
||||
},
|
||||
{
|
||||
title: 'Workspace',
|
||||
href: workspaceSettings(),
|
||||
},
|
||||
{
|
||||
title: 'Members',
|
||||
href: members(),
|
||||
},
|
||||
];
|
||||
|
||||
if (!page.props.selfHosted) {
|
||||
items.push({
|
||||
title: 'Billing',
|
||||
href: billing(),
|
||||
});
|
||||
if (canManageWorkspace.value) {
|
||||
items.push(
|
||||
{
|
||||
title: 'Workspace',
|
||||
href: workspaceSettings(),
|
||||
},
|
||||
{
|
||||
title: 'Members',
|
||||
href: members(),
|
||||
},
|
||||
);
|
||||
|
||||
if (!page.props.selfHosted) {
|
||||
items.push({
|
||||
title: 'Billing',
|
||||
href: billing(),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return items;
|
||||
|
|
|
|||
|
|
@ -15,72 +15,40 @@ import { request } from '@/routes/password';
|
|||
|
||||
defineProps<{
|
||||
status?: string;
|
||||
canResetPassword: boolean;
|
||||
canRegister: boolean;
|
||||
email?: string | null;
|
||||
redirect?: string | null;
|
||||
}>();
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<AuthBase
|
||||
title="Log in to your account"
|
||||
description="Enter your email and password below to log in"
|
||||
>
|
||||
<AuthBase title="Log in to your account" description="Enter your email and password below to log in">
|
||||
|
||||
<Head title="Log in" />
|
||||
|
||||
<div
|
||||
v-if="status"
|
||||
class="mb-4 text-center text-sm font-medium text-green-600"
|
||||
>
|
||||
<div v-if="status" class="mb-4 text-center text-sm font-medium text-green-600">
|
||||
{{ status }}
|
||||
</div>
|
||||
|
||||
<Form
|
||||
v-bind="store.form()"
|
||||
:reset-on-success="['password']"
|
||||
v-slot="{ errors, processing }"
|
||||
class="flex flex-col gap-6"
|
||||
>
|
||||
<Form v-bind="store.form()" :reset-on-success="['password']" v-slot="{ errors, processing }"
|
||||
class="flex flex-col gap-6">
|
||||
<input v-if="redirect" type="hidden" name="redirect" :value="redirect" />
|
||||
<div class="grid gap-6">
|
||||
<div class="grid gap-2">
|
||||
<Label for="email">Email address</Label>
|
||||
<Input
|
||||
id="email"
|
||||
type="email"
|
||||
name="email"
|
||||
required
|
||||
autofocus
|
||||
:tabindex="1"
|
||||
autocomplete="email"
|
||||
placeholder="email@example.com"
|
||||
:default-value="email ?? ''"
|
||||
/>
|
||||
<Input id="email" type="email" name="email" required autofocus :tabindex="1" autocomplete="email"
|
||||
placeholder="email@example.com" :default-value="email ?? ''" />
|
||||
<InputError :message="errors.email" />
|
||||
</div>
|
||||
|
||||
<div class="grid gap-2">
|
||||
<div class="flex items-center justify-between">
|
||||
<Label for="password">Password</Label>
|
||||
<TextLink
|
||||
v-if="canResetPassword"
|
||||
:href="request()"
|
||||
class="text-sm"
|
||||
:tabindex="5"
|
||||
>
|
||||
<TextLink :href="request()" class="text-sm" :tabindex="5">
|
||||
Forgot password?
|
||||
</TextLink>
|
||||
</div>
|
||||
<Input
|
||||
id="password"
|
||||
type="password"
|
||||
name="password"
|
||||
required
|
||||
:tabindex="2"
|
||||
autocomplete="current-password"
|
||||
placeholder="Password"
|
||||
/>
|
||||
<Input id="password" type="password" name="password" required :tabindex="2"
|
||||
autocomplete="current-password" placeholder="Password" />
|
||||
<InputError :message="errors.password" />
|
||||
</div>
|
||||
|
||||
|
|
@ -91,25 +59,16 @@ defineProps<{
|
|||
</Label>
|
||||
</div>
|
||||
|
||||
<Button
|
||||
type="submit"
|
||||
class="mt-4 w-full"
|
||||
:tabindex="4"
|
||||
:disabled="processing"
|
||||
data-test="login-button"
|
||||
>
|
||||
<Button type="submit" class="mt-4 w-full" :tabindex="4" :disabled="processing" data-test="login-button">
|
||||
<Spinner v-if="processing" />
|
||||
Log in
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
<div
|
||||
class="text-center text-sm text-muted-foreground"
|
||||
v-if="canRegister"
|
||||
>
|
||||
<div class="text-center text-sm text-muted-foreground">
|
||||
Don't have an account?
|
||||
<TextLink :href="register()" :tabindex="5">Sign up</TextLink>
|
||||
</div>
|
||||
</Form>
|
||||
</AuthBase>
|
||||
</template>
|
||||
</template>
|
||||
|
|
@ -1,14 +1,16 @@
|
|||
<script setup lang="ts">
|
||||
import { Head, Link, router } from '@inertiajs/vue3';
|
||||
import { Clock, CheckCircle, AlertCircle, Loader2, FileText, Plus, Eye, Pencil, Trash2 } from 'lucide-vue-next';
|
||||
import { Head, Link, router, InfiniteScroll } from '@inertiajs/vue3';
|
||||
import { IconClock, IconCircleCheck, IconAlertCircle, IconLoader2, IconFileText, IconPlus, IconEye, IconPencil, IconTrash } from '@tabler/icons-vue';
|
||||
import { computed } from 'vue';
|
||||
|
||||
import { Badge } from '@/components/ui/badge';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Card, CardContent } from '@/components/ui/card';
|
||||
import { Skeleton } from '@/components/ui/skeleton';
|
||||
import dayjs from '@/dayjs';
|
||||
import AppLayout from '@/layouts/AppLayout.vue';
|
||||
import { calendar } from '@/routes';
|
||||
import { index as postsIndex, create as createPost, show as showPost, edit as editPost, destroy as destroyPost } from '@/routes/posts';
|
||||
import { index as postsIndex, create as createPost, show as showPost, edit as editPost, destroy as destroyPost } from '@/actions/App/Http/Controllers/PostController';
|
||||
import { type BreadcrumbItemType } from '@/types';
|
||||
|
||||
interface SocialAccount {
|
||||
|
|
@ -43,21 +45,10 @@ interface Post {
|
|||
user: User;
|
||||
}
|
||||
|
||||
interface PaginatedPosts {
|
||||
interface ScrollPosts {
|
||||
data: Post[];
|
||||
links: {
|
||||
first: string | null;
|
||||
last: string | null;
|
||||
prev: string | null;
|
||||
next: string | null;
|
||||
};
|
||||
meta: {
|
||||
current_page: number;
|
||||
from: number | null;
|
||||
last_page: number;
|
||||
per_page: number;
|
||||
to: number | null;
|
||||
total: number;
|
||||
hasNextPage: boolean;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -69,11 +60,32 @@ interface Workspace {
|
|||
|
||||
interface Props {
|
||||
workspace: Workspace;
|
||||
posts: PaginatedPosts;
|
||||
posts: ScrollPosts;
|
||||
currentStatus: string | null;
|
||||
}
|
||||
|
||||
const props = defineProps<Props>();
|
||||
|
||||
const statusLabels: Record<string, string> = {
|
||||
draft: 'Draft',
|
||||
scheduled: 'Scheduled',
|
||||
published: 'Published',
|
||||
};
|
||||
|
||||
const pageTitle = computed(() => {
|
||||
if (props.currentStatus && statusLabels[props.currentStatus]) {
|
||||
return `Posts - ${statusLabels[props.currentStatus]}`;
|
||||
}
|
||||
return 'All Posts';
|
||||
});
|
||||
|
||||
const pageDescription = computed(() => {
|
||||
if (props.currentStatus === 'draft') return 'Posts waiting to be scheduled';
|
||||
if (props.currentStatus === 'scheduled') return 'Posts scheduled for publishing';
|
||||
if (props.currentStatus === 'published') return 'Posts already published';
|
||||
return 'Manage all your posts';
|
||||
});
|
||||
|
||||
const breadcrumbs: BreadcrumbItemType[] = [
|
||||
{ title: 'Posts', href: postsIndex.url() },
|
||||
];
|
||||
|
|
@ -96,13 +108,13 @@ const getPlatformLogo = (platform: string): string => {
|
|||
};
|
||||
|
||||
const getStatusConfig = (status: string) => {
|
||||
const configs: Record<string, { label: string; color: string; icon: typeof FileText }> = {
|
||||
'draft': { label: 'Rascunho', color: 'bg-gray-100 text-gray-800', icon: FileText },
|
||||
'scheduled': { label: 'Agendado', color: 'bg-blue-100 text-blue-800', icon: Clock },
|
||||
'publishing': { label: 'Publicando', color: 'bg-yellow-100 text-yellow-800', icon: Loader2 },
|
||||
'published': { label: 'Publicado', color: 'bg-green-100 text-green-800', icon: CheckCircle },
|
||||
'partially_published': { label: 'Parcialmente Publicado', color: 'bg-orange-100 text-orange-800', icon: AlertCircle },
|
||||
'failed': { label: 'Falhou', color: 'bg-red-100 text-red-800', icon: AlertCircle },
|
||||
const configs: Record<string, { label: string; color: string; icon: typeof IconFileText }> = {
|
||||
'draft': { label: 'Draft', color: 'bg-gray-100 text-gray-800', icon: IconFileText },
|
||||
'scheduled': { label: 'Scheduled', color: 'bg-blue-100 text-blue-800', icon: IconClock },
|
||||
'publishing': { label: 'Publishing', color: 'bg-yellow-100 text-yellow-800', icon: IconLoader2 },
|
||||
'published': { label: 'Published', color: 'bg-green-100 text-green-800', icon: IconCircleCheck },
|
||||
'partially_published': { label: 'Partially Published', color: 'bg-orange-100 text-orange-800', icon: IconAlertCircle },
|
||||
'failed': { label: 'Failed', color: 'bg-red-100 text-red-800', icon: IconAlertCircle },
|
||||
};
|
||||
return configs[status] || configs['draft'];
|
||||
};
|
||||
|
|
@ -118,10 +130,10 @@ const getEnabledPlatforms = (post: Post) => {
|
|||
|
||||
const getPostPreview = (post: Post): string => {
|
||||
const enabledPlatforms = getEnabledPlatforms(post);
|
||||
if (enabledPlatforms.length === 0) return 'Sem conteudo';
|
||||
if (enabledPlatforms.length === 0) return 'No content';
|
||||
const firstPlatform = enabledPlatforms[0];
|
||||
const content = firstPlatform.content || '';
|
||||
return content.length > 100 ? content.substring(0, 100) + '...' : content || 'Sem conteudo';
|
||||
return content.length > 100 ? content.substring(0, 100) + '...' : content || 'No content';
|
||||
};
|
||||
|
||||
const canEdit = (post: Post): boolean => {
|
||||
|
|
@ -129,35 +141,35 @@ const canEdit = (post: Post): boolean => {
|
|||
};
|
||||
|
||||
const handleDelete = (post: Post) => {
|
||||
if (confirm('Tem certeza que deseja excluir este post?')) {
|
||||
if (confirm('Are you sure you want to delete this post?')) {
|
||||
router.delete(destroyPost.url(post.id));
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Head title="Posts" />
|
||||
<Head :title="pageTitle" />
|
||||
|
||||
<AppLayout :breadcrumbs="breadcrumbs">
|
||||
<div class="flex flex-col gap-6 p-6">
|
||||
<div class="flex items-center justify-between">
|
||||
<div>
|
||||
<h1 class="text-2xl font-bold tracking-tight">Posts</h1>
|
||||
<h1 class="text-2xl font-bold tracking-tight">{{ pageTitle }}</h1>
|
||||
<p class="text-muted-foreground">
|
||||
Gerencie todos os seus posts
|
||||
{{ pageDescription }}
|
||||
</p>
|
||||
</div>
|
||||
<div class="flex gap-2">
|
||||
<Link :href="calendar.url()">
|
||||
<Button variant="outline">
|
||||
<Clock class="mr-2 h-4 w-4" />
|
||||
Calendario
|
||||
<IconClock class="mr-2 h-4 w-4" />
|
||||
Calendar
|
||||
</Button>
|
||||
</Link>
|
||||
<Link :href="createPost.url()">
|
||||
<Button>
|
||||
<Plus class="mr-2 h-4 w-4" />
|
||||
Novo Post
|
||||
<IconPlus class="mr-2 h-4 w-4" />
|
||||
New Post
|
||||
</Button>
|
||||
</Link>
|
||||
</div>
|
||||
|
|
@ -166,15 +178,15 @@ const handleDelete = (post: Post) => {
|
|||
<div v-if="posts.data.length === 0">
|
||||
<Card>
|
||||
<CardContent class="flex flex-col items-center justify-center py-12">
|
||||
<FileText class="h-12 w-12 text-muted-foreground" />
|
||||
<h3 class="mt-4 text-lg font-semibold">Nenhum post ainda</h3>
|
||||
<IconFileText class="h-12 w-12 text-muted-foreground" />
|
||||
<h3 class="mt-4 text-lg font-semibold">No posts found</h3>
|
||||
<p class="mt-2 text-sm text-muted-foreground">
|
||||
Comece criando seu primeiro post.
|
||||
{{ currentStatus ? `No ${currentStatus} posts yet.` : 'Start by creating your first post.' }}
|
||||
</p>
|
||||
<Link :href="createPost.url()" class="mt-4">
|
||||
<Link v-if="!currentStatus" :href="createPost.url()" class="mt-4">
|
||||
<Button>
|
||||
<Plus class="mr-2 h-4 w-4" />
|
||||
Criar Post
|
||||
<IconPlus class="mr-2 h-4 w-4" />
|
||||
Create Post
|
||||
</Button>
|
||||
</Link>
|
||||
</CardContent>
|
||||
|
|
@ -214,7 +226,7 @@ const handleDelete = (post: Post) => {
|
|||
+{{ getEnabledPlatforms(post).length - 5 }}
|
||||
</span>
|
||||
<span class="text-xs text-muted-foreground ml-2">
|
||||
por {{ post.user.name }}
|
||||
by {{ post.user.name }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -222,12 +234,12 @@ const handleDelete = (post: Post) => {
|
|||
<div class="flex items-center gap-1">
|
||||
<Link :href="showPost.url(post.id)">
|
||||
<Button variant="ghost" size="icon">
|
||||
<Eye class="h-4 w-4" />
|
||||
<IconEye class="h-4 w-4" />
|
||||
</Button>
|
||||
</Link>
|
||||
<Link v-if="canEdit(post)" :href="editPost.url(post.id)">
|
||||
<Button variant="ghost" size="icon">
|
||||
<Pencil class="h-4 w-4" />
|
||||
<IconPencil class="h-4 w-4" />
|
||||
</Button>
|
||||
</Link>
|
||||
<Button
|
||||
|
|
@ -236,38 +248,40 @@ const handleDelete = (post: Post) => {
|
|||
size="icon"
|
||||
@click="handleDelete(post)"
|
||||
>
|
||||
<Trash2 class="h-4 w-4 text-red-500" />
|
||||
<IconTrash class="h-4 w-4 text-red-500" />
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
<div v-if="posts.meta.last_page > 1" class="flex items-center justify-between">
|
||||
<p class="text-sm text-muted-foreground">
|
||||
Mostrando {{ posts.meta.from }} a {{ posts.meta.to }} de {{ posts.meta.total }} posts
|
||||
</p>
|
||||
<div class="flex gap-2">
|
||||
<Link
|
||||
v-if="posts.links.prev"
|
||||
:href="posts.links.prev"
|
||||
preserve-scroll
|
||||
>
|
||||
<Button variant="outline" size="sm">
|
||||
Anterior
|
||||
</Button>
|
||||
</Link>
|
||||
<Link
|
||||
v-if="posts.links.next"
|
||||
:href="posts.links.next"
|
||||
preserve-scroll
|
||||
>
|
||||
<Button variant="outline" size="sm">
|
||||
Proximo
|
||||
</Button>
|
||||
</Link>
|
||||
<InfiniteScroll data="posts" #default="{ loading }">
|
||||
<div v-if="loading" class="space-y-4">
|
||||
<Card v-for="i in 3" :key="i">
|
||||
<CardContent class="p-4">
|
||||
<div class="flex items-start gap-4">
|
||||
<div class="flex-1 space-y-3">
|
||||
<div class="flex items-center gap-2">
|
||||
<Skeleton class="h-5 w-20" />
|
||||
<Skeleton class="h-4 w-32" />
|
||||
</div>
|
||||
<Skeleton class="h-4 w-full" />
|
||||
<Skeleton class="h-4 w-3/4" />
|
||||
<div class="flex items-center gap-2">
|
||||
<Skeleton class="h-6 w-6 rounded-full" />
|
||||
<Skeleton class="h-6 w-6 rounded-full" />
|
||||
<Skeleton class="h-4 w-24" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex gap-1">
|
||||
<Skeleton class="h-8 w-8" />
|
||||
<Skeleton class="h-8 w-8" />
|
||||
</div>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
</div>
|
||||
</InfiniteScroll>
|
||||
</div>
|
||||
</div>
|
||||
</AppLayout>
|
||||
|
|
|
|||
|
|
@ -1,35 +0,0 @@
|
|||
<script setup lang="ts">
|
||||
import { Head } from '@inertiajs/vue3';
|
||||
|
||||
import AppearanceTabs from '@/components/AppearanceTabs.vue';
|
||||
import HeadingSmall from '@/components/HeadingSmall.vue';
|
||||
import AppLayout from '@/layouts/AppLayout.vue';
|
||||
import SettingsLayout from '@/layouts/settings/Layout.vue';
|
||||
import { edit } from '@/routes/appearance';
|
||||
import { type BreadcrumbItem } from '@/types';
|
||||
|
||||
const breadcrumbItems: BreadcrumbItem[] = [
|
||||
{
|
||||
title: 'Appearance settings',
|
||||
href: edit().url,
|
||||
},
|
||||
];
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<AppLayout :breadcrumbs="breadcrumbItems">
|
||||
<Head title="Appearance settings" />
|
||||
|
||||
<h1 class="sr-only">Appearance Settings</h1>
|
||||
|
||||
<SettingsLayout>
|
||||
<div class="space-y-6">
|
||||
<HeadingSmall
|
||||
title="Appearance settings"
|
||||
description="Update your account's appearance settings"
|
||||
/>
|
||||
<AppearanceTabs />
|
||||
</div>
|
||||
</SettingsLayout>
|
||||
</AppLayout>
|
||||
</template>
|
||||
|
|
@ -65,7 +65,7 @@ const breadcrumbItems: BreadcrumbItem[] = [
|
|||
:photo="user.avatar"
|
||||
collection="avatar"
|
||||
:reload-only="['auth']"
|
||||
rounded="lg"
|
||||
rounded="full"
|
||||
/>
|
||||
</div>
|
||||
|
||||
|
|
|
|||
|
|
@ -69,6 +69,7 @@ const submit = () => {
|
|||
:photo="workspace.logo"
|
||||
collection="logo"
|
||||
:reload-only="['workspace']"
|
||||
rounded="full"
|
||||
/>
|
||||
</div>
|
||||
|
||||
|
|
|
|||
1
resources/js/types/index.d.ts
vendored
1
resources/js/types/index.d.ts
vendored
|
|
@ -3,6 +3,7 @@ import type { LucideIcon } from 'lucide-vue-next';
|
|||
|
||||
export interface Auth {
|
||||
user: User;
|
||||
role: 'owner' | 'admin' | 'member' | null;
|
||||
}
|
||||
|
||||
export interface BreadcrumbItem {
|
||||
|
|
|
|||
|
|
@ -18,8 +18,4 @@
|
|||
Route::put('settings/password', [PasswordController::class, 'update'])
|
||||
->middleware('throttle:6,1')
|
||||
->name('user-password.update');
|
||||
|
||||
Route::get('settings/appearance', function () {
|
||||
return Inertia::render('settings/Appearance');
|
||||
})->name('appearance.edit');
|
||||
});
|
||||
|
|
|
|||
|
|
@ -109,8 +109,8 @@
|
|||
Route::get('calendar', [PostController::class, 'calendar'])->name('calendar');
|
||||
|
||||
// Posts
|
||||
Route::get('posts', [PostController::class, 'index'])->name('posts.index');
|
||||
Route::get('posts/create', [PostController::class, 'create'])->name('posts.create');
|
||||
Route::get('posts/{status?}', [PostController::class, 'index'])->name('posts.index')->where('status', 'draft|scheduled|published');
|
||||
Route::post('posts', [PostController::class, 'store'])->name('posts.store');
|
||||
Route::get('posts/{post}', [PostController::class, 'show'])->name('posts.show');
|
||||
Route::get('posts/{post}/edit', [PostController::class, 'edit'])->name('posts.edit');
|
||||
|
|
|
|||
Loading…
Reference in a new issue