Skip to content

Commit

Permalink
fix(poke): use correct endpoint to retrieve features (#8331)
Browse files Browse the repository at this point in the history
Co-authored-by: Henry Fontanier <[email protected]>
  • Loading branch information
fontanierh and Henry Fontanier authored Oct 30, 2024
1 parent 1ca19b5 commit 3fde174
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
3 changes: 2 additions & 1 deletion front/components/poke/features/table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { useRouter } from "next/router";

import { makeColumnsForFeatureFlags } from "@app/components/poke/features/columns";
import { PokeDataTable } from "@app/components/poke/shadcn/ui/data_table";
import { usePokeFeatureFlags } from "@app/lib/swr/poke";
import { useFeatureFlags } from "@app/lib/swr/workspaces";

interface FeatureFlagsDataTableProps {
Expand All @@ -30,7 +31,7 @@ export function FeatureFlagsDataTable({
whitelistableFeatures,
}: FeatureFlagsDataTableProps) {
const router = useRouter();
const { featureFlags } = useFeatureFlags({ workspaceId: owner.sId });
const { featureFlags } = usePokeFeatureFlags({ workspaceId: owner.sId });
const sendNotification = useSendNotification();

return (
Expand Down
16 changes: 16 additions & 0 deletions front/lib/swr/poke.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import type { Fetcher } from "swr";
import { fetcher, useSWRWithDefaults } from "@app/lib/swr/swr";
import type { GetPokePlansResponseBody } from "@app/pages/api/poke/plans";
import type { GetPokeWorkspacesResponseBody } from "@app/pages/api/poke/workspaces";
import type { GetPokeFeaturesResponseBody } from "@app/pages/api/poke/workspaces/[wId]/features";
import type { GetDataSourcePermissionsResponseBody } from "@app/pages/api/w/[wId]/data_sources/[dsId]/managed/permissions";

export function usePokeConnectorPermissions({
Expand Down Expand Up @@ -96,3 +97,18 @@ export function usePokePlans() {
isPlansError: error,
};
}

export function usePokeFeatureFlags({ workspaceId }: { workspaceId: string }) {
const featureFlagsFetcher: Fetcher<GetPokeFeaturesResponseBody> = fetcher;

const { data, error } = useSWRWithDefaults(
`/api/poke/workspaces/${workspaceId}/features`,
featureFlagsFetcher
);

return {
featureFlags: useMemo(() => (data ? data.features : []), [data]),
isFeatureFlagsLoading: !error && !data,
isFeatureFlagsError: error,
};
}

0 comments on commit 3fde174

Please sign in to comment.