summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorRafi Zadanly <zadanlyr@gmail.com>2023-03-31 11:17:55 +0700
committerRafi Zadanly <zadanlyr@gmail.com>2023-03-31 11:17:55 +0700
commit092dc7fc49246580023a8b97101d51845c81bf04 (patch)
tree089121b3c6cf46429411ae6edc6c4babfebe0e0d /src/lib
parentf23d32a4b8402904e8daa7b906c03a64104ed253 (diff)
iframe content
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/content/components/PageContent.jsx2
-rw-r--r--src/lib/iframe/components/IframeContent.jsx30
-rw-r--r--src/lib/invoice/utils/invoices.js4
-rw-r--r--src/lib/transaction/components/Transaction.jsx6
-rw-r--r--src/lib/transaction/utils/transactions.js4
5 files changed, 38 insertions, 8 deletions
diff --git a/src/lib/content/components/PageContent.jsx b/src/lib/content/components/PageContent.jsx
index f7c2f467..bb44dd92 100644
--- a/src/lib/content/components/PageContent.jsx
+++ b/src/lib/content/components/PageContent.jsx
@@ -10,7 +10,7 @@ const PageContent = ({ path }) => {
let parsedContent = content.data.content
parsedContent = parsedContent.replaceAll(
'src="/web/image',
- `src="${process.env.NEXT_PUBLIC_ODOO_HOST}/web/image`
+ `src="${process.env.NEXT_PUBLIC_ODOO_API_HOST}/web/image`
)
const contentClassNames = `
prose
diff --git a/src/lib/iframe/components/IframeContent.jsx b/src/lib/iframe/components/IframeContent.jsx
new file mode 100644
index 00000000..52f2a26e
--- /dev/null
+++ b/src/lib/iframe/components/IframeContent.jsx
@@ -0,0 +1,30 @@
+import { useEffect, useRef, useState } from 'react'
+
+const IframeContent = ({ url }) => {
+ const [iframeLoaded, setIframeLoaded] = useState(false)
+ const [iframe, setIframe] = useState(null)
+ const iframeRef = useRef(null)
+
+ useEffect(() => {
+ if (iframeLoaded) {
+ setIframe({
+ height: document.querySelector('main').offsetHeight
+ })
+ }
+ }, [iframeLoaded])
+
+ return (
+ <div className='mx-auto container h-full'>
+ <iframe
+ ref={iframeRef}
+ src={url}
+ width='100%'
+ seamless
+ style={{ height: iframe?.height || 0 }}
+ onLoad={() => setIframeLoaded(true)}
+ />
+ </div>
+ )
+}
+
+export default IframeContent
diff --git a/src/lib/invoice/utils/invoices.js b/src/lib/invoice/utils/invoices.js
index 63fe91f6..73ffd0ed 100644
--- a/src/lib/invoice/utils/invoices.js
+++ b/src/lib/invoice/utils/invoices.js
@@ -1,10 +1,10 @@
const downloadInvoice = (invoice) => {
- const url = `${process.env.NEXT_PUBLIC_ODOO_HOST}/api/v1/download/invoice/${invoice.id}/${invoice.token}`
+ const url = `${process.env.NEXT_PUBLIC_ODOO_API_HOST}/api/v1/download/invoice/${invoice.id}/${invoice.token}`
window.open(url, 'download')
}
const downloadTaxInvoice = (invoice) => {
- const url = `${process.env.NEXT_PUBLIC_ODOO_HOST}/api/v1/download/tax-invoice/${invoice.id}/${invoice.token}`
+ const url = `${process.env.NEXT_PUBLIC_ODOO_API_HOST}/api/v1/download/tax-invoice/${invoice.id}/${invoice.token}`
window.open(url, 'download')
}
diff --git a/src/lib/transaction/components/Transaction.jsx b/src/lib/transaction/components/Transaction.jsx
index 669966da..51c89b28 100644
--- a/src/lib/transaction/components/Transaction.jsx
+++ b/src/lib/transaction/components/Transaction.jsx
@@ -136,15 +136,15 @@ const Transaction = ({ id }) => {
Apakah anda yakin membatalkan transaksi{' '}
<span className='underline'>{transaction.data?.name}</span>?
</div>
- <div className='flex mt-6 gap-x-4'>
+ <div className='flex justify-end mt-6 gap-x-4'>
<button
- className='btn-solid-red flex-1'
+ className='btn-solid-red w-full md:w-fit'
type='button'
onClick={submitCancelTransaction}
>
Ya, Batalkan
</button>
- <button className='btn-light flex-1' type='button' onClick={closeCancelTransaction}>
+ <button className='btn-light w-full md:w-fit' type='button' onClick={closeCancelTransaction}>
Batal
</button>
</div>
diff --git a/src/lib/transaction/utils/transactions.js b/src/lib/transaction/utils/transactions.js
index ef2f8d97..f960c181 100644
--- a/src/lib/transaction/utils/transactions.js
+++ b/src/lib/transaction/utils/transactions.js
@@ -2,13 +2,13 @@ import { getAuth } from '@/core/utils/auth'
const downloadPurchaseOrder = (transaction) => {
const auth = getAuth()
- const url = `${process.env.NEXT_PUBLIC_ODOO_HOST}/api/v1/partner/${auth.partnerId}/sale_order/${transaction.id}/download_po/${transaction.token}`
+ const url = `${process.env.NEXT_PUBLIC_ODOO_API_HOST}/api/v1/partner/${auth.partnerId}/sale_order/${transaction.id}/download_po/${transaction.token}`
window.open(url, 'download')
}
const downloadQuotation = (transaction) => {
const auth = getAuth()
- const url = `${process.env.NEXT_PUBLIC_ODOO_HOST}/api/v1/partner/${auth.partnerId}/sale_order/${transaction.id}/download/${transaction.token}`
+ const url = `${process.env.NEXT_PUBLIC_ODOO_API_HOST}/api/v1/partner/${auth.partnerId}/sale_order/${transaction.id}/download/${transaction.token}`
window.open(url, 'download')
}