From f76c895fa0ab29d4f57f234b58227a43cd9d5e20 Mon Sep 17 00:00:00 2001
From: Rafi Zadanly <zadanlyr@gmail.com>
Date: Tue, 21 Nov 2023 13:31:01 +0700
Subject: Fix page content component parsing content

---
 src-migrate/modules/page-content/index.tsx | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

(limited to 'src-migrate/modules/page-content/index.tsx')

diff --git a/src-migrate/modules/page-content/index.tsx b/src-migrate/modules/page-content/index.tsx
index cbd58633..608079f8 100644
--- a/src-migrate/modules/page-content/index.tsx
+++ b/src-migrate/modules/page-content/index.tsx
@@ -1,3 +1,4 @@
+import { useMemo } from "react"
 import { useQuery } from "react-query"
 import PageContentSkeleton from "~/common/components/skeleton/PageContentSkeleton"
 import { PageContentProps } from "~/common/types/pageContent"
@@ -10,12 +11,18 @@ type Props = {
 const PageContent = ({ path }: Props) => {
   const { data, isLoading } = useQuery<PageContentProps>(`page-content:${path}`, async () => await getPageContent({ path }))
 
-  if (isLoading) {
-    return <PageContentSkeleton />
-  }
+  const parsedContent = useMemo<string>(() => {
+    if (!data) return ''
+    return data.content.replaceAll(
+      'src="/web/image',
+      `src="${process.env.NEXT_PUBLIC_ODOO_API_HOST}/web/image`
+    )
+  }, [data])
+
+  if (isLoading) return <PageContentSkeleton />
 
   return (
-    <div dangerouslySetInnerHTML={{ __html: data?.content || '' }}></div>
+    <div dangerouslySetInnerHTML={{ __html: parsedContent || '' }}></div>
   )
 }
 
-- 
cgit v1.2.3

