diff --git a/app/Http/Controllers/InfoController.php b/app/Http/Controllers/InfoController.php
index f13e6a0..6945901 100644
--- a/app/Http/Controllers/InfoController.php
+++ b/app/Http/Controllers/InfoController.php
@@ -9,47 +9,66 @@ class InfoController extends Controller
{
public function index()
{
- $query = Info::paginate();
+ $query = Info::orderBy('updated_at', 'desc')->paginate();
return inertia('Info/Index', [
'query' => $query,
]);
}
+ public function create()
+ {
+ return inertia('Info/Form');
+ }
+
public function store(Request $request)
{
$request->validate([
- 'info' => 'required|string',
+ 'title' => 'required|string',
+ 'description' => 'required|string',
'is_publish' => 'required|in:0,1',
]);
Info::create([
- 'title' => $request->info,
+ 'title' => $request->title,
+ 'description' => $request->description,
'is_publish' => $request->is_publish,
]);
- session()->flash('message', ['type' => 'success', 'message' => 'Item has beed saved']);
+ return redirect()->route('info.index')
+ ->with('message', ['type' => 'success', 'message' => 'Item has beed saved']);
+ }
+
+ public function edit(Info $info)
+ {
+ return inertia('Info/Form', [
+ 'info' => $info
+ ]);
}
public function update(Request $request, Info $info)
{
$request->validate([
- 'info' => 'required|string',
+ 'title' => 'required|string',
+ 'description' => 'required|string',
'is_publish' => 'required|in:0,1',
]);
$info->update([
- 'title' => $request->info,
+ 'title' => $request->title,
+ 'description' => $request->description,
'is_publish' => $request->is_publish,
]);
- session()->flash('message', ['type' => 'success', 'message' => 'Item has beed updated']);
+ return redirect()->route('info.index')
+ ->with('message', ['type' => 'success', 'message' => 'Item has beed updated']);
}
public function destroy(Info $info)
{
$info->delete();
- session()->flash('message', ['type' => 'success', 'message' => 'Item has beed deleted']);
+ return redirect()->route('info.index')
+ ->with('message', ['type' => 'success', 'message' => 'Item has beed deleted']);
}
}
diff --git a/app/Models/Info.php b/app/Models/Info.php
index dd8d54c..de7c18b 100644
--- a/app/Models/Info.php
+++ b/app/Models/Info.php
@@ -8,6 +8,7 @@ class Info extends Model
protected $fillable = [
'title',
+ 'description',
'destination',
'type',
'is_publish',
diff --git a/database/migrations/2023_05_24_183208_create_infos_table.php b/database/migrations/2023_05_24_183208_create_infos_table.php
index ec95b4d..8a34c2a 100644
--- a/database/migrations/2023_05_24_183208_create_infos_table.php
+++ b/database/migrations/2023_05_24_183208_create_infos_table.php
@@ -14,7 +14,8 @@ return new class extends Migration
Schema::create('infos', function (Blueprint $table) {
$table->ulid('id')->primary();
- $table->text('title');
+ $table->string('title')->nullable();
+ $table->text('description')->nullable();
$table->string('destination')->nullable();
$table->string('type')->nullable();
$table->smallInteger('is_publish')->nullable();
diff --git a/database/seeders/DummySeeder.php b/database/seeders/DummySeeder.php
index cd081b7..754cff2 100644
--- a/database/seeders/DummySeeder.php
+++ b/database/seeders/DummySeeder.php
@@ -35,6 +35,14 @@ class DummySeeder extends Seeder
{
Info::create([
'title' => 'Welcome to our new site',
+ 'description' => '
+
+ Info: Welcome to new WBB site
+
+ ',
'is_publish' => 1,
]);
}
@@ -44,8 +52,8 @@ class DummySeeder extends Seeder
$images = ['1.webp', '2.webp', '3.webp'];
foreach ($images as $index => $image) {
Banner::create([
- 'title' => 'Banner '.$index,
- 'image' => 'sample/'.$image,
+ 'title' => 'Banner ' . $index,
+ 'image' => 'sample/' . $image,
'description' => 'Banner
',
]);
}
@@ -102,7 +110,7 @@ class DummySeeder extends Seeder
$lp = LocationProfile::create([
'location_id' => $location->id,
- 'name' => 'Profile '.$quota,
+ 'name' => 'Profile ' . $quota,
'quota' => $quota,
'display_note' => 'bisa semua',
'expired' => rand(1, 3),
diff --git a/resources/js/Components/Defaults/Dropdown.jsx b/resources/js/Components/Defaults/Dropdown.jsx
index bbd704a..1bdb88f 100644
--- a/resources/js/Components/Defaults/Dropdown.jsx
+++ b/resources/js/Components/Defaults/Dropdown.jsx
@@ -87,12 +87,13 @@ const Content = ({
)
}
-const DropdownLink = ({ href, method, as, children }) => {
+const DropdownLink = ({ href, method, as, children, target = 'self' }) => {
return (
{children}
diff --git a/resources/js/Customer/Index/Index.jsx b/resources/js/Customer/Index/Index.jsx
index a6360c3..bf26151 100644
--- a/resources/js/Customer/Index/Index.jsx
+++ b/resources/js/Customer/Index/Index.jsx
@@ -84,12 +84,9 @@ export default function Index(props) {
{infos.map((info) => (
- {info.title}
-
+ />
))}
diff --git a/resources/js/Layouts/AuthenticatedLayout.jsx b/resources/js/Layouts/AuthenticatedLayout.jsx
index 25b97aa..374c193 100644
--- a/resources/js/Layouts/AuthenticatedLayout.jsx
+++ b/resources/js/Layouts/AuthenticatedLayout.jsx
@@ -122,6 +122,13 @@ export default function Authenticated({
+
+ Visit Site
+
diff --git a/resources/js/Layouts/Partials/routes.js b/resources/js/Layouts/Partials/routes.js
index 63cd64f..116338f 100644
--- a/resources/js/Layouts/Partials/routes.js
+++ b/resources/js/Layouts/Partials/routes.js
@@ -96,7 +96,7 @@ export default [
show: true,
icon: HiQuestionMarkCircle,
route: route('info.index'),
- active: 'info.index',
+ active: 'info.*',
permission: 'view-info',
},
],
diff --git a/resources/js/Pages/Info/Form.jsx b/resources/js/Pages/Info/Form.jsx
new file mode 100644
index 0000000..13da6f8
--- /dev/null
+++ b/resources/js/Pages/Info/Form.jsx
@@ -0,0 +1,112 @@
+import React, { useEffect, Suspense } from 'react'
+import { isEmpty } from 'lodash'
+
+import AuthenticatedLayout from '@/Layouts/AuthenticatedLayout'
+import FormInput from '@/Components/FormInput'
+import Button from '@/Components/Button'
+import { Head, useForm } from '@inertiajs/react'
+
+const TinyEditor = React.lazy(() => import('@/Components/TinyMCE'))
+
+export default function Form(props) {
+ const { info } = props
+
+ const { data, setData, post, put, processing, errors } = useForm({
+ title: '',
+ description: '',
+ is_publish: 1,
+ })
+
+ const handleOnChange = (event) => {
+ setData(
+ event.target.name,
+ event.target.type === 'checkbox'
+ ? event.target.checked
+ ? 1
+ : 0
+ : event.target.value
+ )
+ }
+ const handleSubmit = () => {
+ if (isEmpty(info) === false) {
+ put(route('info.update', info))
+ return
+ }
+ post(route('info.store'))
+ }
+
+ useEffect(() => {
+ if (isEmpty(info) === false) {
+ setData({
+ title: info.title,
+ description: info.description,
+ is_publish: info.is_publish,
+ })
+ }
+ }, [info])
+
+ return (
+
+
+
+
+
+
+
Info
+
+
+ Loading...
}>
+
{
+ setData(
+ 'description',
+ editor.getContent()
+ )
+ }}
+ />
+
+
+
+
Publish
+
+
+
+
+
+
+
+
+
+ )
+}
diff --git a/resources/js/Pages/Info/Index.jsx b/resources/js/Pages/Info/Index.jsx
index ff8b30c..e38ca52 100644
--- a/resources/js/Pages/Info/Index.jsx
+++ b/resources/js/Pages/Info/Index.jsx
@@ -1,5 +1,5 @@
import React, { useEffect, useState } from 'react'
-import { router } from '@inertiajs/react'
+import { Link, router } from '@inertiajs/react'
import { usePrevious } from 'react-use'
import { Head } from '@inertiajs/react'
import { Button, Dropdown } from 'flowbite-react'
@@ -20,12 +20,6 @@ export default function Info(props) {
} = props
const confirmModal = useModalState()
- const formModal = useModalState()
-
- const toggleFormModal = (info = null) => {
- formModal.setData(info)
- formModal.toggle()
- }
const handleDeleteClick = (info) => {
confirmModal.setData(info)
@@ -51,12 +45,9 @@ export default function Info(props) {
{canCreate && (
-
+
+
+
)}
@@ -108,19 +99,13 @@ export default function Info(props) {
size={'sm'}
>
{canUpdate && (
-
- toggleFormModal(
- info
- )
- }
- >
-
+
)}
{canDelete && (
@@ -154,7 +139,6 @@ export default function Info(props) {
-
)
}
diff --git a/routes/admin.php b/routes/admin.php
index 29ddaca..6c0cb55 100644
--- a/routes/admin.php
+++ b/routes/admin.php
@@ -57,7 +57,9 @@ Route::middleware(['http_secure_aware', 'inertia.admin'])
// Info
Route::get('/infos', [InfoController::class, 'index'])->name('info.index');
+ Route::get('/infos/create', [InfoController::class, 'create'])->name('info.create');
Route::post('/infos', [InfoController::class, 'store'])->name('info.store');
+ Route::get('/infos/{info}', [InfoController::class, 'edit'])->name('info.edit');
Route::put('/infos/{info}', [InfoController::class, 'update'])->name('info.update');
Route::delete('/infos/{info}', [InfoController::class, 'destroy'])->name('info.destroy');
diff --git a/tailwind.config.js b/tailwind.config.js
index c5c1fbc..85f6ee5 100644
--- a/tailwind.config.js
+++ b/tailwind.config.js
@@ -28,7 +28,7 @@ module.exports = {
600: '#0867ff',
700: '#024ff3',
800: '#0940c4',
- 900: '#0e3995',
+ 900: '#0e3995', // default
950: '#0e255d',
},
secondary: {
@@ -37,7 +37,7 @@ module.exports = {
200: '#fbe88c',
300: '#f9d650',
400: '#f7c328',
- 500: '#f1a410',
+ 500: '#f1a410', //default
600: '#d57d0a',
700: '#b1580c',
800: '#904510',