Skip to content

Commit ccde532

Browse files
committed
fixes
1 parent bc7a7a8 commit ccde532

File tree

2 files changed

+21
-7
lines changed

2 files changed

+21
-7
lines changed

src/pages/_app.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { store, persistor } from '../store';
77
import ZiplineTheming from '../components/ZiplineTheming';
88
import UIPlaceholder from '../components/UIPlaceholder';
99

10-
function MyApp({ Component, pageProps }) {
10+
function App({ Component, pageProps }) {
1111
const [theme, setTheme] = useState<'dark' | 'light'>('dark');
1212
useEffect(() => {
1313
const jssStyles = document.querySelector('#jss-server-side');
@@ -41,9 +41,9 @@ function MyApp({ Component, pageProps }) {
4141
);
4242
}
4343

44-
MyApp.propTypes = {
44+
App.propTypes = {
4545
Component: PropTypes.elementType.isRequired,
4646
pageProps: PropTypes.object.isRequired
4747
};
4848

49-
export default MyApp;
49+
export default App;

src/pages/dash/upload.tsx

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ export default function Upload() {
3232
const state = store.getState();
3333
const [files, setFiles] = React.useState<File[]>([]);
3434
const [alertOpen, setAlertOpen] = React.useState<boolean>(false);
35+
const [alertSev, setAlertSev] = React.useState('success');
36+
const [alertMsg, setAlertMsg] = React.useState('Uploaded Image!');
3537

3638
const handleFileUpload = async () => {
3739
const file = files[0];
@@ -46,7 +48,16 @@ export default function Upload() {
4648
body
4749
});
4850

49-
if (res.ok) setAlertOpen(true);
51+
if (res.ok) {
52+
setAlertOpen(true);
53+
setAlertMsg('Uploaded Image!');
54+
setAlertSev('success');
55+
} else {
56+
const d = await res.json();
57+
setAlertOpen(true);
58+
setAlertMsg(`Couldn't upload: ${d.error}`);
59+
setAlertSev('error');
60+
}
5061
};
5162

5263
if (typeof window === 'undefined') return <UIPlaceholder />;
@@ -63,8 +74,10 @@ export default function Upload() {
6374
autoHideDuration={6000}
6475
onClose={() => setAlertOpen(false)}
6576
>
66-
<Alert severity='success' variant='filled'>
67-
Uploaded image!
77+
{/* eslint-disable-next-line @typescript-eslint/ban-ts-comment */}
78+
{/* @ts-ignore */}
79+
<Alert severity={alertSev} variant='filled'>
80+
{alertMsg}
6881
</Alert>
6982
</Snackbar>
7083
<Paper elevation={3} className={classes.padding}>
@@ -76,10 +89,11 @@ export default function Upload() {
7689
acceptedFiles={['image/*']}
7790
dropzoneText={'Drag an image or click to upload an image.'}
7891
onChange={f => setFiles(f)}
92+
filesLimit={1}
7993
maxFileSize={1073741824} // 1gb in byte
8094
/>
8195
</Box>
82-
<Button onClick={handleFileUpload}>Submit</Button>
96+
<Button onClick={handleFileUpload}>Upload</Button>
8397
</Paper>
8498
</UI>
8599
);

0 commit comments

Comments
 (0)