INit
This commit is contained in:
94
resources/js/pages/dashboard/carousel/add.tsx
Normal file
94
resources/js/pages/dashboard/carousel/add.tsx
Normal file
@@ -0,0 +1,94 @@
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Input } from '@/components/ui/input';
|
||||
import { Label } from '@/components/ui/label';
|
||||
import AppLayout from '@/layouts/app-layout';
|
||||
import { Head, useForm } from '@inertiajs/react';
|
||||
import FilePondPluginImageExifOrientation from 'filepond-plugin-image-exif-orientation';
|
||||
import FilePondPluginImagePreview from 'filepond-plugin-image-preview';
|
||||
import 'filepond-plugin-image-preview/dist/filepond-plugin-image-preview.css';
|
||||
import 'filepond/dist/filepond.min.css';
|
||||
import { useState } from 'react';
|
||||
import { FilePond, registerPlugin } from 'react-filepond';
|
||||
import { toast } from 'sonner';
|
||||
|
||||
registerPlugin(FilePondPluginImageExifOrientation, FilePondPluginImagePreview);
|
||||
|
||||
export default function CarouselAdd() {
|
||||
const [file, setFile] = useState<any | null>(null);
|
||||
|
||||
const { data, setData, post, processing, errors, wasSuccessful } = useForm({
|
||||
alt: '',
|
||||
image_url: null as File | null,
|
||||
});
|
||||
|
||||
const handleSubmit = (e: React.FormEvent) => {
|
||||
e.preventDefault();
|
||||
|
||||
if (file) {
|
||||
setData('image_url', file.file);
|
||||
}
|
||||
|
||||
post('/carousel', {
|
||||
forceFormData: true,
|
||||
});
|
||||
|
||||
if (wasSuccessful) {
|
||||
toast.success('Slider image successfully uploaded');
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<AppLayout>
|
||||
<Head title="Add Carousel" />
|
||||
<section className="flex flex-col gap-8 px-8 py-8">
|
||||
<h1 className="text-lg font-semibold tracking-tight">
|
||||
Add Slider Image
|
||||
</h1>
|
||||
<form
|
||||
onSubmit={handleSubmit}
|
||||
method="POST"
|
||||
encType="multipart/formdata"
|
||||
>
|
||||
<div className="flex flex-col gap-4">
|
||||
<Label htmlFor="title">Title</Label>
|
||||
<Input
|
||||
type="text"
|
||||
id="title"
|
||||
value={data.alt}
|
||||
onChange={(e) => setData('alt', e.target.value)}
|
||||
className="rounded border p-2"
|
||||
/>
|
||||
{errors.alt && (
|
||||
<span className="text-red-600">{errors.alt}</span>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="mt-4">
|
||||
<Label>Image</Label>
|
||||
<FilePond
|
||||
files={file ? [file] : []}
|
||||
onupdatefiles={(fileItems) => {
|
||||
setFile(fileItems[0] || null);
|
||||
}}
|
||||
allowMultiple={false}
|
||||
maxFiles={1}
|
||||
name="image_url" // Change this to match your backend expectation
|
||||
instantUpload={false}
|
||||
storeAsFile={true}
|
||||
labelIdle='Drag & Drop your image or <span class="filepond--label-action">Browse</span>'
|
||||
/>
|
||||
{errors.image_url && (
|
||||
<span className="text-red-600">
|
||||
{errors.image_url}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<Button type="submit" disabled={processing}>
|
||||
{processing ? 'Uploading...' : 'Submit'}
|
||||
</Button>
|
||||
</form>
|
||||
</section>
|
||||
</AppLayout>
|
||||
);
|
||||
}
|
||||
83
resources/js/pages/dashboard/carousel/carousel.tsx
Normal file
83
resources/js/pages/dashboard/carousel/carousel.tsx
Normal file
@@ -0,0 +1,83 @@
|
||||
import { Button } from '@/components/ui/button';
|
||||
import {
|
||||
Table,
|
||||
TableBody,
|
||||
TableCell,
|
||||
TableHead,
|
||||
TableHeader,
|
||||
TableRow,
|
||||
} from '@/components/ui/table';
|
||||
import AppLayout from '@/layouts/app-layout';
|
||||
import dashboardcarousel from '@/routes/dashboard/carousel';
|
||||
import { Head, Link } from '@inertiajs/react';
|
||||
import { Pencil, Trash2 } from 'lucide-react';
|
||||
|
||||
export default function Carousel({
|
||||
carousel,
|
||||
}: {
|
||||
carousel: [{ alt: string; image_url: string }];
|
||||
}) {
|
||||
return (
|
||||
<>
|
||||
<AppLayout
|
||||
breadcrumbs={[
|
||||
{ title: 'Carousel', href: dashboardcarousel.index().url },
|
||||
]}
|
||||
>
|
||||
<Head title="Carousel"></Head>
|
||||
<section className="flex flex-col gap-8 px-8 py-8">
|
||||
<div className="flex items-center justify-between">
|
||||
<h1 className="text-xl font-semibold tracking-tight">
|
||||
Carousel
|
||||
</h1>
|
||||
<Link href={dashboardcarousel.add()}>
|
||||
<Button>Add Image</Button>
|
||||
</Link>
|
||||
</div>
|
||||
<Table>
|
||||
<TableHeader>
|
||||
<TableRow>
|
||||
<TableHead className="w-[80px]">S.N.</TableHead>
|
||||
<TableHead className="w-48">Image</TableHead>
|
||||
<TableHead>Title</TableHead>
|
||||
<TableHead className="text-right">
|
||||
Action
|
||||
</TableHead>
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
{carousel.map((item, index) => (
|
||||
<TableRow key={index}>
|
||||
<TableCell className="font-medium">
|
||||
{index + 1}
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
<img
|
||||
src={item.image_url}
|
||||
alt={item.alt}
|
||||
className="aspect-video w-24 rounded-md object-cover object-center"
|
||||
/>
|
||||
</TableCell>
|
||||
<TableCell>{item.alt}</TableCell>
|
||||
<TableCell className="text-right">
|
||||
<div className="flex items-center justify-end gap-2">
|
||||
<Link href="">
|
||||
<Pencil size={18} />
|
||||
</Link>
|
||||
<Link href="">
|
||||
<Trash2
|
||||
size={18}
|
||||
color={'#D2042D'}
|
||||
/>
|
||||
</Link>
|
||||
</div>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
))}
|
||||
</TableBody>
|
||||
</Table>
|
||||
</section>
|
||||
</AppLayout>
|
||||
</>
|
||||
);
|
||||
}
|
||||
17
resources/js/pages/dashboard/testimonial.tsx
Normal file
17
resources/js/pages/dashboard/testimonial.tsx
Normal file
@@ -0,0 +1,17 @@
|
||||
import AppLayout from '@/layouts/app-layout';
|
||||
import testimonial from '@/routes/testimonial';
|
||||
import { Head } from '@inertiajs/react';
|
||||
|
||||
export default function Testimonial() {
|
||||
return (
|
||||
<>
|
||||
<AppLayout
|
||||
breadcrumbs={[
|
||||
{ title: 'testimonial', href: testimonial.index().url },
|
||||
]}
|
||||
>
|
||||
<Head title={'Testimonials'}></Head>
|
||||
</AppLayout>
|
||||
</>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user