Feat/metadata add update and delete on frontend (#2102)

* Reworked metadata creation

* Wip

* Fix from PR

* Removed consolelog

* Post merge

* Fixed seeds
This commit is contained in:
Lucas Bordeau
2023-10-18 16:48:11 +02:00
committed by GitHub
parent 21c2834f52
commit 547a17b145
23 changed files with 482 additions and 77 deletions

View File

@ -0,0 +1,36 @@
/* eslint-disable no-console */
import { useMemo } from 'react';
import { ApolloClient, InMemoryCache } from '@apollo/client';
import { useRecoilState } from 'recoil';
import { tokenPairState } from '@/auth/states/tokenPairState';
import { ApolloMetadataClientContext } from '../context/ApolloClientMetadataContext';
export const ApolloMetadataClientProvider = ({
children,
}: {
children: React.ReactNode;
}) => {
const [tokenPair] = useRecoilState(tokenPairState);
const apolloMetadataClient = useMemo(() => {
if (tokenPair?.accessToken.token) {
return new ApolloClient({
uri: `${process.env.REACT_APP_SERVER_BASE_URL}/metadata`,
cache: new InMemoryCache(),
headers: {
Authorization: `Bearer ${tokenPair.accessToken.token}`,
},
});
} else {
return null;
}
}, [tokenPair]);
return (
<ApolloMetadataClientContext.Provider value={apolloMetadataClient}>
{children}
</ApolloMetadataClientContext.Provider>
);
};