diff --git a/src/pages/gallery/components/AlertBanner.tsx b/src/pages/gallery/components/AlertBanner.tsx new file mode 100644 index 000000000..4f3643deb --- /dev/null +++ b/src/pages/gallery/components/AlertBanner.tsx @@ -0,0 +1,24 @@ +import React from 'react'; +import { Alert } from 'react-bootstrap'; +import constants from 'utils/strings/constants'; + +export default function AlertBanner({ bannerErrorCode }) { + let errorMessage; + switch (bannerErrorCode) { + case 402: + errorMessage = constants.SUBSCRIPTION_EXPIRED; + break; + case 426: + errorMessage = constants.STORAGE_QUOTA_EXCEEDED; + default: + errorMessage = `Unknown Error Code - ${bannerErrorCode} Encountered`; + } + return ( + + {errorMessage} + + ); +} diff --git a/src/pages/gallery/components/ErrorAlert.tsx b/src/pages/gallery/components/ErrorAlert.tsx deleted file mode 100644 index 707b43e94..000000000 --- a/src/pages/gallery/components/ErrorAlert.tsx +++ /dev/null @@ -1,21 +0,0 @@ -import React from "react"; -import { Alert } from "react-bootstrap"; -import constants from "utils/strings/constants"; - -export default function ErrorAlert({ errorCode }) { - let errorMessage; - switch (errorCode) { - case 402: - errorMessage = constants.SUBSCRIPTION_EXPIRED; - break; - case 426: - errorMessage = constants.STORAGE_QUOTA_EXCEEDED; - default: - errorMessage = errorCode; - } - return ( - - {errorMessage} - - ) -} diff --git a/src/pages/gallery/index.tsx b/src/pages/gallery/index.tsx index b95726dbc..1f916fb5f 100644 --- a/src/pages/gallery/index.tsx +++ b/src/pages/gallery/index.tsx @@ -22,7 +22,7 @@ import { getCollectionUpdationTime, } from 'services/collectionService'; import constants from 'utils/strings/constants'; -import ErrorAlert from './components/ErrorAlert'; +import AlertBanner from './components/AlertBanner'; import { Alert } from 'react-bootstrap'; const DATE_CONTAINER_HEIGHT = 45; @@ -111,7 +111,7 @@ export default function Gallery(props) { const [open, setOpen] = useState(false); const [currentIndex, setCurrentIndex] = useState(0); const fetching: { [k: number]: boolean } = {}; - const [errorCode, setErrorCode] = useState(null); + const [bannerErrorCode, setBannerErrorCode] = useState(null); const [sinceTime, setSinceTime] = useState(0); const [isFirstLoad, setIsFirstLoad] = useState(false); @@ -123,7 +123,7 @@ export default function Gallery(props) { return; } const main = async () => { - setIsFirstLoad(await getCollectionUpdationTime() == 0); + setIsFirstLoad((await getCollectionUpdationTime()) == 0); const data = await localFiles(); const collections = await getLocalCollections(); const collectionAndItsLatestFile = await getCollectionAndItsLatestFile( @@ -325,7 +325,7 @@ export default function Gallery(props) { )} - + {filteredData.length ? ( @@ -413,7 +413,7 @@ export default function Gallery(props) { timeStampList[index].itemType === - ITEM_TYPE.TIME + ITEM_TYPE.TIME ? DATE_CONTAINER_HEIGHT : IMAGE_CONTAINER_HEIGHT } @@ -430,14 +430,14 @@ export default function Gallery(props) { columns={ timeStampList[index] .itemType === - ITEM_TYPE.TIME + ITEM_TYPE.TIME ? 1 : columns } > {timeStampList[index] .itemType === - ITEM_TYPE.TIME ? ( + ITEM_TYPE.TIME ? ( { timeStampList[ @@ -456,7 +456,7 @@ export default function Gallery(props) { index ] .itemStartIndex + - idx + idx ); } )