1
0
Fork 0
mirror of https://github.com/plankanban/planka.git synced 2025-07-19 21:29:43 +02:00
planka/client/src/hooks/use-steps.js

27 lines
509 B
JavaScript
Raw Normal View History

2019-08-31 04:07:25 +05:00
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 open = useCallback((type, params) => {
2019-08-31 04:07:25 +05:00
setStep(createStep(type, params));
}, []);
const handleBack = useCallback(() => {
setStep(null);
}, []);
return [step, open, handleBack];
2019-08-31 04:07:25 +05:00
};