Skip to content
Merged
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
4 changes: 2 additions & 2 deletions src/api/artist-notes/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ export type SetNote = {
note_content: string;
created_at: string;
updated_at: string;
author_username?: string;
author_email?: string;
author_username?: string | undefined;
author_email?: string | undefined;
};

// Query key factory
Expand Down
2 changes: 1 addition & 1 deletion src/api/auth/useSignInWithOtpMutation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useToast } from "@/components/ui/use-toast";

interface SignInWithOtpParams {
email: string;
inviteToken?: string;
inviteToken?: string | undefined;
}

export function useSignInWithOtpMutation() {
Expand Down
14 changes: 10 additions & 4 deletions src/api/auth/useUpdateProfile.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import { useMutation, useQueryClient } from "@tanstack/react-query";
import { useToast } from "@/hooks/use-toast";
import { supabase } from "@/integrations/supabase/client";
import type { Database } from "@/integrations/supabase/types";
import { profileKeys } from "./types";

type ValidateProfileUpdateArgs =
Database["public"]["Functions"]["validate_profile_update"]["Args"];

// Mutation function
async function updateProfile(variables: {
userId: string;
Expand All @@ -11,12 +15,14 @@ async function updateProfile(variables: {
const { userId, updates } = variables;

// Validate username uniqueness before attempting update
const trimmedUsername = updates.username?.trim();
const rpcArgs: ValidateProfileUpdateArgs = { user_id: userId };
if (trimmedUsername !== undefined) {
rpcArgs.new_username = trimmedUsername;
}
const { data: validationResult, error: validationError } = await supabase.rpc(
"validate_profile_update",
{
user_id: userId,
new_username: updates.username?.trim(),
},
rpcArgs,
);

if (validationError) {
Expand Down
2 changes: 1 addition & 1 deletion src/api/editions/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export type FestivalEdition =
export const editionsKeys = {
root: (festivalId: string) =>
[...festivalsKeys.root(), festivalId, "editions"] as const,
all: (festivalId: string, { all }: { all?: boolean } = {}) =>
all: (festivalId: string, { all }: { all?: boolean | undefined } = {}) =>
[...editionsKeys.root(festivalId), { all }] as const,
item: ({
editionId,
Expand Down
6 changes: 3 additions & 3 deletions src/api/editions/useFestivalEditionsForFestival.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { FestivalEdition, editionsKeys } from "./types";

export async function fetchFestivalEditions(
festivalId: string,
{ all }: { all?: boolean } = {},
{ all }: { all?: boolean | undefined } = {},
): Promise<FestivalEdition[]> {
let query = supabase
.from("festival_editions")
Expand All @@ -31,7 +31,7 @@ export async function fetchFestivalEditions(

export function editionsForFestivalQuery(
festivalId: string,
{ all }: { all?: boolean } = {},
{ all }: { all?: boolean | undefined } = {},
) {
return queryOptions({
queryKey: editionsKeys.all(festivalId, { all }),
Expand All @@ -41,7 +41,7 @@ export function editionsForFestivalQuery(

export function useFestivalEditionsForFestivalQuery(
festivalId: string | undefined,
{ all }: { all?: boolean } = {},
{ all }: { all?: boolean | undefined } = {},
) {
return useQuery({
...editionsForFestivalQuery(festivalId!, { all }),
Expand Down
2 changes: 1 addition & 1 deletion src/api/festivals/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export type Festival = Database["public"]["Tables"]["festivals"]["Row"];
// Query key factory for festivals
export const festivalsKeys = {
root: () => ["festivals"] as const,
all: ({ all }: { all?: boolean } = {}) =>
all: ({ all }: { all?: boolean | undefined } = {}) =>
[...festivalsKeys.root(), { all }] as const,
item: (festivalId: string) => [...festivalsKeys.root(), festivalId] as const,
bySlug: (festivalSlug: string) =>
Expand Down
6 changes: 4 additions & 2 deletions src/api/festivals/useFestivals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import { isTimeoutError, withTimeout } from "@/lib/timeout";
async function fetchFestivals({
all,
signal,
}: { all?: boolean; signal?: AbortSignal } = {}): Promise<Festival[]> {
}: { all?: boolean | undefined; signal?: AbortSignal } = {}): Promise<
Festival[]
> {
let query = supabase
.from("festivals")
.select("*")
Expand All @@ -32,7 +34,7 @@ async function fetchFestivals({
export function festivalsQuery({
all,
timeoutMs = 10000,
}: { all?: boolean; timeoutMs?: number } = {}) {
}: { all?: boolean | undefined; timeoutMs?: number } = {}) {
return queryOptions({
queryKey: festivalsKeys.all({ all }),
queryFn: ({ signal }) =>
Expand Down
4 changes: 2 additions & 2 deletions src/api/groups/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ export type Group = Database["public"]["Tables"]["groups"]["Row"] & {
export type GroupMember =
Database["public"]["Tables"]["group_members"]["Row"] & {
profiles?: {
username?: string;
email?: string;
username?: string | undefined;
email?: string | undefined;
};
};

Expand Down
21 changes: 14 additions & 7 deletions src/api/groups/useCreateGroup.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,32 @@
import { useMutation, useQueryClient } from "@tanstack/react-query";
import { useToast } from "@/hooks/use-toast";
import { supabase } from "@/integrations/supabase/client";
import type { Database } from "@/integrations/supabase/types";
import { groupsKeys } from "./types";
import { generateSlug } from "@/lib/slug";

type GroupInsert = Database["public"]["Tables"]["groups"]["Insert"];

// Mutation function
async function createGroup(variables: {
name: string;
description?: string;
description?: string | undefined;
userId: string;
}) {
const { name, description, userId } = variables;

const groupData: GroupInsert = {
name,
slug: generateSlug(name),
created_by: userId,
};
if (description !== undefined) {
groupData.description = description;
}

const { data: group, error } = await supabase
.from("groups")
.insert({
name,
slug: generateSlug(name),
description,
created_by: userId,
})
.insert(groupData)
.select()
.single();

Expand Down
14 changes: 11 additions & 3 deletions src/api/invites/useGenerateInviteMutation.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import { useMutation, useQueryClient } from "@tanstack/react-query";
import { useToast } from "@/components/ui/use-toast";
import { supabase } from "@/integrations/supabase/client";
import type { Database } from "@/integrations/supabase/types";
import { inviteKeys } from "./types";

type GroupInviteInsert =
Database["public"]["Tables"]["group_invites"]["Insert"];

async function generateInviteLink(
groupId: string,
options?: {
Expand All @@ -21,13 +25,17 @@ async function generateInviteLink(
throw new Error("Authentication required");
}

const inviteData = {
const inviteData: GroupInviteInsert = {
group_id: groupId,
invite_token: token,
created_by: user.id,
expires_at: options?.expiresAt?.toISOString(),
max_uses: options?.maxUses,
};
if (options?.expiresAt !== undefined) {
inviteData.expires_at = options.expiresAt.toISOString();
}
if (options?.maxUses !== undefined) {
inviteData.max_uses = options.maxUses;
}

const { error } = await supabase.from("group_invites").insert(inviteData);

Expand Down
2 changes: 1 addition & 1 deletion src/api/ratings/useRateSet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ async function rateSet({
setId: string;
rating: number;
userId: string;
existingRating?: number;
existingRating?: number | undefined;
}) {
if (existingRating === rating) {
const { error } = await supabase
Expand Down
29 changes: 20 additions & 9 deletions src/api/sets/useUpdateSet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,29 @@ export type UpdateSetInput = Partial<
async function updateSet(variables: { id: string; updates: UpdateSetInput }) {
const { id, updates } = variables;

const updateData: SetUpdate = {
name: updates.name,
description: updates.description,
festival_edition_id: updates.festival_edition_id,
stage_id: updates.stage_id,
time_start: updates.time_start,
time_end: updates.time_end,
archived: updates.archived,
};
const updateData: SetUpdate = {};
if (updates.name !== undefined) {
updateData.name = updates.name;
updateData.slug = generateSlug(updates.name);
}
if (updates.description !== undefined) {
updateData.description = updates.description;
}
if (updates.festival_edition_id !== undefined) {
updateData.festival_edition_id = updates.festival_edition_id;
}
if (updates.stage_id !== undefined) {
updateData.stage_id = updates.stage_id;
}
if (updates.time_start !== undefined) {
updateData.time_start = updates.time_start;
}
if (updates.time_end !== undefined) {
updateData.time_end = updates.time_end;
}
if (updates.archived !== undefined) {
updateData.archived = updates.archived;
}

const { data, error } = await supabase
.from("sets")
Expand Down
2 changes: 1 addition & 1 deletion src/api/voting/useVoteMutation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export async function vote(variables: {
setId: string;
voteType: number;
userId: string;
existingVote?: number;
existingVote?: number | undefined;
}) {
const { setId, voteType, userId, existingVote } = variables;

Expand Down
2 changes: 1 addition & 1 deletion src/components/Admin/ScheduleImport/CsvUploadStep.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { CsvDropZone } from "./CsvDropZone";

type Props = {
festivalEditionId: string;
defaultTimezone?: string;
defaultTimezone?: string | undefined;
onDiffReady: (diff: DiffResult, timezone: string) => void;
};

Expand Down
2 changes: 1 addition & 1 deletion src/components/ArtistImageLoader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useState } from "react";
import { Music } from "lucide-react";

interface ArtistImageLoaderProps {
src?: string | null;
src?: string | null | undefined;
alt: string;
className?: string;
}
Expand Down
4 changes: 2 additions & 2 deletions src/components/AuthDialog/AuthDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ interface AuthDialogProps {
open: boolean;
onOpenChange: (open: boolean) => void;
onSuccess: () => void;
inviteToken?: string;
groupName?: string;
inviteToken?: string | undefined;
groupName?: string | undefined;
}

export function AuthDialog({
Expand Down
2 changes: 1 addition & 1 deletion src/components/AuthDialog/EmailStep.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Input } from "@/components/ui/input";
import { Label } from "@/components/ui/label";

interface EmailStepProps {
inviteToken?: string;
inviteToken?: string | undefined;
onSuccess: (email: string) => void;
}

Expand Down
2 changes: 1 addition & 1 deletion src/components/AuthDialog/OtpStep.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {

interface OtpStepProps {
email: string;
inviteToken?: string;
inviteToken?: string | undefined;
onSuccess: () => void;
}

Expand Down
9 changes: 6 additions & 3 deletions src/components/ErrorBoundary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@ import React from "react";

interface ErrorBoundaryState {
hasError: boolean;
error?: Error;
error?: Error | undefined;
}

interface ErrorBoundaryProps {
children: React.ReactNode;
fallback?: React.ComponentType<{ error?: Error; retry: () => void }>;
fallback?: React.ComponentType<{
error?: Error | undefined;
retry: () => void;
}>;
}

export class ErrorBoundary extends React.Component<
Expand Down Expand Up @@ -46,7 +49,7 @@ function DefaultErrorFallback({
error,
retry,
}: {
error?: Error;
error?: Error | undefined;
retry: () => void;
}) {
return (
Expand Down
6 changes: 3 additions & 3 deletions src/components/StageBadge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { MapPin } from "lucide-react";

interface StageBadgeProps {
stageName: string;
stageColor?: string;
size?: "sm" | "md";
showIcon?: boolean;
stageColor?: string | undefined;
size?: "sm" | "md" | undefined;
showIcon?: boolean | undefined;
}

export function StageBadge({
Expand Down
2 changes: 1 addition & 1 deletion src/components/filters/FilterToggle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ interface FilterToggleProps {
hasActiveFilters: boolean;
activeFilterCount: number;
label?: string;
onClearFilters?: () => void;
onClearFilters?: (() => void) | undefined;
}

export function FilterToggle({
Expand Down
4 changes: 2 additions & 2 deletions src/components/layout/AppHeader/FestivalIndicator.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
interface FestivalIndicatorProps {
isTitleVisible?: boolean;
logoUrl?: string | null;
festivalName?: string;
logoUrl?: string | null | undefined;
festivalName?: string | undefined;
}

export function FestivalIndicator({
Expand Down
2 changes: 1 addition & 1 deletion src/components/layout/AppHeader/TitleSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Music, Heart } from "lucide-react";

interface TitleSectionProps {
title: string;
logoUrl?: string | null;
logoUrl?: string | null | undefined;
onLogoRefChange?: (ref: HTMLElement | null) => void;
}

Expand Down
4 changes: 2 additions & 2 deletions src/components/layout/AppHeader/UserAvatar.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar";

interface UserAvatarProps {
username?: string | null;
email?: string | null;
username?: string | null | undefined;
email?: string | null | undefined;
size?: "sm" | "md" | "lg";
}

Expand Down
2 changes: 1 addition & 1 deletion src/components/layout/AppHeader/UserMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type Profile = Database["public"]["Tables"]["profiles"]["Row"];

interface UserMenuProps {
user: User;
profile?: Profile;
profile?: Profile | undefined;
onSignOut: () => void;
isMobile?: boolean;
}
Expand Down
Loading
Loading