merge fetch and fetcher
This commit is contained in:
@@ -1,5 +1,4 @@
|
|||||||
"use client";
|
"use client";
|
||||||
import { getUser } from "muzak/data/fetch";
|
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { api, User } from "muzak/data/fetcher";
|
import { api, User } from "muzak/data/fetcher";
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +0,0 @@
|
|||||||
"use client";
|
|
||||||
import { oidcConfig } from "muzak/config/auth";
|
|
||||||
import { User } from "oidc-client-ts";
|
|
||||||
|
|
||||||
export function getUser() {
|
|
||||||
let oidcStorage = window?.sessionStorage.getItem(
|
|
||||||
`oidc.user:${oidcConfig.authority}:${oidcConfig.client_id}`,
|
|
||||||
);
|
|
||||||
if (!oidcStorage) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return User.fromStorageString(oidcStorage);
|
|
||||||
}
|
|
||||||
@@ -1,7 +1,18 @@
|
|||||||
"use client";
|
"use client";
|
||||||
import { Fetcher } from "openapi-typescript-fetch";
|
import { Fetcher } from "openapi-typescript-fetch";
|
||||||
import { getUser } from "./fetch";
|
|
||||||
import { paths, components } from "muzak/data/types";
|
import { paths, components } from "muzak/data/types";
|
||||||
|
import { oidcConfig } from "muzak/config/auth";
|
||||||
|
import { User } from "oidc-client-ts";
|
||||||
|
|
||||||
|
export function getUser() {
|
||||||
|
let oidcStorage = window?.sessionStorage.getItem(
|
||||||
|
`oidc.user:${oidcConfig.authority}:${oidcConfig.client_id}`,
|
||||||
|
);
|
||||||
|
if (!oidcStorage) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return User.fromStorageString(oidcStorage);
|
||||||
|
}
|
||||||
|
|
||||||
const fetcher = Fetcher.for<paths>();
|
const fetcher = Fetcher.for<paths>();
|
||||||
const BASE_URL = process.env.NEXT_PUBLIC_BACKEND_HOST!;
|
const BASE_URL = process.env.NEXT_PUBLIC_BACKEND_HOST!;
|
||||||
|
|||||||
Reference in New Issue
Block a user