Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 9 additions & 3 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import NavigationBar from './NavigationBar';
import AuthDialog from './AuthDialog';
import UploadInterface from './UploadInterface';
import ProjectForm from './ProjectForm';
import { githubUpload } from './github-upload';

const Item = styled(Paper)(({ theme }) => ({
backgroundColor: theme.palette.mode === 'dark' ? '#1A2027' : '#fff',
Expand All @@ -18,8 +19,8 @@ function App() {
const [token, setToken] = useState(null);
const [repository, setRepository] = useState(null);
const [show, setShow] = useState(true);
const isAuthorized = token && repository;

const isAuthorized = !!(token && repository); // or Boolean(...)
return (
<>
<NavigationBar
Expand All @@ -33,7 +34,12 @@ function App() {
<AuthDialog show={show} setShow={setShow} setToken={setToken} setRepository={setRepository} />
<Stack direction={'row'}>
<Item>
<UploadInterface isAuthorized={isAuthorized} />
<UploadInterface
isAuthorized={isAuthorized}
uploadFile={(file) => {
githubUpload(token, repository, file).then(console.log).catch(console.error);
}}
/>
</Item>
<Item>
<ProjectForm />
Expand Down
10 changes: 7 additions & 3 deletions src/UploadInterface.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import PropTypes from 'prop-types';

const fileTypes = ["jpg", "jpeg", "png", "bmp", "gif"];

function UploadInterface({ isAuthorized }) {
function UploadInterface({ isAuthorized, uploadFile }) {
const [image, setImage] = useState(null);
const imgPreviewEl = useRef(null);

Expand Down Expand Up @@ -55,6 +55,9 @@ function UploadInterface({ isAuthorized }) {
variant="success"
className="mt-3"
disabled={!(isAuthorized && image)}
onClick={() => {
uploadFile(image);
}}
>
Upload
</Button>
Expand All @@ -66,7 +69,8 @@ function UploadInterface({ isAuthorized }) {
}

UploadInterface.propTypes = {
isAuthorized:PropTypes.bool
isAuthorized:PropTypes.bool,
uploadFile: PropTypes.func
}

export default UploadInterface
export default UploadInterface
File renamed without changes.