tambah logo di admin bank akun

dev
Aji Kamaludin 1 year ago
parent 5a64b99860
commit dc4a5eea4b
No known key found for this signature in database
GPG Key ID: 19058F67F0083AD3

@ -16,7 +16,7 @@
# Back Office
- [ ] tambah biaya admin di deposit manual transfer
- [ ] info di ubah jadi html
- [x] info di ubah jadi html
- [ ] tambahan detail customer untuk detail mitra wbb
- [ ] detail customer level untuk tampilan screen level customer di depan
- [ ] rombak fitur affiliasi

@ -16,6 +16,11 @@ class AccountController extends Controller
]);
}
public function create()
{
return inertia('Account/Form');
}
public function store(Request $request)
{
$request->validate([
@ -23,16 +28,29 @@ class AccountController extends Controller
'bank_name' => 'required|string',
'holder_name' => 'required|string',
'account_number' => 'required|string',
'logo' => 'required|image',
]);
$file = $request->file('logo');
$file->store('uploads', 'public');
Account::create([
'name' => $request->name,
'bank_name' => $request->bank_name,
'holder_name' => $request->holder_name,
'account_number' => $request->account_number,
'logo' => $file->hashName('uploads'),
]);
session()->flash('message', ['type' => 'success', 'message' => 'Item has been saved']);
return redirect()->route('account.index')
->with('message', ['type' => 'success', 'message' => 'Item has been saved']);
}
public function edit(Account $account)
{
return inertia('Account/Form', [
'account' => $account
]);
}
public function update(Request $request, Account $account)
@ -42,8 +60,16 @@ class AccountController extends Controller
'bank_name' => 'required|string',
'holder_name' => 'required|string',
'account_number' => 'required|string',
'logo' => 'nullable|image',
]);
if ($request->hasFile('logo')) {
$file = $request->file('logo');
$file->store('uploads', 'public');
$account->fill(['logo' => $file->hashName('uploads')]);
}
$account->update([
'name' => $request->name,
'bank_name' => $request->bank_name,
@ -51,7 +77,8 @@ class AccountController extends Controller
'account_number' => $request->account_number,
]);
session()->flash('message', ['type' => 'success', 'message' => 'Item has been updated']);
return redirect()->route('account.index')
->with('message', ['type' => 'success', 'message' => 'Item has been updated']);
}
public function destroy(Account $account)

@ -68,7 +68,6 @@ class InfoController extends Controller
{
$info->delete();
return redirect()->route('info.index')
->with('message', ['type' => 'success', 'message' => 'Item has beed deleted']);
session()->flash('message', ['type' => 'success', 'message' => 'Item has beed deleted']);
}
}

@ -2,6 +2,8 @@
namespace App\Models;
use Illuminate\Database\Eloquent\Casts\Attribute;
class Account extends Model
{
protected $fillable = [
@ -12,4 +14,15 @@ class Account extends Model
'logo',
'admin_fee',
];
protected $appends = [
'logo_url',
];
protected function logoUrl(): Attribute
{
return Attribute::make(get: function () {
return asset($this->logo);
});
}
}

@ -62,8 +62,8 @@ class DummySeeder extends Seeder
public function account()
{
$banks = [
['name' => 'BRI', 'bank_name' => 'Bank Rakyat Indonesia', 'holder_name' => 'Aji Kamaludin', 'account_number' => '187391738129'],
['name' => 'Jago', 'bank_name' => 'Bank Jago', 'holder_name' => 'Aji Kamaludin', 'account_number' => '718297389172'],
['name' => 'BTPN', 'bank_name' => 'BTPN', 'holder_name' => 'Aji Kamaludin', 'account_number' => '187391738129', 'logo' => 'sample/logo-jenius.png'],
['name' => 'Jago', 'bank_name' => 'Bank Jago', 'holder_name' => 'Aji Kamaludin', 'account_number' => '718297389172', 'logo' => 'sample/logo-jago.png'],
];
foreach ($banks as $bank) {
@ -72,6 +72,7 @@ class DummySeeder extends Seeder
'bank_name' => $bank['bank_name'],
'holder_name' => $bank['holder_name'],
'account_number' => $bank['account_number'],
'logo' => $bank['logo']
]);
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 90 KiB

