Skip to content

Commit

Permalink
Merge pull request #112 from RafaelBlum/dashboard-show-products-app
Browse files Browse the repository at this point in the history
Dashboard show products app
  • Loading branch information
icarojobs authored Aug 13, 2024
2 parents 875a506 + a4c7d2c commit 68e6aaf
Show file tree
Hide file tree
Showing 9 changed files with 409 additions and 7 deletions.
78 changes: 78 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,83 @@
# Changelog

## [1.1.0](https://github.com/RafaelBlum/freezer-control/compare/v1.0.0...v1.1.0) (2024-05-01)


### Features

* add logo admin/app PanelProvider ([f1ef222](https://github.com/RafaelBlum/freezer-control/commit/f1ef2229a79478e428e04689278529e75be45fe5))
* add logo name in login and Admin/App PanelProvider ([fe3526e](https://github.com/RafaelBlum/freezer-control/commit/fe3526ee64743a03722163d693dafb58d6e5b6c4))
* added customer id integration with ASAAS ([6aed087](https://github.com/RafaelBlum/freezer-control/commit/6aed08780390480bea03655d7b435b2f2a513385))
* added customer register flow ([5ecdd7d](https://github.com/RafaelBlum/freezer-control/commit/5ecdd7d43131e76244bdf394a928a7a5244955ff))
* added local folder to db ([cfafb56](https://github.com/RafaelBlum/freezer-control/commit/cfafb561bc6419935800cd1c0a023443416bb361))
* added normalize customer command ([34dfd3b](https://github.com/RafaelBlum/freezer-control/commit/34dfd3b0c755a2d3efdf39710bd04f5b03b8f9c7))
* added qr-code link ([07e6de0](https://github.com/RafaelBlum/freezer-control/commit/07e6de0f20f28c5cc3b8b54035d571fba76193e5))
* addiing filter stats - General adjustments ([e7ddb4a](https://github.com/RafaelBlum/freezer-control/commit/e7ddb4a12cecf95263bbb0fb95e3c05919a43fc9))
* adding command normalize cost price ([51d74c0](https://github.com/RafaelBlum/freezer-control/commit/51d74c0da2e1f3039ad2ae067004a0816da831c5))
* adding document mask ([fa04c91](https://github.com/RafaelBlum/freezer-control/commit/fa04c9146d86067c628e192b28d7c0f5bd8446c0))
* adding stats overview ([8b009e4](https://github.com/RafaelBlum/freezer-control/commit/8b009e463abfbf97e73e65eb6e99cc951d70e0b6))
* adiciona-testes-com-pest ([27228bf](https://github.com/RafaelBlum/freezer-control/commit/27228bf39f7405ea807171bb9ad6bdefea23aad2))
* Adicionando Resumo do pedido na etapa de pagamento do checkout. ([e429adf](https://github.com/RafaelBlum/freezer-control/commit/e429adf8874fb82d5effb774f42fb4fe6fdf14b8))
* adicionando validacao de maioridade na selecao de cliente no checkout ([95ba17d](https://github.com/RafaelBlum/freezer-control/commit/95ba17dd84e8c854be4025f94bede716d8f5d3fa))
* age validation ([e3865ad](https://github.com/RafaelBlum/freezer-control/commit/e3865ade6d02d2bc519d4569e5b566d3b3bd4bfe))
* cell mask addition ([566dbe2](https://github.com/RafaelBlum/freezer-control/commit/566dbe204773d5845e14ee9176d5539805546946))
* centralizar logo no header ([71e4b03](https://github.com/RafaelBlum/freezer-control/commit/71e4b03a5300c7da48a95feb0453cbc228513842))
* checkout venda com cartao de credito ([0a9f093](https://github.com/RafaelBlum/freezer-control/commit/0a9f093f8b4164c51065ba969e56c1d74b943d76))
* created custom register form ([72f0df4](https://github.com/RafaelBlum/freezer-control/commit/72f0df4e65e8c5ef24354d11903311aa5a3797a5))
* created Makefile automation ([19c71c5](https://github.com/RafaelBlum/freezer-control/commit/19c71c56e4b6a4eec4f2c9853deec8ebc3c3308f))
* created observer for customer resource ([2fdd0ed](https://github.com/RafaelBlum/freezer-control/commit/2fdd0ed822d59da12d7df22b9ab7e74b9f19be6e))
* created products and products transactions resource ([10d659f](https://github.com/RafaelBlum/freezer-control/commit/10d659f56d60dea42f82b5adfb2a05a5f4e0b362))
* created Users and Customers resource ([0bd0d38](https://github.com/RafaelBlum/freezer-control/commit/0bd0d38b4365232564f880c558fa199b4a12f826))
* cria a estrutura basica do webhook endpoint api ([9728bc2](https://github.com/RafaelBlum/freezer-control/commit/9728bc227ec0b5060b913b58d45e5e8631700359))
* estilizando pagina 403 ([d9a8b57](https://github.com/RafaelBlum/freezer-control/commit/d9a8b570c5179496936512a2611bb9b35ac1631c))
* finished checkout using PIX payment method ([71c81f5](https://github.com/RafaelBlum/freezer-control/commit/71c81f5bfd648e253ab2976e13f1c4f9437b2263))
* form order seller admin ([faf8aac](https://github.com/RafaelBlum/freezer-control/commit/faf8aacb5d5a880564163ee69e3ee0c1da0c6154))
* implementa label e color ([21a76e8](https://github.com/RafaelBlum/freezer-control/commit/21a76e8f7f5f6a2ed9c36b50d1a5b6c383f2f7df))
* implemented CustomerCreate ASAAS integration ([294bed8](https://github.com/RafaelBlum/freezer-control/commit/294bed8b2be19b6321d1c81e1cf918b9d4935d01))
* installed filament api service ([34f3dd9](https://github.com/RafaelBlum/freezer-control/commit/34f3dd9469971b131b9c38d368829f7eceef4686))
* integrated with Customer List on ASAAS PHP Gateway ([6d4f934](https://github.com/RafaelBlum/freezer-control/commit/6d4f9346369a943bbf381bb84b6c27b400e590d1))
* mostra quantide de itens no estoque ([2dee31e](https://github.com/RafaelBlum/freezer-control/commit/2dee31e3156f37a5a99a99ddcb8c299440de5b49))
* propoe uma nova integracao com a Asaas via adapter ([11de7d6](https://github.com/RafaelBlum/freezer-control/commit/11de7d6a0895d8e752b110538f8431ddb9ac5329))
* restrict user app to access the admin panel ([b7320e9](https://github.com/RafaelBlum/freezer-control/commit/b7320e9c37f6d90bd6ff85372540eb54997a36fb))
* small improvements on app.php config ([6577692](https://github.com/RafaelBlum/freezer-control/commit/6577692bbb68269d99b2cd4cba86686486982c76))
* started API endpoints architecture ([cb16d99](https://github.com/RafaelBlum/freezer-control/commit/cb16d9985232af60ca74c7e1ad995e635411bfb2))
* stats general ([9741101](https://github.com/RafaelBlum/freezer-control/commit/9741101505920585bd734891680a043e76a96c5b))


### Bug Fixes

* add ASAAS ID on Customer Resource ([5cd258a](https://github.com/RafaelBlum/freezer-control/commit/5cd258acd77db47658f7d0b2d100a18d2105ee34))
* add correct namespace to enum import on migration file ([039d37e](https://github.com/RafaelBlum/freezer-control/commit/039d37e9fc9fc2609799aad19449d8666d6f3ed8))
* add logo condition to login and registration area ([2ea1f2a](https://github.com/RafaelBlum/freezer-control/commit/2ea1f2acbe3100e733f43afccc05fc00236bf952))
* add method opening external link in another tab ([63f800f](https://github.com/RafaelBlum/freezer-control/commit/63f800f45f7b3989fef3d18d985fb45305fd0ffd))
* added image column to products table ([be9b4e0](https://github.com/RafaelBlum/freezer-control/commit/be9b4e09f1f70783bc99e1da013585ea3294884b))
* adicionado .docker ao gitignore ([86f6663](https://github.com/RafaelBlum/freezer-control/commit/86f6663bc12f2d08b14aa75cba93a4192fae9ff3))
* adjusting enum type ([0d240b5](https://github.com/RafaelBlum/freezer-control/commit/0d240b52d034c8c981bd360d8b8af6bcff2d3a99))
* correção no texto do pull request template ([aeaf43e](https://github.com/RafaelBlum/freezer-control/commit/aeaf43e1ac4d03686d4b4baae37a418477d82ac2))
* corrige cadastro de novos clientes ([d3f2248](https://github.com/RafaelBlum/freezer-control/commit/d3f2248ae310f669ef0100a759b354d2aae283dd))
* corrige obtenção de constante de ambiente ([ebaf86a](https://github.com/RafaelBlum/freezer-control/commit/ebaf86a61e582d074d1b62c951ab2c50fb17e17c))
* corrige os imports do Gateway e AssasConnector do arquivo README ([04be80f](https://github.com/RafaelBlum/freezer-control/commit/04be80f19d5aca0ea5f76ba00e52cb1a84e6b65c))
* corrige redirecionamento para o admin ([c2f2afe](https://github.com/RafaelBlum/freezer-control/commit/c2f2afee6a51de4af25c169e2ab02fd5721fc280))
* corrige relacionamento ([702304e](https://github.com/RafaelBlum/freezer-control/commit/702304e78e18f0689948f15ff7012df137354a03))
* defini quantide inicial do produto ([c9385da](https://github.com/RafaelBlum/freezer-control/commit/c9385da810f0818ac685cc5051f225412d1593be))
* dockerfile ([e98c342](https://github.com/RafaelBlum/freezer-control/commit/e98c34288e902e833c322aa4aa68ed2f36381f9c))
* enable quantity field after selected item ([b142086](https://github.com/RafaelBlum/freezer-control/commit/b142086e587cb001ebc5cf75307e7aad1a4f0344))
* fixed AppAdminPanel login ([906fe31](https://github.com/RafaelBlum/freezer-control/commit/906fe31583b0bbcb5acc810f18295758f4449fe0))
* fixed AppAdminPanel login ([d28dd6e](https://github.com/RafaelBlum/freezer-control/commit/d28dd6e38e8c472d5bcaa512ca5531783d818784))
* fixed checkout ([43243b9](https://github.com/RafaelBlum/freezer-control/commit/43243b9f5a03202dfacc7ad5ef53bcd75e281594))
* fixed default routes ([e84bf56](https://github.com/RafaelBlum/freezer-control/commit/e84bf565b7663515c7222a89f5b294030c41a240))
* fixed pix charge process ([ce0a301](https://github.com/RafaelBlum/freezer-control/commit/ce0a30171742be90140a440f419e8fa374a3612a))
* fixed store customer on checkout ([a06d6d6](https://github.com/RafaelBlum/freezer-control/commit/a06d6d67b7669c69857f462738d974624e01e2e2))
* fixed users and customers seeders ([aee0c84](https://github.com/RafaelBlum/freezer-control/commit/aee0c84a822dbaa24f92b684b44ef0dd88fb902d))
* fixed wrong route ([38427ef](https://github.com/RafaelBlum/freezer-control/commit/38427ef0c516b831f65a37b46d5b23ed638e9f0e))
* improving enum user and list badge ([54807c3](https://github.com/RafaelBlum/freezer-control/commit/54807c3fd973caaf8422f53e92d459e5a9f54e6a))
* listagem e cadastro de orders ([0b585cb](https://github.com/RafaelBlum/freezer-control/commit/0b585cb2998ec45221cc998265fd3479a88c9608))
* logo directory problem ([659ebfd](https://github.com/RafaelBlum/freezer-control/commit/659ebfdb2d8d514e17463d7051b04af442415ace))
* remove component input bugado ([6a427c2](https://github.com/RafaelBlum/freezer-control/commit/6a427c246a738a7387d3eef7667507c2a5c087c1))
* removed registration from /admin mano ([3008623](https://github.com/RafaelBlum/freezer-control/commit/3008623462ab285251b609b4abe2b75713829c34))
* small improvements on register form ([ae7310a](https://github.com/RafaelBlum/freezer-control/commit/ae7310aa0684f0eadf50021217da8fb04677f9f6))
* validating if the error is valid json ([842701a](https://github.com/RafaelBlum/freezer-control/commit/842701ab4b2e55d1c07fd4d96da52078aa46ac6b))

## 1.0.0 (2024-05-01)


Expand Down
220 changes: 220 additions & 0 deletions app/Filament/App/FreezerApp.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,220 @@
<?php

namespace App\Filament\App;

use App\Enums\PanelTypeEnum;
use App\Filament\Forms\Components\PtbrMoney;
use App\Filament\Resources\OrderResource;
use App\Filament\Resources\ProductResource;
use App\Models\Order;
use App\Models\Product;
use Filament\Forms\Components\Grid;
use Filament\Forms\Components\Hidden;
use Filament\Forms\Components\Repeater;
use Filament\Forms\Components\Section;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\Wizard;
use Filament\Forms\Components\Wizard\Step;
use Filament\Forms\Concerns\InteractsWithForms;
use Filament\Forms\Contracts\HasForms;
use Filament\Forms\Form;
use Filament\Forms\Get;
use Filament\Infolists\Infolist;
use Filament\Pages\Page;
use Filament\Support\Colors\Color;
use Filament\Support\Enums\ActionSize;
use Filament\Support\Enums\FontWeight;
use Filament\Support\Enums\MaxWidth;
use Filament\Tables\Actions\Action;
use Filament\Tables\Actions\ActionGroup;
use Filament\Tables\Actions\AttachAction;
use Filament\Tables\Actions\CreateAction;
use Filament\Tables\Actions\DeleteAction;
use Filament\Tables\Actions\EditAction;
use Filament\Tables\Actions\ViewAction;
use Filament\Tables\Columns\ImageColumn;
use Filament\Tables\Columns\Layout\Panel;
use Filament\Tables\Columns\Layout\Split;
use Filament\Tables\Columns\Layout\Stack;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Concerns\InteractsWithTable;
use Filament\Tables\Contracts\HasTable;
use Filament\Tables\Table;
use Filament\Pages\Dashboard as BaseDashboard;
use Illuminate\Support\Facades\Auth;


class FreezerApp extends BaseDashboard implements HasTable, HasForms
{
use InteractsWithTable;
use InteractsWithForms;

protected static ?string $model = Product::class;

protected static string $resource = OrderResource::class;
protected static ?string $activeNavigationIcon = 'heroicon-o-shopping-cart';
protected static ?string $navigationLabel = "Meu freezer";
protected static ?string $navigationIcon = 'heroicon-o-document-text';

protected static string $view = 'filament.app.freezer-app';

public Product $product;

public ?array $data = [];

public function mount(Product $product): void
{
$this->form->fill($product->toArray());
}

public function form(Form $form): Form
{
$product = Product::all();

return $form
->schema([
Repeater::make('items')
->schema([
Select::make('product_id')
->label('Produtos')
->options($product->pluck('name', 'id'))
->searchable()
->preload()
->required()
->reactive()
->afterStateUpdated(function ($state, $set) {
$product = Product::find($state);
$set('name', $product->name ?? '');
$set('unit_price', $product->sale_price ?? 0);
$set('cost_price', $product->cost_price ?? 0);
$set('sub_total', $product->sale_price ?? 0);
$set('quantity', 1);
})
->distinct()
->disableOptionsWhenSelectedInSiblingRepeaterItems()
->columnSpan(3),

Hidden::make('user_id')
->dehydrateStateUsing(fn($state) => Auth::id()),

TextInput::make('quantity')
->label('Quantidade')
->numeric()
->reactive()
->minValue(1)
->hint(function ($get) {
$stock = Product::find($get('product_id'))?->in_stock;

return !is_null($stock) ? "{$stock} em estoque" : null;
})
->afterStateUpdated(function ($state, $set, $get) {

$unit_price = $get('unit_price');

$sub_total = number_format((float)$state * $unit_price, 2, '.', '');

$set('sub_total', $sub_total);
})
->disabled(fn (Get $get) => empty($get('name')))
->columnSpan(2),
])->statePath('data')
->addActionLabel('Adicionar item')
->maxItems($product->count())
->columns(7)
->columnSpanFull(),
]);
}

public function table(Table $table): Table
{
return OrderResource::table($table)
->query(Product::query())//where('in_stock', '>', 0)
->columns([
Stack::make([
ImageColumn::make('image')
->height('100%')
->width('100%')
->action(
ViewAction::make()->label('')
->infolist(fn(Infolist $infolist) => ProductResource::infolist($infolist))
->form(fn(Form $form) => ProductResource::form($form))->icon('heroicon-m-eye')->tooltip('Ver mais'),
),
Stack::make([
TextColumn::make('name')
->weight(FontWeight::ExtraBold)
->alignCenter()->size(200)
->action(
ViewAction::make()->label('')
->infolist(fn(Infolist $infolist) => ProductResource::infolist($infolist))
->form(fn(Form $form) => ProductResource::form($form))->icon('heroicon-m-eye')->tooltip('Ver mais'),
),
]),

Split::make([
TextColumn::make('sale_price')
->prefix('R$ ')->size(90)->alignCenter(),

])
])->space(1),
// Menu lateral opcional
//Panel::make([
// Split::make([
// TextColumn::make('in_stock')->suffix(' Un.'),
// TextColumn::make('cost_price')->prefix('R$ '),
// ]),
//])->collapsible(),
])->headerActions([
// ...
Action::make('shopping-cart')
->label(' Finalizar comprar')
->button()
->icon('heroicon-m-plus-circle')
->color(Color::Cyan),

])
->contentGrid([
'sm' => 1,
'md' => 3,
'lg' => 3,
'xl' => 4,
'2xl' => 4
])
->description('Aproveite as bebidas mais deliciosas de nosso freezer.')
->paginated([
18,
36,
72,
'all',
])
->filters([
// ...
])
->actions([
Action::make('shopping-cart')
->label(' Comprar')
->button()
->icon('heroicon-m-plus-circle')
->color(Color::Teal)
->url(fn(Product $record): string => '#' . urlencode($record->url)),
ActionGroup::make([
EditAction::make()->form(fn(Form $form) => ProductResource::form($form)),
DeleteAction::make(),
])->tooltip("Menu")->size(ActionSize::Small)->dropdownPlacement('top-middle')
->hidden( ! auth()->user()->panel->value === PanelTypeEnum::ADMIN->value),

])
->bulkActions([
// ...
]);
}

public static function getPages(): array
{
return [
//https://filamentphp.com/docs/3.x/panels/resources/viewing-records#creating-another-view-page
//https://filamentphp.com/docs/3.x/tables/layout#custom-html
];
}

}
1 change: 1 addition & 0 deletions app/Filament/Resources/OrderResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ public static function getCustomerFormDetails(): array
->columnSpan(1),
])
->columnSpan(2),

Section::make()
->schema([
Placeholder::make('total')
Expand Down
1 change: 1 addition & 0 deletions app/Filament/Resources/OrderResource/Pages/CreateOrder.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ protected function getSteps(): array
->label('Cliente')
->disabled()
->columnSpan(1),

TextInput::make('placeholder_total')
->label('Valor total da compra')
->disabled()
Expand Down
15 changes: 15 additions & 0 deletions app/Filament/Resources/ProductResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,14 @@

use App\Filament\Forms\Components\PtbrMoney;
use App\Filament\Resources\ProductResource\Pages;
use App\Models\Blog\Link;
use App\Models\Product;
use Filament\Forms;
use Filament\Forms\Form;
use Filament\Infolists\Components\ColorEntry;
use Filament\Infolists\Components\ImageEntry;
use Filament\Infolists\Components\TextEntry;
use Filament\Infolists\Infolist;
use Filament\Resources\Resource;
use Filament\Tables;
use Filament\Tables\Actions\DeleteAction;
Expand Down Expand Up @@ -66,6 +71,16 @@ public static function form(Form $form): Form
]);
}

public static function infolist(Infolist $infolist): Infolist
{
return $infolist
->schema([
TextEntry::make('name'),
TextEntry::make('sale_price'),
ImageEntry::make('image'),
]);
}

public static function table(Table $table): Table
{
return $table
Expand Down
Loading

0 comments on commit 68e6aaf

Please sign in to comment.