From c497b832ae60a45d3db28d2e388a5cde577eac31 Mon Sep 17 00:00:00 2001 From: Kenneth Date: Sun, 26 Jan 2025 17:30:59 +0000 Subject: [PATCH] feat: impl accepted/rejected button --- app/home/application-list.tsx | 29 +++++++++++++++++++++++++++-- app/home/graph.ts | 8 ++++++++ app/home/store.ts | 6 +++++- 3 files changed, 40 insertions(+), 3 deletions(-) diff --git a/app/home/application-list.tsx b/app/home/application-list.tsx index fc76da7..e8df4e5 100644 --- a/app/home/application-list.tsx +++ b/app/home/application-list.tsx @@ -102,14 +102,27 @@ function ApplicationActions() { const DefaultActions = memo(() => { const entry = useContext(EntryContext) const setIsAddingStage = useListItemStore((state) => state.setIsAddingStage) + const addStageToEntry = useStore((state) => state.addStageInEntry) const deleteEntry = useStore((state) => state.deleteEntry) + const isApplicationFinalized = + entry.stages.at(-1) === DEFAULT_NODE.acceptedNode.key || + entry.stages.at(-1) === DEFAULT_NODE.rejectedNode.key + function onDeleteApplication() { if (confirm("Are you sure you want to delete this application?")) { deleteEntry(entry.name) } } + function onAccepted() { + addStageToEntry(DEFAULT_NODE.acceptedNode.key, entry.name) + } + + function onRejected() { + addStageToEntry(DEFAULT_NODE.rejectedNode.key, entry.name) + } + return (
- - + + diff --git a/app/home/graph.ts b/app/home/graph.ts index 8380e0a..979c538 100644 --- a/app/home/graph.ts +++ b/app/home/graph.ts @@ -18,6 +18,14 @@ const DEFAULT_NODE = { key: "Application submitted", outs: {}, }, + acceptedNode: { + key: "Accepted", + outs: {}, + }, + rejectedNode: { + key: "Rejected", + outs: {}, + }, } as const export { DEFAULT_NODE } diff --git a/app/home/store.ts b/app/home/store.ts index 28cc702..a5e23ad 100644 --- a/app/home/store.ts +++ b/app/home/store.ts @@ -53,7 +53,11 @@ const useStore = create()( } const lastStageNodeKey = entry.stages.at(-1) ?? state.starts[0] - if (lastStageNodeKey === stage) { + if ( + lastStageNodeKey === stage || + lastStageNodeKey === DEFAULT_NODE.acceptedNode.key || + lastStageNodeKey === DEFAULT_NODE.rejectedNode.key + ) { return }