mirror of
https://github.com/umami-software/umami.git
synced 2026-02-19 03:55:37 +01:00
Added SettingsContext.
This commit is contained in:
parent
3f657d97b2
commit
4fca98d25d
22 changed files with 106 additions and 83 deletions
|
|
@ -1,8 +1,9 @@
|
|||
import { SubmitButton, Form, FormInput, FormRow, FormButtons, TextField } from 'react-basics';
|
||||
import { useRef } from 'react';
|
||||
import { useContext, useRef } from 'react';
|
||||
import useApi from 'components/hooks/useApi';
|
||||
import { DOMAIN_REGEX } from 'lib/constants';
|
||||
import useMessages from 'components/hooks/useMessages';
|
||||
import SettingsContext from '../../SettingsContext';
|
||||
|
||||
export function WebsiteEditForm({
|
||||
websiteId,
|
||||
|
|
@ -14,13 +15,14 @@ export function WebsiteEditForm({
|
|||
onSave?: (data: any) => void;
|
||||
}) {
|
||||
const { formatMessage, labels, messages } = useMessages();
|
||||
const { websitesUrl } = useContext(SettingsContext);
|
||||
const { post, useMutation } = useApi();
|
||||
const { mutate, error } = useMutation({
|
||||
mutationFn: (data: any) => post(`/websites/${websiteId}`, data),
|
||||
mutationFn: (data: any) => post(`${websitesUrl}/${websiteId}`, data),
|
||||
});
|
||||
const ref = useRef(null);
|
||||
|
||||
const handleSubmit = async data => {
|
||||
const handleSubmit = async (data: any) => {
|
||||
mutate(data, {
|
||||
onSuccess: async () => {
|
||||
ref.current.reset(data);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue