wip
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
@props(['id' => null, 'maxWidth' => null])
|
||||
|
||||
<x-modal :id="$id" :maxWidth="$maxWidth" {{ $attributes }}>
|
||||
<div class="px-4 pt-5 pb-4 sm:p-6 sm:pb-4">
|
||||
<div class="p-4">
|
||||
<div class="sm:flex sm:items-start">
|
||||
<div class="mx-auto shrink-0 flex items-center justify-center h-12 w-12 rounded-full bg-red-100 sm:mx-0 sm:h-10 sm:w-10">
|
||||
<svg class="h-6 w-6 text-red-600 dark:text-red-400" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
<div class="grow"></div>
|
||||
@@ -0,0 +1,43 @@
|
||||
@props([
|
||||
'key' => 'modal',
|
||||
'showClose' => true,
|
||||
'closeOnEscape' => true,
|
||||
'title' => null,
|
||||
'subtitle' => null
|
||||
])
|
||||
|
||||
<div
|
||||
x-data="{ open: false }"
|
||||
x-on:toggle-{{ $key }}.window="open = !open"
|
||||
class="relative z-50 w-auto h-auto"
|
||||
@if($closeOnEscape)
|
||||
@keydown.window.escape="open = false"
|
||||
@endif
|
||||
>
|
||||
<template x-teleport="body">
|
||||
<div x-transition.opacity x-show="open" class="fixed top-0 left-0 z-[99] flex items-center justify-center w-full h-full" x-cloak>
|
||||
<div
|
||||
@click="open=false"
|
||||
class="absolute inset-0 w-full h-full bg-black bg-opacity-40"
|
||||
></div>
|
||||
|
||||
<x-card
|
||||
x-trap.inert.noscroll="open"
|
||||
:title="$title"
|
||||
:subtitle="$subtitle"
|
||||
{{ $attributes->merge(['class' => 'relative transform overflow-hidden rounded-md ext-left shadow-xl w-full sm:w-2/3 lg:w-1/3 m-2 sm:m-0']) }}
|
||||
>
|
||||
@if ($showClose)
|
||||
<x-button
|
||||
icon="o-x-mark"
|
||||
class="absolute top-4 right-4 btn-ghost btn-circle btn-sm"
|
||||
@click="open = false"
|
||||
/>
|
||||
@endif
|
||||
|
||||
{{ $slot }}
|
||||
|
||||
</x-card>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
@@ -1,23 +1,23 @@
|
||||
<x-menu activate-by-route>
|
||||
|
||||
<x-menu-item title="{{ __('Dashboard') }}" icon="o-home" link="{{ @route('dashboard') }}" />
|
||||
<x-menu-item title="{{ __('Dashboard') }}" icon="o-home" link="{{ route('dashboard') }}" />
|
||||
<x-menu-sub title="{{ __('Portfolios') }}" icon="o-document-duplicate">
|
||||
@foreach (auth()->user()->portfolios as $portfolio)
|
||||
<x-menu-item icon="o-document" link="{{ route('portfolio.show', ['portfolio' => $portfolio->id ]) }}" exact>
|
||||
<x-menu-item icon="o-document" link="{{ route('portfolio.show', ['portfolio' => $portfolio->id ]) }}" >
|
||||
<x-slot:title>
|
||||
{{ $portfolio->title }}
|
||||
@if($portfolio->wishlist)
|
||||
<x-badge value="{{ __('Wishlist') }}" class="badge-primary badge-sm ml-2" />
|
||||
<x-badge value="{{ __('Wishlist') }}" class="badge-secondary badge-sm ml-2" />
|
||||
@endif
|
||||
</x-slot:title>
|
||||
|
||||
</x-menu-item>
|
||||
@endforeach
|
||||
|
||||
<x-menu-item title="{{ __('Create Portfolio') }}" icon="o-document-plus" link="{{ @route('portfolio.create') }}" />
|
||||
<x-menu-item title="{{ __('Create Portfolio') }}" icon="o-document-plus" link="{{ route('portfolio.create') }}" />
|
||||
</x-menu-sub>
|
||||
<x-menu-item title="{{ __('Transactions') }}" icon="o-banknotes" link="####" />
|
||||
<x-menu-item title="{{ __('Reporting') }}" icon="o-chart-bar-square" link="####" />
|
||||
<x-menu-item title="{{ __('Transactions') }}" icon="o-banknotes" link="{{ route('transaction.index') }}" />
|
||||
{{-- <x-menu-item title="{{ __('Reporting') }}" icon="o-chart-bar-square" link="####" /> --}}
|
||||
|
||||
</x-menu>
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<x-app-layout>
|
||||
|
||||
@livewire('portfolio-performance-cards', [
|
||||
@livewire('portfolio-performance-chart', [
|
||||
'name' => 'dashboard'
|
||||
])
|
||||
|
||||
@@ -47,7 +47,7 @@
|
||||
<x-slot:value>
|
||||
{{ $portfolio->title }}
|
||||
@if($portfolio->wishlist)
|
||||
<x-badge value="{{ __('Wishlist') }}" class="badge-primary badge-sm ml-2" />
|
||||
<x-badge value="{{ __('Wishlist') }}" class="badge-secondary badge-sm ml-2" />
|
||||
@endif
|
||||
</x-slot:value>
|
||||
</x-list-item>
|
||||
@@ -69,7 +69,7 @@
|
||||
</x-ib-card>
|
||||
@endif
|
||||
|
||||
@if (!$user->portfolios->isEmpty())
|
||||
{{-- @if (!$user->portfolios->isEmpty())
|
||||
<x-ib-card title="{{ __('Top headlines') }}" class="md:col-span-3">
|
||||
|
||||
@php
|
||||
@@ -81,7 +81,7 @@
|
||||
@endforeach
|
||||
|
||||
</x-ib-card>
|
||||
@endif
|
||||
@endif --}}
|
||||
|
||||
@if (!$user->portfolios->isEmpty())
|
||||
<x-ib-card title="{{ __('Recent activity') }}" class="md:col-span-4">
|
||||
|
||||
@@ -7,14 +7,11 @@
|
||||
|
||||
<title>{{ config('app.name', 'Laravel') }}</title>
|
||||
|
||||
<!-- Fonts -->
|
||||
<link rel="preconnect" href="https://fonts.bunny.net">
|
||||
<link href="https://fonts.bunny.net/css?family=figtree:400,500,600&display=swap" rel="stylesheet" />
|
||||
|
||||
<!-- Scripts -->
|
||||
@vite(['resources/css/app.css', 'resources/js/app.js'])
|
||||
|
||||
<!-- Styles -->
|
||||
@livewireStyles
|
||||
</head>
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ new class extends Component {
|
||||
|
||||
$this->portfolio->delete();
|
||||
|
||||
$this->success(__('Portfolio deleted'), redirectTo: "/dashboard");
|
||||
$this->success(__('Portfolio deleted'), redirectTo: route('dashboard'));
|
||||
}
|
||||
}; ?>
|
||||
|
||||
@@ -92,10 +92,11 @@ new class extends Component {
|
||||
<x-slot:actions>
|
||||
@if ($portfolio)
|
||||
<x-button
|
||||
class="ms-3 btn-error btn-outline text-white"
|
||||
class="ms-3 btn btn-ghost text-error"
|
||||
wire:click="$toggle('confirmingPortfolioDeletion')"
|
||||
wire:loading.attr="disabled"
|
||||
icon="o-trash"
|
||||
label="{{ __('Delete') }}"
|
||||
title="{{ __('Delete Portfolio') }}"
|
||||
/>
|
||||
@endif
|
||||
|
||||
|
||||
@@ -0,0 +1,150 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Transaction;
|
||||
use App\Models\Portfolio;
|
||||
use Illuminate\Support\Collection;
|
||||
use Livewire\Attributes\Rule;
|
||||
use Livewire\Volt\Component;
|
||||
use Mary\Traits\Toast;
|
||||
use Livewire\Attributes\Computed;
|
||||
|
||||
new class extends Component {
|
||||
use Toast;
|
||||
|
||||
// props
|
||||
public ?Portfolio $portfolio;
|
||||
public ?Transaction $transaction;
|
||||
|
||||
#[Rule('required|string|max:15')]
|
||||
public String $symbol;
|
||||
|
||||
#[Rule('required|string|in:BUY,SELL')]
|
||||
public String $transaction_type;
|
||||
|
||||
#[Rule('required|date')]
|
||||
public String $date;
|
||||
|
||||
#[Rule('required|numeric')]
|
||||
public String $quantity;
|
||||
|
||||
#[Rule('required|numeric')]
|
||||
public String $cost_basis;
|
||||
|
||||
public Bool $confirmingTransactionDeletion = false;
|
||||
|
||||
#[Computed]
|
||||
public function cost_basis_label()
|
||||
{
|
||||
if (isset($this->transaction_type) && $this->transaction_type == 'SELL') {
|
||||
return __('Sale Price');
|
||||
}
|
||||
|
||||
return __('Cost Basis');
|
||||
}
|
||||
|
||||
// methods
|
||||
public function mount()
|
||||
{
|
||||
if (isset($this->transaction)) {
|
||||
|
||||
$this->symbol = $this->transaction->symbol;
|
||||
$this->transaction_type = $this->transaction->transaction_type;
|
||||
$this->date = $this->transaction->date->format('Y-m-d');
|
||||
$this->quantity = $this->transaction->quantity;
|
||||
$this->cost_basis = $this->transaction_type == 'SELL'
|
||||
? $this->transaction->sale_price
|
||||
: $this->transaction->cost_basis;
|
||||
|
||||
} else {
|
||||
$this->transaction_type = 'BUY';
|
||||
$this->date = now()->format('Y-m-d');
|
||||
}
|
||||
}
|
||||
|
||||
public function update()
|
||||
{
|
||||
|
||||
$this->transaction->update($this->validate());
|
||||
// $this->transaction->owner_id = auth()->user()->id;
|
||||
$this->transaction->save();
|
||||
|
||||
$this->success(__('Transaction updated'), redirectTo: route('portfolio.show', ['portfolio' => $this->portfolio->id]));
|
||||
}
|
||||
|
||||
public function save()
|
||||
{
|
||||
|
||||
$transaction = $this->portfolio->transactions()->create($this->validate());
|
||||
$transaction->save();
|
||||
|
||||
$this->success(__('Transaction created'), redirectTo: route('portfolio.show', ['portfolio' => $this->portfolio->id]));
|
||||
}
|
||||
|
||||
public function delete()
|
||||
{
|
||||
|
||||
$this->transaction->delete();
|
||||
|
||||
$this->success(__('Transaction deleted'), redirectTo: route('portfolio.show', ['portfolio' => $this->portfolio->id]));
|
||||
}
|
||||
}; ?>
|
||||
|
||||
<div class="">
|
||||
<x-form wire:submit="{{ $transaction ? 'update' : 'save' }}" class="">
|
||||
|
||||
<x-input label="{{ __('Symbol') }}" wire:model="symbol" required />
|
||||
|
||||
<x-select label="{{ __('Transaction Type') }}" :options="[
|
||||
['id' => 'BUY', 'name' => 'Buy'],
|
||||
['id' => 'SELL', 'name' => 'Sell']
|
||||
]" wire:model.live="transaction_type" />
|
||||
|
||||
<x-datetime label="{{ __('Transaction Date') }}" wire:model="date" required />
|
||||
|
||||
<x-input label="{{ __('Quantity') }}" type="number" step="any" wire:model="quantity" required />
|
||||
|
||||
<x-input
|
||||
label="{{ $this->cost_basis_label }}"
|
||||
wire:model="cost_basis"
|
||||
required
|
||||
prefix="USD"
|
||||
money
|
||||
type="number"
|
||||
step="any"
|
||||
/>
|
||||
|
||||
<x-slot:actions>
|
||||
@if ($transaction)
|
||||
<x-button
|
||||
class="ms-3 btn btn-ghost text-error"
|
||||
wire:click="$toggle('confirmingTransactionDeletion')"
|
||||
wire:loading.attr="disabled"
|
||||
label="{{ __('Delete') }}"
|
||||
title="{{ __('Delete Transaction') }}"
|
||||
/>
|
||||
@endif
|
||||
|
||||
<x-button label="{{ $transaction ? 'Update' : 'Create' }}" type="submit" icon="o-paper-airplane" class="btn-primary" spinner="save" />
|
||||
</x-slot:actions>
|
||||
</x-form>
|
||||
|
||||
<x-confirmation-modal wire:model.live="confirmingTransactionDeletion">
|
||||
<x-slot name="title">
|
||||
{{ __('Delete Transaction') }}
|
||||
</x-slot>
|
||||
|
||||
<x-slot name="content">
|
||||
{{ __('Are you sure you want to delete this transaction?') }}
|
||||
</x-slot>
|
||||
|
||||
<x-slot name="footer">
|
||||
<x-button class="btn-outline" wire:click="$toggle('confirmingTransactionDeletion')" wire:loading.attr="disabled">
|
||||
{{ __('Cancel') }}
|
||||
</x-secondary-button>
|
||||
|
||||
<x-button class="ms-3 btn-error text-white" wire:click="delete" wire:loading.attr="disabled">
|
||||
{{ __('Delete Transaction') }}
|
||||
</x-button>
|
||||
</x-slot>
|
||||
</x-confirmation-modal>
|
||||
</div>
|
||||
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Portfolio;
|
||||
use App\Models\Transaction;
|
||||
use Illuminate\Support\Collection;
|
||||
use Livewire\Volt\Component;
|
||||
|
||||
new class extends Component {
|
||||
|
||||
// props
|
||||
public ?Collection $transactions;
|
||||
public Portfolio $portfolio;
|
||||
public ?Transaction $editingTransaction;
|
||||
|
||||
// methods
|
||||
public function showTransactionDialog($transactionId)
|
||||
{
|
||||
$this->editingTransaction = Transaction::findOrFail($transactionId);
|
||||
$this->dispatch('toggle-manage-transaction');
|
||||
}
|
||||
|
||||
}; ?>
|
||||
|
||||
<div class="">
|
||||
|
||||
@foreach($transactions as $transaction)
|
||||
<div x-data="{ loading: false, timeout: null }">
|
||||
<x-list-item
|
||||
no-separator
|
||||
:item="$transaction"
|
||||
class="cursor-pointer"
|
||||
@click="
|
||||
timeout = setTimeout(() => { loading = true }, 200);
|
||||
$wire.showTransactionDialog('{{ $transaction->id }}').then(() => {
|
||||
clearTimeout(timeout);
|
||||
loading = false;
|
||||
})
|
||||
"
|
||||
>
|
||||
<x-slot:value class="flex items-center">
|
||||
<x-badge
|
||||
:value="$transaction->transaction_type"
|
||||
class="{{ $transaction->transaction_type == 'BUY' ? 'badge-success' : 'badge-error' }} badge-sm mr-3"
|
||||
/>
|
||||
{{ $transaction->date->format('M j, Y') }}
|
||||
{{ $transaction->symbol }}
|
||||
({{ $transaction->quantity }}
|
||||
@ {{ Number::currency($transaction->cost_basis) }})
|
||||
|
||||
<x-loading x-show="loading" x-cloak class="text-gray-400 ml-2" />
|
||||
</x-slot:value>
|
||||
</x-list-item>
|
||||
</div>
|
||||
@endforeach
|
||||
|
||||
<x-ib-modal
|
||||
key="manage-transaction"
|
||||
title="Manage Transaction"
|
||||
>
|
||||
@livewire('manage-transaction-form', [
|
||||
'portfolio' => $portfolio,
|
||||
'transaction' => $editingTransaction,
|
||||
], key($editingTransaction->id ?? 'new'))
|
||||
|
||||
</x-ib-modal>
|
||||
</div>
|
||||
@@ -1,7 +1,7 @@
|
||||
<x-app-layout>
|
||||
<div>
|
||||
|
||||
<x-ib-toolbar title="Create Portfolio" />
|
||||
<x-ib-toolbar title="{{ __('Create Portfolio') }}" />
|
||||
|
||||
@livewire('manage-portfolio-form')
|
||||
</div>
|
||||
|
||||
@@ -1,11 +1,20 @@
|
||||
<x-app-layout>
|
||||
<div x-data>
|
||||
|
||||
<x-ib-modal
|
||||
key="new-transaction"
|
||||
title="New Transaction"
|
||||
>
|
||||
@livewire('manage-transaction-form', [
|
||||
'portfolio' => $portfolio,
|
||||
])
|
||||
|
||||
</x-ib-modal>
|
||||
|
||||
<x-ib-drawer
|
||||
key="manage-portfolio"
|
||||
title="{{ $portfolio->title }}"
|
||||
>
|
||||
|
||||
@livewire('manage-portfolio-form', [
|
||||
'portfolio' => $portfolio,
|
||||
'hideCancel' => true
|
||||
@@ -16,7 +25,7 @@
|
||||
<x-ib-toolbar :title="$portfolio->title">
|
||||
|
||||
@if($portfolio->wishlist)
|
||||
<x-badge value="{{ __('Wishlist') }}" class="badge-primary mr-3" />
|
||||
<x-badge value="{{ __('Wishlist') }}" class="badge-secondary mr-3" />
|
||||
@endif
|
||||
|
||||
<x-button
|
||||
@@ -25,9 +34,19 @@
|
||||
class="btn-circle btn-ghost btn-sm text-secondary"
|
||||
@click="$dispatch('toggle-manage-portfolio')"
|
||||
/>
|
||||
|
||||
<x-ib-flex-spacer />
|
||||
|
||||
<div>
|
||||
<x-button
|
||||
label="{{ __('Create Transaction') }}"
|
||||
class="btn-sm btn-primary"
|
||||
@click="$dispatch('toggle-new-transaction')"
|
||||
/>
|
||||
</div>
|
||||
</x-ib-toolbar>
|
||||
|
||||
@livewire('portfolio-performance-cards', [
|
||||
@livewire('portfolio-performance-chart', [
|
||||
'name' => 'portfolio-'.$portfolio->id,
|
||||
'portfolio' => $portfolio
|
||||
])
|
||||
@@ -64,7 +83,7 @@
|
||||
|
||||
<div class="mt-6 grid md:grid-cols-7 gap-5">
|
||||
|
||||
<x-ib-card title="All portfolio holdings" class="md:col-span-4">
|
||||
<x-ib-card title="{{ __('Holdings') }}" class="md:col-span-4">
|
||||
|
||||
@php
|
||||
$users = App\Models\User::take(3)->get();
|
||||
@@ -76,7 +95,7 @@
|
||||
|
||||
</x-ib-card>
|
||||
|
||||
<x-ib-card title="Top performers" class="md:col-span-3">
|
||||
<x-ib-card title="{{ __('Top performers') }}" class="md:col-span-3">
|
||||
|
||||
@php
|
||||
$users = App\Models\User::take(3)->get();
|
||||
@@ -88,7 +107,7 @@
|
||||
|
||||
</x-ib-card>
|
||||
|
||||
<x-ib-card title="Top headlines" class="md:col-span-3">
|
||||
{{-- <x-ib-card title="{{ __('Top headlines') }}" class="md:col-span-3">
|
||||
|
||||
@php
|
||||
$users = App\Models\User::take(3)->get();
|
||||
@@ -98,21 +117,17 @@
|
||||
<x-list-item no-separator :item="$user" avatar="profile_photo_url" link="/docs/installation" />
|
||||
@endforeach
|
||||
|
||||
</x-ib-card>
|
||||
</x-ib-card> --}}
|
||||
|
||||
<x-ib-card title="Recent activity" class="md:col-span-4">
|
||||
|
||||
@php
|
||||
$users = App\Models\User::take(3)->get();
|
||||
@endphp
|
||||
<x-ib-card title="{{ __('Recent activity') }}" class="md:col-span-4">
|
||||
|
||||
@foreach($users as $user)
|
||||
<x-list-item no-separator :item="$user" avatar="profile_photo_url" link="/docs/installation" />
|
||||
@endforeach
|
||||
@livewire('transactions-list', [
|
||||
'transactions' => $portfolio->transactions,
|
||||
'portfolio' => $portfolio
|
||||
])
|
||||
|
||||
</x-ib-card>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</x-app-layout>
|
||||
@@ -0,0 +1,8 @@
|
||||
<x-app-layout>
|
||||
<div>
|
||||
|
||||
<x-ib-toolbar title="{{ __('All Transactions') }}" />
|
||||
|
||||
{{-- @livewire('manage-transaction-form', ['portfolio' => $portfolio]) --}}
|
||||
</div>
|
||||
</x-app-layout>
|
||||
Reference in New Issue
Block a user