chnaged ErrorAlert to AlertBanner and errorCode state to bannerErrorCode
This commit is contained in:
parent
5b5278d5ea
commit
42c46165fa
3 changed files with 33 additions and 30 deletions
24
src/pages/gallery/components/AlertBanner.tsx
Normal file
24
src/pages/gallery/components/AlertBanner.tsx
Normal file
|
@ -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 (
|
||||
<Alert
|
||||
variant={'danger'}
|
||||
style={{ display: bannerErrorCode ? 'block' : 'none' }}
|
||||
>
|
||||
{errorMessage}
|
||||
</Alert>
|
||||
);
|
||||
}
|
|
@ -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 (
|
||||
<Alert variant={'danger'} style={{ display: errorCode ? 'block' : 'none' }}>
|
||||
{errorMessage}
|
||||
</Alert>
|
||||
)
|
||||
}
|
|
@ -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<number>(0);
|
||||
const fetching: { [k: number]: boolean } = {};
|
||||
const [errorCode, setErrorCode] = useState<number>(null);
|
||||
const [bannerErrorCode, setBannerErrorCode] = useState<number>(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) {
|
|||
</Alert>
|
||||
</div>
|
||||
)}
|
||||
<ErrorAlert errorCode={errorCode} />
|
||||
<AlertBanner bannerErrorCode={bannerErrorCode} />
|
||||
|
||||
<Collections
|
||||
collections={collections}
|
||||
|
@ -338,7 +338,7 @@ export default function Gallery(props) {
|
|||
showUploadModal={props.showUploadModal}
|
||||
collectionAndItsLatestFile={collectionAndItsLatestFile}
|
||||
refetchData={syncWithRemote}
|
||||
setErrorCode={setErrorCode}
|
||||
setBannerErrorCode={setBannerErrorCode}
|
||||
/>
|
||||
{filteredData.length ? (
|
||||
<Container>
|
||||
|
@ -413,7 +413,7 @@ export default function Gallery(props) {
|
|||
<List
|
||||
itemSize={(index) =>
|
||||
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 ? (
|
||||
<DateContainer>
|
||||
{
|
||||
timeStampList[
|
||||
|
@ -456,7 +456,7 @@ export default function Gallery(props) {
|
|||
index
|
||||
]
|
||||
.itemStartIndex +
|
||||
idx
|
||||
idx
|
||||
);
|
||||
}
|
||||
)
|
||||
|
|
Loading…
Add table
Reference in a new issue