mirror of
https://github.com/lukevella/rallly.git
synced 2025-05-15 09:56:47 +02:00
♻️ Replace useContext with useUtils
This commit is contained in:
parent
e792a2aaeb
commit
fca8948ea2
9 changed files with 12 additions and 12 deletions
|
@ -129,7 +129,7 @@ export const LoginForm: React.FunctionComponent<{
|
||||||
});
|
});
|
||||||
|
|
||||||
const session = useSession();
|
const session = useSession();
|
||||||
const queryClient = trpc.useContext();
|
const queryClient = trpc.useUtils();
|
||||||
const [email, setEmail] = React.useState<string>();
|
const [email, setEmail] = React.useState<string>();
|
||||||
const posthog = usePostHog();
|
const posthog = usePostHog();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
|
@ -60,7 +60,7 @@ export const CreatePoll: React.FunctionComponent = () => {
|
||||||
useUnmount(clear);
|
useUnmount(clear);
|
||||||
|
|
||||||
const posthog = usePostHog();
|
const posthog = usePostHog();
|
||||||
const queryClient = trpc.useContext();
|
const queryClient = trpc.useUtils();
|
||||||
const createPoll = trpc.polls.create.useMutation();
|
const createPoll = trpc.polls.create.useMutation();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -48,7 +48,7 @@ const Discussion: React.FunctionComponent = () => {
|
||||||
);
|
);
|
||||||
const posthog = usePostHog();
|
const posthog = usePostHog();
|
||||||
|
|
||||||
const queryClient = trpc.useContext();
|
const queryClient = trpc.useUtils();
|
||||||
|
|
||||||
const addComment = trpc.polls.comments.add.useMutation({
|
const addComment = trpc.polls.comments.add.useMutation({
|
||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
|
|
|
@ -54,7 +54,7 @@ import { NextPageWithLayout } from "../../types";
|
||||||
const StatusControl = () => {
|
const StatusControl = () => {
|
||||||
const poll = usePoll();
|
const poll = usePoll();
|
||||||
const state = poll.event ? "closed" : poll.closed ? "paused" : "live";
|
const state = poll.event ? "closed" : poll.closed ? "paused" : "live";
|
||||||
const queryClient = trpc.useContext();
|
const queryClient = trpc.useUtils();
|
||||||
const reopen = trpc.polls.reopen.useMutation({
|
const reopen = trpc.polls.reopen.useMutation({
|
||||||
onMutate: () => {
|
onMutate: () => {
|
||||||
queryClient.polls.get.setData({ urlId: poll.id }, (oldPoll) => {
|
queryClient.polls.get.setData({ urlId: poll.id }, (oldPoll) => {
|
||||||
|
|
|
@ -180,7 +180,7 @@ const ChangeNameModal = (props: {
|
||||||
onOpenChange: (open: boolean) => void;
|
onOpenChange: (open: boolean) => void;
|
||||||
}) => {
|
}) => {
|
||||||
const posthog = usePostHog();
|
const posthog = usePostHog();
|
||||||
const queryClient = trpc.useContext();
|
const queryClient = trpc.useUtils();
|
||||||
const changeName = trpc.polls.participants.rename.useMutation({
|
const changeName = trpc.polls.participants.rename.useMutation({
|
||||||
onSuccess: (_, { participantId, newName }) => {
|
onSuccess: (_, { participantId, newName }) => {
|
||||||
queryClient.polls.participants.invalidate();
|
queryClient.polls.participants.invalidate();
|
||||||
|
|
|
@ -20,7 +20,7 @@ export const DeletePollDialog: React.FunctionComponent<{
|
||||||
urlId: string;
|
urlId: string;
|
||||||
}> = ({ open, onOpenChange, urlId }) => {
|
}> = ({ open, onOpenChange, urlId }) => {
|
||||||
const posthog = usePostHog();
|
const posthog = usePostHog();
|
||||||
const queryClient = trpc.useContext();
|
const queryClient = trpc.useUtils();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const deletePoll = trpc.polls.delete.useMutation({
|
const deletePoll = trpc.polls.delete.useMutation({
|
||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
|
|
|
@ -16,7 +16,7 @@ export const normalizeVotes = (
|
||||||
|
|
||||||
export const useAddParticipantMutation = () => {
|
export const useAddParticipantMutation = () => {
|
||||||
const posthog = usePostHog();
|
const posthog = usePostHog();
|
||||||
const queryClient = trpc.useContext();
|
const queryClient = trpc.useUtils();
|
||||||
|
|
||||||
return trpc.polls.participants.add.useMutation({
|
return trpc.polls.participants.add.useMutation({
|
||||||
onSuccess: (_, { pollId, name, email }) => {
|
onSuccess: (_, { pollId, name, email }) => {
|
||||||
|
@ -31,7 +31,7 @@ export const useAddParticipantMutation = () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
export const useUpdateParticipantMutation = () => {
|
export const useUpdateParticipantMutation = () => {
|
||||||
const queryClient = trpc.useContext();
|
const queryClient = trpc.useUtils();
|
||||||
const posthog = usePostHog();
|
const posthog = usePostHog();
|
||||||
return trpc.polls.participants.update.useMutation({
|
return trpc.polls.participants.update.useMutation({
|
||||||
onSuccess: (participant) => {
|
onSuccess: (participant) => {
|
||||||
|
@ -59,7 +59,7 @@ export const useUpdateParticipantMutation = () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
export const useDeleteParticipantMutation = () => {
|
export const useDeleteParticipantMutation = () => {
|
||||||
const queryClient = trpc.useContext();
|
const queryClient = trpc.useUtils();
|
||||||
const posthog = usePostHog();
|
const posthog = usePostHog();
|
||||||
const { poll } = usePoll();
|
const { poll } = usePoll();
|
||||||
return trpc.polls.participants.delete.useMutation({
|
return trpc.polls.participants.delete.useMutation({
|
||||||
|
@ -82,7 +82,7 @@ export const useDeleteParticipantMutation = () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
export const useUpdatePollMutation = () => {
|
export const useUpdatePollMutation = () => {
|
||||||
const queryClient = trpc.useContext();
|
const queryClient = trpc.useUtils();
|
||||||
const posthog = usePostHog();
|
const posthog = usePostHog();
|
||||||
return trpc.polls.update.useMutation({
|
return trpc.polls.update.useMutation({
|
||||||
onSuccess: (_data, { urlId }) => {
|
onSuccess: (_data, { urlId }) => {
|
||||||
|
|
|
@ -29,7 +29,7 @@ const FinalizationForm = () => {
|
||||||
const redirectBackToPoll = () => {
|
const redirectBackToPoll = () => {
|
||||||
router.replace(`/poll/${poll.id}`);
|
router.replace(`/poll/${poll.id}`);
|
||||||
};
|
};
|
||||||
const queryClient = trpc.useContext();
|
const queryClient = trpc.useUtils();
|
||||||
|
|
||||||
const bookDate = trpc.polls.book.useMutation({
|
const bookDate = trpc.polls.book.useMutation({
|
||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
|
|
|
@ -36,7 +36,7 @@ export const RegisterForm: React.FunctionComponent<{
|
||||||
defaultValues: { email: defaultEmail },
|
defaultValues: { email: defaultEmail },
|
||||||
});
|
});
|
||||||
|
|
||||||
const queryClient = trpc.useContext();
|
const queryClient = trpc.useUtils();
|
||||||
const requestRegistration = trpc.auth.requestRegistration.useMutation();
|
const requestRegistration = trpc.auth.requestRegistration.useMutation();
|
||||||
const authenticateRegistration =
|
const authenticateRegistration =
|
||||||
trpc.auth.authenticateRegistration.useMutation();
|
trpc.auth.authenticateRegistration.useMutation();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue