Skip to content

Commit

Permalink
finished supercharging update
Browse files Browse the repository at this point in the history
  • Loading branch information
Christopher-Stevers committed Sep 3, 2023
1 parent 581d83f commit 087381c
Show file tree
Hide file tree
Showing 18 changed files with 505 additions and 486 deletions.
6 changes: 3 additions & 3 deletions components/FundBounty/hooks/useFundBounty/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { useContext } from 'react';
import StoreContext from '../../../../store/Store/StoreContext';
import FundContext from '../../FundStore/FundContext';
import useWeb3 from '../../../../hooks/useWeb3';
import { ethers } from 'ethers';
import { getBigNumberVol } from '../../../../services/utils/lib';

const useFundBounty = () => {
Expand Down Expand Up @@ -32,11 +33,10 @@ const useFundBounty = () => {
let fundTxnReceipt;
fundTxnReceipt = await openQClient.fundBounty(
library,
bounty.bountyAddress,
ethers.utils.getAddress(bounty.bountyAddress),
token.address,
bigNumberVolumeInWei,
depositPeriodDays,
accountData.id
depositPeriodDays
);
const transactionDispatch = {
type: 'SET_TRANSACTION_HASH',
Expand Down
2 changes: 1 addition & 1 deletion components/Hackathon/CreateHackathonButton/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const CreateHackathonButton = ({ teamAccountId, isEditing, hackathonProductInsta
{responseMap[createHackathonResponse].text}
<Loader />
</button>
<button className='btn-default'>Preview</button>
{/* <button className='btn-default'>Preview</button>*/}
</div>
{error && <div className='text-red-500'>{error}</div>}
</div>
Expand Down
14 changes: 8 additions & 6 deletions components/Hackathon/HackathonCard/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const HackathonCard = ({ repository }) => {
</h3>
</div>
<div>
{repository.isDraft && <button className='btn-default bg-input-bg mx-4'>Preview</button>}
{/*repository.isDraft && <button className='btn-default bg-input-bg mx-4'>Preview</button>*/}
{teamAccountId && (
<Link href={`/hackathons/${repository.id}/edit`} className='btn-default bg-input-bg mx-4'>
Edit
Expand All @@ -47,10 +47,12 @@ const HackathonCard = ({ repository }) => {
{monthsToStart ? `about ${monthsToStart} month${getPlural(monthsToStart)} left` : 'Happening this month.'}
</div>
<div className='flex justify-between'>
<div className=''>
<span className='font-bold'>$100,500</span> <span> in prizes</span>
<span></span>
</div>
{repository.prizePool && (
<div className=''>
<span className='font-bold'>{repository.prizePool}</span> <span> in prizes</span>
<span></span>
</div>
)}
<div className='flex gap-2 items-center'>
<CalendarIcon />
<NoSSRWrapper>
Expand All @@ -64,7 +66,7 @@ const HackathonCard = ({ repository }) => {
<div className='border-x border-y rounded-b border-web-gray flex items-center justify-between p-4'>
<div className='flex gap-8'>
<div className='flex gap-2 items-center'>
<LocationIcon className='' /> <span>{repository.city}</span>
<LocationIcon className='' /> <span>{repository.isIrl ? repository.city : 'Virtual'}</span>
</div>
<div className='flex gap-2'>
{repository?.topic?.map((topic, index) => {
Expand Down
14 changes: 13 additions & 1 deletion components/Hackathon/HackathonDefinition/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import HackathonContext from '../HackathonStore/HackathonContext';
import { handleDispatch } from '../../../services/utils/lib';
const HackathonDefinition = ({ isEditing }) => {
const [hackathonState, hackathonDispatch] = useContext(HackathonContext);
const { eventOrganizer, eventName, repositoryUrl, description } = hackathonState;
const { eventOrganizer, eventName, repositoryUrl, description, prizePool } = hackathonState;
const handleUpdateGithubRepositoryUrl = async (e) => {
const urlInput = e.target.value;
const ownerRegex = /github.com\/([a-zA-Z0-9-]+)\/([a-zA-Z0-9-]+)/;
Expand Down Expand Up @@ -89,6 +89,18 @@ const HackathonDefinition = ({ isEditing }) => {
onChange={(e) => handleDispatch(e, 'SET_DESCRIPTION', hackathonDispatch)}
/>
</div>
<div className='my-2 mb-4'>
<label className='font-semibold text-lg block my-2' htmlFor={'name'}>
Prize Pool
</label>

<input
className='input-field w-full h-8'
id={'prize pool'}
value={prizePool}
onChange={(e) => handleDispatch(e, 'SET_PRIZE_POOL', hackathonDispatch)}
/>
</div>
</>
);
};
Expand Down
2 changes: 2 additions & 0 deletions components/Hackathon/HackathonStore/HackathonReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ const HackathonReducer = (state, action) => {
return { ...state, eventName: action.payload };
case 'SET_DESCRIPTION':
return { ...state, description: action.payload };
case 'SET_PRIZE_POOL':
return { ...state, prizePool: action.payload };
case 'SET_REPOSITORY_URL':
return { ...state, repositoryUrl: action.payload };
case 'SET_IS_IRL':
Expand Down
4 changes: 2 additions & 2 deletions components/Hackathon/HackathonTime/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const HackathonTime = () => {
};
return (
<>
<div className='my-2'>
<div className='my-2 hidden'>
<label className='font-semibold text-lg block my-2 ' htmlFor={'teamAccount'}>
Timezone
</label>
Expand Down Expand Up @@ -77,7 +77,7 @@ const HackathonTime = () => {
</div>
</div>
</div>
<div className='my-2'>
<div className='my-2 hidden'>
<label className='font-semibold text-lg my-2 max-w-xs flex content-center gap-2 items-center'>
Enable Registration Deadline
<InfoInToolTip toolTipText={'Choose the start and end dates for your hackathon'} />
Expand Down
5 changes: 4 additions & 1 deletion components/Submissions/CreateSubmission/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ import React, { useContext, useState } from 'react';
import StoreContext from '../../../store/Store/StoreContext';

import { marked } from 'marked';
import { useRouter } from 'next/router';

const CreateSubmission = ({ bounties, githubRepository }) => {
console.log(bounties, 'my bounties');
const router = useRouter();
const [writingState, setWritingState] = useState('Write');
const [title, setTitle] = useState('');
const [selectedBounties, setSelectedBounties] = useState([]);
Expand Down Expand Up @@ -75,6 +76,8 @@ const CreateSubmission = ({ bounties, githubRepository }) => {
coverImage,
teamName,
});

router.push(`${router.asPath}?tab=submissions`);
};

const selectedClasses = ' border-web-gray rounded-t-sm ';
Expand Down
4 changes: 2 additions & 2 deletions components/Submissions/SubmissionCard/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const SubmissionCard = ({ submission, bounty, refreshBounty }) => {

const linkedPrize = tierWon >= 0 && tierWon + 1;

const bodyTextString = submission.bodyHTML
const bodyTextString = submission.overviewHTML
.replace(/<\/?[^>]+(>|$)/g, '')
.replace(/<\/?[^>]+(>|$)/g, '')
.replace(/\s+/g, ' ')
Expand All @@ -59,7 +59,7 @@ const SubmissionCard = ({ submission, bounty, refreshBounty }) => {
<div className='w-16 h-16 relative'>
<Image
className='rounded-full'
src={submission?.thumbnail}
src={submission?.coverImage}
placeholder={'blur'}
blurDataURL={'/diverse/placeholder-px.png'}
alt='n/a'
Expand Down
3 changes: 0 additions & 3 deletions components/Submissions/Submissions/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ const Submissions = ({ bounty, refreshBounty }) => {
console.log(bounty, 'bounty');
return (
<>
<div className='w-full bg-info border-info-strong border-2 p-3 rounded-sm'>
Don't see your submission yet? Click 'Refresh' above to get the latest pull requests from Github.
</div>
<div className='grid gap-8 w-full pt-8 justify-between justify-items-center grid-cols-[repeat(auto-fit,_minmax(300px,_1fr))]'>
{submissions?.map((submission, index) => {
return <SubmissionCard refreshBounty={refreshBounty} key={index} submission={submission} bounty={bounty} />;
Expand Down
1 change: 1 addition & 0 deletions pages/contract/[id]/[address].js
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ export const getServerSideProps = async (context) => {
bountyMetadata = await openQPrismaClient.instance.getBounty(ethers.utils.getAddress(address));
console.log(bountyMetadata, 'bountyMetadata');
} catch (err) {
console.log(err.networkError.result.errors, 'my error');
logger.error(err, null, '[address.js]3');
}

Expand Down
26 changes: 11 additions & 15 deletions pages/hackathons/[id]/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState, useContext } from 'react';
import React, { useState, useContext, useEffect } from 'react';
import Image from 'next/image';
import Link from 'next/link';

Expand All @@ -22,27 +22,23 @@ import ShowCaseCard from '../../../components/ShowCase/SubmissionCard';
import ShowCasePage from '../../../components/ShowCase/SubmissionPage';
import { ChevronLeftIcon } from '@primer/octicons-react';
import CreateSubmission from '../../../components/Submissions/CreateSubmission';
import { useRouter } from 'next/router';

const Hackathon = ({ githubRepository, hackathon, paginationObj }) => {
const internalMenuState = useState('View');
const [internalMenu] = internalMenuState;
const [internalMenu, setInternalMenu] = internalMenuState;

const [appState] = useContext(StoreContext);
const [searchValue, setSearchValue] = useState('');
const [singleSubmission, setSingleSubmission] = useState(null);

const router = useRouter();
const { tab } = router.query;
useEffect(() => {
if (tab === 'submissions') {
setInternalMenu('Submissions');
}
}, [tab]);
const getNonBlacklisted = async (appState, oldCursor, batch, ordering) => {
console.log(
{
repositoryId: githubRepository.id,
limit: batch,
after: oldCursor,
blacklisted: false,
orderBy: ordering.field,
sortOrder: ordering.direction,
},
'vars'
);
const submissions = await appState.openQPrismaClient.getSubmissions({
repositoryId: githubRepository.id,
limit: batch,
Expand All @@ -64,7 +60,7 @@ const Hackathon = ({ githubRepository, hackathon, paginationObj }) => {
};

const filterFunction = (item, filters) => {
return item.title.includes(filters.searchText) || item.body.includes(filters.searchText);
return item.title?.includes(filters.searchText) || item.body?.includes(filters.searchText);
};

const githubPagination = {
Expand Down
7 changes: 3 additions & 4 deletions pages/hackathons/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ import Link from 'next/link';
import Manager from '../../components/Manager';

const Hackathons = ({ teamAccount, githubRepositoryIndex, repositories }) => {
const hasSuperchargedHackathons = teamAccount?.permissionedProducts?.nodes?.some(
(node) => node.name === 'SuperchargingHackathonsProduct'
);
const hasSuperchargedHackathons =
teamAccount?.permissionedProducts?.nodes?.some((node) => node.name === 'SuperchargingHackathonsProduct') || true;
const [searchText, setSearchText] = useState('');
const HACKATHONS = 'Hackathons';
const menuState = useState(HACKATHONS);
Expand All @@ -36,7 +35,7 @@ const Hackathons = ({ teamAccount, githubRepositoryIndex, repositories }) => {
},
},
};
const hackathonMenuItem = hasSuperchargedHackathons ? [{ name: HACKATHONS }] : [{}];
const hackathonMenuItem = hasSuperchargedHackathons ? [{ name: HACKATHONS }] : [];
const items = [...hackathonMenuItem];
const handleSearchInput = (e) => {
setSearchText(e.target.value);
Expand Down
6 changes: 3 additions & 3 deletions pages/pro/[id]/createHackathon.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import HackathonDefinition from '../../../components/Hackathon/HackathonDefinition';
import HackathonLocation from '../../../components/Hackathon/HackathonLocation';
import HackathonExtraInfo from '../../../components/Hackathon/HackathonExtraInfo';
import HackathonTime from '../../../components/Hackathon/HackathonTime';
// import HackathonTime from '../../../components/Hackathon/HackathonTime';
import HackathonProvider from '../../../components/Hackathon/HackathonStore/HackathonProvider';
import CreateHackathonButton from '../../../components/Hackathon/CreateHackathonButton';
import CreateAsDraftButton from '../../../components/Hackathon/CreateAsDraftButton';
Expand Down Expand Up @@ -32,8 +32,8 @@ const CreateHackathon = ({ teamAccount }) => {
<HackathonDefinition />

<HackathonLocation />
<div className='border-t border-web-gray my-8'>
<HackathonTime />
<div className=' border-web-gray my-8'>
{/* <HackathonTime />*/}
<HackathonExtraInfo />
</div>
<div className='border-web-gray border-t'>
Expand Down
13 changes: 6 additions & 7 deletions pages/pro/[id]/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import Manager from '../../../components/Manager';
import WrappedGithubClient from '../../../services/github/WrappedGithubClient.js';

const TeamAccount = ({ teamAccount, repositories }) => {
const hasSuperchargedHackathons = teamAccount?.permissionedProducts?.nodes?.some(
(node) => node.name === 'SuperchargingHackathonsProduct'
);
const hasSuperchargedHackathons =
teamAccount?.permissionedProducts?.nodes?.some((node) => node.name === 'SuperchargingHackathonsProduct') || true;
console.log(hasSuperchargedHackathons, 'now');
const [searchText, setSearchText] = useState('');
const HACKATHONS = 'Hackathons';
const TEAM = 'Team';
Expand Down Expand Up @@ -92,9 +92,8 @@ const TeamAccount = ({ teamAccount, repositories }) => {
<ManageUserGroup groupName={'Owner(s)'} groupKey='ownerUsers' teamAccount={teamAccount} />

<ManageUserGroup groupName={'Admins'} groupKey='adminUsers' teamAccount={teamAccount} />
{teamAccount.permissionedProducts.nodes.some(
(node) => node.name === 'SuperchargingHackathonsProduct'
) && <SuperchargingHackathons teamAccount={teamAccount} />}
{(teamAccount.permissionedProducts.nodes.some((node) => node.name === 'SuperchargingHackathonsProduct') ||
true) && <SuperchargingHackathons teamAccount={teamAccount} />}
</div>
</ProProvider>
)}
Expand All @@ -121,8 +120,8 @@ export const getServerSideProps = async (context) => {
}
const combinedRepo = repositories.nodes.map((repository) => {
return {
...repository,
...githubRepositoryIndex[repository.id],
...repository,
};
});
return {
Expand Down
2 changes: 2 additions & 0 deletions services/ethers/OpenQClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,8 @@ class OpenQClient {
let txnReceipt;

if (_tokenAddress == ethers.constants.AddressZero) {
console.log(' is executings');
console.log(contract.fundBountyToken);
txnResponse = await contract.fundBountyToken(_bountyAddress, _tokenAddress, _value, expiration, uuid, {
value: _value,
});
Expand Down
1 change: 1 addition & 0 deletions services/openq-api/OpenQPrismaClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ class OpenQPrismaClient {
contractAddress: ethers.utils.getAddress(contractAddress),
},
});
console.log('submissions', result.data.bounty.submissions);
resolve({
...result.data.bounty,
});
Expand Down
7 changes: 5 additions & 2 deletions services/openq-api/graphql/query.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,8 @@ export const GET_BOUNTY_BY_ADDRESS = gql`
}
}
id
bodyHTML
overviewHTML
title
thumbnail
}
}
}
Expand Down Expand Up @@ -606,6 +605,7 @@ export const GET_REPOSITORY_BY_ID = gql`
isContest
isDraft
startDate
prizePool
registrationDeadline
city
timezone
Expand Down Expand Up @@ -850,6 +850,7 @@ export const UPDATE_REPOSITORY_AS_CONTEST = gql`
$slack: String
$description: String
$hackathonProductInstanceId: String!
$prizePool: String
) {
updateRepositoryAsContest(
repositoryId: $repositoryId
Expand All @@ -874,6 +875,7 @@ export const UPDATE_REPOSITORY_AS_CONTEST = gql`
discord: $discord
telegram: $telegram
slack: $slack
prizePool: $prizePool
) {
isContest
id
Expand Down Expand Up @@ -950,6 +952,7 @@ export const GET_PRO_ACCOUNT = gql`
eventOrganizer
repositoryUrl
isIrl
prizePool
endDate
topic
website
Expand Down
Loading

0 comments on commit 087381c

Please sign in to comment.