mirror of
https://github.com/hanzonet/explore.git
synced 2026-10-30 18:16:57 +00:00
* add prefix to API resources * fix pw tests * refactor config * remove unnecessary prefixes in resource names * fixes * update screenshots
60 lines
1.5 KiB
TypeScript
60 lines
1.5 KiB
TypeScript
import { useRouter } from 'next/router';
|
|
import React from 'react';
|
|
|
|
import useApiQuery from 'lib/api/useApiQuery';
|
|
import throwOnResourceLoadError from 'lib/errors/throwOnResourceLoadError';
|
|
import getQueryParamString from 'lib/router/getQueryParamString';
|
|
import { BLOB } from 'stubs/blobs';
|
|
import BlobInfo from 'ui/blob/BlobInfo';
|
|
import TextAd from 'ui/shared/ad/TextAd';
|
|
import isCustomAppError from 'ui/shared/AppError/isCustomAppError';
|
|
import DataFetchAlert from 'ui/shared/DataFetchAlert';
|
|
import BlobEntity from 'ui/shared/entities/blob/BlobEntity';
|
|
import PageTitle from 'ui/shared/Page/PageTitle';
|
|
|
|
const BlobPageContent = () => {
|
|
const router = useRouter();
|
|
const hash = getQueryParamString(router.query.hash);
|
|
|
|
const { data, isPlaceholderData, isError, error } = useApiQuery('general:blob', {
|
|
pathParams: { hash },
|
|
queryOptions: {
|
|
placeholderData: BLOB,
|
|
refetchOnMount: false,
|
|
},
|
|
});
|
|
|
|
const content = (() => {
|
|
if (isError) {
|
|
if (isCustomAppError(error)) {
|
|
throwOnResourceLoadError({ resource: 'general:blob', error, isError: true });
|
|
}
|
|
|
|
return <DataFetchAlert/>;
|
|
}
|
|
|
|
if (!data) {
|
|
return null;
|
|
}
|
|
|
|
return <BlobInfo data={ data } isLoading={ isPlaceholderData }/>;
|
|
})();
|
|
|
|
const titleSecondRow = (
|
|
<BlobEntity hash={ hash } noLink variant="subheading"/>
|
|
);
|
|
|
|
return (
|
|
<>
|
|
<TextAd mb={ 6 }/>
|
|
<PageTitle
|
|
title="Blob details"
|
|
secondRow={ titleSecondRow }
|
|
/>
|
|
{ content }
|
|
</>
|
|
);
|
|
};
|
|
|
|
export default BlobPageContent;
|