mirror of
https://github.com/yusufipk/OpenFrame.git
synced 2026-09-11 17:46:06 +00:00
refactor: Update API response handling to access nested data structure
This commit is contained in:
@@ -68,8 +68,8 @@ export default function ProjectMembersPage() {
|
||||
return;
|
||||
}
|
||||
const data = await res.json();
|
||||
setMembers(data.members);
|
||||
setOwner(data.owner);
|
||||
setMembers(data.data.members);
|
||||
setOwner(data.data.owner);
|
||||
} catch {
|
||||
setError('Failed to load members');
|
||||
} finally {
|
||||
|
||||
@@ -89,10 +89,11 @@ export default function ProjectSettingsPage({ params }: ProjectSettingsPageProps
|
||||
if (data.error) {
|
||||
setError(data.error);
|
||||
} else {
|
||||
const project = data.data;
|
||||
setFormData({
|
||||
name: data.name || '',
|
||||
description: data.description || '',
|
||||
visibility: data.visibility || 'PRIVATE',
|
||||
name: project.name || '',
|
||||
description: project.description || '',
|
||||
visibility: project.visibility || 'PRIVATE',
|
||||
});
|
||||
}
|
||||
})
|
||||
@@ -103,8 +104,8 @@ export default function ProjectSettingsPage({ params }: ProjectSettingsPageProps
|
||||
fetch(`/api/projects/${id}/tags`)
|
||||
.then((res) => res.json())
|
||||
.then((data) => {
|
||||
if (Array.isArray(data)) {
|
||||
setTags(data);
|
||||
if (Array.isArray(data.data)) {
|
||||
setTags(data.data);
|
||||
}
|
||||
})
|
||||
.catch(() => { /* Silent fail - tags are optional */ });
|
||||
@@ -150,7 +151,8 @@ export default function ProjectSettingsPage({ params }: ProjectSettingsPageProps
|
||||
body: JSON.stringify({ name: newTagName.trim(), color: newTagColor }),
|
||||
});
|
||||
if (res.ok) {
|
||||
const newTag = await res.json();
|
||||
const data = await res.json();
|
||||
const newTag = data.data;
|
||||
setTags([...tags, newTag]);
|
||||
setNewTagName('');
|
||||
setNewTagColor('#3B82F6');
|
||||
@@ -171,7 +173,8 @@ export default function ProjectSettingsPage({ params }: ProjectSettingsPageProps
|
||||
body: JSON.stringify({ name: editTagName.trim(), color: editTagColor }),
|
||||
});
|
||||
if (res.ok) {
|
||||
const updated = await res.json();
|
||||
const data = await res.json();
|
||||
const updated = data.data;
|
||||
setTags(tags.map((t) => (t.id === tagId ? updated : t)));
|
||||
setEditingTagId(null);
|
||||
}
|
||||
|
||||
@@ -45,9 +45,10 @@ export default function ProjectSharePage({ params }: ProjectSharePageProps) {
|
||||
if (data.error) {
|
||||
setError(data.error);
|
||||
} else {
|
||||
setProjectName(data.name || '');
|
||||
setProjectVisibility(data.visibility || 'PRIVATE');
|
||||
setMembers(data.members || []);
|
||||
const project = data.data;
|
||||
setProjectName(project.name || '');
|
||||
setProjectVisibility(project.visibility || 'PRIVATE');
|
||||
setMembers(project.members || []);
|
||||
}
|
||||
})
|
||||
.catch(() => setError('Failed to load project'))
|
||||
|
||||
@@ -79,7 +79,8 @@ export default function CompareVersionsPage() {
|
||||
setLoading(false);
|
||||
return;
|
||||
}
|
||||
const data = await res.json();
|
||||
const response = await res.json();
|
||||
const data = response.data;
|
||||
setVideo(data);
|
||||
|
||||
// Set initial versions from query params or defaults
|
||||
|
||||
@@ -240,7 +240,8 @@ export default function VideoPage() {
|
||||
try {
|
||||
const res = await fetch(`/api/projects/${projectId}/tags`);
|
||||
if (res.ok) {
|
||||
const tags = await res.json();
|
||||
const data = await res.json();
|
||||
const tags = data.data || [];
|
||||
setAvailableTags(tags);
|
||||
// Auto-select first tag (Feedback) as default
|
||||
if (tags.length > 0 && !selectedTagId) {
|
||||
@@ -1165,7 +1166,7 @@ export default function VideoPage() {
|
||||
const res = await fetch(`/api/projects/${projectId}/videos/${videoId}`);
|
||||
if (res.ok) {
|
||||
const data = await res.json();
|
||||
setVideo(data);
|
||||
setVideo(data.data);
|
||||
}
|
||||
} catch { /* silent */ }
|
||||
}, 10000);
|
||||
|
||||
Reference in New Issue
Block a user