mirror of
https://github.com/kremalicious/umami.git
synced 2024-11-22 09:57:00 +01:00
Fixed website refresh after save.
This commit is contained in:
parent
f01073c46a
commit
f50067e44f
@ -7,7 +7,6 @@ import {
|
||||
Button,
|
||||
Toggle,
|
||||
LoadingButton,
|
||||
useToasts,
|
||||
} from 'react-basics';
|
||||
import { useContext, useState } from 'react';
|
||||
import { getRandomChars } from 'next-basics';
|
||||
@ -18,6 +17,7 @@ const generateId = () => getRandomChars(16);
|
||||
|
||||
export function ShareUrl({
|
||||
hostUrl,
|
||||
onSave,
|
||||
}: {
|
||||
websiteId: string;
|
||||
hostUrl?: string;
|
||||
@ -27,7 +27,6 @@ export function ShareUrl({
|
||||
const { domain, shareId } = website;
|
||||
const { formatMessage, labels, messages } = useMessages();
|
||||
const [id, setId] = useState(shareId);
|
||||
const { showToast } = useToasts();
|
||||
const { post, useMutation } = useApi();
|
||||
const { mutate, error, isPending } = useMutation({
|
||||
mutationFn: (data: any) => post(`/websites/${website.id}`, data),
|
||||
@ -46,7 +45,8 @@ export function ShareUrl({
|
||||
const data = { shareId: checked ? generateId() : null };
|
||||
mutate(data, {
|
||||
onSuccess: async () => {
|
||||
showToast({ message: formatMessage(messages.saved), variant: 'success' });
|
||||
touch(`website:${website.id}`);
|
||||
onSave?.();
|
||||
},
|
||||
});
|
||||
setId(data.shareId);
|
||||
@ -57,8 +57,8 @@ export function ShareUrl({
|
||||
{ shareId: id },
|
||||
{
|
||||
onSuccess: async () => {
|
||||
showToast({ message: formatMessage(messages.saved), variant: 'success' });
|
||||
touch(`website:${website?.id}`);
|
||||
touch(`website:${website.id}`);
|
||||
onSave?.();
|
||||
},
|
||||
},
|
||||
);
|
||||
|
@ -1,18 +1,10 @@
|
||||
import { useContext, useRef } from 'react';
|
||||
import {
|
||||
SubmitButton,
|
||||
Form,
|
||||
FormInput,
|
||||
FormRow,
|
||||
FormButtons,
|
||||
TextField,
|
||||
useToasts,
|
||||
} from 'react-basics';
|
||||
import { SubmitButton, Form, FormInput, FormRow, FormButtons, TextField } from 'react-basics';
|
||||
import { useApi, useMessages, useModified } from 'components/hooks';
|
||||
import { DOMAIN_REGEX } from 'lib/constants';
|
||||
import { WebsiteContext } from 'app/(main)/websites/[websiteId]/WebsiteProvider';
|
||||
|
||||
export function WebsiteEditForm({ websiteId }: { websiteId: string }) {
|
||||
export function WebsiteEditForm({ websiteId, onSave }: { websiteId: string; onSave?: () => void }) {
|
||||
const website = useContext(WebsiteContext);
|
||||
const { formatMessage, labels, messages } = useMessages();
|
||||
const { post, useMutation } = useApi();
|
||||
@ -20,15 +12,14 @@ export function WebsiteEditForm({ websiteId }: { websiteId: string }) {
|
||||
mutationFn: (data: any) => post(`/websites/${websiteId}`, data),
|
||||
});
|
||||
const ref = useRef(null);
|
||||
const { showToast } = useToasts();
|
||||
const { touch } = useModified();
|
||||
|
||||
const handleSubmit = async (data: any) => {
|
||||
mutate(data, {
|
||||
onSuccess: async () => {
|
||||
showToast({ message: formatMessage(messages.saved), variant: 'success' });
|
||||
ref.current.reset(data);
|
||||
touch(`website:${website?.id}`);
|
||||
touch(`website:${website.id}`);
|
||||
onSave?.();
|
||||
},
|
||||
});
|
||||
};
|
||||
|
@ -38,9 +38,9 @@ export function WebsiteSettings({ websiteId, openExternal = false }) {
|
||||
<Item key="share">{formatMessage(labels.shareUrl)}</Item>
|
||||
<Item key="data">{formatMessage(labels.data)}</Item>
|
||||
</Tabs>
|
||||
{tab === 'details' && <WebsiteEditForm websiteId={websiteId} />}
|
||||
{tab === 'details' && <WebsiteEditForm websiteId={websiteId} onSave={handleSave} />}
|
||||
{tab === 'tracking' && <TrackingCode websiteId={websiteId} />}
|
||||
{tab === 'share' && <ShareUrl websiteId={websiteId} />}
|
||||
{tab === 'share' && <ShareUrl websiteId={websiteId} onSave={handleSave} />}
|
||||
{tab === 'data' && <WebsiteData websiteId={websiteId} onSave={handleSave} />}
|
||||
</>
|
||||
);
|
||||
|
@ -89,3 +89,18 @@ main::-webkit-scrollbar-track {
|
||||
background-color: var(--base800);
|
||||
background-clip: padding-box;
|
||||
}
|
||||
|
||||
:root {
|
||||
--dark50: #111111;
|
||||
--dark75: #191919;
|
||||
--dark100: #222222;
|
||||
--dark150: #2a2a2a;
|
||||
--dark200: #313131;
|
||||
--dark300: #3a3a3a;
|
||||
--dark400: #484848;
|
||||
--dark500: #606060;
|
||||
--dark600: #6e6e6e;
|
||||
--dark700: #7b7b7b;
|
||||
--dark800: #b4b4b4;
|
||||
--dark900: #eeeeee;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user