Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
diced committed Nov 12, 2020
1 parent bc7a7a8 commit ccde532
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { store, persistor } from '../store';
import ZiplineTheming from '../components/ZiplineTheming';
import UIPlaceholder from '../components/UIPlaceholder';

function MyApp({ Component, pageProps }) {
function App({ Component, pageProps }) {
const [theme, setTheme] = useState<'dark' | 'light'>('dark');
useEffect(() => {
const jssStyles = document.querySelector('#jss-server-side');
Expand Down Expand Up @@ -41,9 +41,9 @@ function MyApp({ Component, pageProps }) {
);
}

MyApp.propTypes = {
App.propTypes = {
Component: PropTypes.elementType.isRequired,
pageProps: PropTypes.object.isRequired
};

export default MyApp;
export default App;
22 changes: 18 additions & 4 deletions src/pages/dash/upload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ export default function Upload() {
const state = store.getState();
const [files, setFiles] = React.useState<File[]>([]);
const [alertOpen, setAlertOpen] = React.useState<boolean>(false);
const [alertSev, setAlertSev] = React.useState('success');
const [alertMsg, setAlertMsg] = React.useState('Uploaded Image!');

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

if (res.ok) setAlertOpen(true);
if (res.ok) {
setAlertOpen(true);
setAlertMsg('Uploaded Image!');
setAlertSev('success');
} else {
const d = await res.json();
setAlertOpen(true);
setAlertMsg(`Couldn't upload: ${d.error}`);
setAlertSev('error');
}
};

if (typeof window === 'undefined') return <UIPlaceholder />;
Expand All @@ -63,8 +74,10 @@ export default function Upload() {
autoHideDuration={6000}
onClose={() => setAlertOpen(false)}
>
<Alert severity='success' variant='filled'>
Uploaded image!
{/* eslint-disable-next-line @typescript-eslint/ban-ts-comment */}
{/* @ts-ignore */}
<Alert severity={alertSev} variant='filled'>
{alertMsg}
</Alert>
</Snackbar>
<Paper elevation={3} className={classes.padding}>
Expand All @@ -76,10 +89,11 @@ export default function Upload() {
acceptedFiles={['image/*']}
dropzoneText={'Drag an image or click to upload an image.'}
onChange={f => setFiles(f)}
filesLimit={1}
maxFileSize={1073741824} // 1gb in byte
/>
</Box>
<Button onClick={handleFileUpload}>Submit</Button>
<Button onClick={handleFileUpload}>Upload</Button>
</Paper>
</UI>
);
Expand Down

0 comments on commit ccde532

Please sign in to comment.