typescript fixin
Some checks failed
Deploy to Web Server flyer-crawler.projectium.com / deploy (push) Failing after 19s
Some checks failed
Deploy to Web Server flyer-crawler.projectium.com / deploy (push) Failing after 19s
This commit is contained in:
@@ -520,7 +520,7 @@ export const addWatchedItem = async (userId: string, itemName: string, category:
|
||||
category_id: masterItem.category_id,
|
||||
category_name: masterItem.category_name?.name ?? null,
|
||||
};
|
||||
} catch (error: any) {
|
||||
} catch (error) {
|
||||
// This catch block is now valid because of the preceding `try`.
|
||||
const errorMessage = error instanceof Error ? error.message : 'An unknown error occurred in addWatchedItem.';
|
||||
throw new Error(`Failed to add watched item: ${errorMessage}`);
|
||||
@@ -645,7 +645,7 @@ export const updateUserProfile = async (userId: string, updates: { full_name?: s
|
||||
const data = await handleResponse<Profile | null>(supabaseClient
|
||||
.from('profiles')
|
||||
// Cast to `any` to handle potential JSONB type mismatches if more fields are added
|
||||
.update(updates as any)
|
||||
.update(updates)
|
||||
.eq('id', userId)
|
||||
.select()
|
||||
.single());
|
||||
@@ -664,7 +664,7 @@ export const updateUserPreferences = async (userId: string, preferences: Profile
|
||||
const data = await handleResponse<Profile | null>(supabaseClient
|
||||
.from('profiles')
|
||||
// Cast to `any` to handle the JSONB type mismatch for `preferences`
|
||||
.update({ preferences: preferences as any })
|
||||
.update({ preferences: preferences as Json })
|
||||
.eq('id', userId)
|
||||
.select().single()
|
||||
);
|
||||
@@ -687,7 +687,17 @@ export const updateUserPassword = async (newPassword: string): Promise<void> =>
|
||||
* @param userId The UUID of the user.
|
||||
* @returns An object containing all of the user's data.
|
||||
*/
|
||||
export const exportUserData = async (userId: string): Promise<object> => {
|
||||
|
||||
type WatchedItemExport = { created_at: string; item: { name: string; category: { name: string } | null } | null };
|
||||
type ShoppingListExport = { name: string; created_at: string; items: { custom_item_name: string | null; quantity: number; is_purchased: boolean; master_item: { name: string } | null }[] };
|
||||
|
||||
interface UserDataExport {
|
||||
profile: Profile | null;
|
||||
watchedItems: WatchedItemExport[] | null;
|
||||
shoppingLists: ShoppingListExport[] | null;
|
||||
}
|
||||
|
||||
export const exportUserData = async (userId: string): Promise<UserDataExport> => {
|
||||
const supabaseClient = ensureSupabase();
|
||||
|
||||
const profile = await handleResponse<Profile | null>(supabaseClient
|
||||
@@ -696,12 +706,12 @@ export const exportUserData = async (userId: string): Promise<object> => {
|
||||
.eq('id', userId)
|
||||
.single());
|
||||
|
||||
const watchedItems = await handleResponse<any[] | null>(supabaseClient
|
||||
const watchedItems = await handleResponse<WatchedItemExport[] | null>(supabaseClient
|
||||
.from('user_watched_items')
|
||||
.select('created_at, item:master_grocery_items(name, category:categories(name))')
|
||||
.eq('user_id', userId));
|
||||
|
||||
const shoppingLists = await handleResponse<any[] | null>(supabaseClient
|
||||
const shoppingLists = await handleResponse<ShoppingListExport[] | null>(supabaseClient
|
||||
.from('shopping_lists')
|
||||
.select('name, created_at, items:shopping_list_items(custom_item_name, quantity, is_purchased, master_item:master_grocery_items(name))')
|
||||
.eq('user_id', userId));
|
||||
|
||||
Reference in New Issue
Block a user