68 lines
2.2 KiB
JavaScript
68 lines
2.2 KiB
JavaScript
import React, { useRef } from 'react';
|
|
import { FormattedMessage } from 'react-intl';
|
|
import { useRouter } from 'next/router';
|
|
import Button from 'components/common/Button';
|
|
import FormLayout, { FormButtons, FormRow } from 'components/layout/FormLayout';
|
|
import CopyButton from 'components/common/CopyButton';
|
|
|
|
export default function TrackingCodeForm({ values, onClose }) {
|
|
const ref = useRef();
|
|
const ref1 = useRef();
|
|
const { basePath } = useRouter();
|
|
const { name, shareId, websiteUuid } = values;
|
|
|
|
return (
|
|
<FormLayout>
|
|
<p>
|
|
<FormattedMessage
|
|
id="message.share-url"
|
|
defaultMessage="This is the publicly shared URL for {target}."
|
|
values={{ target: <b>{values.name}</b> }}
|
|
/>
|
|
</p>
|
|
<FormRow>
|
|
<textarea
|
|
ref={ref}
|
|
rows={3}
|
|
cols={60}
|
|
spellCheck={false}
|
|
defaultValue={`${
|
|
document.location.origin
|
|
}${basePath}/share/${shareId}/${encodeURIComponent(name)}`}
|
|
readOnly
|
|
/>
|
|
</FormRow>
|
|
<FormButtons>
|
|
<CopyButton type="submit" variant="action" element={ref} />
|
|
</FormButtons>
|
|
<p>
|
|
<FormattedMessage
|
|
id="message.embedded-url"
|
|
defaultMessage="This is the public embedded code for {target}."
|
|
values={{ target: <b>{values.name}</b> }}
|
|
/>
|
|
</p>
|
|
<FormRow>
|
|
<textarea
|
|
ref={ref1}
|
|
rows={3}
|
|
cols={60}
|
|
spellCheck={false}
|
|
defaultValue={`<canvas id="unamiChart" style="height: 300px;" data-url="${document.location.origin}${basePath}" data-website="${websiteUuid}" data-share-id="${shareId}" data-reload="5" data-start-at="auto" data-end-at="auto" data-unit="hour" data-tz="Asia/Dhaka"></canvas>
|
|
<script src="${document.location.origin}/embedded.js"></script>
|
|
`}
|
|
readOnly
|
|
/>
|
|
</FormRow>
|
|
<FormButtons>
|
|
<CopyButton type="submit" variant="action" element={ref1} />
|
|
</FormButtons>
|
|
<FormButtons>
|
|
<Button onClick={onClose}>
|
|
<FormattedMessage id="label.cancel" defaultMessage="Cancel" />
|
|
</Button>
|
|
</FormButtons>
|
|
</FormLayout>
|
|
);
|
|
}
|