feat: impl accepted/rejected button
This commit is contained in:
@@ -102,14 +102,27 @@ function ApplicationActions() {
|
|||||||
const DefaultActions = memo(() => {
|
const DefaultActions = memo(() => {
|
||||||
const entry = useContext(EntryContext)
|
const entry = useContext(EntryContext)
|
||||||
const setIsAddingStage = useListItemStore((state) => state.setIsAddingStage)
|
const setIsAddingStage = useListItemStore((state) => state.setIsAddingStage)
|
||||||
|
const addStageToEntry = useStore((state) => state.addStageInEntry)
|
||||||
const deleteEntry = useStore((state) => state.deleteEntry)
|
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() {
|
function onDeleteApplication() {
|
||||||
if (confirm("Are you sure you want to delete this application?")) {
|
if (confirm("Are you sure you want to delete this application?")) {
|
||||||
deleteEntry(entry.name)
|
deleteEntry(entry.name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function onAccepted() {
|
||||||
|
addStageToEntry(DEFAULT_NODE.acceptedNode.key, entry.name)
|
||||||
|
}
|
||||||
|
|
||||||
|
function onRejected() {
|
||||||
|
addStageToEntry(DEFAULT_NODE.rejectedNode.key, entry.name)
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-row flex-wrap gap-2 pl-4 mt-2">
|
<div className="flex flex-row flex-wrap gap-2 pl-4 mt-2">
|
||||||
<Button
|
<Button
|
||||||
@@ -120,8 +133,20 @@ const DefaultActions = memo(() => {
|
|||||||
>
|
>
|
||||||
New stage
|
New stage
|
||||||
</Button>
|
</Button>
|
||||||
<Button className="text-xs py-0">Accepted</Button>
|
<Button
|
||||||
<Button className="text-xs py-0">Rejected</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">
|
<Button onClick={onDeleteApplication} className="text-xs py-0">
|
||||||
Delete application
|
Delete application
|
||||||
</Button>
|
</Button>
|
||||||
|
@@ -18,6 +18,14 @@ const DEFAULT_NODE = {
|
|||||||
key: "Application submitted",
|
key: "Application submitted",
|
||||||
outs: {},
|
outs: {},
|
||||||
},
|
},
|
||||||
|
acceptedNode: {
|
||||||
|
key: "Accepted",
|
||||||
|
outs: {},
|
||||||
|
},
|
||||||
|
rejectedNode: {
|
||||||
|
key: "Rejected",
|
||||||
|
outs: {},
|
||||||
|
},
|
||||||
} as const
|
} as const
|
||||||
|
|
||||||
export { DEFAULT_NODE }
|
export { DEFAULT_NODE }
|
||||||
|
@@ -53,7 +53,11 @@ const useStore = create<Store>()(
|
|||||||
}
|
}
|
||||||
|
|
||||||
const lastStageNodeKey = entry.stages.at(-1) ?? state.starts[0]
|
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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user