Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/api/custom-links/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import type { Tables } from "@/integrations/supabase/types";

export type CustomLink = Tables<"custom_links">;

export const customLinksKeys = {
all: ["customLinks"] as const,
byFestival: (festivalId: string) =>
[...customLinksKeys.all, festivalId] as const,
};
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
import { useQuery } from "@tanstack/react-query";
import { queryOptions, useQuery } from "@tanstack/react-query";
import { supabase } from "@/integrations/supabase/client";
import { Tables } from "@/integrations/supabase/types";

export type CustomLink = Tables<"custom_links">;

export const customLinksKeys = {
all: ["customLinks"] as const,
byFestival: (festivalId: string) =>
[...customLinksKeys.all, festivalId] as const,
};
import { CustomLink, customLinksKeys } from "./types";

async function fetchCustomLinks(festivalId: string): Promise<CustomLink[]> {
const { data, error } = await supabase
Expand All @@ -26,10 +18,16 @@ async function fetchCustomLinks(festivalId: string): Promise<CustomLink[]> {
return data || [];
}

export function customLinksQuery(festivalId: string) {
return queryOptions({
queryKey: customLinksKeys.byFestival(festivalId),
queryFn: () => fetchCustomLinks(festivalId),
});
}

export function useCustomLinksQuery(festivalId: string | undefined) {
return useQuery({
queryKey: customLinksKeys.byFestival(festivalId || ""),
queryFn: () => fetchCustomLinks(festivalId!),
...customLinksQuery(festivalId ?? ""),
enabled: !!festivalId,
});
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useMutation, useQueryClient } from "@tanstack/react-query";
import { useToast } from "@/hooks/use-toast";
import { supabase } from "@/integrations/supabase/client";
import { customLinksKeys } from "./useCustomLinks";
import { customLinksKeys } from "./types";

interface BulkUpdateCustomLinksData {
festivalId: string;
Expand Down
2 changes: 1 addition & 1 deletion src/pages/EditionView/EditionLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { MainTabNavigation } from "./TabNavigation/TabNavigation";
import ErrorBoundary from "@/components/ErrorBoundary";
import { useFestivalEdition } from "@/contexts/FestivalEditionContext";
import { Outlet } from "@tanstack/react-router";
import { useCustomLinksQuery } from "@/hooks/queries/custom-links/useCustomLinks";
import { useCustomLinksQuery } from "@/api/custom-links/useCustomLinks";

export default function EditionView() {
const { festival, edition } = useFestivalEdition();
Expand Down
2 changes: 1 addition & 1 deletion src/pages/EditionView/tabs/InfoTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { CustomLinks } from "./InfoTab/CustomLinks";
import { NoInfo } from "./InfoTab/NoInfo";
import { LoadingInfo } from "./InfoTab/LoadingInfo";
import { SocialLinkItem } from "./InfoTab/SocialLinkItem";
import { useCustomLinksQuery } from "@/hooks/queries/custom-links/useCustomLinks";
import { useCustomLinksQuery } from "@/api/custom-links/useCustomLinks";

export function InfoTab() {
const { edition, festival } = useFestivalEdition();
Expand Down
2 changes: 1 addition & 1 deletion src/pages/FestivalSelection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
isMainGetuplineDomain,
} from "@/lib/subdomain";
import { Link } from "@tanstack/react-router";
import { useCustomLinksQuery } from "@/hooks/queries/custom-links/useCustomLinks";
import { useCustomLinksQuery } from "@/api/custom-links/useCustomLinks";
import { PageTitle } from "@/components/PageTitle/PageTitle";
import { TopBar } from "@/components/layout/TopBar";
import { AppHeader } from "@/components/layout/AppHeader";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { Input } from "@/components/ui/input";
import { ExternalLink, Plus, Trash2 } from "lucide-react";
import { EditableField } from "./shared/EditableField";
import { EditContainer } from "./shared/EditContainer";
import { CustomLink } from "@/hooks/queries/custom-links/useCustomLinks";
import { useBulkUpdateCustomLinksMutation } from "@/hooks/queries/custom-links/useCustomLinksMutation";
import { CustomLink } from "@/api/custom-links/types";
import { useBulkUpdateCustomLinksMutation } from "@/api/custom-links/useCustomLinksMutation";

interface FestivalLinksFieldProps {
festivalId: string;
Expand Down
2 changes: 1 addition & 1 deletion src/pages/admin/festivals/info/FestivalInfoDetails.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Button } from "@/components/ui/button";
import { Loader2, Edit } from "lucide-react";
import { useFestivalInfoQuery } from "@/hooks/queries/festival-info/useFestivalInfo";
import { useCustomLinksQuery } from "@/hooks/queries/custom-links/useCustomLinks";
import { useCustomLinksQuery } from "@/api/custom-links/useCustomLinks";
import { FestivalMapField } from "./FestivalFields/FestivalMapField";
import { FestivalInfoField } from "./FestivalFields/FestivalInfoField";
import { FestivalSocialField } from "./FestivalFields/FestivalSocialField";
Expand Down
Loading