♻️ getUser

This commit is contained in:
Timur Ercan
2023-03-01 15:11:08 +01:00
parent 53094dd9e4
commit 5e70b4620c
4 changed files with 10 additions and 6 deletions

View File

@ -17,6 +17,7 @@ import {
WrenchIcon, WrenchIcon,
} from "@heroicons/react/24/outline"; } from "@heroicons/react/24/outline";
import Logo from "./logo"; import Logo from "./logo";
import { getUser } from "@documenso/lib/api";
const navigation = [ const navigation = [
{ {
@ -86,9 +87,8 @@ export default function TopNavigation() {
}); });
useEffect(() => { useEffect(() => {
// todo encapsulate getUser().then((res) => {
fetch("/api/users/me").then((res) => { res.json().then((j: any) => {
res.json().then((j) => {
setUser(j); setUser(j);
}); });
}); });

View File

@ -6,6 +6,7 @@ import Head from "next/head";
import { useSession } from "next-auth/react"; import { useSession } from "next-auth/react";
import { updateUser } from "@documenso/features"; import { updateUser } from "@documenso/features";
import { Button } from "@documenso/ui"; import { Button } from "@documenso/ui";
import { getUser } from "@documenso/lib/api";
const subNavigation = [ const subNavigation = [
{ {
@ -34,9 +35,8 @@ export default function Setttings() {
}); });
useEffect(() => { useEffect(() => {
// todo encapsulate getUser().then((res: any) => {
fetch("/api/users/me").then((res) => { res.json().then((j: any) => {
res.json().then((j) => {
setUser(j); setUser(j);
}); });
}); });

View File

@ -0,0 +1,3 @@
export const getUser = (): Promise<any> => {
return fetch("/api/users/me");
};

View File

@ -1,3 +1,4 @@
export { createOrUpdateField } from "./createOrUpdateField"; export { createOrUpdateField } from "./createOrUpdateField";
export { deleteField } from "./deleteField"; export { deleteField } from "./deleteField";
export { signDocument } from "./signDocument"; export { signDocument } from "./signDocument";
export { getUser } from "./getUser";