upgrade flowbite deps
parent
3123971f2b
commit
585888f37e
@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
|
||||
class CustomerAsDataPartner extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'customer_id',
|
||||
'job',
|
||||
'image_selfie',
|
||||
'file_statement',
|
||||
'file_agreement',
|
||||
'additional_json',
|
||||
];
|
||||
|
||||
protected $appends = [
|
||||
'image_selfie_url',
|
||||
'file_statement_url',
|
||||
'file_agreement_url',
|
||||
];
|
||||
|
||||
public function imageSelfieUrl(): Attribute
|
||||
{
|
||||
return Attribute::make(get: function () {
|
||||
if ($this->image_selfie != null) {
|
||||
return asset($this->image_selfie);
|
||||
}
|
||||
return null;
|
||||
});
|
||||
}
|
||||
public function fileStatementUrl(): Attribute
|
||||
{
|
||||
return Attribute::make(get: function () {
|
||||
if ($this->file_statement != null) {
|
||||
return asset($this->file_statement);
|
||||
}
|
||||
return null;
|
||||
});
|
||||
}
|
||||
public function fileAgreementUrl(): Attribute
|
||||
{
|
||||
return Attribute::make(get: function () {
|
||||
if ($this->file_agreement != null) {
|
||||
return asset($this->file_agreement);
|
||||
}
|
||||
return null;
|
||||
});
|
||||
}
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
<?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('customer_as_data_partners', function (Blueprint $table) {
|
||||
$table->ulid('id')->primary();
|
||||
|
||||
$table->ulid('customer_id')->nullable();
|
||||
$table->string('job')->nullable();
|
||||
$table->string('image_selfie')->nullable();
|
||||
$table->string('file_statement')->nullable();
|
||||
$table->string('file_agreement')->nullable();
|
||||
$table->text('additional_json')->nullable();
|
||||
|
||||
$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('customer_as_data_partners');
|
||||
}
|
||||
};
|
@ -1,6 +1,7 @@
|
||||
module.exports = {
|
||||
plugins: {
|
||||
'postcss-import': {},
|
||||
tailwindcss: {},
|
||||
autoprefixer: {},
|
||||
},
|
||||
};
|
||||
}
|
||||
|
@ -0,0 +1,331 @@
|
||||
''
|
||||
|
||||
import React, { useEffect, useRef, useState } from 'react'
|
||||
import { usePage, useForm } from '@inertiajs/react'
|
||||
import { isEmpty } from 'lodash'
|
||||
|
||||
import Button from '@/Components/Button'
|
||||
import FormInput from '@/Components/FormInput'
|
||||
import FormFile from '@/Components/FormFile'
|
||||
import { Spinner } from 'flowbite-react'
|
||||
import { HiXCircle } from 'react-icons/hi2'
|
||||
|
||||
export default function Partner() {
|
||||
const {
|
||||
props: { customer, csrf_token },
|
||||
} = usePage()
|
||||
|
||||
const [uploadIndex, setUploadIndex] = useState(null)
|
||||
const [loading, setLoading] = useState(false)
|
||||
const generalUploadRef = useRef()
|
||||
|
||||
const { data, setData, post, processing, errors } = useForm({
|
||||
job: '',
|
||||
image_selfie: null,
|
||||
image_selfie_url: '',
|
||||
file_statement: null,
|
||||
file_statement_url: '',
|
||||
file_agreement: null,
|
||||
file_agreement_url: '',
|
||||
items: [],
|
||||
})
|
||||
|
||||
const addItem = () => {
|
||||
setData(
|
||||
'items',
|
||||
data.items.concat({
|
||||
name: '',
|
||||
type: 'text',
|
||||
value: '',
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
const removeItem = (index) => {
|
||||
setData(
|
||||
'items',
|
||||
data.items.filter((_, i) => i !== index)
|
||||
)
|
||||
}
|
||||
|
||||
const changeValueItem = (index, e) => {
|
||||
setData(
|
||||
'items',
|
||||
data.items.map((item, i) => {
|
||||
if (i === index) {
|
||||
item[e.target.name] = e.target.value
|
||||
}
|
||||
return item
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
const handleClickUpload = (index) => {
|
||||
setUploadIndex(index)
|
||||
generalUploadRef.current.click()
|
||||
}
|
||||
|
||||
const handleFileUpload = (e) => {
|
||||
const body = new FormData()
|
||||
body.append('_token', csrf_token)
|
||||
body.append('image', e.target.files[0])
|
||||
|
||||
setLoading(true)
|
||||
fetch(route('post.upload'), {
|
||||
method: 'post',
|
||||
body: body,
|
||||
headers: {
|
||||
'accept-content': 'application/json',
|
||||
'X-CSSRF-TOKEN': csrf_token,
|
||||
},
|
||||
credentials: 'include',
|
||||
})
|
||||
.then((res) => res.json())
|
||||
.then((res) => {
|
||||
changeValueItem(uploadIndex, {
|
||||
target: { name: 'value', value: res.url },
|
||||
})
|
||||
})
|
||||
.catch((err) => {
|
||||
alert(err)
|
||||
})
|
||||
.finally(() => {
|
||||
setLoading(false)
|
||||
})
|
||||
}
|
||||
|
||||
const handleOnChange = (event) => {
|
||||
setData(
|
||||
event.target.name,
|
||||
event.target.type === 'checkbox'
|
||||
? event.target.checked
|
||||
? 1
|
||||
: 0
|
||||
: event.target.value
|
||||
)
|
||||
}
|
||||
|
||||
const handleSubmit = () => {
|
||||
post(route('customer.update_partner', customer))
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
if (!isEmpty(customer?.partner)) {
|
||||
let items = JSON.parse(customer.partner.additional_json)
|
||||
if (isEmpty(items)) {
|
||||
items = []
|
||||
}
|
||||
setData({
|
||||
job: customer.partner.job,
|
||||
image_selfie_url: customer.partner.image_selfie_url,
|
||||
file_statement_url: customer.partner.file_statement_url,
|
||||
file_agreement_url: customer.partner.file_agreement_url,
|
||||
items: items,
|
||||
})
|
||||
}
|
||||
}, [customer])
|
||||
|
||||
if (isEmpty(customer)) {
|
||||
return
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="mt-2 flex flex-col p-4 border rounded border-gray-200">
|
||||
<input
|
||||
ref={generalUploadRef}
|
||||
type="file"
|
||||
onChange={handleFileUpload}
|
||||
className="hidden"
|
||||
/>
|
||||
<div className="font-semibold ">Data Mitra</div>
|
||||
<div className="mt-4">
|
||||
<FormInput
|
||||
name="job"
|
||||
value={data.job}
|
||||
onChange={handleOnChange}
|
||||
label="Pekerjaan"
|
||||
error={errors.job}
|
||||
/>
|
||||
</div>
|
||||
<div className="">
|
||||
<FormFile
|
||||
label={'Image Selfie'}
|
||||
onChange={(e) => setData('image_selfie', e.target.files[0])}
|
||||
error={errors.image_selfie}
|
||||
preview={
|
||||
isEmpty(data.image_selfie_url) === false && (
|
||||
<a href={data.image_selfie_url} target="_blank">
|
||||
<img
|
||||
src={data.image_selfie_url}
|
||||
className="mb-1 h-40 object-fill"
|
||||
alt="preview"
|
||||
loading="lazy"
|
||||
/>
|
||||
</a>
|
||||
)
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
<div className="">
|
||||
<FormFile
|
||||
label={'Surat Pernyataan'}
|
||||
onChange={(e) =>
|
||||
setData('file_statement', e.target.files[0])
|
||||
}
|
||||
error={errors.file_statement}
|
||||
preview={
|
||||
isEmpty(data.file_statement_url) === false && (
|
||||
<div className="w-full text-right">
|
||||
<a
|
||||
href={data.file_statement_url}
|
||||
target="_blank"
|
||||
className="underline text-sm "
|
||||
>
|
||||
Download Surat Pernyataan
|
||||
</a>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
<div className="">
|
||||
<FormFile
|
||||
label={'Surat Perjanjian'}
|
||||
onChange={(e) =>
|
||||
setData('file_agreement', e.target.files[0])
|
||||
}
|
||||
error={errors.file_agreement}
|
||||
preview={
|
||||
isEmpty(data.file_agreement_url) === false && (
|
||||
<div className="w-full text-right">
|
||||
<a
|
||||
href={data.file_agreement_url}
|
||||
target="_blank"
|
||||
className="underline text-sm "
|
||||
>
|
||||
Download Surat Perjanjian
|
||||
</a>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
<div className="border rounded-md px-2">
|
||||
<div className="font-semibold p-2">Data Lainnya</div>
|
||||
{loading ? (
|
||||
<Spinner className="w-full h-72 py-5" size="xl" />
|
||||
) : (
|
||||
<>
|
||||
<table className="w-full">
|
||||
<thead>
|
||||
<tr>
|
||||
<th className="text-left px-2 py-1 w-2/6">
|
||||
Nama
|
||||
</th>
|
||||
<th className="text-left px-2 py-1 w-1/6">
|
||||
Tipe
|
||||
</th>
|
||||
<th className="text-left px-2 py-1 w-3/6">
|
||||
Nilai
|
||||
</th>
|
||||
<th />
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{data.items.map((item, index) => (
|
||||
<tr key={index}>
|
||||
<td className="px-2 py-1">
|
||||
<FormInput
|
||||
value={item.name}
|
||||
name="name"
|
||||
onChange={(e) =>
|
||||
changeValueItem(index, e)
|
||||
}
|
||||
/>
|
||||
</td>
|
||||
<td className="px-2 py-1">
|
||||
<select
|
||||
className="w-full bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"
|
||||
value={item.type}
|
||||
name="type"
|
||||
onChange={(e) =>
|
||||
changeValueItem(index, e)
|
||||
}
|
||||
>
|
||||
<option value="text">
|
||||
text
|
||||
</option>
|
||||
<option value="file">
|
||||
file
|
||||
</option>
|
||||
</select>
|
||||
</td>
|
||||
<td className="px-2 py-1">
|
||||
{item.type === 'text' ? (
|
||||
<FormInput
|
||||
value={item.value}
|
||||
name="value"
|
||||
onChange={(e) =>
|
||||
changeValueItem(
|
||||
index,
|
||||
e
|
||||
)
|
||||
}
|
||||
/>
|
||||
) : (
|
||||
<div className="w-full flex flex-row gap-1 items-center">
|
||||
<div
|
||||
className="px-2 py-1 border rounded-md hover:bg-gray-200"
|
||||
onClick={() =>
|
||||
handleClickUpload(
|
||||
index
|
||||
)
|
||||
}
|
||||
>
|
||||
Choose File
|
||||
</div>
|
||||
<div>
|
||||
{isEmpty(item.value) ? (
|
||||
'No file chosen'
|
||||
) : (
|
||||
<a
|
||||
href={
|
||||
item.value
|
||||
}
|
||||
target="_blank"
|
||||
className="underline pl-2"
|
||||
>
|
||||
File Uploaded
|
||||
</a>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</td>
|
||||
<td>
|
||||
<div
|
||||
onClick={() =>
|
||||
removeItem(index)
|
||||
}
|
||||
>
|
||||
<HiXCircle className="text-red-700 w-10 h-7" />
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
<div className="w-full flex flex-row justify-end">
|
||||
<Button onClick={() => addItem()}>Tambah</Button>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
<div className="mt-4 flex items-center">
|
||||
<Button onClick={handleSubmit} processing={processing}>
|
||||
Simpan
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
@ -0,0 +1,87 @@
|
||||
import React from 'react'
|
||||
import { usePage, useForm } from '@inertiajs/react'
|
||||
import { isEmpty } from 'lodash'
|
||||
|
||||
import Button from '@/Components/Button'
|
||||
import FormInputNumeric from '@/Components/FormInputNumeric'
|
||||
|
||||
export default function Paylater() {
|
||||
const {
|
||||
props: { customer, levels },
|
||||
} = usePage()
|
||||
const { data, setData, post, processing, errors } = useForm({
|
||||
level: customer?.level.key,
|
||||
paylater_limit: +customer?.paylater?.limit,
|
||||
})
|
||||
|
||||
const handleOnChange = (event) => {
|
||||
setData(
|
||||
event.target.name,
|
||||
event.target.type === 'checkbox'
|
||||
? event.target.checked
|
||||
? 1
|
||||
: 0
|
||||
: event.target.value
|
||||
)
|
||||
}
|
||||
|
||||
const handleSubmit = () => {
|
||||
post(route('customer.update_level', customer))
|
||||
}
|
||||
|
||||
if (isEmpty(customer)) {
|
||||
return
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="mt-2 flex flex-col p-4 border rounded border-gray-200">
|
||||
<div className="mt-4">
|
||||
{!isEmpty(customer.identity_image_url) && (
|
||||
<div>
|
||||
<div className="pb-4 font-bold">KTP</div>
|
||||
<img
|
||||
alt="identity"
|
||||
src={customer?.identity_image_url}
|
||||
className="w-full object-fill h-96"
|
||||
loading="lazy"
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
<div className="mb-1 text-sm">Level</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>
|
||||
{errors.level && (
|
||||
<p className="mb-2 text-sm text-red-600 dark:text-red-500">
|
||||
{errors.level}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
<div className="mb-4 mt-2">
|
||||
<FormInputNumeric
|
||||
type="number"
|
||||
label="Limit Hutang"
|
||||
name="paylater_limit"
|
||||
onChange={handleOnChange}
|
||||
value={data.paylater_limit}
|
||||
error={errors.paylater_limit}
|
||||
/>
|
||||
</div>
|
||||
<div className="flex items-center">
|
||||
<Button onClick={handleSubmit} processing={processing}>
|
||||
Simpan
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
@ -0,0 +1,149 @@
|
||||
import React, { useEffect } from 'react'
|
||||
import { usePage, useForm } from '@inertiajs/react'
|
||||
import { isEmpty } from 'lodash'
|
||||
|
||||
import FormInput from '@/Components/FormInput'
|
||||
import FormInputWith from '@/Components/FormInputWith'
|
||||
import TextArea from '@/Components/TextArea'
|
||||
import FormFile from '@/Components/FormFile'
|
||||
import Button from '@/Components/Button'
|
||||
|
||||
export default function Profile() {
|
||||
const {
|
||||
props: { customer, statuses },
|
||||
} = usePage()
|
||||
|
||||
const { data, setData, post, processing, errors } = useForm({
|
||||
username: '',
|
||||
password: '',
|
||||
name: '',
|
||||
fullname: '',
|
||||
address: '',
|
||||
phone: '',
|
||||
image: '',
|
||||
image_url: '',
|
||||
status: 0,
|
||||
})
|
||||
|
||||
const handleOnChange = (event) => {
|
||||
setData(
|
||||
event.target.name,
|
||||
event.target.type === 'checkbox'
|
||||
? event.target.checked
|
||||
? 1
|
||||
: 0
|
||||
: event.target.value
|
||||
)
|
||||
}
|
||||
const handleSubmit = () => {
|
||||
if (isEmpty(customer) === false) {
|
||||
post(route('customer.update', customer))
|
||||
return
|
||||
}
|
||||
post(route('customer.store'))
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
if (isEmpty(customer) === false) {
|
||||
setData({
|
||||
username: customer.username,
|
||||
password: customer.password,
|
||||
name: customer.name,
|
||||
fullname: customer.fullname,
|
||||
address: customer.address,
|
||||
phone: customer.phone,
|
||||
image_url: customer.image_url,
|
||||
status: customer.status,
|
||||
})
|
||||
}
|
||||
}, [customer])
|
||||
|
||||
return (
|
||||
<div className="flex flex-col p-4 border rounded border-gray-200">
|
||||
<div className="pb-4 font-bold">Profile</div>
|
||||
<FormInput
|
||||
name="fullname"
|
||||
value={data.fullname}
|
||||
onChange={handleOnChange}
|
||||
label="Nama Lengkap"
|
||||
error={errors.fullname}
|
||||
/>
|
||||
<FormInput
|
||||
name="name"
|
||||
value={data.name}
|
||||
onChange={handleOnChange}
|
||||
label="Nama Panggilan"
|
||||
error={errors.name}
|
||||
/>
|
||||
<FormInputWith
|
||||
type="number"
|
||||
leftItem={<div className="text-sm">+62</div>}
|
||||
name="phone"
|
||||
value={data.phone}
|
||||
onChange={handleOnChange}
|
||||
error={errors.phone}
|
||||
formClassName={'pl-10'}
|
||||
label="Whatsapp"
|
||||
/>
|
||||
<TextArea
|
||||
name="address"
|
||||
value={data.address}
|
||||
onChange={handleOnChange}
|
||||
label="Alamat Lengkap"
|
||||
error={errors.address}
|
||||
rows={4}
|
||||
/>
|
||||
<FormInput
|
||||
name="username"
|
||||
value={data.username}
|
||||
onChange={handleOnChange}
|
||||
label="username"
|
||||
error={errors.username}
|
||||
/>
|
||||
<FormInput
|
||||
name="password"
|
||||
value={data.password}
|
||||
onChange={handleOnChange}
|
||||
label="password"
|
||||
error={errors.password}
|
||||
/>
|
||||
<div className="mt-2">
|
||||
<div className="mb-1 text-sm">Status</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.status}
|
||||
name="status"
|
||||
>
|
||||
<option value=""></option>
|
||||
{statuses.map((status, index) => (
|
||||
<option value={index} key={status}>
|
||||
{status}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</div>
|
||||
<FormFile
|
||||
label={'Image'}
|
||||
onChange={(e) => setData('image', e.target.files[0])}
|
||||
error={errors.image}
|
||||
preview={
|
||||
isEmpty(data.image_url) === false && (
|
||||
<img
|
||||
src={data.image_url}
|
||||
className="mb-1 h-24 w-24 object-cover rounded-full"
|
||||
alt="preview"
|
||||
loading="lazy"
|
||||
/>
|
||||
)
|
||||
}
|
||||
/>
|
||||
|
||||
<div className="mt-1">
|
||||
<Button onClick={handleSubmit} processing={processing}>
|
||||
Simpan
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
@ -1,22 +1,26 @@
|
||||
import './bootstrap';
|
||||
import '../css/app.css';
|
||||
import 'flowbite';
|
||||
import 'react-toastify/dist/ReactToastify.css';
|
||||
import './bootstrap'
|
||||
import '../css/app.css'
|
||||
import 'react-toastify/dist/ReactToastify.css'
|
||||
|
||||
import React from 'react';
|
||||
import { createRoot } from 'react-dom/client';
|
||||
import { createInertiaApp } from '@inertiajs/react';
|
||||
import { resolvePageComponent } from 'laravel-vite-plugin/inertia-helpers';
|
||||
import React from 'react'
|
||||
import { createRoot } from 'react-dom/client'
|
||||
import { createInertiaApp } from '@inertiajs/react'
|
||||
import { resolvePageComponent } from 'laravel-vite-plugin/inertia-helpers'
|
||||
|
||||
const appName = window.document.getElementsByTagName('title')[0]?.innerText || 'Laravel';
|
||||
const appName =
|
||||
window.document.getElementsByTagName('title')[0]?.innerText || 'Laravel'
|
||||
|
||||
createInertiaApp({
|
||||
title: (title) => `${title} - ${appName}`,
|
||||
resolve: (name) => resolvePageComponent(`./Pages/${name}.jsx`, import.meta.glob('./Pages/**/*.jsx')),
|
||||
resolve: (name) =>
|
||||
resolvePageComponent(
|
||||
`./Pages/${name}.jsx`,
|
||||
import.meta.glob('./Pages/**/*.jsx')
|
||||
),
|
||||
setup({ el, App, props }) {
|
||||
const root = createRoot(el);
|
||||
const root = createRoot(el)
|
||||
|
||||
root.render(<App {...props} />);
|
||||
root.render(<App {...props} />)
|
||||
},
|
||||
progress: { color: '#003bf1', showSpinner: true, includeCSS: true },
|
||||
});
|
||||
})
|
||||
|
Loading…
Reference in New Issue