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

This PR adds Project creation functionality #2

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 2 additions & 0 deletions debug.log
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,5 @@
[0602/190943.215:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0602/192715.867:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0602/192715.870:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0603/212048.026:ERROR:crash_report_database_win.cc(469)] failed to stat report
[0603/212048.028:ERROR:crash_report_database_win.cc(469)] failed to stat report
2 changes: 2 additions & 0 deletions src/components/Dashboard/APIcall.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ function APIcall() {

const onFailure = (response) => console.error(response)

const TokenContext = React.createContext(localStorage.getItem('ACCESS TOKEN'))

return (
<div style={{ display: 'flex', justifyContent: 'flex-end' }}>
<Button mode='normal'>
Expand Down
79 changes: 49 additions & 30 deletions src/components/Disputes/Import.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable */
import React, { useState, useRef } from 'react'
import { SidePanel, Button, DropDown, TextInput } from '@aragon/ui'
import { SidePanel, Button, DropDown, TextInput, LoadingRing } from '@aragon/ui'
import { Octokit } from '@octokit/rest'
import { useWallet } from 'use-wallet'
import { useProjectCreationActions } from '../../hooks/useProjectCreation'
Expand All @@ -16,6 +16,8 @@ function Import() {

const [list, setList] = useState([])

// const [loading, setLoading] = useState(false)

const { create } = useProjectCreationActions()

const TOKEN = localStorage.getItem('ACCESS TOKEN')
Expand All @@ -31,9 +33,9 @@ function Import() {
setPublicRepos(num - 1)
return data
}

async function listUserRepos() {
setOpened(true)

let repoList = []
const user = await userInfo()
for (let page = 1; page <= Math.ceil(user.public_repos / 100); page++) {
Expand Down Expand Up @@ -68,45 +70,62 @@ function Import() {
async function handleProjectCreationn() {
let nameInput = inputName.current.value
let budgetInput = inputBudget.current.value
let dropdownInput = inputDropdown.current.value
console.log(nameInput, budgetInput)
await create('123', nameInput, budgetInput)
await create(dropdownInput, nameInput, budgetInput)
}

return (
<>
{wallet.account !== null ? (
{wallet.account !== null &&
localStorage.getItem('ACCESS TOKEN') !== null ? (
abhinav-anshul marked this conversation as resolved.
Show resolved Hide resolved
<Button mode='strong' onClick={listUserRepos}>
Import Project
</Button>
) : null}

<SidePanel onClose={handleClose} title='Repository' opened={opened}>
<DropDown
selected={selected}
onChange={handleOnChange}
items={[...list]}
style={{ marginTop: '4rem' }}
/>

<TextInput
ref={inputName}
style={{ marginTop: '2rem' }}
placeholder='Provide a Name'
/>

<TextInput
ref={inputBudget}
style={{ marginTop: '2rem' }}
placeholder='Budget'
/>

<Button
onClick={handleProjectCreationn}
style={{ marginTop: '4rem' }}
mode='positive'
>
Import Project
</Button>
{list.length === 0 ? (
<div
style={{
display: 'flex',
justifyContent: 'center',
marginTop: '4rem',
}}
>
<LoadingRing mode='half-circle' />
</div>
) : (
<>
<DropDown
selected={selected}
onChange={handleOnChange}
items={[...list]}
ref={inputDropdown}
abhinav-anshul marked this conversation as resolved.
Show resolved Hide resolved
style={{
marginTop: '4rem',
}}
/>
{console.log(selected)}
<TextInput
ref={inputName}
style={{ marginTop: '2rem' }}
placeholder='Provide a Name'
/>
<TextInput
ref={inputBudget}
style={{ marginTop: '2rem' }}
placeholder='Budget'
/>
<Button
onClick={handleProjectCreationn}
style={{ marginTop: '4rem' }}
mode='positive'
>
Import Project
</Button>
</>
)}
</SidePanel>
</>
)
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/useProjectCreation.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export function useProjectCreationActions() {
gasLimit: GAS_LIMIT,
}),
'newProject',
{ name: name, budget: budget }
{ id: id, name: name, budget: budget }
)
},
[addActivity, projectCreationContract]
Expand Down