diff --git a/TODO.md b/TODO.md
index 790f9b9..3757832 100644
--- a/TODO.md
+++ b/TODO.md
@@ -10,7 +10,7 @@
- [x] CRUD Voucher
- [x] Import Voucher
- [x] Setting Web (enable affilate, amount bonus affilate)
-- [ ] Setting Level Customer (view levels, edit name of level,minimal saldo, max amount saldo, max hutang)
+- [x] Setting Level Customer (view levels, edit name of level,minimal saldo, max amount saldo, max hutang)
- [ ] Deposit Menu (view daftar histori deposit)
- [ ] Manual Approve Deposit
- [ ] Setting Bonus Coin (memasukan amount bonus coin yang didapat dengan level dan harga voucher) - coin rewards
diff --git a/app/Http/Controllers/CustomerLevelController.php b/app/Http/Controllers/CustomerLevelController.php
new file mode 100644
index 0000000..f3ccd79
--- /dev/null
+++ b/app/Http/Controllers/CustomerLevelController.php
@@ -0,0 +1,36 @@
+ $query->paginate()
+ ]);
+ }
+
+ public function update(Request $request, CustomerLevel $customerLevel)
+ {
+ $request->validate([
+ 'name' => 'required|string',
+ 'description' => 'nullable|string',
+ 'min_amount' => 'required|numeric|min:0',
+ 'max_amount' => 'required|numeric|min:0'
+ ]);
+
+ $customerLevel->update([
+ 'name' => $request->name,
+ 'description' => $request->description,
+ 'min_amount' => $request->min_amount,
+ 'max_amount' => $request->max_amount,
+ ]);
+
+ session()->flash('message', ['type' => 'success', 'message' => 'Item has beed updated']);
+ }
+}
diff --git a/database/seeders/InstallationSeed.php b/database/seeders/InstallationSeed.php
index c2d25fb..a0fdd11 100644
--- a/database/seeders/InstallationSeed.php
+++ b/database/seeders/InstallationSeed.php
@@ -38,10 +38,10 @@ class InstallationSeed extends Seeder
public function customer_levels()
{
$levels = [
- ['name' => 'Basic', 'key' => 'basic'],
- ['name' => 'Silver', 'key' => 'silver'],
- ['name' => 'Gold', 'key' => 'gold'],
- ['name' => 'Platinum', 'key' => 'platinum'],
+ ['name' => 'Basic', 'key' => 'basic', 'description' => '-', 'min_amount' => '100000', 'max_amount' => '500000'],
+ ['name' => 'Silver', 'key' => 'silver', 'description' => '-', 'min_amount' => '100000', 'max_amount' => '1000000'],
+ ['name' => 'Gold', 'key' => 'gold', 'description' => '-', 'min_amount' => '100000', 'max_amount' => '2000000'],
+ ['name' => 'Platinum', 'key' => 'platinum', 'description' => '-', 'min_amount' => '100000', 'max_amount' => '3000000'],
];
foreach ($levels as $level) {
diff --git a/database/seeders/PermissionSeeder.php b/database/seeders/PermissionSeeder.php
index 5a12655..562eb22 100644
--- a/database/seeders/PermissionSeeder.php
+++ b/database/seeders/PermissionSeeder.php
@@ -51,10 +51,8 @@ class PermissionSeeder extends Seeder
['id' => Str::ulid(), 'label' => 'View Customer', 'name' => 'view-customer'],
['id' => Str::ulid(), 'label' => 'Delete Customer', 'name' => 'delete-customer'],
- ['id' => Str::ulid(), 'label' => 'Create Customer Level', 'name' => 'create-customer-level'],
['id' => Str::ulid(), 'label' => 'Update Customer Level', 'name' => 'update-customer-level'],
['id' => Str::ulid(), 'label' => 'View Customer Level', 'name' => 'view-customer-level'],
- ['id' => Str::ulid(), 'label' => 'Delete Customer Level', 'name' => 'delete-customer-level'],
['id' => Str::ulid(), 'label' => 'Create Customer Verification', 'name' => 'create-customer-verification'],
['id' => Str::ulid(), 'label' => 'Update Customer Verification', 'name' => 'update-customer-verification'],
diff --git a/resources/js/Layouts/Partials/routes.js b/resources/js/Layouts/Partials/routes.js
index 502cd8c..2fb4418 100644
--- a/resources/js/Layouts/Partials/routes.js
+++ b/resources/js/Layouts/Partials/routes.js
@@ -32,6 +32,14 @@ export default [
active: 'customer.*',
permission: 'view-customer',
},
+ {
+ name: 'Customer Level',
+ show: true,
+ icon: HiUserCircle,
+ route: route('customer-level.index'),
+ active: 'customer-level.*',
+ permission: 'view-customer-level',
+ },
{
name: 'Bank Akun',
show: true,
diff --git a/resources/js/Pages/CustomerLevel/FormModal.jsx b/resources/js/Pages/CustomerLevel/FormModal.jsx
new file mode 100644
index 0000000..3bcfe88
--- /dev/null
+++ b/resources/js/Pages/CustomerLevel/FormModal.jsx
@@ -0,0 +1,104 @@
+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({
+ name: '',
+ description: '',
+ min_amount: 0,
+ max_amount: 0,
+ })
+
+ 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 customerLevel = modalState.data
+ put(route('customer-level.update', customerLevel.id), {
+ onSuccess: () => handleClose(),
+ })
+ }
+
+ useEffect(() => {
+ const customerLevel = modalState.data
+ if (isEmpty(customerLevel) === false) {
+ setData({
+ name: customerLevel.name,
+ description: customerLevel.description,
+ min_amount: customerLevel.min_amount,
+ max_amount: customerLevel.max_amount,
+ })
+ return
+ }
+ }, [modalState])
+
+ return (
+
+ Name + | ++ Description + | ++ Minimal Deposit + | ++ Maximal Deposit + | ++ |
---|---|---|---|---|
+ {level.name} + | ++ {level.description} + | ++ {formatIDR( + level.min_amount + )} + | ++ {formatIDR( + level.max_amount + )} + | +
+
+
+
+ Ubah
+
+ |
+