kopia lustrzana https://github.com/bugout-dev/moonstream
in entryid.js
rodzic
712284fdd4
commit
846177f2b2
|
@ -1,19 +1,26 @@
|
||||||
import React, {useContext} from "react";
|
import React, { useContext } from "react";
|
||||||
import { Flex, HStack, Skeleton, Box, Heading, Center, Spinner } from "@chakra-ui/react";
|
import {
|
||||||
import { useTxInfo, useTxCashe, useRouter } from "../../src/core/hooks";
|
Flex,
|
||||||
|
HStack,
|
||||||
|
Skeleton,
|
||||||
|
Box,
|
||||||
|
Heading,
|
||||||
|
Center,
|
||||||
|
Spinner,
|
||||||
|
} from "@chakra-ui/react";
|
||||||
|
import { useTxInfo, useRouter } from "../../src/core/hooks";
|
||||||
import FourOFour from "../../src/components/FourOFour";
|
import FourOFour from "../../src/components/FourOFour";
|
||||||
import FourOThree from "../../src/components/FourOThree";
|
import FourOThree from "../../src/components/FourOThree";
|
||||||
import Tags from "../../src/components/Tags";
|
import Tags from "../../src/components/Tags";
|
||||||
import { getLayout } from "../../src/layouts/EntriesLayout";
|
import { getLayout } from "../../src/layouts/EntriesLayout";
|
||||||
import Scrollable from "../../src/components/Scrollable";
|
import Scrollable from "../../src/components/Scrollable";
|
||||||
import TxInfo from "../../src/components/TxInfo"
|
import TxInfo from "../../src/components/TxInfo";
|
||||||
import UIContext from "../../src/core/providers/UIProvider/context";
|
import UIContext from "../../src/core/providers/UIProvider/context";
|
||||||
|
|
||||||
const Entry = () => {
|
const Entry = () => {
|
||||||
const ui = useContext(UIContext);
|
const ui = useContext(UIContext);
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const { entryId } = router.params;
|
const { entryId } = router.params;
|
||||||
const txCache = useTxCashe;
|
|
||||||
|
|
||||||
const callReroute = () => {
|
const callReroute = () => {
|
||||||
ui.setEntriesViewMode("list");
|
ui.setEntriesViewMode("list");
|
||||||
|
@ -35,12 +42,8 @@ const Entry = () => {
|
||||||
</Center>
|
</Center>
|
||||||
</Box>
|
</Box>
|
||||||
);
|
);
|
||||||
return (
|
return <LoadingSpinner />;
|
||||||
<LoadingSpinner/>
|
};
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
const transaction = txCache.getCurrentTransaction()
|
|
||||||
|
|
||||||
const {
|
const {
|
||||||
data: entry,
|
data: entry,
|
||||||
|
@ -48,9 +51,11 @@ const Entry = () => {
|
||||||
isLoading,
|
isLoading,
|
||||||
isError,
|
isError,
|
||||||
error,
|
error,
|
||||||
} = useTxInfo({tx:transaction})
|
} = useTxInfo({ tx: ui.currentTransaction });
|
||||||
|
|
||||||
if (isError) {return callReroute()}
|
if (isError) {
|
||||||
|
return callReroute();
|
||||||
|
}
|
||||||
if (isError && error.response.status === 404) return <FourOFour />;
|
if (isError && error.response.status === 404) return <FourOFour />;
|
||||||
if (isError && error.response.status === 403) return <FourOThree />;
|
if (isError && error.response.status === 403) return <FourOThree />;
|
||||||
// if (!entry || isLoading) return "";
|
// if (!entry || isLoading) return "";
|
||||||
|
@ -106,7 +111,7 @@ const Entry = () => {
|
||||||
isLoaded={isFetchedAfterMount || entry}
|
isLoaded={isFetchedAfterMount || entry}
|
||||||
>
|
>
|
||||||
<Scrollable>
|
<Scrollable>
|
||||||
{!isLoading && (<TxInfo transaction = {entry}></TxInfo> )}
|
{!isLoading && <TxInfo transaction={entry}></TxInfo>}
|
||||||
</Scrollable>
|
</Scrollable>
|
||||||
</Skeleton>
|
</Skeleton>
|
||||||
</Flex>
|
</Flex>
|
||||||
|
|
Ładowanie…
Reference in New Issue