customer login and profile page
parent
cabe8a2e71
commit
c64cf07702
@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Customer;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Customer;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Laravel\Socialite\Facades\Socialite;
|
||||
use SocialiteProviders\Manager\Config;
|
||||
|
||||
class AuthController extends Controller
|
||||
{
|
||||
public function login()
|
||||
{
|
||||
return inertia('Home/Auth/Login');
|
||||
}
|
||||
|
||||
public function update(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'username' => 'string|required|alpha_dash',
|
||||
'password' => 'string|required',
|
||||
]);
|
||||
|
||||
$isAuth = Auth::guard('customer')->attempt(['username' => $request->username, 'password' => $request->password]);
|
||||
if ($isAuth) {
|
||||
return redirect()->route('home.index');
|
||||
}
|
||||
|
||||
return redirect()->route('customer.login')
|
||||
->with('message', ['type' => 'error', 'message' => 'invalid credentials']);
|
||||
}
|
||||
|
||||
public function signin_google()
|
||||
{
|
||||
$config = new Config(
|
||||
env('GOOGLE_CLIENT_ID'),
|
||||
env('GOOGLE_CLIENT_SECRET'),
|
||||
route('customer.login.callback_google')
|
||||
);
|
||||
|
||||
return Socialite::driver('google')
|
||||
->setConfig($config)
|
||||
->redirect();
|
||||
}
|
||||
|
||||
public function callback_google()
|
||||
{
|
||||
$user = Socialite::driver('google')->user();
|
||||
$customer = Customer::where('google_id', $user->id)->first();
|
||||
if ($customer == null) {
|
||||
$customer = Customer::create([
|
||||
'fullname' => $user->name,
|
||||
'name' => $user->nickname,
|
||||
'email' => $user->email,
|
||||
'username' => $user->id,
|
||||
'google_id' => $user->id,
|
||||
'image' => 'GOOGLE-' . $user->avatar,
|
||||
'google_oauth_response' => json_encode($user),
|
||||
]);
|
||||
}
|
||||
|
||||
Auth::guard('customer')->loginUsingId($customer->id);
|
||||
|
||||
return redirect()->route('home.index');
|
||||
}
|
||||
|
||||
public function register()
|
||||
{
|
||||
return inertia('Home/Auth/Register');
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'fullname' => 'string|required',
|
||||
'name' => 'string|required',
|
||||
'address' => 'string|required',
|
||||
'phone' => 'string|required|numeric',
|
||||
'username' => 'string|required|min:5|alpha_dash|unique:customers,username',
|
||||
'password' => 'string|required|min:8|confirmed',
|
||||
]);
|
||||
|
||||
$customer = Customer::create([
|
||||
'fullname' => $request->fullname,
|
||||
'name' => $request->name,
|
||||
'address' => $request->address,
|
||||
'phone' => $request->phone,
|
||||
'username' => $request->username,
|
||||
'password' => bcrypt($request->password),
|
||||
]);
|
||||
|
||||
Auth::guard('customer')->loginUsingId($customer->id);
|
||||
|
||||
return redirect()->route('home.index');
|
||||
}
|
||||
|
||||
public function destroy()
|
||||
{
|
||||
Auth::logout();
|
||||
|
||||
return redirect()->route('customer.login')
|
||||
->with('message', ['type' => 'success', 'message' => 'you are logged out, see you next time']);
|
||||
}
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Customer;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ProfileController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
return inertia('Home/Profile/Index');
|
||||
}
|
||||
|
||||
public function show()
|
||||
{
|
||||
return inertia('Home/Profile/Form');
|
||||
}
|
||||
|
||||
public function update(Request $request)
|
||||
{
|
||||
$customer = auth()->user();
|
||||
|
||||
$request->validate([
|
||||
'fullname' => 'string|required',
|
||||
'name' => 'string|required',
|
||||
'address' => 'string|required',
|
||||
'phone' => 'string|required|numeric',
|
||||
'username' => 'string|required|min:5|alpha_dash|unique:customers,username,' . $customer->id,
|
||||
'password' => 'nullable|string|min:8|confirmed',
|
||||
'image' => 'nullable|image',
|
||||
]);
|
||||
|
||||
if ($request->hasFile('image')) {
|
||||
$file = $request->file('image');
|
||||
$file->store('uploads', 'public');
|
||||
$customer->image = $file->hashName();
|
||||
}
|
||||
|
||||
$customer->update([
|
||||
'fullname' => $request->fullname,
|
||||
'name' => $request->name,
|
||||
'address' => $request->address,
|
||||
'phone' => $request->phone,
|
||||
'username' => $request->username,
|
||||
'password' => bcrypt($request->password),
|
||||
'image' => $customer->image,
|
||||
]);
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class GuardCustomer
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
|
||||
*/
|
||||
public function handle(Request $request, Closure $next): Response
|
||||
{
|
||||
Auth::shouldUse('customer');
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1 @@
|
||||
<svg stroke="currentColor" fill="none" stroke-width="1.5" viewBox="0 0 24 24" aria-hidden="true" class="text-white h-14 w-14" height="1em" width="1em" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" d="M17.982 18.725A7.488 7.488 0 0012 15.75a7.488 7.488 0 00-5.982 2.975m11.963 0a9 9 0 10-11.963 0m11.963 0A8.966 8.966 0 0112 21a8.966 8.966 0 01-5.982-2.275M15 9.75a3 3 0 11-6 0 3 3 0 016 0z"></path></svg>
|
After Width: | Height: | Size: 446 B |
@ -0,0 +1,39 @@
|
||||
import { isEmpty } from 'lodash'
|
||||
import React from 'react'
|
||||
|
||||
export default function Alert({ type = '', children }) {
|
||||
if (type === null) {
|
||||
return ''
|
||||
}
|
||||
|
||||
if (type === 'error') {
|
||||
return (
|
||||
<div
|
||||
className="p-4 mb-4 text-sm text-red-800 rounded-lg bg-red-50 dark:bg-gray-800 dark:text-red-400"
|
||||
role="alert"
|
||||
>
|
||||
{children}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
if (type === 'success') {
|
||||
return (
|
||||
<div
|
||||
className="p-4 mb-4 text-sm text-red-800 rounded-lg bg-red-50 dark:bg-gray-800 dark:text-red-400"
|
||||
role="alert"
|
||||
>
|
||||
{children}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<div
|
||||
className="p-4 mb-4 text-sm text-blue-800 rounded-lg bg-blue-50 dark:bg-gray-800 dark:text-blue-400"
|
||||
role="alert"
|
||||
>
|
||||
{children}
|
||||
</div>
|
||||
)
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
import React, { useRef } from 'react'
|
||||
|
||||
export default function FormFile({
|
||||
label,
|
||||
onChange,
|
||||
error,
|
||||
preview,
|
||||
inputRef = useRef(),
|
||||
}) {
|
||||
return (
|
||||
<div className="my-4">
|
||||
{label !== '' && (
|
||||
<label
|
||||
htmlFor={label}
|
||||
className="block mb-2 text-sm font-medium text-gray-900 dark:text-white"
|
||||
>
|
||||
{label}
|
||||
</label>
|
||||
)}
|
||||
{preview && preview}
|
||||
<input
|
||||
id={label}
|
||||
className="block w-full mb-5 text-xs text-gray-900 border border-gray-300 rounded-lg cursor-pointer bg-gray-50 dark:text-gray-400 focus:outline-none dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400"
|
||||
type="file"
|
||||
onChange={onChange}
|
||||
ref={inputRef}
|
||||
/>
|
||||
{error && (
|
||||
<p className="mb-2 text-sm text-red-600 dark:text-red-500">
|
||||
{error}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
@ -1,22 +1,50 @@
|
||||
import React from "react";
|
||||
import Input from "./Input";
|
||||
import React from 'react'
|
||||
import Input from './Input'
|
||||
|
||||
export default function FormInput({ type, name, onChange, value, label, className, error, autoComplete, autoFocus, placeholder, disabled, readOnly}) {
|
||||
export default function FormInput({
|
||||
type,
|
||||
name,
|
||||
onChange,
|
||||
value,
|
||||
label,
|
||||
className,
|
||||
error,
|
||||
autoComplete,
|
||||
autoFocus,
|
||||
placeholder,
|
||||
disabled,
|
||||
readOnly,
|
||||
onKeyDownCapture,
|
||||
leftItem,
|
||||
formClassName,
|
||||
}) {
|
||||
return (
|
||||
<div className={className}>
|
||||
<label htmlFor="first_name" className="block mb-2 text-sm font-medium text-gray-900 dark:text-white">{label}</label>
|
||||
<Input
|
||||
type={type}
|
||||
name={name}
|
||||
onChange={onChange}
|
||||
value={value}
|
||||
error={error}
|
||||
autoComplete={autoComplete}
|
||||
autoFocus={autoFocus}
|
||||
placeholder={placeholder}
|
||||
disabled={disabled}
|
||||
readOnly={readOnly}
|
||||
/>
|
||||
<label
|
||||
htmlFor={name}
|
||||
className="block mb-2 text-sm font-medium text-gray-900 dark:text-white"
|
||||
>
|
||||
{label}
|
||||
</label>
|
||||
<div className="relative">
|
||||
<div className="absolute inset-y-0 left-0 flex items-center pl-3 pointer-events-none">
|
||||
{leftItem}
|
||||
</div>
|
||||
<Input
|
||||
className={formClassName}
|
||||
type={type}
|
||||
name={name}
|
||||
onChange={onChange}
|
||||
value={value}
|
||||
error={error}
|
||||
autoComplete={autoComplete}
|
||||
autoFocus={autoFocus}
|
||||
placeholder={placeholder}
|
||||
disabled={disabled}
|
||||
readOnly={readOnly}
|
||||
onKeyDownCapture={onKeyDownCapture}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,58 @@
|
||||
import React from 'react'
|
||||
import Input from './Input'
|
||||
|
||||
export default function FormInputWith({
|
||||
type,
|
||||
name,
|
||||
onChange,
|
||||
value,
|
||||
label,
|
||||
className,
|
||||
error,
|
||||
autoComplete,
|
||||
autoFocus,
|
||||
placeholder,
|
||||
disabled,
|
||||
readOnly,
|
||||
onKeyDownCapture,
|
||||
leftItem,
|
||||
formClassName,
|
||||
}) {
|
||||
return (
|
||||
<div className={className}>
|
||||
<label
|
||||
htmlFor={name}
|
||||
className="block mb-2 text-sm font-medium text-gray-900 dark:text-white"
|
||||
>
|
||||
{label}
|
||||
</label>
|
||||
<div className="relative">
|
||||
<div className="absolute inset-y-0 left-0 flex items-center pl-3 pointer-events-none">
|
||||
{leftItem}
|
||||
</div>
|
||||
<input
|
||||
type={type}
|
||||
className={`mb-2 bg-gray-50 border text-gray-900 text-sm rounded-lg block w-full p-2.5 dark:bg-gray-700 dark:placeholder-gray-400 dark:text-white ${
|
||||
error
|
||||
? 'border-red-500 dark:border-red-500 focus:ring-red-500 focus:border-red-500 dark:focus:ring-red-500 dark:focus:border-red-500'
|
||||
: 'border-gray-300 dark:border-gray-600 focus:ring-blue-500 focus:border-blue-500 dark:focus:ring-blue-500 dark:focus:border-blue-500'
|
||||
} ${formClassName}`}
|
||||
onChange={onChange}
|
||||
name={name}
|
||||
value={value}
|
||||
autoComplete={autoComplete ? 'on' : 'off'}
|
||||
autoFocus={autoFocus}
|
||||
placeholder={placeholder}
|
||||
disabled={disabled}
|
||||
readOnly={readOnly}
|
||||
onKeyDownCapture={onKeyDownCapture}
|
||||
/>
|
||||
</div>
|
||||
{error && (
|
||||
<p className="mb-2 text-sm text-red-600 dark:text-red-500">
|
||||
{error}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
@ -1,24 +1,43 @@
|
||||
import React from 'react'
|
||||
|
||||
export default function Input({ type = 'text', name, onChange, value, error = "", autoComplete = false, autoFocus = false, placeholder , className ,disabled, readOnly}) {
|
||||
export default function Input({
|
||||
type = 'text',
|
||||
name,
|
||||
onChange,
|
||||
value,
|
||||
error = '',
|
||||
autoComplete = false,
|
||||
autoFocus = false,
|
||||
placeholder,
|
||||
className,
|
||||
disabled,
|
||||
readOnly,
|
||||
onKeyDownCapture = null,
|
||||
}) {
|
||||
return (
|
||||
<>
|
||||
<input
|
||||
<input
|
||||
type={type}
|
||||
className={`mb-2 bg-gray-50 border text-gray-900 text-sm rounded-lg block w-full p-2.5 dark:bg-gray-700 dark:placeholder-gray-400 dark:text-white ${error ? "border-red-500 dark:border-red-500 focus:ring-red-500 focus:border-red-500 dark:focus:ring-red-500 dark:focus:border-red-500" : "border-gray-300 dark:border-gray-600 focus:ring-blue-500 focus:border-blue-500 dark:focus:ring-blue-500 dark:focus:border-blue-500"} ${className}`}
|
||||
onChange={onChange}
|
||||
className={`mb-2 bg-gray-50 border text-gray-900 text-sm rounded-lg block w-full p-2.5 dark:bg-gray-700 dark:placeholder-gray-400 dark:text-white ${
|
||||
error
|
||||
? 'border-red-500 dark:border-red-500 focus:ring-red-500 focus:border-red-500 dark:focus:ring-red-500 dark:focus:border-red-500'
|
||||
: 'border-gray-300 dark:border-gray-600 focus:ring-blue-500 focus:border-blue-500 dark:focus:ring-blue-500 dark:focus:border-blue-500'
|
||||
} ${className}`}
|
||||
onChange={onChange}
|
||||
name={name}
|
||||
value={value}
|
||||
autoComplete={autoComplete ? "on" : "off"}
|
||||
autoComplete={autoComplete ? 'on' : 'off'}
|
||||
autoFocus={autoFocus}
|
||||
placeholder={placeholder}
|
||||
disabled={disabled}
|
||||
readOnly={readOnly}
|
||||
onKeyDownCapture={onKeyDownCapture}
|
||||
/>
|
||||
{error && (
|
||||
<p className="mb-2 text-sm text-red-600 dark:text-red-500">{error}</p>
|
||||
<p className="mb-2 text-sm text-red-600 dark:text-red-500">
|
||||
{error}
|
||||
</p>
|
||||
)}
|
||||
</>
|
||||
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,104 @@
|
||||
import React from 'react'
|
||||
import { Head, useForm, Link } from '@inertiajs/react'
|
||||
import { FcGoogle } from 'react-icons/fc'
|
||||
|
||||
import CustomerLayout from '@/Layouts/CustomerLayout'
|
||||
import FormInput from '@/Components/FormInput'
|
||||
import Button from '@/Components/Button'
|
||||
import Alert from '@/Components/Alert'
|
||||
|
||||
export default function Index({ app_name, flash }) {
|
||||
const { data, setData, post, processing, errors } = useForm({
|
||||
username: '',
|
||||
password: '',
|
||||
})
|
||||
|
||||
const handleOnChange = (event) => {
|
||||
setData(
|
||||
event.target.name,
|
||||
event.target.type === 'checkbox'
|
||||
? event.target.checked
|
||||
? 1
|
||||
: 0
|
||||
: event.target.value
|
||||
)
|
||||
}
|
||||
|
||||
const handleSubmit = () => {
|
||||
post(route('customer.login'))
|
||||
}
|
||||
|
||||
const handleKeyDown = (e) => {
|
||||
if (e.code === 'Enter') {
|
||||
handleSubmit()
|
||||
}
|
||||
}
|
||||
|
||||
const handleLoginWithGoogle = () => {
|
||||
window.location = route('customer.login.google')
|
||||
}
|
||||
|
||||
return (
|
||||
<CustomerLayout>
|
||||
<Head title="Login" />
|
||||
<div className="flex flex-col justify-center min-h-screen">
|
||||
<div className="m-4 border shadow-md p-6 pt-4">
|
||||
<div className="text-2xl font-bold mb-4">Sign in</div>
|
||||
<Alert type={flash.message.type}>
|
||||
<span className="font-semibold">
|
||||
{flash.message.message}
|
||||
</span>
|
||||
</Alert>
|
||||
<div className="w-full">
|
||||
<FormInput
|
||||
placeholder="username"
|
||||
name="username"
|
||||
value={data.username}
|
||||
onChange={handleOnChange}
|
||||
error={errors.username}
|
||||
onKeyDownCapture={(e) => handleKeyDown(e)}
|
||||
/>
|
||||
</div>
|
||||
<div className="w-full">
|
||||
<FormInput
|
||||
type="password"
|
||||
placeholder="password"
|
||||
name="password"
|
||||
value={data.password}
|
||||
onChange={handleOnChange}
|
||||
error={errors.username}
|
||||
onKeyDownCapture={(e) => handleKeyDown(e)}
|
||||
/>
|
||||
</div>
|
||||
<div className="w-full flex flex-row justify-between">
|
||||
<Button processing={processing} onClick={handleSubmit}>
|
||||
Sign in
|
||||
</Button>
|
||||
{/* <a href="#" className="text-sm underline text-blue-600">
|
||||
forgot password
|
||||
</a> */}
|
||||
</div>
|
||||
<div className="flex flex-row items-center space-x-2 justify-between my-3">
|
||||
<div className="border-b-2 w-full" />
|
||||
<div>OR</div>
|
||||
<div className="border-b-2 w-full" />
|
||||
</div>
|
||||
<div className="flex flex-row w-full justify-center">
|
||||
<div
|
||||
className="flex flex-row items-center space-x-2 border-2 border-blue-600 px-4 py-2 hover:bg-blue-500 hover:text-white rounded"
|
||||
onClick={handleLoginWithGoogle}
|
||||
>
|
||||
<FcGoogle className="h-6 w-6" />
|
||||
<div>Sign in with Google</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="mt-10 w-full text-center text-blue-600 underline">
|
||||
<Link href={route('customer.register')}>
|
||||
dont have an account ? register
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</CustomerLayout>
|
||||
)
|
||||
}
|
@ -0,0 +1,163 @@
|
||||
import React from 'react'
|
||||
import { Head, useForm, Link } from '@inertiajs/react'
|
||||
import { FcGoogle } from 'react-icons/fc'
|
||||
|
||||
import CustomerLayout from '@/Layouts/CustomerLayout'
|
||||
import FormInput from '@/Components/FormInput'
|
||||
import Button from '@/Components/Button'
|
||||
import Alert from '@/Components/Alert'
|
||||
import FormInputWith from '@/Components/FormInputWith'
|
||||
import TextArea from '@/Components/TextArea'
|
||||
|
||||
export default function Index({ app_name, flash }) {
|
||||
const { data, setData, post, processing, errors } = useForm({
|
||||
username: '',
|
||||
password: '',
|
||||
password_confirmation: '',
|
||||
fullname: '',
|
||||
name: '',
|
||||
address: '',
|
||||
phone: '',
|
||||
})
|
||||
|
||||
const handleOnChange = (event) => {
|
||||
setData(
|
||||
event.target.name,
|
||||
event.target.type === 'checkbox'
|
||||
? event.target.checked
|
||||
? 1
|
||||
: 0
|
||||
: event.target.value
|
||||
)
|
||||
}
|
||||
|
||||
const handleSubmit = () => {
|
||||
post(route('customer.register'))
|
||||
}
|
||||
|
||||
const handleKeyDown = (e) => {
|
||||
if (e.code === 'Enter') {
|
||||
handleSubmit()
|
||||
}
|
||||
}
|
||||
|
||||
const handleLoginWithGoogle = () => {
|
||||
window.location = route('customer.login.google')
|
||||
}
|
||||
|
||||
return (
|
||||
<CustomerLayout>
|
||||
<Head title="Login" />
|
||||
<div className="flex flex-col justify-center min-h-screen">
|
||||
<div className="m-4 border shadow-md p-6 pt-4">
|
||||
<div className="text-2xl font-bold mb-4">Register</div>
|
||||
<Alert type={flash.message.type}>
|
||||
<span className="font-semibold">
|
||||
{flash.message.message}
|
||||
</span>
|
||||
</Alert>
|
||||
<div className="w-full">
|
||||
<FormInput
|
||||
placeholder="nama lengkap"
|
||||
name="fullname"
|
||||
value={data.fullname}
|
||||
onChange={handleOnChange}
|
||||
error={errors.fullname}
|
||||
onKeyDownCapture={(e) => handleKeyDown(e)}
|
||||
/>
|
||||
</div>
|
||||
<div className="w-full">
|
||||
<FormInput
|
||||
placeholder="nama panggilan"
|
||||
name="name"
|
||||
value={data.name}
|
||||
onChange={handleOnChange}
|
||||
error={errors.name}
|
||||
onKeyDownCapture={(e) => handleKeyDown(e)}
|
||||
/>
|
||||
</div>
|
||||
<FormInputWith
|
||||
type="number"
|
||||
leftItem={<div className="text-sm">+62</div>}
|
||||
placeholder="whatsapp"
|
||||
name="phone"
|
||||
value={data.phone}
|
||||
onChange={handleOnChange}
|
||||
error={errors.phone}
|
||||
onKeyDownCapture={(e) => handleKeyDown(e)}
|
||||
formClassName={'pl-10'}
|
||||
/>
|
||||
<div className="w-full">
|
||||
<TextArea
|
||||
placeholder="alamat lengkap"
|
||||
name="address"
|
||||
value={data.address}
|
||||
onChange={handleOnChange}
|
||||
error={errors.address}
|
||||
onKeyDownCapture={(e) => handleKeyDown(e)}
|
||||
/>
|
||||
</div>
|
||||
<div className="w-full">
|
||||
<FormInput
|
||||
placeholder="username"
|
||||
name="username"
|
||||
value={data.username}
|
||||
onChange={handleOnChange}
|
||||
error={errors.username}
|
||||
onKeyDownCapture={(e) => handleKeyDown(e)}
|
||||
/>
|
||||
</div>
|
||||
<div className="w-full">
|
||||
<FormInput
|
||||
type="password"
|
||||
placeholder="password"
|
||||
name="password"
|
||||
value={data.password}
|
||||
onChange={handleOnChange}
|
||||
error={errors.password}
|
||||
onKeyDownCapture={(e) => handleKeyDown(e)}
|
||||
/>
|
||||
</div>
|
||||
<div className="w-full">
|
||||
<FormInput
|
||||
type="password"
|
||||
placeholder="retype password"
|
||||
name="password_confirmation"
|
||||
value={data.password_confirmation}
|
||||
onChange={handleOnChange}
|
||||
error={errors.password_confirmation}
|
||||
onKeyDownCapture={(e) => handleKeyDown(e)}
|
||||
/>
|
||||
</div>
|
||||
<div className="w-full flex flex-row justify-between">
|
||||
<Button processing={processing} onClick={handleSubmit}>
|
||||
Register
|
||||
</Button>
|
||||
{/* <a href="#" className="text-sm underline text-blue-600">
|
||||
forgot password
|
||||
</a> */}
|
||||
</div>
|
||||
<div className="flex flex-row items-center space-x-2 justify-between my-3">
|
||||
<div className="border-b-2 w-full" />
|
||||
<div>OR</div>
|
||||
<div className="border-b-2 w-full" />
|
||||
</div>
|
||||
<div className="flex flex-row w-full justify-center">
|
||||
<div
|
||||
className="flex flex-row items-center space-x-2 border-2 border-blue-600 px-4 py-2 hover:bg-blue-500 hover:text-white rounded"
|
||||
onClick={handleLoginWithGoogle}
|
||||
>
|
||||
<FcGoogle className="h-6 w-6" />
|
||||
<div>Register with Google</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="mt-10 w-full text-center text-blue-600 underline">
|
||||
<Link href={route('customer.login')}>
|
||||
already have account ? login
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</CustomerLayout>
|
||||
)
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
import React from 'react'
|
||||
import { Head } from '@inertiajs/react'
|
||||
import CustomerLayout from '@/Layouts/CustomerLayout'
|
||||
|
||||
export default function Index({ status }) {
|
||||
return (
|
||||
<CustomerLayout>
|
||||
<Head title="Login" />
|
||||
<div className="flex flex-col min-h-screen">
|
||||
<div>Login</div>
|
||||
</div>
|
||||
</CustomerLayout>
|
||||
)
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
import React from 'react'
|
||||
import { HiOutlineCash, HiOutlineBell } from 'react-icons/hi'
|
||||
|
||||
export default function UserBanner({ user }) {
|
||||
return (
|
||||
<div>
|
||||
{/* user */}
|
||||
<div className="flex flex-row justify-between items-center px-5 py-6 text-lg bg-blue-600">
|
||||
<div className="flex flex-col text-white">
|
||||
<div className="font-bold">{user.name}</div>
|
||||
<div className="flex flex-row items-center space-x-1">
|
||||
<div>+62{user.phone}</div>
|
||||
<div className="text-xs font-semibold px-2 py-1 bg-white text-black rounded-xl">
|
||||
Gold
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex flex-row">
|
||||
<HiOutlineBell className="text-white w-7 h-7" />
|
||||
<div>
|
||||
<div className="bg-white text-blue-700 rounded-lg px-1 text-xs -ml-2.5">
|
||||
1
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/* saldo */}
|
||||
<div className="flex flex-row px-5 pb-3 text-base bg-blue-600">
|
||||
<div className="flex flex-row w-full shadow py-2 px-2 rounded bg-white items-center justify-between">
|
||||
<div className="flex flex-col">
|
||||
<div className="text-xs flex flex-row items-center space-x-1 text-gray-400">
|
||||
<HiOutlineCash />
|
||||
<div>Saldo</div>
|
||||
</div>
|
||||
<div className="font-bold">Rp 10.000</div>
|
||||
<div className="text-xs flex flex-row items-center space-x-1 text-gray-400">
|
||||
<div>Coin 10.000</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex flex-col border-l-2 pl-5 pr-5">
|
||||
<div className="text-xs flex flex-row items-center space-x-1 text-gray-400">
|
||||
{/* <HiOutlineAwa /> */}
|
||||
<div>Rewards</div>
|
||||
</div>
|
||||
<div className="font-bold">Gold Member</div>
|
||||
<div className="text-xs flex flex-row items-center space-x-1 text-gray-400">
|
||||
<div>Limit 100.000</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
@ -0,0 +1,159 @@
|
||||
import React from 'react'
|
||||
import { Head, useForm, Link } from '@inertiajs/react'
|
||||
import { FcGoogle } from 'react-icons/fc'
|
||||
|
||||
import CustomerLayout from '@/Layouts/CustomerLayout'
|
||||
import FormInput from '@/Components/FormInput'
|
||||
import Button from '@/Components/Button'
|
||||
import Alert from '@/Components/Alert'
|
||||
import FormInputWith from '@/Components/FormInputWith'
|
||||
import TextArea from '@/Components/TextArea'
|
||||
import FormFile from '@/Components/FormFile'
|
||||
|
||||
export default function Index({ auth: { user }, flash }) {
|
||||
const { data, setData, post, processing, errors } = useForm({
|
||||
username: user.username,
|
||||
password: '',
|
||||
password_confirmation: '',
|
||||
fullname: user.fullname,
|
||||
name: user.name,
|
||||
address: user.address,
|
||||
phone: user.phone,
|
||||
image: null,
|
||||
image_url: user.image_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.show'))
|
||||
}
|
||||
|
||||
const handleKeyDown = (e) => {
|
||||
if (e.code === 'Enter') {
|
||||
handleSubmit()
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<CustomerLayout>
|
||||
<Head title="Login" />
|
||||
<div className="flex flex-col min-h-screen">
|
||||
<div className="m-4 p-2">
|
||||
<div className="text-2xl font-bold mb-4">Profile</div>
|
||||
<Alert type={flash.message.type}>
|
||||
<span className="font-semibold">
|
||||
{flash.message.message}
|
||||
</span>
|
||||
</Alert>
|
||||
<div className="w-full">
|
||||
<FormInput
|
||||
placeholder="nama lengkap"
|
||||
name="fullname"
|
||||
value={data.fullname}
|
||||
onChange={handleOnChange}
|
||||
error={errors.fullname}
|
||||
onKeyDownCapture={(e) => handleKeyDown(e)}
|
||||
/>
|
||||
</div>
|
||||
<div className="w-full">
|
||||
<FormInput
|
||||
placeholder="nama panggilan"
|
||||
name="name"
|
||||
value={data.name}
|
||||
onChange={handleOnChange}
|
||||
error={errors.name}
|
||||
onKeyDownCapture={(e) => handleKeyDown(e)}
|
||||
/>
|
||||
</div>
|
||||
<FormInputWith
|
||||
type="number"
|
||||
leftItem={<div className="text-sm">+62</div>}
|
||||
placeholder="whatsapp"
|
||||
name="phone"
|
||||
value={data.phone}
|
||||
onChange={handleOnChange}
|
||||
error={errors.phone}
|
||||
onKeyDownCapture={(e) => handleKeyDown(e)}
|
||||
formClassName={'pl-10'}
|
||||
/>
|
||||
<div className="w-full">
|
||||
<TextArea
|
||||
placeholder="alamat lengkap"
|
||||
name="address"
|
||||
value={data.address}
|
||||
onChange={handleOnChange}
|
||||
error={errors.address}
|
||||
onKeyDownCapture={(e) => handleKeyDown(e)}
|
||||
/>
|
||||
</div>
|
||||
<div className="w-full">
|
||||
<FormInput
|
||||
placeholder="username"
|
||||
name="username"
|
||||
value={data.username}
|
||||
onChange={handleOnChange}
|
||||
error={errors.username}
|
||||
onKeyDownCapture={(e) => handleKeyDown(e)}
|
||||
/>
|
||||
</div>
|
||||
<div className="w-full">
|
||||
<FormInput
|
||||
type="password"
|
||||
placeholder="password , leave blank if unchange"
|
||||
name="password"
|
||||
value={data.password}
|
||||
onChange={handleOnChange}
|
||||
error={errors.password}
|
||||
onKeyDownCapture={(e) => handleKeyDown(e)}
|
||||
/>
|
||||
</div>
|
||||
<div className="w-full">
|
||||
<FormInput
|
||||
type="password"
|
||||
placeholder="retype password"
|
||||
name="password_confirmation"
|
||||
value={data.password_confirmation}
|
||||
onChange={handleOnChange}
|
||||
error={errors.password_confirmation}
|
||||
onKeyDownCapture={(e) => handleKeyDown(e)}
|
||||
/>
|
||||
</div>
|
||||
<div className="w-full">
|
||||
<FormFile
|
||||
label={'Profile Image'}
|
||||
onChange={(e) =>
|
||||
setData('image', e.target.files[0])
|
||||
}
|
||||
error={errors.image}
|
||||
preview={
|
||||
<img
|
||||
src={`${data.image_url}`}
|
||||
className="w-40 mb-1"
|
||||
alt="site logo"
|
||||
/>
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
<div className="w-full flex flex-row justify-between">
|
||||
<Button processing={processing} onClick={handleSubmit}>
|
||||
Simpan
|
||||
</Button>
|
||||
{/* <a href="#" className="text-sm underline text-blue-600">
|
||||
forgot password
|
||||
</a> */}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</CustomerLayout>
|
||||
)
|
||||
}
|
@ -0,0 +1,115 @@
|
||||
import React from 'react'
|
||||
import { Head, Link, router } from '@inertiajs/react'
|
||||
import CustomerLayout from '@/Layouts/CustomerLayout'
|
||||
import UserBanner from '../Index/UserBanner'
|
||||
import {
|
||||
HiChevronRight,
|
||||
HiOutlineUser,
|
||||
HiOutlineUserCircle,
|
||||
} from 'react-icons/hi2'
|
||||
import { HiOutlineBell, HiOutlineCash } from 'react-icons/hi'
|
||||
import { useModalState } from '@/hooks'
|
||||
import ModalConfirm from '@/Components/ModalConfirm'
|
||||
|
||||
export default function Index({ auth: { user } }) {
|
||||
const confirmModal = useModalState()
|
||||
|
||||
const handleLogoutClick = () => {
|
||||
confirmModal.toggle()
|
||||
}
|
||||
|
||||
const onLogout = () => {
|
||||
router.post(route('customer.logout'))
|
||||
}
|
||||
|
||||
return (
|
||||
<CustomerLayout>
|
||||
<Head title="Login" />
|
||||
<div className="flex flex-col min-h-screen">
|
||||
<div>
|
||||
{/* user */}
|
||||
<div className="flex flex-row justify-between items-center px-5 py-6 text-lg bg-blue-600">
|
||||
<div className="flex flex-row items-center space-x-2">
|
||||
<HiOutlineUserCircle className="text-white h-14 w-14" />
|
||||
<div className="flex flex-col text-white">
|
||||
<div className="font-bold">{user.name}</div>
|
||||
<div className="flex flex-row items-center space-x-1">
|
||||
<div>+62{user.phone}</div>
|
||||
<div className="text-xs font-semibold px-2 py-1 bg-white text-black rounded-xl">
|
||||
Gold
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex flex-row">
|
||||
<HiOutlineBell className="text-white w-7 h-7" />
|
||||
<div>
|
||||
<div className="bg-white text-blue-700 rounded-lg px-1 text-xs -ml-2.5">
|
||||
1
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/* saldo */}
|
||||
<div className="flex flex-row px-5 pb-3 text-base bg-blue-600">
|
||||
<div className="flex flex-row w-full shadow py-2 px-2 rounded bg-white items-center justify-between">
|
||||
<div className="flex flex-col">
|
||||
<div className="text-xs flex flex-row items-center space-x-1 text-gray-400">
|
||||
<HiOutlineCash />
|
||||
<div>Saldo</div>
|
||||
</div>
|
||||
<div className="font-bold">Rp 10.000</div>
|
||||
<div className="text-xs flex flex-row items-center space-x-1 text-gray-400">
|
||||
<div>Coin 10.000</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex flex-col border-l-2 pl-5 pr-5">
|
||||
<div className="text-xs flex flex-row items-center space-x-1 text-gray-400">
|
||||
<div>Rewards</div>
|
||||
</div>
|
||||
<div className="font-bold">Gold Member</div>
|
||||
<div className="text-xs flex flex-row items-center space-x-1 text-gray-400">
|
||||
<div>Limit 100.000</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="p-4 flex flex-col">
|
||||
<div className="flex flex-row justify-between items-center px-2 py-4 w-full border-b border-gray-400 hover:bg-gray-100">
|
||||
<div>Upgrade Member</div>
|
||||
<HiChevronRight className="h-5 w-5" />
|
||||
</div>
|
||||
<div className="flex flex-row justify-between items-center px-2 py-4 w-full border-b border-gray-400 hover:bg-gray-100">
|
||||
<div>Deposit Saldo</div>
|
||||
<HiChevronRight className="h-5 w-5" />
|
||||
</div>
|
||||
<div className="flex flex-row justify-between items-center px-2 py-4 w-full border-b border-gray-400 hover:bg-gray-100">
|
||||
<div>Transaksi</div>
|
||||
<HiChevronRight className="h-5 w-5" />
|
||||
</div>
|
||||
<div className="flex flex-row justify-between items-center px-2 py-4 w-full border-b border-gray-400 hover:bg-gray-100">
|
||||
<div>Notifikasi</div>
|
||||
<HiChevronRight className="h-5 w-5" />
|
||||
</div>
|
||||
<div
|
||||
className="flex flex-row justify-between items-center px-2 py-4 w-full border-b border-gray-400 hover:bg-gray-100"
|
||||
onClick={() =>
|
||||
router.get(route('customer.profile.show'))
|
||||
}
|
||||
>
|
||||
<div>Profile</div>
|
||||
<HiChevronRight className="h-5 w-5" />
|
||||
</div>
|
||||
<div
|
||||
onClick={() => handleLogoutClick()}
|
||||
className="flex flex-row justify-between items-center px-2 py-4 w-full border-b border-gray-400 text-red-700 hover:bg-gray-100"
|
||||
>
|
||||
Logout
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<ModalConfirm modalState={confirmModal} onConfirm={onLogout} />
|
||||
</CustomerLayout>
|
||||
)
|
||||
}
|
Loading…
Reference in New Issue