Fixed share url.

This commit is contained in:
Mike Cao 2023-12-06 01:26:58 -08:00
parent 4fca98d25d
commit c8eb76c7af
3 changed files with 5 additions and 6 deletions

View File

@ -21,7 +21,7 @@ export default function SettingsLayout({ children }) {
const getKey = () => items.find(({ url }) => pathname === url)?.key; const getKey = () => items.find(({ url }) => pathname === url)?.key;
if (cloudMode && pathname != '/settings/profile') { if (cloudMode && pathname !== '/settings/profile') {
return null; return null;
} }
@ -29,7 +29,6 @@ export default function SettingsLayout({ children }) {
const config = { const config = {
settingsUrl: '/settings/websites', settingsUrl: '/settings/websites',
hostUrl,
shareUrl: hostUrl, shareUrl: hostUrl,
trackingCodeUrl: hostUrl, trackingCodeUrl: hostUrl,
websitesUrl: `/websites`, websitesUrl: `/websites`,

View File

@ -51,7 +51,7 @@ export function WebsiteSettings({ websiteId, openExternal = false }) {
}, [data]); }, [data]);
if (isLoading || !values) { if (isLoading || !values) {
return <Loading />; return <Loading position="page" />;
} }
return ( return (

View File

@ -17,15 +17,15 @@ import SettingsContext from '../../SettingsContext';
const generateId = () => getRandomChars(16); const generateId = () => getRandomChars(16);
export function ShareUrl({ websiteId, data, onSave }) { export function ShareUrl({ websiteId, data, onSave }) {
const ref = useRef(null);
const { shareUrl, websitesUrl } = useContext(SettingsContext);
const { formatMessage, labels, messages } = useMessages(); const { formatMessage, labels, messages } = useMessages();
const { name, shareId } = data; const { name, shareId } = data;
const [id, setId] = useState(shareId); const [id, setId] = useState(shareId);
const { post, useMutation } = useApi(); const { post, useMutation } = useApi();
const { mutate, error } = useMutation({ const { mutate, error } = useMutation({
mutationFn: (data: any) => post(`/websites/${websiteId}`, data), mutationFn: (data: any) => post(`${websitesUrl}/${websiteId}`, data),
}); });
const ref = useRef(null);
const { shareUrl } = useContext(SettingsContext);
const url = useMemo( const url = useMemo(
() => `${shareUrl}${process.env.basePath}/share/${id}/${encodeURIComponent(name)}`, () => `${shareUrl}${process.env.basePath}/share/${id}/${encodeURIComponent(name)}`,
[id, name], [id, name],