fix share to users UI
All checks were successful
Build and deploy / Build and Push Docker Images (push) Successful in 3m22s
All checks were successful
Build and deploy / Build and Push Docker Images (push) Successful in 3m22s
This commit is contained in:
@@ -51,7 +51,7 @@ export function ShareDialog({ mapId, onClose }: ShareDialogProps) {
|
|||||||
setLoading(true);
|
setLoading(true);
|
||||||
try {
|
try {
|
||||||
await mapShareService.shareWithUser(mapId, {
|
await mapShareService.shareWithUser(mapId, {
|
||||||
user_id: newUserId.trim(),
|
user_identifier: newUserId.trim(),
|
||||||
permission: newUserPermission,
|
permission: newUserPermission,
|
||||||
});
|
});
|
||||||
setNewUserId('');
|
setNewUserId('');
|
||||||
@@ -59,7 +59,20 @@ export function ShareDialog({ mapId, onClose }: ShareDialogProps) {
|
|||||||
showToast('Map shared successfully!', 'success');
|
showToast('Map shared successfully!', 'success');
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
console.error('Share error:', error);
|
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');
|
showToast(message, 'error');
|
||||||
} finally {
|
} finally {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ export interface MapShareLink {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface CreateMapShare {
|
export interface CreateMapShare {
|
||||||
user_id: string;
|
user_identifier: string;
|
||||||
permission: 'read' | 'edit';
|
permission: 'read' | 'edit';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user