summaryrefslogtreecommitdiff
path: root/src-migrate/modules
diff options
context:
space:
mode:
authorit-fixcomart <it@fixcomart.co.id>2024-11-13 10:08:16 +0700
committerit-fixcomart <it@fixcomart.co.id>2024-11-13 10:08:16 +0700
commit0d3c0cf6a00ef81bfdb944490e48f16af41fc029 (patch)
treead5dd0c580c33d4856455a1272a31ce8349ddda9 /src-migrate/modules
parent0ecb7ba546cd1fdd3811f76aa09b20642ab4952c (diff)
<iman> add radis
Diffstat (limited to 'src-migrate/modules')
-rw-r--r--src-migrate/modules/page-content/index.tsx33
1 files changed, 13 insertions, 20 deletions
diff --git a/src-migrate/modules/page-content/index.tsx b/src-migrate/modules/page-content/index.tsx
index 3423ca8b..54ee0a04 100644
--- a/src-migrate/modules/page-content/index.tsx
+++ b/src-migrate/modules/page-content/index.tsx
@@ -10,28 +10,21 @@ type Props = {
const PageContent = ({ path }: Props) => {
const [localData, setData] = useState<PageContentProps>();
const [shouldFetch, setShouldFetch] = useState(false);
+ const [isLoading, setIsLoading] = useState(false);
useEffect(() => {
- const localData = localStorage.getItem(`page-content:${path}`);
- if (localData) {
- setData(JSON.parse(localData));
- }else{
- setShouldFetch(true);
- }
- },[])
-
- const { data, isLoading } = useQuery<PageContentProps>(
- `page-content:${path}`,
- async () => await getPageContent({ path }), {
- enabled: shouldFetch,
- onSuccess: (data) => {
- if (data) {
- localStorage.setItem(`page-content:${path}`, JSON.stringify(data));
- setData(data);
- }
- },
- }
- );
+ const fetchData = async () => {
+ setIsLoading(true);
+ const res = await fetch(`/api/page-content?path=${path}`);
+ const { data } = await res.json();
+ if (data) {
+ setData(data);
+ }
+ setIsLoading(false);
+ };
+
+ fetchData();
+ }, []);
const parsedContent = useMemo<string>(() => {
if (!localData) return '';