Skip to content

Commit

Permalink
comments
Browse files Browse the repository at this point in the history
  • Loading branch information
christophertorres1 committed Dec 11, 2024
1 parent 014badd commit b828d51
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/supabase/queries/trees.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ export async function addTree(species: string) {
}
}

// Function to add multiple trees of the same species. Returns an array of UUIDs for all trees that were added.
export async function addMultipleTrees(
species: string,
quantity: number,
): Promise<string[]> {
// add_multiple_trees returns all uuids of trees added in JSON form
const { data, error } = await supabase.rpc('add_multiple_trees', {
species: species,
quantity: quantity,
Expand All @@ -29,7 +29,6 @@ export async function addMultipleTrees(
throw new Error(`Error adding multiple trees: ${error.message}`);
}

// data is now a JSON array of UUIDs, parse it if needed
const treeIds: string[] = Array.isArray(data) ? data : [];
return treeIds;
}
Expand Down Expand Up @@ -271,7 +270,7 @@ export async function generateQRImage(treeId: string): Promise<void> {
body: { tree_id: treeId },
});

// typed error handling because generic error.message provides no info
// Typed error handling because generic error.message provides no information
if (error instanceof FunctionsHttpError) {
const errorMessage = await error.context.text();
throw new Error(`FunctionsHttpError: ${errorMessage}$`);
Expand Down

0 comments on commit b828d51

Please sign in to comment.