mirror of
https://github.com/StanGirard/quivr.git
synced 2024-12-15 21:53:59 +03:00
9c8e0aa0e4
* 🗑️ remove date input from fetch_user_id_from_credentials * ♻️ refactor backend utils by splitting it into files * 💡 comments for next actions to update /upload * 🚚 move SupabaseProvider tp libs * 🚚 move useAxios to hooks * ♻️ refacto brain routes * 🚨 update lintermfor paths * ✨ new brain context provider * ✨ new brain component in navbar * 🚨 fix linter and async * 🇸🇪 add feature flag for multiple-brains
39 lines
1006 B
TypeScript
39 lines
1006 B
TypeScript
"use client"
|
|
import type { FeatureDefinition } from "@growthbook/growthbook";
|
|
import { GrowthBook, GrowthBookProvider } from "@growthbook/growthbook-react";
|
|
import axios from "axios";
|
|
import { useAsync } from "react-use";
|
|
|
|
|
|
const growthBook = new GrowthBook({
|
|
apiHost: "https://cdn.growthbook.io",
|
|
clientKey:process.env.NEXT_PUBLIC_GROWTHBOOK_CLIENT_KEY,
|
|
enableDevMode: true,
|
|
});
|
|
|
|
|
|
|
|
const unauthenticatedClient = axios.create();
|
|
|
|
export const FeatureFlagsProvider = ({
|
|
children,
|
|
}: {
|
|
children?: React.ReactNode;
|
|
}): JSX.Element => {
|
|
|
|
const growthBookUrl = process.env.NEXT_PUBLIC_GROWTHBOOK_URL;
|
|
|
|
useAsync(async () => {
|
|
if (growthBookUrl !== undefined) {
|
|
const growthBookInitResponse = await unauthenticatedClient.get<{
|
|
features: Record<string, FeatureDefinition>;
|
|
}>(growthBookUrl);
|
|
growthBook.setFeatures(growthBookInitResponse.data.features);
|
|
}
|
|
});
|
|
|
|
return (
|
|
<GrowthBookProvider growthbook={growthBook}>{children}</GrowthBookProvider>
|
|
);
|
|
};
|