Skip to content

Commit

Permalink
Fix to detect first refund vote (#259)
Browse files Browse the repository at this point in the history
* freelancer search page fixed

* reviewed changes

* update call created in an immutable way

* dummy push

* reviewed changes
  • Loading branch information
ssani7 authored Nov 16, 2023
1 parent 85160dd commit c629a5e
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 30 deletions.
6 changes: 3 additions & 3 deletions src/components/ClientView/ClientView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,19 @@ export default function ClientView({
onClick={() => setSwitcher('application')}
className='text-2xl text-black py-5 border-r text-center w-full '
>
Briefs ({briefs?.briefsUnderReview?.length})
Briefs ({briefs?.briefsUnderReview?.length || 0})
</p>
<p
onClick={() => setSwitcher('projects')}
className='text-2xl text-black py-5 border-r text-center w-full'
>
Projects({briefs?.acceptedBriefs?.length})
Projects({briefs?.acceptedBriefs?.length || 0})
</p>
<p
onClick={() => setSwitcher('grants')}
className='text-2xl text-black border-r py-5 text-center w-full'
>
Grants({ongoingGrants.length})
Grants({ongoingGrants?.length || 0})
</p>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/components/GoogleSignIn.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const GoogleSignIn = ({ sizeRef: walletRef, redirectUrl }: GoogleComponentProps)
}, [walletRef]);

const redirect = (path: string) => {
window.location.href = `${window.location.origin}/${path}`;
window.location.href = `${window.location.origin}${path}`;
}

const googleLogin = async (response: any) => {
Expand Down
18 changes: 14 additions & 4 deletions src/components/RefundModal/RefundModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,17 @@ export default function RefundModal({

return (
<div className='bg-white max-w-[31.938rem] text-left rounded-[18px]'>
<div className='inline-block bg-light-grey pt-2 pb-4 mt-12 mb-8 px-4 rounded-lg'>
<div className='w-fit bg-light-grey pt-2 pb-4 mt-12 mb-8 mx-auto px-4 rounded-lg'>
<Image src={'/wallet.svg'} width={70} height={70} alt='icon' />
</div>
<div className='text-left'>
<h4 className='text-[27px]'>Should a refund be initiated?</h4>
<div className='text-center'>
<h4 className='text-[27px]'>
{
undergoingRefund
? "Should a Refund be Approved?"
: "Should a refund be initiated?"
}
</h4>
<p className='text-base mt-4 '>
A refund can be made when you vote against a milestone deliverables
and believe strongly that its deliverables is not quantifiable by
Expand All @@ -66,7 +72,11 @@ export default function RefundModal({
className='primary-btn in-dark w-button w-[70%] !mx-auto'
style={{ textAlign: 'center' }}
>
Yes, initiate refund
{
undergoingRefund
? "Yes, Approve Refund"
: "Yes, initiate refund"
}
<BiArrowBack
className='rotate-180 ml-3 text-imbue-lime '
size={18}
Expand Down
6 changes: 2 additions & 4 deletions src/components/RefundModal/SuccessRefundModal.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import Image from 'next/image';

interface VotingModalProps {
vote: boolean;
setVisible: (_visible: boolean) => void;
undergoingRefund: boolean;
}

export default function SuccessRefundModal({
setVisible,
vote,
undergoingRefund
}: VotingModalProps) {
return (
Expand All @@ -17,13 +15,13 @@ export default function SuccessRefundModal({
<Image src={require('../../assets/svgs/refundInit.svg')} width={70} height={70} alt='icon' />
</div>
<h4 className='text-[27px]'>{
!vote
!undergoingRefund
? "Thanks for initiating a refund"
: "Thank you for your vote on refunding this grant"
}</h4>
<p className='text-base mt-4 mb-9'>
{
(!undergoingRefund && !vote)
!undergoingRefund
? "This project at this time would be put on hold and the approvers would be notified to vote on this refund request."
: "Your decision for refund has been recorded. Thank you for contributing to the decision-making process."
}
Expand Down
26 changes: 13 additions & 13 deletions src/components/ReviewModal/VoteModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export default function VoteModal({
projectType,
}: VotingModalProps) {
const [vote, setVote] = useState<boolean>(true);
const [voteRefund, setVoteRefund] = useState<boolean>(false);
const [voteRefund, setVoteRefund] = useState<boolean | undefined>();
const [step, setStep] = useState<number>(0);

const handleVoteOnMilestone = async (vote: boolean) => {
Expand Down Expand Up @@ -174,22 +174,22 @@ export default function VoteModal({
await updateProject(project?.id, project);

setVisible(true);
setVoteRefund(true);
setVoteRefund(vote);
setStep(4);
break;
} else if (noConfidencePoll == ImbueChainPollResult.EventFound) {
await insertNoConfidenceVote(project?.id, voteData);

setVisible(true);
setVoteRefund(true);
setVoteRefund(vote);
setStep(4);
break;
} else if (result.status) {
await insertNoConfidenceVote(project?.id, voteData);

setVisible(true);
setStep(4);
setVoteRefund(true);
setVoteRefund(vote);
break;
} else if (result.txError) {
setError({ message: result.errorMessage });
Expand Down Expand Up @@ -221,18 +221,18 @@ export default function VoteModal({
pollResult == ImbueChainPollResult.EventFound
) {
if (pollResult == ImbueChainPollResult.EventFound) {
project.project_in_voting_of_no_confidence = true;
await updateProject(project?.id, project);
// project.project_in_voting_of_no_confidence = true;
await updateProject(project?.id, { ...project, project_in_voting_of_no_confidence: true });
await insertNoConfidenceVote(project?.id, voteData);
setStep(4);
setVoteRefund(true);
setVoteRefund(vote);
setVisible(true);
} else if (result.status) {
project.project_in_voting_of_no_confidence = true;
await updateProject(project?.id, project);
// project.project_in_voting_of_no_confidence = true;
await updateProject(project?.id, { ...project, project_in_voting_of_no_confidence: true });
await insertNoConfidenceVote(project?.id, voteData);
setStep(4);
setVoteRefund(true);
setVoteRefund(vote);
setVisible(true);
} else if (result.txError) {
setError({ message: result.errorMessage });
Expand Down Expand Up @@ -374,12 +374,12 @@ export default function VoteModal({

{step === 4 && (
<>
{!voteRefund ? (
{voteRefund === undefined ? (
<SuccessModal setVisible={setVisible} />
) : (
<SuccessRefundModal
undergoingRefund={project.project_in_voting_of_no_confidence || false}
vote={voteRefund} setVisible={setVisible}
undergoingRefund={project?.project_in_voting_of_no_confidence || false}
setVisible={setVisible}
/>
)}
</>
Expand Down
4 changes: 2 additions & 2 deletions src/pages/auth/sign-in/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export default function SignIn() {
});

if (resp.ok) {
redirect('/dashboard');
redirect('dashboard');
} else {
setErrorMessage('incorrect username or password');
}
Expand All @@ -73,7 +73,7 @@ export default function SignIn() {
account
);
if (resp.ok) {
redirect('/dashboard');
redirect('dashboard');
}
} catch (error) {
// FIXME: error handling
Expand Down
4 changes: 2 additions & 2 deletions src/pages/auth/sign-up/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export default function SignIn() {

if (resp.ok) {
window.localStorage.setItem('newUser', '1');
redirect('/dashboard');
redirect('dashboard');
} else {
const errorMessage = await resp.json();

Expand All @@ -134,7 +134,7 @@ export default function SignIn() {
account
);
if (resp.ok) {
redirect('/dashboard');
redirect('dashboard');
}
} catch (error) {
// FIXME: error handling
Expand Down
6 changes: 5 additions & 1 deletion src/pages/grants/new.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,11 @@ const GrantApplication = (): JSX.Element => {
Ecosystem
</h3>
<div className='mt-2 text-content-primary'>
Kusama Treasury (KSM)
{
currencyId < 100
? "Kusama Treasury (KSM)"
: "Ethereum"
}
</div>
</div>
</div>
Expand Down

0 comments on commit c629a5e

Please sign in to comment.