50 lines
2.5 KiB
JavaScript
50 lines
2.5 KiB
JavaScript
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
import { useState, useEffect } from "react";
|
|
import { Link } from "react-router-dom";
|
|
import { DynamicTable } from "@/components/DynamicTable";
|
|
import { getFeedbacks, getFeedbackFields } from "@/services/feedback";
|
|
import { ErrorDisplay } from "@/components/ErrorDisplay";
|
|
import { Button } from "@/components/ui/button";
|
|
export function FeedbackListPage() {
|
|
const [fields, setFields] = useState([]);
|
|
const [feedbacks, setFeedbacks] = useState([]);
|
|
const [loading, setLoading] = useState(true);
|
|
const [error, setError] = useState(null);
|
|
// TODO: projectId와 channelId는 URL 파라미터나 컨텍스트에서 가져와야 합니다.
|
|
const projectId = "1";
|
|
const channelId = "4";
|
|
useEffect(() => {
|
|
const fetchFieldsAndFeedbacks = async () => {
|
|
try {
|
|
setLoading(true);
|
|
const fieldsData = await getFeedbackFields(projectId, channelId);
|
|
setFields(fieldsData);
|
|
try {
|
|
const feedbacksData = await getFeedbacks(projectId, channelId);
|
|
setFeedbacks(feedbacksData);
|
|
}
|
|
catch (feedbackError) {
|
|
console.error("Failed to fetch feedbacks:", feedbackError);
|
|
setError("피드백 목록을 불러오는 데 실패했습니다.");
|
|
}
|
|
}
|
|
catch (fieldsError) {
|
|
if (fieldsError instanceof Error) {
|
|
setError(fieldsError.message);
|
|
}
|
|
else {
|
|
setError("테이블 구조를 불러오는 데 실패했습니다.");
|
|
}
|
|
}
|
|
finally {
|
|
setLoading(false);
|
|
}
|
|
};
|
|
fetchFieldsAndFeedbacks();
|
|
}, [projectId, channelId]);
|
|
if (loading) {
|
|
return _jsx("div", { children: "\uB85C\uB529 \uC911..." });
|
|
}
|
|
return (_jsxs("div", { className: "container mx-auto p-4", children: [_jsxs("div", { className: "flex justify-between items-center mb-4", children: [_jsx("h1", { className: "text-2xl font-bold", children: "\uD53C\uB4DC\uBC31 \uBAA9\uB85D" }), _jsx(Button, { asChild: true, children: _jsx(Link, { to: "new", children: "\uC0C8 \uD53C\uB4DC\uBC31 \uC791\uC131" }) })] }), error && _jsx(ErrorDisplay, { message: error }), _jsx(DynamicTable, { columns: fields, data: feedbacks, projectId: projectId, channelId: channelId })] }));
|
|
}
|