2022-08-05 22:06:53 +00:00
|
|
|
import { useState, useEffect } from 'react';
|
|
|
|
|
|
|
|
export function useSession() {
|
|
|
|
|
|
|
|
const [state, setState] = useState({
|
|
|
|
conversation: false,
|
|
|
|
details: false,
|
|
|
|
cards: false,
|
|
|
|
contact: false,
|
|
|
|
profile: false,
|
|
|
|
});
|
|
|
|
|
|
|
|
const updateState = (value) => {
|
|
|
|
setState((s) => ({ ...s, ...value }));
|
|
|
|
}
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
setTimeout(() => {
|
|
|
|
updateState({ cards: true });
|
|
|
|
}, 1000);
|
|
|
|
setTimeout(() => {
|
|
|
|
updateState({ contact: true });
|
|
|
|
}, 2000);
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
const actions = {
|
|
|
|
closeDetails: () => {
|
|
|
|
updateState({ details: false });
|
|
|
|
},
|
2022-08-07 06:41:09 +00:00
|
|
|
openCards: () => {
|
|
|
|
updateState({ cards: true });
|
|
|
|
},
|
2022-08-05 22:06:53 +00:00
|
|
|
closeCards: () => {
|
|
|
|
updateState({ cards: false });
|
|
|
|
},
|
|
|
|
closeContact: () => {
|
|
|
|
updateState({ contact: false });
|
|
|
|
},
|
2022-08-07 06:41:09 +00:00
|
|
|
openProfile: () => {
|
|
|
|
updateState({ profile: true });
|
|
|
|
},
|
2022-08-05 22:06:53 +00:00
|
|
|
closeProfile: () => {
|
|
|
|
updateState({ profile: false });
|
|
|
|
},
|
|
|
|
closeConversation: () => {
|
|
|
|
updateState({ conversation: false });
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
return { state, actions };
|
|
|
|
}
|
|
|
|
|