Convert useModified into a real hook.
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
import { useMessages } from 'components/hooks';
|
||||
import { useMessages, useModified } from 'components/hooks';
|
||||
import { Button, Icon, Icons, Modal, ModalTrigger, Text, useToasts } from 'react-basics';
|
||||
import { touch } from 'store/modified';
|
||||
import WebsiteAddForm from './WebsiteAddForm';
|
||||
|
||||
export function WebsiteAddButton({ teamId, onSave }: { teamId: string; onSave?: () => void }) {
|
||||
const { formatMessage, labels, messages } = useMessages();
|
||||
const { showToast } = useToasts();
|
||||
const { touch } = useModified();
|
||||
|
||||
const handleSave = async () => {
|
||||
showToast({ message: formatMessage(messages.saved), variant: 'success' });
|
||||
|
||||
@@ -11,9 +11,8 @@ import {
|
||||
} from 'react-basics';
|
||||
import { useContext, useState } from 'react';
|
||||
import { getRandomChars } from 'next-basics';
|
||||
import { useApi, useMessages } from 'components/hooks';
|
||||
import { useApi, useMessages, useModified } from 'components/hooks';
|
||||
import { WebsiteContext } from 'app/(main)/websites/[websiteId]/WebsiteProvider';
|
||||
import { touch } from 'store/modified';
|
||||
|
||||
const generateId = () => getRandomChars(16);
|
||||
|
||||
@@ -33,6 +32,7 @@ export function ShareUrl({
|
||||
const { mutate, error, isPending } = useMutation({
|
||||
mutationFn: (data: any) => post(`/websites/${website.id}`, data),
|
||||
});
|
||||
const { touch } = useModified();
|
||||
|
||||
const url = `${hostUrl || process.env.hostUrl || window?.location.origin}${
|
||||
process.env.basePath
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import { Button, Modal, ModalTrigger, ActionForm, useToasts } from 'react-basics';
|
||||
import { useRouter } from 'next/navigation';
|
||||
import { useMessages } from 'components/hooks';
|
||||
import { useMessages, useModified } from 'components/hooks';
|
||||
import WebsiteDeleteForm from './WebsiteDeleteForm';
|
||||
import WebsiteResetForm from './WebsiteResetForm';
|
||||
import { touch } from 'store/modified';
|
||||
|
||||
export function WebsiteData({ websiteId, onSave }: { websiteId: string; onSave?: () => void }) {
|
||||
const { formatMessage, labels, messages } = useMessages();
|
||||
const router = useRouter();
|
||||
const { showToast } = useToasts();
|
||||
const { touch } = useModified();
|
||||
|
||||
const handleReset = async () => {
|
||||
showToast({ message: formatMessage(messages.saved), variant: 'success' });
|
||||
|
||||
@@ -8,9 +8,8 @@ import {
|
||||
TextField,
|
||||
useToasts,
|
||||
} from 'react-basics';
|
||||
import { useApi, useMessages } from 'components/hooks';
|
||||
import { useApi, useMessages, useModified } from 'components/hooks';
|
||||
import { DOMAIN_REGEX } from 'lib/constants';
|
||||
import { touch } from 'store/modified';
|
||||
import { WebsiteContext } from 'app/(main)/websites/[websiteId]/WebsiteProvider';
|
||||
|
||||
export function WebsiteEditForm({ websiteId }: { websiteId: string }) {
|
||||
@@ -22,6 +21,7 @@ export function WebsiteEditForm({ websiteId }: { websiteId: string }) {
|
||||
});
|
||||
const ref = useRef(null);
|
||||
const { showToast } = useToasts();
|
||||
const { touch } = useModified();
|
||||
|
||||
const handleSubmit = async (data: any) => {
|
||||
mutate(data, {
|
||||
|
||||
Reference in New Issue
Block a user