fix event admin
This commit is contained in:
30
src/app/zz-makuro/LoadDataContoh.tsx
Normal file
30
src/app/zz-makuro/LoadDataContoh.tsx
Normal file
@@ -0,0 +1,30 @@
|
||||
"use client";
|
||||
import { Stack } from "@mantine/core";
|
||||
import useSwr from "swr";
|
||||
|
||||
const fether = (url: string) =>
|
||||
fetch("https://jsonplaceholder.typicode.com" + url, {
|
||||
cache: "force-cache",
|
||||
next: {
|
||||
revalidate: 60,
|
||||
},
|
||||
}).then((res) => res.json());
|
||||
|
||||
export default function LoadDataContoh() {
|
||||
const { data, isLoading, error, mutate, isValidating } = useSwr(
|
||||
"/posts/1",
|
||||
fether,
|
||||
{
|
||||
revalidateOnFocus: false,
|
||||
revalidateOnReconnect: false,
|
||||
refreshInterval: 1000,
|
||||
}
|
||||
);
|
||||
return (
|
||||
<Stack>
|
||||
{isLoading && <div>Loading...</div>}
|
||||
LoadDataContoh
|
||||
{JSON.stringify(data, null, 2)}
|
||||
</Stack>
|
||||
);
|
||||
}
|
||||
9
src/app/zz-makuro/get-data-example.ts
Normal file
9
src/app/zz-makuro/get-data-example.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
async function getDataExample() {
|
||||
const res = await fetch("https://jsonplaceholder.typicode.com/posts", {
|
||||
next: {
|
||||
revalidate: 60,
|
||||
},
|
||||
});
|
||||
|
||||
return res.json();
|
||||
}
|
||||
@@ -1,14 +1,51 @@
|
||||
"use client";
|
||||
import { useHookstate } from "@hookstate/core";
|
||||
import { Button, Stack } from "@mantine/core";
|
||||
import { Suspense } from "react";
|
||||
import LoadDataContoh from "./LoadDataContoh";
|
||||
|
||||
const listMenu = [
|
||||
{
|
||||
name: "Dashboard",
|
||||
url: "/dashboard",
|
||||
icon: "dashboard",
|
||||
},
|
||||
{
|
||||
name: "Event",
|
||||
url: "/event",
|
||||
icon: "event",
|
||||
},
|
||||
{
|
||||
name: "Donasi",
|
||||
url: "/donasi",
|
||||
icon: "donasi",
|
||||
},
|
||||
];
|
||||
|
||||
export default function Page() {
|
||||
const fether = async (url: string) =>
|
||||
fetch("https://jsonplaceholder.typicode.com" + url, {
|
||||
next: {
|
||||
revalidate: 2,
|
||||
},
|
||||
}).then(async (res) => {
|
||||
const data = await res.json();
|
||||
// console.log(data);
|
||||
return data;
|
||||
});
|
||||
|
||||
export default async function Page() {
|
||||
const data = await fether("/posts/1");
|
||||
|
||||
return (
|
||||
<Stack>
|
||||
|
||||
<Button onClick={() => {}}>tekan</Button>
|
||||
</Stack>
|
||||
<div>
|
||||
{listMenu.map((item) => {
|
||||
return (
|
||||
<div key={item.name}>
|
||||
<a href={item.url}>{item.name}</a>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
{/* <LoadDataContoh /> */}
|
||||
<Suspense fallback={<div>Loading...</div>}>
|
||||
{JSON.stringify(data, null, 2)}
|
||||
</Suspense>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user