Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integration github-upload with the rest of the app #35

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 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.

10 changes: 8 additions & 2 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,7 +19,7 @@ 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 && true;
batunpc marked this conversation as resolved.
Show resolved Hide resolved

return (
<>
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);
humphd marked this conversation as resolved.
Show resolved Hide resolved
}}
/>
</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.