mirror of
https://github.com/kremalicious/umami.git
synced 2025-02-14 21:10:34 +01:00
make website/team add consistent
This commit is contained in:
parent
194472b104
commit
86d482f18a
@ -1,14 +1,13 @@
|
|||||||
import {
|
|
||||||
Form,
|
|
||||||
FormRow,
|
|
||||||
FormInput,
|
|
||||||
FormButtons,
|
|
||||||
TextField,
|
|
||||||
Button,
|
|
||||||
SubmitButton,
|
|
||||||
} from 'react-basics';
|
|
||||||
import { touch } from 'store/modified';
|
|
||||||
import { useApi, useMessages } from 'components/hooks';
|
import { useApi, useMessages } from 'components/hooks';
|
||||||
|
import {
|
||||||
|
Button,
|
||||||
|
Form,
|
||||||
|
FormButtons,
|
||||||
|
FormInput,
|
||||||
|
FormRow,
|
||||||
|
SubmitButton,
|
||||||
|
TextField,
|
||||||
|
} from 'react-basics';
|
||||||
|
|
||||||
export function TeamAddForm({ onSave, onClose }: { onSave: () => void; onClose: () => void }) {
|
export function TeamAddForm({ onSave, onClose }: { onSave: () => void; onClose: () => void }) {
|
||||||
const { formatMessage, labels } = useMessages();
|
const { formatMessage, labels } = useMessages();
|
||||||
@ -20,7 +19,6 @@ export function TeamAddForm({ onSave, onClose }: { onSave: () => void; onClose:
|
|||||||
const handleSubmit = async (data: any) => {
|
const handleSubmit = async (data: any) => {
|
||||||
mutate(data, {
|
mutate(data, {
|
||||||
onSuccess: async () => {
|
onSuccess: async () => {
|
||||||
touch('teams');
|
|
||||||
onSave?.();
|
onSave?.();
|
||||||
onClose?.();
|
onClose?.();
|
||||||
},
|
},
|
||||||
|
@ -1,10 +1,19 @@
|
|||||||
import { Button, Icon, Modal, ModalTrigger, Text } from 'react-basics';
|
import { Button, Icon, Modal, ModalTrigger, Text, useToasts } from 'react-basics';
|
||||||
import Icons from 'components/icons';
|
import Icons from 'components/icons';
|
||||||
import { useMessages } from 'components/hooks';
|
import { useMessages } from 'components/hooks';
|
||||||
import TeamAddForm from './TeamAddForm';
|
import TeamAddForm from './TeamAddForm';
|
||||||
|
import { messages } from 'components/messages';
|
||||||
|
import { touch } from 'store/modified';
|
||||||
|
|
||||||
export function TeamsAddButton({ onAdd }: { onAdd?: () => void }) {
|
export function TeamsAddButton({ onSave }: { onSave?: () => void }) {
|
||||||
const { formatMessage, labels } = useMessages();
|
const { formatMessage, labels } = useMessages();
|
||||||
|
const { showToast } = useToasts();
|
||||||
|
|
||||||
|
const handleSave = async () => {
|
||||||
|
showToast({ message: formatMessage(messages.saved), variant: 'success' });
|
||||||
|
touch('teams');
|
||||||
|
onSave?.();
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ModalTrigger>
|
<ModalTrigger>
|
||||||
@ -15,7 +24,7 @@ export function TeamsAddButton({ onAdd }: { onAdd?: () => void }) {
|
|||||||
<Text>{formatMessage(labels.createTeam)}</Text>
|
<Text>{formatMessage(labels.createTeam)}</Text>
|
||||||
</Button>
|
</Button>
|
||||||
<Modal title={formatMessage(labels.createTeam)}>
|
<Modal title={formatMessage(labels.createTeam)}>
|
||||||
{(close: () => void) => <TeamAddForm onSave={onAdd} onClose={close} />}
|
{(close: () => void) => <TeamAddForm onSave={handleSave} onClose={close} />}
|
||||||
</Modal>
|
</Modal>
|
||||||
</ModalTrigger>
|
</ModalTrigger>
|
||||||
);
|
);
|
||||||
|
@ -1,13 +1,15 @@
|
|||||||
import useApi from './useApi';
|
import useApi from './useApi';
|
||||||
import useFilterQuery from './useFilterQuery';
|
import useFilterQuery from './useFilterQuery';
|
||||||
import { useLogin } from 'components/hooks';
|
import { useLogin } from 'components/hooks';
|
||||||
|
import useModified from 'store/modified';
|
||||||
|
|
||||||
export function useTeams(userId?: string) {
|
export function useTeams(userId?: string) {
|
||||||
const { get } = useApi();
|
const { get } = useApi();
|
||||||
const { user } = useLogin();
|
const { user } = useLogin();
|
||||||
|
const modified = useModified((state: any) => state?.teams);
|
||||||
|
|
||||||
return useFilterQuery({
|
return useFilterQuery({
|
||||||
queryKey: ['teams', { userId: userId || user?.id }],
|
queryKey: ['teams', { userId: userId || user?.id, modified }],
|
||||||
queryFn: (params: any) => {
|
queryFn: (params: any) => {
|
||||||
return get(`/teams`, params);
|
return get(`/teams`, params);
|
||||||
},
|
},
|
||||||
|
@ -3,15 +3,13 @@ import { useFilterQuery } from './useFilterQuery';
|
|||||||
import { useLogin } from './useLogin';
|
import { useLogin } from './useLogin';
|
||||||
import useModified from 'store/modified';
|
import useModified from 'store/modified';
|
||||||
|
|
||||||
const selector = (state: any) => state?.websites;
|
|
||||||
|
|
||||||
export function useWebsites(
|
export function useWebsites(
|
||||||
{ userId, teamId }: { userId?: string; teamId?: string },
|
{ userId, teamId }: { userId?: string; teamId?: string },
|
||||||
params?: { [key: string]: string | number },
|
params?: { [key: string]: string | number },
|
||||||
) {
|
) {
|
||||||
const { get } = useApi();
|
const { get } = useApi();
|
||||||
const { user } = useLogin();
|
const { user } = useLogin();
|
||||||
const modified = useModified(selector);
|
const modified = useModified((state: any) => state?.websites);
|
||||||
|
|
||||||
return useFilterQuery({
|
return useFilterQuery({
|
||||||
queryKey: ['websites', { userId, teamId, modified, ...params }],
|
queryKey: ['websites', { userId, teamId, modified, ...params }],
|
||||||
|
Loading…
Reference in New Issue
Block a user