mirror of
https://github.com/documenso/documenso.git
synced 2025-11-13 16:23:06 +10:00
♻️ getUser
This commit is contained in:
@ -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);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -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);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
3
packages/lib/api/getUser.ts
Normal file
3
packages/lib/api/getUser.ts
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
export const getUser = (): Promise<any> => {
|
||||||
|
return fetch("/api/users/me");
|
||||||
|
};
|
||||||
@ -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";
|
||||||
|
|||||||
Reference in New Issue
Block a user