mirror of
https://github.com/umami-software/umami.git
synced 2026-02-15 10:05:36 +01:00
Use context hooks.
This commit is contained in:
parent
00adb00d2d
commit
600a3d28c3
13 changed files with 46 additions and 44 deletions
|
|
@ -1,4 +1,3 @@
|
|||
import { useContext } from 'react';
|
||||
import {
|
||||
FormSubmitButton,
|
||||
Form,
|
||||
|
|
@ -7,12 +6,11 @@ import {
|
|||
TextField,
|
||||
useToast,
|
||||
} from '@umami/react-zen';
|
||||
import { useApi, useMessages, useModified } from '@/components/hooks';
|
||||
import { useApi, useMessages, useModified, useWebsite } from '@/components/hooks';
|
||||
import { DOMAIN_REGEX } from '@/lib/constants';
|
||||
import { WebsiteContext } from '@/app/(main)/websites/WebsiteProvider';
|
||||
|
||||
export function WebsiteEditForm({ websiteId, onSave }: { websiteId: string; onSave?: () => void }) {
|
||||
const website = useContext(WebsiteContext);
|
||||
const website = useWebsite();
|
||||
const { formatMessage, labels, messages } = useMessages();
|
||||
const { post, useMutation } = useApi();
|
||||
const { toast } = useToast();
|
||||
|
|
|
|||
|
|
@ -1,14 +1,12 @@
|
|||
import { useContext } from 'react';
|
||||
import { Tabs, TabList, Tab, TabPanel } from '@umami/react-zen';
|
||||
import { WebsiteContext } from '@/app/(main)/websites/WebsiteProvider';
|
||||
import { useMessages } from '@/components/hooks';
|
||||
import { useMessages, useWebsite } from '@/components/hooks';
|
||||
import { WebsiteShareForm } from './WebsiteShareForm';
|
||||
import { WebsiteTrackingCode } from './WebsiteTrackingCode';
|
||||
import { WebsiteData } from './WebsiteData';
|
||||
import { WebsiteEditForm } from './WebsiteEditForm';
|
||||
|
||||
export function WebsiteSettings({ websiteId }: { websiteId: string; openExternal?: boolean }) {
|
||||
const website = useContext(WebsiteContext);
|
||||
const website = useWebsite();
|
||||
const { formatMessage, labels } = useMessages();
|
||||
|
||||
return (
|
||||
|
|
|
|||
|
|
@ -1,10 +1,9 @@
|
|||
import { useContext } from 'react';
|
||||
import { WebsiteContext } from '@/app/(main)/websites/WebsiteProvider';
|
||||
import { PageHeader } from '@/components/common/PageHeader';
|
||||
import { Globe } from '@/components/icons';
|
||||
import { useWebsite } from '@/components/hooks';
|
||||
|
||||
export function WebsiteSettingsHeader() {
|
||||
const website = useContext(WebsiteContext);
|
||||
const website = useWebsite();
|
||||
|
||||
return <PageHeader title={website?.name} icon={<Globe />} />;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { Key, useContext, useState } from 'react';
|
||||
import { Key, useState } from 'react';
|
||||
import {
|
||||
Button,
|
||||
Form,
|
||||
|
|
@ -10,8 +10,13 @@ import {
|
|||
ListItem,
|
||||
Text,
|
||||
} from '@umami/react-zen';
|
||||
import { useApi, useLoginQuery, useMessages, useUserTeamsQuery } from '@/components/hooks';
|
||||
import { WebsiteContext } from '@/app/(main)/websites/WebsiteProvider';
|
||||
import {
|
||||
useApi,
|
||||
useLoginQuery,
|
||||
useMessages,
|
||||
useUserTeamsQuery,
|
||||
useWebsite,
|
||||
} from '@/components/hooks';
|
||||
import { ROLES } from '@/lib/constants';
|
||||
|
||||
export function WebsiteTransferForm({
|
||||
|
|
@ -24,7 +29,7 @@ export function WebsiteTransferForm({
|
|||
onClose?: () => void;
|
||||
}) {
|
||||
const { user } = useLoginQuery();
|
||||
const website = useContext(WebsiteContext);
|
||||
const website = useWebsite();
|
||||
const [teamId, setTeamId] = useState<string>(null);
|
||||
const { formatMessage, labels, messages } = useMessages();
|
||||
const { post, useMutation } = useApi();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue