Skip to content

Commit

Permalink
fix: user queries
Browse files Browse the repository at this point in the history
  • Loading branch information
williamluke4 committed Oct 9, 2024
1 parent 9ec7219 commit 5af5359
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 19 deletions.
7 changes: 3 additions & 4 deletions src/app/(app)/wallet/profile/profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export const Profile = () => {
const utils = trpc.useUtils();
const { mutateAsync, isPending } = trpc.me.update.useMutation();
const auth = useAuth();
const { data: me } = trpc.me.get.useQuery();
const updateUser = (values: UserProfileFormType) => {
mutateAsync(values)
.then(() => {
Expand Down Expand Up @@ -48,7 +47,7 @@ export const Profile = () => {
{auth?.user?.given_names ?? "Unknown"}
</div>
<div className="text-sm font-semibold text-primary/80">
{me?.vpa}
{auth?.user?.vpa}
</div>
</div>
</div>
Expand All @@ -64,11 +63,11 @@ export const Profile = () => {
</TabsList>
<TabsContent value="profile" className="mt-0">
<div className="p-4">
{me && (
{auth?.user && (
<ProfileForm
buttonLabel="Update"
isLoading={isPending}
initialValues={me}
initialValues={auth?.user}
onSubmit={updateUser}
/>
)}
Expand Down
24 changes: 10 additions & 14 deletions src/components/users/dialogs/gas-request-dialog.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
"use client";
import { useState } from "react";
import { toast } from "sonner";
import { Loading } from "~/components/loading";
import { useAuth } from "~/hooks/useAuth";
import { trpc } from "~/lib/trpc";
import { Button } from "../../ui/button";
import {
Dialog,
Expand All @@ -12,9 +13,8 @@ import {
DialogTrigger,
} from "../../ui/dialog";
import { ProfileForm, type UserProfileFormType } from "../forms/profile-form";
import { trpc } from "~/lib/trpc";
const GasRequestDialog = () => {
const me = trpc.me.get.useQuery();
const auth = useAuth();
const updateMe = trpc.me.update.useMutation();
const utils = trpc.useUtils();
const requestGas = trpc.me.requestGas.useMutation();
Expand Down Expand Up @@ -44,17 +44,13 @@ const GasRequestDialog = () => {
Please update your profile to receive Celo access
</DialogDescription>
</DialogHeader>
{me.isLoading ? (
<Loading />
) : (
me.data && (
<ProfileForm
buttonLabel="Apply and Update Profile"
initialValues={me.data}
onSubmit={applyAndUpdateProfile}
isLoading={updateMe.isPending || requestGas.isPending}
/>
)
{auth?.user && (
<ProfileForm
buttonLabel="Apply and Update Profile"
initialValues={auth.user}
onSubmit={applyAndUpdateProfile}
isLoading={updateMe.isPending || requestGas.isPending}
/>
)}
</DialogContent>
</Dialog>
Expand Down
2 changes: 1 addition & 1 deletion src/context/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ function ContextProvider({
<trpc.Provider client={trpcClient} queryClient={queryClient}>
<ReactQueryDevtools initialIsOpen={false} />
<AuthProvider>
<RainbowKitProvider coolMode>{children}</RainbowKitProvider>
<RainbowKitProvider>{children}</RainbowKitProvider>
</AuthProvider>
</trpc.Provider>
</QueryClientProvider>
Expand Down

0 comments on commit 5af5359

Please sign in to comment.