mirror of
https://github.com/plankanban/planka.git
synced 2025-07-20 13:49:43 +02:00
27 lines
517 B
JavaScript
27 lines
517 B
JavaScript
|
import { useCallback, useState } from 'react';
|
||
|
|
||
|
const createStep = (type, params = {}) => {
|
||
|
if (!type) {
|
||
|
return null;
|
||
|
}
|
||
|
|
||
|
return {
|
||
|
type,
|
||
|
params,
|
||
|
};
|
||
|
};
|
||
|
|
||
|
export default (initialType, initialParams) => {
|
||
|
const [step, setStep] = useState(() => createStep(initialType, initialParams));
|
||
|
|
||
|
const openStep = useCallback((type, params) => {
|
||
|
setStep(createStep(type, params));
|
||
|
}, []);
|
||
|
|
||
|
const handleBack = useCallback(() => {
|
||
|
setStep(null);
|
||
|
}, []);
|
||
|
|
||
|
return [step, openStep, handleBack];
|
||
|
};
|