Merge pull request #297 from bipproduction/amalia/09-okt-24
upd: banner
This commit is contained in:
BIN
public/assets/img/banner/bg-10.png
Normal file
BIN
public/assets/img/banner/bg-10.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 497 KiB |
@@ -1,6 +1,9 @@
|
|||||||
|
import { IDataBanner } from './lib/type_banner';
|
||||||
|
import { funGetAllBanner } from './lib/api_banner';
|
||||||
import NavbarBanner from "./ui/navbar_banner";
|
import NavbarBanner from "./ui/navbar_banner";
|
||||||
import ListBanner from "./ui/list_banner";
|
import ListBanner from "./ui/list_banner";
|
||||||
import CreateBanner from "./ui/create_banner";
|
import CreateBanner from "./ui/create_banner";
|
||||||
import EditBanner from "./ui/edit_banner";
|
import EditBanner from "./ui/edit_banner";
|
||||||
import ViewfileBanner from "./ui/viewfile_banner";
|
import ViewfileBanner from "./ui/viewfile_banner";
|
||||||
export { NavbarBanner, ListBanner, CreateBanner, EditBanner, ViewfileBanner }
|
export { NavbarBanner, ListBanner, CreateBanner, EditBanner, ViewfileBanner, funGetAllBanner };
|
||||||
|
export type { IDataBanner };
|
||||||
@@ -1,13 +1,46 @@
|
|||||||
'use client'
|
'use client'
|
||||||
import React, { useRef } from 'react';
|
|
||||||
import { Carousel } from '@mantine/carousel';
|
|
||||||
import { TEMA } from '@/module/_global';
|
import { TEMA } from '@/module/_global';
|
||||||
import Autoplay from 'embla-carousel-autoplay';
|
import { funGetAllBanner, IDataBanner } from '@/module/banner';
|
||||||
import { Flex, Text } from '@mantine/core';
|
import { funGetHome } from '@/module/home';
|
||||||
import { useHookstate } from '@hookstate/core';
|
import { useHookstate } from '@hookstate/core';
|
||||||
|
import { Carousel } from '@mantine/carousel';
|
||||||
|
import { Flex, Image, Text } from '@mantine/core';
|
||||||
|
import { useShallowEffect } from '@mantine/hooks';
|
||||||
|
import Autoplay from 'embla-carousel-autoplay';
|
||||||
|
import { useRef, useState } from 'react';
|
||||||
|
import toast from 'react-hot-toast';
|
||||||
export default function CarouselDivision() {
|
export default function CarouselDivision() {
|
||||||
const autoplay = useRef(Autoplay({ delay: 5000 }));
|
const autoplay = useRef(Autoplay({ delay: 5000 }));
|
||||||
const tema = useHookstate(TEMA)
|
const tema = useHookstate(TEMA)
|
||||||
|
const [isDesa, setDesa] = useState("")
|
||||||
|
const [isData, setData] = useState<IDataBanner[]>([])
|
||||||
|
|
||||||
|
|
||||||
|
const fetchData = async () => {
|
||||||
|
try {
|
||||||
|
const res_banner = await funGetAllBanner()
|
||||||
|
if (res_banner.success) {
|
||||||
|
setData(res_banner.data)
|
||||||
|
} else {
|
||||||
|
toast.error(res_banner.message);
|
||||||
|
}
|
||||||
|
const response = await funGetHome('?cat=header')
|
||||||
|
if (response.success) {
|
||||||
|
setDesa(response.data.village)
|
||||||
|
} else {
|
||||||
|
toast.error(response.message);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
toast.error("Gagal mendapatkan data, coba lagi nanti");
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
useShallowEffect(() => {
|
||||||
|
fetchData();
|
||||||
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Carousel
|
<Carousel
|
||||||
@@ -17,21 +50,22 @@ export default function CarouselDivision() {
|
|||||||
onMouseEnter={autoplay.current.stop}
|
onMouseEnter={autoplay.current.stop}
|
||||||
onMouseLeave={autoplay.current.reset}
|
onMouseLeave={autoplay.current.reset}
|
||||||
>
|
>
|
||||||
<Carousel.Slide bg={tema.get().utama} style={{ borderRadius: 10 }}>
|
{
|
||||||
|
isData.length > 0 ?
|
||||||
|
isData.map((item, index) => (
|
||||||
|
<Carousel.Slide key={index} bg={tema.get().utama} style={{ borderRadius: 10 }}>
|
||||||
|
<Image alt={item.title} h={"100%"} style={{ borderRadius: 10 }} src={`https://wibu-storage.wibudev.com/api/files/${item.image}`} />
|
||||||
|
</Carousel.Slide>
|
||||||
|
))
|
||||||
|
:
|
||||||
|
[...Array(3)].map((_, index) => (
|
||||||
|
<Carousel.Slide key={index} bg={tema.get().utama} style={{ borderRadius: 10 }}>
|
||||||
<Flex justify={'center'} h={"100%"} align={'center'}>
|
<Flex justify={'center'} h={"100%"} align={'center'}>
|
||||||
<Text c={"white"}>INFORMASI DARMASABA</Text>
|
<Text c={"white"}>INFORMASI {isDesa.toUpperCase()}</Text>
|
||||||
</Flex>
|
|
||||||
</Carousel.Slide>
|
|
||||||
<Carousel.Slide bg={tema.get().utama} style={{ borderRadius: 10 }}>
|
|
||||||
<Flex justify={'center'} h={"100%"} align={'center'}>
|
|
||||||
<Text c={"white"}>INFORMASI DARMASABA</Text>
|
|
||||||
</Flex>
|
|
||||||
</Carousel.Slide>
|
|
||||||
<Carousel.Slide bg={tema.get().utama} style={{ borderRadius: 10 }}>
|
|
||||||
<Flex justify={'center'} h={"100%"} align={'center'}>
|
|
||||||
<Text c={"white"}>INFORMASI DARMASABA</Text>
|
|
||||||
</Flex>
|
</Flex>
|
||||||
</Carousel.Slide>
|
</Carousel.Slide>
|
||||||
|
))
|
||||||
|
}
|
||||||
</Carousel>
|
</Carousel>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { funGetHome } from "./lib/api_home";
|
||||||
import ViewDetailFeature from "./ui/view_detail_feature";
|
import ViewDetailFeature from "./ui/view_detail_feature";
|
||||||
import ViewHome from "./ui/view_home";
|
import ViewHome from "./ui/view_home";
|
||||||
import ViewNotification from "./ui/view_notification";
|
import ViewNotification from "./ui/view_notification";
|
||||||
@@ -7,3 +8,4 @@ export { ViewHome }
|
|||||||
export { ViewDetailFeature }
|
export { ViewDetailFeature }
|
||||||
export { ViewSearch }
|
export { ViewSearch }
|
||||||
export { ViewNotification }
|
export { ViewNotification }
|
||||||
|
export { funGetHome }
|
||||||
@@ -1,13 +1,46 @@
|
|||||||
'use client'
|
'use client'
|
||||||
import React, { useRef } from 'react';
|
import { TEMA } from '@/module/_global';
|
||||||
import { Carousel } from '@mantine/carousel';
|
import { funGetAllBanner, IDataBanner } from '@/module/banner';
|
||||||
import { TEMA, WARNA } from '@/module/_global';
|
|
||||||
import Autoplay from 'embla-carousel-autoplay';
|
|
||||||
import { Flex, Text } from '@mantine/core';
|
|
||||||
import { useHookstate } from '@hookstate/core';
|
import { useHookstate } from '@hookstate/core';
|
||||||
|
import { Carousel } from '@mantine/carousel';
|
||||||
|
import { Flex, Image, Text } from '@mantine/core';
|
||||||
|
import { useShallowEffect } from '@mantine/hooks';
|
||||||
|
import Autoplay from 'embla-carousel-autoplay';
|
||||||
|
import { useRef, useState } from 'react';
|
||||||
|
import toast from 'react-hot-toast';
|
||||||
|
import { funGetHome } from '../lib/api_home';
|
||||||
export default function Carosole() {
|
export default function Carosole() {
|
||||||
const autoplay = useRef(Autoplay({ delay: 5000 }));
|
const autoplay = useRef(Autoplay({ delay: 5000 }));
|
||||||
const tema = useHookstate(TEMA)
|
const tema = useHookstate(TEMA)
|
||||||
|
const [isDesa, setDesa] = useState("")
|
||||||
|
const [isData, setData] = useState<IDataBanner[]>([])
|
||||||
|
|
||||||
|
|
||||||
|
const fetchData = async () => {
|
||||||
|
try {
|
||||||
|
const res_banner = await funGetAllBanner()
|
||||||
|
if (res_banner.success) {
|
||||||
|
setData(res_banner.data)
|
||||||
|
} else {
|
||||||
|
toast.error(res_banner.message);
|
||||||
|
}
|
||||||
|
const response = await funGetHome('?cat=header')
|
||||||
|
if (response.success) {
|
||||||
|
setDesa(response.data.village)
|
||||||
|
} else {
|
||||||
|
toast.error(response.message);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
toast.error("Gagal mendapatkan data, coba lagi nanti");
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
useShallowEffect(() => {
|
||||||
|
fetchData();
|
||||||
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Carousel
|
<Carousel
|
||||||
@@ -17,21 +50,22 @@ export default function Carosole() {
|
|||||||
onMouseEnter={autoplay.current.stop}
|
onMouseEnter={autoplay.current.stop}
|
||||||
onMouseLeave={autoplay.current.reset}
|
onMouseLeave={autoplay.current.reset}
|
||||||
>
|
>
|
||||||
<Carousel.Slide bg={tema.get().utama} style={{ borderRadius: 10 }}>
|
{
|
||||||
|
isData.length > 0 ?
|
||||||
|
isData.map((item, index) => (
|
||||||
|
<Carousel.Slide key={index} bg={tema.get().utama} style={{ borderRadius: 10 }}>
|
||||||
|
<Image alt={item.title} h={"100%"} style={{ borderRadius: 10 }} src={`https://wibu-storage.wibudev.com/api/files/${item.image}`} />
|
||||||
|
</Carousel.Slide>
|
||||||
|
))
|
||||||
|
:
|
||||||
|
[...Array(3)].map((_, index) => (
|
||||||
|
<Carousel.Slide key={index} bg={tema.get().utama} style={{ borderRadius: 10 }}>
|
||||||
<Flex justify={'center'} h={"100%"} align={'center'}>
|
<Flex justify={'center'} h={"100%"} align={'center'}>
|
||||||
<Text c={"white"}>INFORMASI DARMASABA</Text>
|
<Text c={"white"}>INFORMASI {isDesa.toUpperCase()}</Text>
|
||||||
</Flex>
|
|
||||||
</Carousel.Slide>
|
|
||||||
<Carousel.Slide bg={tema.get().utama} style={{ borderRadius: 10 }}>
|
|
||||||
<Flex justify={'center'} h={"100%"} align={'center'}>
|
|
||||||
<Text c={"white"}>INFORMASI DARMASABA</Text>
|
|
||||||
</Flex>
|
|
||||||
</Carousel.Slide>
|
|
||||||
<Carousel.Slide bg={tema.get().utama} style={{ borderRadius: 10 }}>
|
|
||||||
<Flex justify={'center'} h={"100%"} align={'center'}>
|
|
||||||
<Text c={"white"}>INFORMASI DARMASABA</Text>
|
|
||||||
</Flex>
|
</Flex>
|
||||||
</Carousel.Slide>
|
</Carousel.Slide>
|
||||||
|
))
|
||||||
|
}
|
||||||
</Carousel>
|
</Carousel>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user