bit fix sale customer, verified partial, and replan for paylater and coin
parent
b5e55ca95c
commit
4d56b27731
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Customer;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Customer;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class VerificationController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
return inertia('Verification/Index');
|
||||
}
|
||||
|
||||
public function update(Request $request)
|
||||
{
|
||||
$request->validate(['image' => 'required|image']);
|
||||
|
||||
$customer = Customer::where('id', auth()->id())->first();
|
||||
|
||||
$file = $request->file('image');
|
||||
$file->store('uploads/KTP', 'public');
|
||||
$customer->update([
|
||||
'identity_image' => $file->hashName('uploads/KTP'),
|
||||
'identity_verified' => Customer::IN_VERICATION,
|
||||
]);
|
||||
|
||||
return redirect()->route('customer.verification')
|
||||
->with('message', ['type' => 'success', 'message' => 'verification is in progress']);
|
||||
}
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Customer;
|
||||
use App\Models\CustomerLevel;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class VerificationController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
$query = Customer::with(['level'])
|
||||
->where('identity_verified', Customer::IN_VERICATION)
|
||||
->orderBy('updated_at', 'desc');
|
||||
|
||||
return inertia('Verification/Index', [
|
||||
'query' => $query->paginate()
|
||||
]);
|
||||
}
|
||||
|
||||
public function edit(Customer $customer)
|
||||
{
|
||||
$levels = [
|
||||
CustomerLevel::where('key', CustomerLevel::GOLD)->first(),
|
||||
CustomerLevel::where('key', CustomerLevel::PLATINUM)->first(),
|
||||
];
|
||||
|
||||
return inertia('Verification/Form', [
|
||||
'customer' => $customer->load(['level']),
|
||||
'levels' => $levels
|
||||
]);
|
||||
}
|
||||
|
||||
public function update(Request $request, Customer $customer)
|
||||
{
|
||||
// TODO: here
|
||||
$request->validate([]);
|
||||
//
|
||||
$customer->update([]);
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
class PaylaterCustomer extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'limit',
|
||||
'usage',
|
||||
'description',
|
||||
'customer_id',
|
||||
];
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('paylater_customers', function (Blueprint $table) {
|
||||
$table->ulid('id')->primary();
|
||||
|
||||
$table->text('description')->nullable();
|
||||
$table->ulid('customer_id')->nullable();
|
||||
$table->decimal('limit', 20, 2)->default(0);
|
||||
$table->decimal('usage', 20, 2)->default(0);
|
||||
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
$table->ulid('created_by')->nullable();
|
||||
$table->ulid('updated_by')->nullable();
|
||||
$table->ulid('deleted_by')->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('paylater_customers');
|
||||
}
|
||||
};
|
Binary file not shown.
After Width: | Height: | Size: 6.4 KiB |
@ -0,0 +1,102 @@
|
||||
import React, { useState } from 'react'
|
||||
import { Head, useForm, router, usePage } from '@inertiajs/react'
|
||||
import CustomerLayout from '@/Layouts/CustomerLayout'
|
||||
import FormFile from '@/Components/FormFile'
|
||||
import { HiCheckCircle, HiClock } from 'react-icons/hi2'
|
||||
|
||||
// 0 yuk verifikasi
|
||||
const VerificationForm = () => {
|
||||
const {
|
||||
props: {
|
||||
auth: { user },
|
||||
},
|
||||
} = usePage()
|
||||
const [show, setShow] = useState(false)
|
||||
|
||||
const { setData, post, errors } = useForm({ image: null })
|
||||
|
||||
const handleSubmit = () => {
|
||||
post(route('customer.verification'))
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="px-4 text-gray-400">
|
||||
upgrade akun kamu untuk mendapatkan banefit lebih, cukup lakukan
|
||||
verifikasi data dengan upload foto KTP kamu
|
||||
</div>
|
||||
{show === false ? (
|
||||
<div
|
||||
className="w-full px-4 mt-10"
|
||||
onClick={() => setShow(true)}
|
||||
>
|
||||
<div className="py-3 px-4 rounded-full border bg-blue-600 text-white hover:bg-gray-100 hover:text-black">
|
||||
Verifikasi
|
||||
</div>
|
||||
</div>
|
||||
) : (
|
||||
<div className="w-full flex flex-col px-5">
|
||||
<FormFile
|
||||
label="KTP"
|
||||
onChange={(e) => setData('image', e.target.files[0])}
|
||||
error={errors.image}
|
||||
preview={
|
||||
<img
|
||||
src={`${user.identity_image_url}`}
|
||||
className="w-full object-fill h-48 mb-1 "
|
||||
alt="ktp image"
|
||||
/>
|
||||
}
|
||||
/>
|
||||
|
||||
<div
|
||||
className="py-3 px-4 rounded-full border bg-blue-600 text-white hover:bg-gray-100 hover:text-black"
|
||||
onClick={() => handleSubmit()}
|
||||
>
|
||||
Upload
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
// 1 verified
|
||||
const Verified = () => {
|
||||
return (
|
||||
<div className="flex flex-col w-full items-center my-auto">
|
||||
<HiCheckCircle className="h-32 w-32 text-green-500" />
|
||||
<div className="font-bold text-lg px-10 pt-5 text-center">
|
||||
Akun anda berhasil terverifikasi
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
// 2 your data is in review
|
||||
const VerificationInProgress = () => {
|
||||
return (
|
||||
<div className="flex flex-col w-full items-center my-auto">
|
||||
<HiClock className="h-32 w-32 text-gray-400 border rounded-full border-gray-600" />
|
||||
<div className="font-bold text-lg px-10 pt-5 text-center">
|
||||
Data anda sedang kami proses untuk verifikasi
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default function Index({ auth: { user } }) {
|
||||
return (
|
||||
<CustomerLayout>
|
||||
<Head title="Upgrade Member" />
|
||||
<div className="flex flex-col min-h-[calc(95dvh)]">
|
||||
<div className="px-4 pt-10 text-2xl font-bold">
|
||||
Upgrade Member
|
||||
</div>
|
||||
{+user.identity_verified === 0 && <VerificationForm />}
|
||||
{+user.identity_verified === 1 && <Verified />}
|
||||
{+user.identity_verified === 2 && <VerificationInProgress />}
|
||||
</div>
|
||||
</CustomerLayout>
|
||||
)
|
||||
}
|
@ -0,0 +1,102 @@
|
||||
import React, { useEffect, useState } from 'react'
|
||||
import { useForm, Head, Link } from '@inertiajs/react'
|
||||
import { isEmpty } from 'lodash'
|
||||
|
||||
import AuthenticatedLayout from '@/Layouts/AuthenticatedLayout'
|
||||
import Button from '@/Components/Button'
|
||||
|
||||
export default function Form(props) {
|
||||
const { customer, levels } = props
|
||||
const { data, setData, post, processing, errors, reset, clearErrors } =
|
||||
useForm({
|
||||
level: '',
|
||||
image_prove_url: '',
|
||||
})
|
||||
|
||||
const handleOnChange = (event) => {
|
||||
setData(
|
||||
event.target.name,
|
||||
event.target.type === 'checkbox'
|
||||
? event.target.checked
|
||||
? 1
|
||||
: 0
|
||||
: event.target.value
|
||||
)
|
||||
}
|
||||
|
||||
const handleSubmit = () => {
|
||||
post(route('customer-verification.update', customer))
|
||||
}
|
||||
|
||||
return (
|
||||
<AuthenticatedLayout
|
||||
auth={props.auth}
|
||||
errors={props.errors}
|
||||
flash={props.flash}
|
||||
page={'Verifikasi Customer'}
|
||||
action={'Form'}
|
||||
>
|
||||
<Head title="Verifikasi Customer" />
|
||||
|
||||
<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">
|
||||
Verifikasi Customer
|
||||
</div>
|
||||
<table className="relative w-full overflow-x-auto border-collapse border p-2 rounded">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td className="font-bold">Customer</td>
|
||||
<td>:</td>
|
||||
<td className="hover:underline">
|
||||
<Link
|
||||
href={route(
|
||||
'customer.edit',
|
||||
customer
|
||||
)}
|
||||
>
|
||||
{customer.name}
|
||||
</Link>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<div className="py-2">
|
||||
<img
|
||||
src={customer.identity_image_url}
|
||||
className="w-full object-fill h-96"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="my-4">
|
||||
<div className="mb-1 text-sm">Level Upgrade</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.level}
|
||||
name="level"
|
||||
>
|
||||
<option value=""></option>
|
||||
{levels.map((level) => (
|
||||
<option value={level.key} key={level.key}>
|
||||
{level.name}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</div>
|
||||
<div className="flex items-center">
|
||||
<Button
|
||||
onClick={handleSubmit}
|
||||
processing={processing}
|
||||
>
|
||||
Simpan
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</AuthenticatedLayout>
|
||||
)
|
||||
}
|
@ -0,0 +1,163 @@
|
||||
import React, { useEffect, useState } from 'react'
|
||||
import { router } from '@inertiajs/react'
|
||||
import { usePrevious } from 'react-use'
|
||||
import { Head } from '@inertiajs/react'
|
||||
import { Dropdown } from 'flowbite-react'
|
||||
import { HiEye } from 'react-icons/hi2'
|
||||
|
||||
import AuthenticatedLayout from '@/Layouts/AuthenticatedLayout'
|
||||
import Pagination from '@/Components/Pagination'
|
||||
import SearchInput from '@/Components/SearchInput'
|
||||
|
||||
export default function Index(props) {
|
||||
const {
|
||||
query: { links, data },
|
||||
auth,
|
||||
} = props
|
||||
|
||||
const [search, setSearch] = useState('')
|
||||
const preValue = usePrevious(search)
|
||||
|
||||
const params = { q: search }
|
||||
useEffect(() => {
|
||||
if (preValue) {
|
||||
router.get(
|
||||
route(route().current()),
|
||||
{ q: search },
|
||||
{
|
||||
replace: true,
|
||||
preserveState: true,
|
||||
}
|
||||
)
|
||||
}
|
||||
}, [search])
|
||||
|
||||
return (
|
||||
<AuthenticatedLayout
|
||||
auth={props.auth}
|
||||
errors={props.errors}
|
||||
flash={props.flash}
|
||||
page={'Verifikasi Customer'}
|
||||
action={''}
|
||||
>
|
||||
<Head title="Verifikasi Customer" />
|
||||
|
||||
<div>
|
||||
<div className="mx-auto sm:px-6 lg:px-8 ">
|
||||
<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">
|
||||
<div className="flex items-center">
|
||||
<SearchInput
|
||||
onChange={(e) => setSearch(e.target.value)}
|
||||
value={search}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div className="overflow-auto">
|
||||
<div>
|
||||
<table className="w-full text-sm text-left text-gray-500 dark:text-gray-400 mb-4">
|
||||
<thead className="text-xs text-gray-700 uppercase bg-gray-50 dark:bg-gray-700 dark:text-gray-400">
|
||||
<tr>
|
||||
<th
|
||||
scope="col"
|
||||
className="py-3 px-6"
|
||||
>
|
||||
Nama
|
||||
</th>
|
||||
<th
|
||||
scope="col"
|
||||
className="py-3 px-6"
|
||||
>
|
||||
Level
|
||||
</th>
|
||||
<th
|
||||
scope="col"
|
||||
className="py-3 px-6"
|
||||
>
|
||||
Deposit
|
||||
</th>
|
||||
<th
|
||||
scope="col"
|
||||
className="py-3 px-6"
|
||||
>
|
||||
Coin
|
||||
</th>
|
||||
<th
|
||||
scope="col"
|
||||
className="py-3 px-6"
|
||||
>
|
||||
Referal Code
|
||||
</th>
|
||||
<th
|
||||
scope="col"
|
||||
className="py-3 px-6 w-1/8"
|
||||
/>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{data.map((customer) => (
|
||||
<tr
|
||||
className="bg-white border-b dark:bg-gray-800 dark:border-gray-700"
|
||||
key={customer.id}
|
||||
>
|
||||
<td
|
||||
scope="row"
|
||||
className="py-4 px-6 font-medium text-gray-900 whitespace-nowrap dark:text-white"
|
||||
>
|
||||
{customer.name}
|
||||
</td>
|
||||
<td
|
||||
scope="row"
|
||||
className="py-4 px-6"
|
||||
>
|
||||
{customer.level.name}
|
||||
</td>
|
||||
<td
|
||||
scope="row"
|
||||
className="py-4 px-6"
|
||||
>
|
||||
{customer.display_deposit}
|
||||
</td>
|
||||
<td
|
||||
scope="row"
|
||||
className="py-4 px-6"
|
||||
>
|
||||
{customer.display_coin}
|
||||
</td>
|
||||
<td
|
||||
scope="row"
|
||||
className="py-4 px-6"
|
||||
>
|
||||
{customer.referral_code}
|
||||
</td>
|
||||
<td className="py-4 px-6 flex justify-center">
|
||||
<div
|
||||
className="flex space-x-1 items-center hover:underline"
|
||||
onClick={() => {
|
||||
router.get(
|
||||
route(
|
||||
'customer-verification.edit',
|
||||
customer
|
||||
)
|
||||
)
|
||||
}}
|
||||
>
|
||||
<HiEye />
|
||||
<div>Lihat</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div className="w-full flex items-center justify-center">
|
||||
<Pagination links={links} params={params} />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</AuthenticatedLayout>
|
||||
)
|
||||
}
|
Loading…
Reference in New Issue