More refactoring, cleaned up icons, nav buttons, add messages.

This commit is contained in:
Mike Cao 2023-01-27 21:53:13 -08:00
parent 4b1013c8c6
commit 5f15ad0807
68 changed files with 391 additions and 790 deletions

View file

@ -1,6 +1,7 @@
import { useEffect, useState } from 'react';
import { Breadcrumbs, Item, Tabs, useToast, Button, Text, Icon, Icons } from 'react-basics';
import { useIntl } from 'react-intl';
import { useRouter } from 'next/router';
import Link from 'next/link';
import Page from 'components/layout/Page';
import PageHeader from 'components/layout/PageHeader';
@ -11,9 +12,8 @@ import ShareUrl from 'components/pages/settings/websites/ShareUrl';
import useApi from 'hooks/useApi';
import { labels, messages } from 'components/messages';
const { External } = Icons;
export default function WebsiteSettings({ websiteId }) {
const router = useRouter();
const { formatMessage } = useIntl();
const [values, setValues] = useState(null);
const [tab, setTab] = useState('details');
@ -34,6 +34,12 @@ export default function WebsiteSettings({ websiteId }) {
setValues(state => ({ ...state, ...data }));
};
const handleReset = async value => {
if (value === 'delete') {
await router.push('/websites');
}
};
useEffect(() => {
if (data) {
setValues(data);
@ -54,7 +60,7 @@ export default function WebsiteSettings({ websiteId }) {
<a>
<Button variant="primary">
<Icon>
<External />
<Icons.External />
</Icon>
<Text>{formatMessage(labels.view)}</Text>
</Button>
@ -72,7 +78,7 @@ export default function WebsiteSettings({ websiteId }) {
)}
{tab === 'tracking' && <TrackingCode websiteId={websiteId} data={values} />}
{tab === 'share' && <ShareUrl websiteId={websiteId} data={values} onSave={handleSave} />}
{tab === 'data' && <WebsiteReset websiteId={websiteId} onSave={handleSave} />}
{tab === 'data' && <WebsiteReset websiteId={websiteId} onSave={handleReset} />}
</Page>
);
}