From 0d9f588ea4b030fa6365d8e6624515d1cc5d0f41 Mon Sep 17 00:00:00 2001 From: ZawaReck Date: Wed, 10 Jan 2024 13:48:57 +0900 Subject: [PATCH] =?UTF-8?q?Custom=E3=82=BB=E3=83=AC=E3=82=AF=E3=83=88?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0(=E3=82=BD=E3=83=BC=E3=83=88=E3=81=AB?= =?UTF-8?q?=E3=81=AFSave=E3=82=92=E6=8A=BC=E3=81=99=E5=BF=85=E8=A6=81?= =?UTF-8?q?=E3=81=82=E3=82=8A)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/MemoList.tsx | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/pages/MemoList.tsx b/src/pages/MemoList.tsx index 9d75d7b..9d80315 100644 --- a/src/pages/MemoList.tsx +++ b/src/pages/MemoList.tsx @@ -47,6 +47,13 @@ export function MemoList(): JSX.Element { const [showNoResults, setShowNoResults] = useState(false); const [showResults,setShowResults] = useState(false); const [isDragging, setIsDragging] = useState(false); + const [savedOrder, setSavedOrder] = useState([]); + + const handleSaveOrder = () => { + setSavedOrder([...memoList]); + // ここでバックエンドに保存するロジックを追加することができます + }; + //これが消えるまでなら戻してよい const moveToMemo = (id?: string) => { if (id) { @@ -116,6 +123,15 @@ export function MemoList(): JSX.Element { if (reverseOrder) { sortedList.reverse(); // 逆順にする } + if (selectedOrder === "custom") { + const savedMemos = savedOrder; + const unsavedMemos = memoList.filter( + memo => !savedMemos.find(savedMemo => savedMemo.id === memo.id) + ); + + // 未保存のメモをリストの上部に配置 + sortedList = [...unsavedMemos, ...savedMemos]; + } setMemoList(selectedOrder === "update" ? updateOrder : sortedList); }; @@ -211,6 +227,7 @@ export function MemoList(): JSX.Element { Update Title Date + Custom {/* ここに他の並び替えオプションを追加 */} + ); -} +} \ No newline at end of file