import { useEffect, useState } from 'react';
import AmityPostDetailPage from '../../features/post/Detail';
import { useNavigation, useRoute } from '@react-navigation/native';
function PostDetail({
  defaultPostId
}) {
  var _route$params, _route$params2, _route$params3, _route$params4;
  const route = useRoute();
  const navigation = useNavigation();
  const postIdFromRoute = route === null || route === void 0 || (_route$params = route.params) === null || _route$params === void 0 ? void 0 : _route$params.postId;
  const [postId, setPostId] = useState('');
  useEffect(() => {
    const routes = navigation.getState().routes;
    if (defaultPostId && routes.length === 1) {
      setPostId(defaultPostId);
    } else if (postIdFromRoute) {
      setPostId(postIdFromRoute);
    }
    return () => {
      setPostId('');
    };
  }, [defaultPostId, navigation, postIdFromRoute]);
  return /*#__PURE__*/React.createElement(AmityPostDetailPage, {
    showEndPopup: route === null || route === void 0 || (_route$params2 = route.params) === null || _route$params2 === void 0 ? void 0 : _route$params2.showEndPopup,
    isFromComponent: !!defaultPostId && !postIdFromRoute,
    postId: postId,
    category: route === null || route === void 0 || (_route$params3 = route.params) === null || _route$params3 === void 0 ? void 0 : _route$params3.category,
    isDeleted: route === null || route === void 0 || (_route$params4 = route.params) === null || _route$params4 === void 0 ? void 0 : _route$params4.isDeleted
  });
}
export default PostDetail;
//# sourceMappingURL=index.js.map