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