Path: blob/main/components/dashboard/src/data/git-providers/suggested-repositories-query.ts
2501 views
/**1* Copyright (c) 2023 Gitpod GmbH. All rights reserved.2* Licensed under the GNU Affero General Public License (AGPL).3* See License.AGPL.txt in the project root for license information.4*/56import { useQuery } from "@tanstack/react-query";7import { useCurrentOrg } from "../organizations/orgs-query";8import { scmClient } from "../../service/public-api";910type Props = {11excludeConfigurations: boolean;12};13export const useSuggestedRepositories = ({ excludeConfigurations }: Props) => {14const { data: org } = useCurrentOrg();1516return useQuery(17["suggested-repositories", { orgId: org?.id, excludeConfigurations }],18async () => {19if (!org) {20throw new Error("No org selected");21}2223const { repositories } = await scmClient.listSuggestedRepositories({24organizationId: org.id,25excludeConfigurations,26pagination: {27pageSize: 100,28},29});30return repositories;31},32{33// Keeps data in cache for 7 days - will still refresh though34cacheTime: 1000 * 60 * 60 * 24 * 7,35},36);37};383940