@ -5,6 +5,9 @@ import {
HiUserGroup,
HiInformationCircle,
HiCog,
HiOutlineCash,
HiOutlineTable,
HiCash,
} from 'react-icons/hi'
import {
HiArchiveBox,
@ -156,6 +159,11 @@ export default [
},
],
},
{
name: 'Akun Pembayaran',
show: true,
icon: HiOutlineCash,
items: [
{
name: 'Bank Akun',
show: true,
@ -164,6 +172,24 @@ export default [
active: 'account.*',
permission: 'view-account',
},
{
name: 'Payment Gateway',
show: true,
icon: HiOutlineTable,
route: route('account.index'),
active: 'account.pg',
permission: 'view-account',
},
{
name: 'Cash / Setor Tunai',
show: true,
icon: HiCash,
route: route('account.index'),
active: 'account.st',
permission: 'view-account',
},
],
},
{
name: 'Setting',
show: true,

@ -0,0 +1,115 @@
import React, { useEffect } from 'react'
import { isEmpty } from 'lodash'
import AuthenticatedLayout from '@/Layouts/AuthenticatedLayout'
import FormInput from '@/Components/FormInput'
import FormFile from '@/Components/FormFile'
import Button from '@/Components/Button'
import { Head, useForm } from '@inertiajs/react'
export default function Form(props) {
const { account } = props
const { data, setData, post, processing, errors } = useForm({
name: '',
bank_name: '',
holder_name: '',
account_number: '',
logo: null,
logo_url: ''
})
const handleOnChange = (event) => {
setData(
event.target.name,
event.target.type === 'checkbox'
? event.target.checked
? 1
: 0
: event.target.value
)
}
const handleSubmit = () => {
if (isEmpty(account) === false) {
post(route('account.update', account))
return
}
post(route('account.store'))
}
useEffect(() => {
if (isEmpty(account) === false) {
setData({
name: account.name,
bank_name: account.bank_name,
holder_name: account.holder_name,
account_number: account.account_number,
logo_url: account.logo_url
})
}
}, [account])
return (
<AuthenticatedLayout page={'Bank Akun'} action={'Form'}>
<Head title="Bank Akun" />
<div>
<div className="mx-auto sm:px-6 lg:px-8">
<div className="overflow-hidden p-4 shadow-sm sm:rounded-lg bg-white dark:bg-gray-800 flex flex-col ">
<div className="text-xl font-bold mb-4">Bank Akun</div>
<FormInput
name="name"
value={data.name}
onChange={handleOnChange}
label="Nama"
error={errors.name}
/>
<FormInput
name="bank_name"
value={data.bank_name}
onChange={handleOnChange}
label="Nama Bank"
error={errors.bank_name}
/>
<FormInput
name="holder_name"
value={data.holder_name}
onChange={handleOnChange}
label="Atas Nama Rekening"
error={errors.holder_name}
/>
<FormInput
name="account_number"
value={data.account_number}
onChange={handleOnChange}
label="Nomor Rekening"
error={errors.account_number}
/>
<FormFile
label={'Logo'}
onChange={(e) => setData('logo', e.target.files[0])}
error={errors.logo}
preview={
isEmpty(data.logo_url) === false && (
<img
src={data.logo_url}
className="mb-1 h-24 object-cover"
alt="preview"
/>
)
}
/>
<div className="mt-8">
<Button
onClick={handleSubmit}
processing={processing}
>
Simpan
</Button>
</div>
</div>
</div>
</div>
</AuthenticatedLayout>
)
}

@ -1,7 +1,5 @@
import React, { useEffect, useState } from 'react'
import { router } from '@inertiajs/react'
import { usePrevious } from 'react-use'
import { Head } from '@inertiajs/react'
import React from 'react'
import { Head, Link, router } from '@inertiajs/react'
import { Button, Dropdown } from 'flowbite-react'
import { HiPencil, HiTrash } from 'react-icons/hi'
import { useModalState } from '@/hooks'
@ -50,12 +48,9 @@ export default function Account(props) {
<div className="p-6 overflow-hidden shadow-sm sm:rounded-lg bg-gray-200 dark:bg-gray-800 space-y-4">
<div className="flex justify-between">
{canCreate && (
<Button
size="sm"
onClick={() => toggleFormModal()}
>
Tambah
</Button>
<Link href={route('account.create')}>
<Button size="sm">Tambah</Button>
</Link>
)}
</div>
<div className="overflow-auto">
@ -81,6 +76,12 @@ export default function Account(props) {
>
Nomor Rekening
</th>
<th
scope="col"
className="py-3 px-6"
>
Logo
</th>
<th
scope="col"
className="py-3 px-6"
@ -105,6 +106,9 @@ export default function Account(props) {
<td className="py-4 px-6">
{account.account_number}
</td>
<td className="py-4 px-6">
<img src={account.logo_url} alt='bank logo alt' className='h-5'/>
</td>
<td className="py-4 px-6 flex justify-end">
<Dropdown
label={'Opsi'}
@ -114,19 +118,13 @@ export default function Account(props) {
size={'sm'}
>
{canUpdate && (
<Dropdown.Item
onClick={() =>
toggleFormModal(
account
)
}
>
<div className="flex space-x-1 items-center">
<Dropdown.Item>
<Link href={route('account.edit', account)} className="flex space-x-1 items-center">
<HiPencil />
<div>
Ubah
</div>
</div>
</Link>
</Dropdown.Item>
)}
{canDelete && (

@ -1,95 +0,0 @@
import React, { useEffect } from 'react'
import Modal from '@/Components/Modal'
import { useForm } from '@inertiajs/react'
import Button from '@/Components/Button'
import FormInput from '@/Components/FormInput'
import RoleSelectionInput from '../Role/SelectionInput'
import { isEmpty } from 'lodash'
export default function FormModal(props) {
const { modalState } = props
const { data, setData, post, put, processing, errors, reset, clearErrors } =
useForm({
info: '',
is_publish: 1,
})
const handleOnChange = (event) => {
setData(
event.target.name,
event.target.type === 'checkbox'
? event.target.checked
? 1
: 0
: event.target.value
)
}
const handleReset = () => {
modalState.setData(null)
reset()
clearErrors()
}
const handleClose = () => {
handleReset()
modalState.toggle()
}
const handleSubmit = () => {
const info = modalState.data
if (info !== null) {
put(route('info.update', info), {
onSuccess: () => handleClose(),
})
return
}
post(route('info.store'), {
onSuccess: () => handleClose(),
})
}
useEffect(() => {
const info = modalState.data
if (isEmpty(info) === false) {
setData({
info: info.title,
is_publish: info.is_publish,
})
return
}
}, [modalState])
return (
<Modal isOpen={modalState.isOpen} toggle={handleClose} title={'Info'}>
<FormInput
name="info"
value={data.info}
onChange={handleOnChange}
label="info"
error={errors.info}
/>
<div className="my-4">
<div className="mb-1 text-sm">Publish </div>
<select
className="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5"
onChange={handleOnChange}
value={+data.is_publish}
name="is_publish"
>
<option value={0}>No</option>
<option value={1}>Yes</option>
</select>
</div>
<div className="flex items-center">
<Button onClick={handleSubmit} processing={processing}>
Simpan
</Button>
<Button onClick={handleClose} type="secondary">
Batal
</Button>
</div>
</Modal>
)
}

@ -1,17 +1,14 @@
import React, { useEffect, useState } from 'react'
import React from 'react'
import { Link, router } from '@inertiajs/react'
import { usePrevious } from 'react-use'
import { Head } from '@inertiajs/react'
import { Button, Dropdown } from 'flowbite-react'
import { HiPencil, HiTrash } from 'react-icons/hi'
import { useModalState } from '@/hooks'
import { hasPermission } from '@/utils'
import AuthenticatedLayout from '@/Layouts/AuthenticatedLayout'
import Pagination from '@/Components/Pagination'
import ModalConfirm from '@/Components/ModalConfirm'
import FormModal from './FormModal'
import SearchInput from '@/Components/SearchInput'
import { hasPermission } from '@/utils'
export default function Info(props) {
const {

@ -79,8 +79,10 @@ Route::middleware(['http_secure_aware', 'inertia.admin'])
// Account
Route::get('/accounts', [AccountController::class, 'index'])->name('account.index');
Route::get('/accounts/create', [AccountController::class, 'create'])->name('account.create');
Route::post('/accounts', [AccountController::class, 'store'])->name('account.store');
Route::put('/accounts/{account}', [AccountController::class, 'update'])->name('account.update');
Route::get('/accounts/{account}', [AccountController::class, 'edit'])->name('account.edit');
Route::post('/accounts/{account}', [AccountController::class, 'update'])->name('account.update');
Route::delete('/accounts/{account}', [AccountController::class, 'destroy'])->name('account.destroy');
// upload

Loading…
Cancel
Save