Merge branch 'dev' into analytics

This commit is contained in:
Mike Cao 2023-04-06 20:41:24 -07:00
commit b1fbb20967
6 changed files with 26 additions and 25 deletions

View File

@ -3,11 +3,13 @@ import { useRouter } from 'next/router';
import Icons from 'components/icons';
import useMessages from 'hooks/useMessages';
import useUser from 'hooks/useUser';
import useConfig from 'hooks/useConfig';
import styles from './ProfileButton.module.css';
export default function ProfileButton() {
const { formatMessage, labels } = useMessages();
const { user } = useUser();
const { cloudMode } = useConfig();
const router = useRouter();
const handleSelect = key => {
@ -40,12 +42,14 @@ export default function ProfileButton() {
</Icon>
<Text>{formatMessage(labels.profile)}</Text>
</Item>
<Item key="logout" className={styles.item}>
<Icon>
<Icons.Logout />
</Icon>
<Text>{formatMessage(labels.logout)}</Text>
</Item>
{!cloudMode && (
<Item key="logout" className={styles.item}>
<Icon>
<Icons.Logout />
</Icon>
<Text>{formatMessage(labels.logout)}</Text>
</Item>
)}
</Menu>
</Popup>
</PopupTrigger>

View File

@ -50,7 +50,7 @@ export default function NavBar() {
<div className={styles.actions}>
<ThemeButton />
<LanguageButton />
{!cloudMode && <ProfileButton />}
<ProfileButton />
</div>
</Column>
</Row>

View File

@ -35,7 +35,10 @@ export default function MetricsTable({
const { get, useQuery } = useApi();
const { data, isLoading, isFetched, error } = useQuery(
['websites:metrics', websiteId, type, modified, url, referrer, os, browser, device, country],
[
'websites:metrics',
{ websiteId, type, modified, url, referrer, os, browser, device, country },
],
() =>
get(`/websites/${websiteId}/metrics`, {
type,

View File

@ -39,7 +39,7 @@ export default function WebsiteChart({
const { ref, isSticky } = useSticky({ enabled: stickyHeader });
const { data, isLoading, error } = useQuery(
['websites:pageviews', websiteId, modified, url, referrer, os, browser, device, country],
['websites:pageviews', { websiteId, modified, url, referrer, os, browser, device, country }],
() =>
get(`/websites/${websiteId}/pageviews`, {
startAt: +startDate,

View File

@ -26,14 +26,20 @@ export default function WebsiteSettings({ websiteId }) {
const [values, setValues] = useState(null);
const [tab, setTab] = useState('details');
const handleSave = data => {
const showSuccess = () => {
showToast({ message: formatMessage(messages.saved), variant: 'success' });
};
const handleSave = data => {
showSuccess();
setValues(state => ({ ...state, ...data }));
};
const handleReset = async value => {
if (value === 'delete') {
await router.push('/websites');
await router.push('/settings/websites');
} else if (value === 'reset') {
showSuccess();
}
};

View File

@ -2,30 +2,18 @@ import { useEffect } from 'react';
import { Loading } from 'react-basics';
import { useRouter } from 'next/router';
import { setClientAuthToken } from 'lib/client';
import useApi from '../hooks/useApi';
export default function SingleSignOnPage() {
const { post } = useApi();
const router = useRouter();
const { token, url } = router.query;
useEffect(() => {
const signOn = async token => {
setClientAuthToken(token);
const data = await post('/auth/sso');
setClientAuthToken(data.token);
await router.push(url);
};
if (url && token) {
setClientAuthToken(token);
signOn();
router.push(url);
}
}, [url, token]);
}, [router, url, token]);
return <Loading size="xl" />;
}