Aji Kamaludin 1 year ago
parent 0abb8f5a07
commit 1374340b4d
No known key found for this signature in database
GPG Key ID: 19058F67F0083AD3

@ -2,11 +2,15 @@
namespace App\Http\Controllers;
use App\Models\Customer;
class GeneralController extends Controller
{
public function index()
{
return inertia('Dashboard');
return inertia('Dashboard', [
'customer_count' => Customer::count()
]);
}
public function maintance()

@ -2,8 +2,10 @@
namespace App\Http\Controllers;
use App\Models\Customer;
use App\Models\Setting;
use Illuminate\Http\Request;
use Illuminate\Support\Str;
class HomeController extends Controller
{
@ -11,6 +13,8 @@ class HomeController extends Controller
{
return inertia('Home', [
'app_name' => Setting::where('key', 'app_name')->value('value'),
'customer' => null,
'point' => 0,
]);
}
@ -19,5 +23,18 @@ class HomeController extends Controller
$request->validate([
'customer_code' => 'required|string|exists:customers,code'
]);
$name = "";
$customer = Customer::where('code', $request->customer_code)->first();
$names = explode(' ', $customer->name);
foreach ($names as $n) {
$name .= Str::mask($n, '*', 3) . ' ';
}
return inertia('Home', [
'app_name' => Setting::where('key', 'app_name')->value('value'),
'customer' => $name,
'point' => $customer->last_point,
'names' => $names
]);
}
}

@ -84,6 +84,7 @@ export default function Customer(props) {
onItemSelected={(id) =>
setCustomerId(id)
}
placeholder="filter customer"
/>
</div>
<div className="w-full">

@ -1,8 +1,10 @@
import React from 'react';
import AuthenticatedLayout from '@/Layouts/AuthenticatedLayout';
import { Head } from '@inertiajs/react';
import React from 'react'
import AuthenticatedLayout from '@/Layouts/AuthenticatedLayout'
import { Head } from '@inertiajs/react'
import { formatIDR } from '@/utils'
export default function Dashboard(props) {
const { customer_count } = props
return (
<AuthenticatedLayout
auth={props.auth}
@ -15,11 +17,18 @@ export default function Dashboard(props) {
<div>
<div className="mx-auto sm:px-6 lg:px-8 ">
<div className="overflow-hidden shadow-sm sm:rounded-lg bg-white dark:bg-gray-800">
<div className="p-6 dark:text-gray-100 ">Dashboard</div>
<div className="">
<div className="grid grid-cols-4 gap-1">
<div className="px-3 py-2 flex flex-col rounded-md bg-white shadow-md">
<div className="text-2xl">Total Customer</div>
<div className="text-3xl font-bold">
{formatIDR(customer_count)}
</div>
</div>
</div>
</div>
</div>
</div>
</AuthenticatedLayout>
);
)
}

@ -4,7 +4,7 @@ import InputError from '@/Components/Defaults/InputError'
import { Head, Link, useForm } from '@inertiajs/react'
import { Button, TextInput, Label, Checkbox, Spinner } from 'flowbite-react'
export default function Login({ app_name }) {
export default function Login({ app_name, customer, point }) {
const { data, setData, post, processing, errors, reset } = useForm({
customer_code: '',
})
@ -44,7 +44,6 @@ export default function Login({ app_name }) {
type="text"
name="customer_code"
value={data.customer_code}
className="mt-1 block w-full"
autoFocus={true}
onChange={onHandleChange}
placeholder="Customer Code"
@ -53,9 +52,24 @@ export default function Login({ app_name }) {
<InputError
message={errors.customer_code}
className="mt-2"
className="mt-5"
/>
</div>
{customer !== null && (
<div
className="p-4 my-4 text-sm text-blue-800 rounded-lg bg-blue-50 dark:bg-gray-800 dark:text-blue-400"
role="alert"
>
<div className="text-lg">
Customer:{' '}
<span className="font-bold">{customer}</span>
</div>
<div className="text-lg">
Point:{' '}
<span className="font-bold">{point}</span>
</div>
</div>
)}
<div className="flex items-center justify-end mt-4">
<Button onClick={submit} disabled={processing}>

Loading…
Cancel
Save