feat: impl accepted/rejected button

This commit is contained in:
2025-01-26 17:30:59 +00:00
parent 1bc4206e39
commit c497b832ae
3 changed files with 40 additions and 3 deletions

View File

@@ -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 (
<div className="flex flex-row flex-wrap gap-2 pl-4 mt-2">
<Button
@@ -120,8 +133,20 @@ const DefaultActions = memo(() => {
>
New stage
</Button>
<Button className="text-xs py-0">Accepted</Button>
<Button className="text-xs py-0">Rejected</Button>
<Button
disabled={isApplicationFinalized}
className="text-xs py-0"
onClick={onAccepted}
>
Accepted
</Button>
<Button
disabled={isApplicationFinalized}
className="text-xs py-0"
onClick={onRejected}
>
Rejected
</Button>
<Button onClick={onDeleteApplication} className="text-xs py-0">
Delete application
</Button>

View File

@@ -18,6 +18,14 @@ const DEFAULT_NODE = {
key: "Application submitted",
outs: {},
},
acceptedNode: {
key: "Accepted",
outs: {},
},
rejectedNode: {
key: "Rejected",
outs: {},
},
} as const
export { DEFAULT_NODE }

View File

@@ -53,7 +53,11 @@ const useStore = create<Store>()(
}
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
}