G
Size: a a a
G
G
ДА
export const ModalContainer: FC<ModalContainerProps> = (props) => {
const [visibility, dispatch] = useReducer(
(state: VisibilityState, name: ModalName) => ({
...state,
[name]: !state[name],
}),
{
[ModalName.PROFILE]: false,
[ModalName.REPORT]: false,
[ModalName.FILTERS]: false,
[ModalName.CHAT_ACTIONS]: false,
[ModalName.PREMIUM_ACCOUNT]: false,
},
);
const { route } = props;
const { modalName, userId } = route.params;
useEffect(() => {
if (modalName) {
dispatch(modalName);
}
}, [dispatch]);
return (
<>
{visibility[ModalName.FILTERS] && <Filter />}
{visibility[ModalName.PROFILE] && userId && <Profile userId={userId} />}
{visibility[ModalName.REPORT] && <Report {...props} />}
{visibility[ModalName.CHAT_ACTIONS] && <ChatActions {...props} />}
{visibility[ModalName.PREMIUM_ACCOUNT] && <PremiumAccount />}
</>
);
};
ДА
ДА
G
AM
AM
G
export const ModalContainer: FC<ModalContainerProps> = (props) => {
const [visibility, dispatch] = useReducer(
(state: VisibilityState, name: ModalName) => ({
...state,
[name]: !state[name],
}),
{
[ModalName.PROFILE]: false,
[ModalName.REPORT]: false,
[ModalName.FILTERS]: false,
[ModalName.CHAT_ACTIONS]: false,
[ModalName.PREMIUM_ACCOUNT]: false,
},
);
const { route } = props;
const { modalName, userId } = route.params;
useEffect(() => {
if (modalName) {
dispatch(modalName);
}
}, [dispatch]);
return (
<>
{visibility[ModalName.FILTERS] && <Filter />}
{visibility[ModalName.PROFILE] && userId && <Profile userId={userId} />}
{visibility[ModalName.REPORT] && <Report {...props} />}
{visibility[ModalName.CHAT_ACTIONS] && <ChatActions {...props} />}
{visibility[ModalName.PREMIUM_ACCOUNT] && <PremiumAccount />}
</>
);
};
ДА
G
ДА
AB
AB
AT
MS
D
S
CM
CM