(null)
if (!store.current) {
store.current = createListItemStore()
}
return (
{entry.name}
{entry.stages.map((step) => (
))}
)
})
const StageItem = memo(({ stage }: { stage: string }) => (
{stage}
{stage !== DEFAULT_NODE.applicationSubmittedNode.key ? (
) : null}
))
function StageItemActions({ stage }: { stage: string }) {
const entry = useContext(EntryContext)
const deleteStageInEntry = useRootStore((state) => state.deleteStageInEntry)
return (
)
}
function NewStageInput() {
const isAddingStage = useListItemStore((state) => state.isAddingStage)
const inputRef = useRef(null)
useEffect(() => {
if (isAddingStage) {
inputRef.current?.focus()
}
}, [isAddingStage])
if (isAddingStage) {
return (
)
}
return null
}
function ActualStageInput({ ref }: { ref: Ref }) {
const entry = useContext(EntryContext)
const newStageValue = useListItemStore((state) => state.newStageValue)
const setNewStageValue = useListItemStore((state) => state.setNewStageValue)
const addStage = useListItemStore((state) => state.addStage)
return (
{
setNewStageValue(event.currentTarget.value)
}}
onKeyDown={(event) => {
if (event.key === "Enter") {
addStage(entry.name)
}
}}
className="bg-transparent"
/>
)
}
function ApplicationActions() {
const isAddingStage = useListItemStore((state) => state.isAddingStage)
if (isAddingStage) {
return
}
return
}
const DefaultActions = memo(() => {
const entry = useContext(EntryContext)
const setIsAddingStage = useListItemStore((state) => state.setIsAddingStage)
const addStageToEntry = useRootStore((state) => state.addStageInEntry)
const deleteEntry = useRootStore((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 (
)
})
const AddStageActions = memo(() => {
const entry = useContext(EntryContext)
const setIsAddingStage = useListItemStore((state) => state.setIsAddingStage)
const addStage = useListItemStore((state) => state.addStage)
function onOk() {
addStage(entry.name)
}
function onCancel() {
setIsAddingStage(false)
}
return (
)
})
export { ApplicationList }