From 0e436aac2619ae1d8ae41e0cf1ffb6ae48d5d87a Mon Sep 17 00:00:00 2001 From: Shihaam Abdul Rahman Date: Sat, 13 Dec 2025 16:48:03 +0500 Subject: [PATCH] fix share to users UI --- public/src/components/map/ShareDialog.tsx | 17 +++++++++++++++-- public/src/services/mapShareService.ts | 2 +- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/public/src/components/map/ShareDialog.tsx b/public/src/components/map/ShareDialog.tsx index af70a9c..0c60de0 100644 --- a/public/src/components/map/ShareDialog.tsx +++ b/public/src/components/map/ShareDialog.tsx @@ -51,7 +51,7 @@ export function ShareDialog({ mapId, onClose }: ShareDialogProps) { setLoading(true); try { await mapShareService.shareWithUser(mapId, { - user_id: newUserId.trim(), + user_identifier: newUserId.trim(), permission: newUserPermission, }); setNewUserId(''); @@ -59,7 +59,20 @@ export function ShareDialog({ mapId, onClose }: ShareDialogProps) { showToast('Map shared successfully!', 'success'); } catch (error: any) { console.error('Share error:', error); - const message = error.response?.data?.detail || error.message || 'Failed to share map'; + let message = 'Failed to share map'; + + if (error.response?.data?.detail) { + const detail = error.response.data.detail; + // Handle FastAPI validation errors (array of objects) + if (Array.isArray(detail)) { + message = detail.map((err: any) => err.msg).join(', '); + } else if (typeof detail === 'string') { + message = detail; + } + } else if (error.message) { + message = error.message; + } + showToast(message, 'error'); } finally { setLoading(false); diff --git a/public/src/services/mapShareService.ts b/public/src/services/mapShareService.ts index bc0cc54..a01cf97 100644 --- a/public/src/services/mapShareService.ts +++ b/public/src/services/mapShareService.ts @@ -23,7 +23,7 @@ export interface MapShareLink { } export interface CreateMapShare { - user_id: string; + user_identifier: string; permission: 'read' | 'edit'; }