Skip to content

Commit

Permalink
Merge pull request #173 from PotLock/staging
Browse files Browse the repository at this point in the history
Staging => mian
  • Loading branch information
wpdas authored Jul 31, 2024
2 parents 88f1afc + 03228b6 commit d64a98a
Show file tree
Hide file tree
Showing 10 changed files with 314 additions and 92 deletions.
3 changes: 3 additions & 0 deletions src/components/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@ type Props = {
stopPropagation?: boolean;
style?: React.CSSProperties;
target?: TargetValue;
key?: string;
iconSrc?: string;
children: string | React.ReactNode;
};

const Button = ({
key,
type,
varient,
name,
Expand Down Expand Up @@ -45,6 +47,7 @@ const Button = ({
style: style ?? {},
target: target,
...(href ? { href } : {}),
...(key ? { key } : {}),
...(name ? { name } : {}),
}}
>
Expand Down
4 changes: 2 additions & 2 deletions src/modals/ModalOverlay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ type Props = {
overlayStyle?: React.CSSProperties;
};

const ModalOverlay = ({ children, onOverlayClick, contentStyle }: Props) => {
const ModalOverlay = ({ children, onOverlayClick, contentStyle, overlayStyle }: Props) => {
const ModalOverlay = styled.div`
position: fixed;
padding: 0 10px;
Expand Down Expand Up @@ -46,7 +46,7 @@ const ModalOverlay = ({ children, onOverlayClick, contentStyle }: Props) => {
`;

return (
<ModalOverlay style={contentStyle}>
<ModalOverlay style={overlayStyle}>
<Screen onClick={onOverlayClick} />
<ModalContent style={contentStyle}>{children}</ModalContent>
</ModalOverlay>
Expand Down
22 changes: 15 additions & 7 deletions src/pages/Pot/components/Header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ const Header = () => {
const [potDetail, setPotDetail] = useState<null | PotDetail>(null);
const [allDonations, setAlldonations] = useState<null | PotDonation[]>(null);
const [payoutsToProcess, setPayoutsToProcess] = useState<any>(null);

// set fund mathcing pool success
const [fundDonation, setFundDonation] = useState<null | ExtendedFundDonation>(null);

Expand Down Expand Up @@ -145,10 +146,9 @@ const Header = () => {

const now = Date.now();

const cooldown_end_ms = _cooldown_end_ms ?? now + 1;
const cooldown_end_ms = _cooldown_end_ms ?? now + 1000;

const publicRoundOpen = now >= public_round_start_ms && now < public_round_end_ms;
const publicRoundEnded = now > public_round_end_ms;

const applicationOpen = now >= application_start_ms && now < application_end_ms;

Expand All @@ -158,9 +158,9 @@ const Header = () => {
context.accountId && `&referrerId=${context.accountId}`
}`;

const canPayoutsBeProcessed = userIsAdminOrGreater && now >= cooldown_end_ms && !all_paid_out;
const canPayoutsBeProcessed = userIsAdminOrGreater && cooldown_end_ms && !all_paid_out;

const canPayoutsBeSet = userIsChefOrGreater && !all_paid_out && publicRoundEnded;
const canPayoutsBeSet = userIsChefOrGreater && !all_paid_out && (now > cooldown_end_ms || !_cooldown_end_ms);

const payoutsChallenges = PotSDK.getPayoutsChallenges(potId);

Expand Down Expand Up @@ -237,13 +237,21 @@ const Header = () => {
{registrationApprovedOrNoRegistryProvider ? "Apply to pot" : `Project Registration ${registryStatus}`}
</Button>
)}
{now > public_round_end_ms && now < cooldown_end_ms && (
{now > public_round_end_ms && now < cooldown_end_ms && !!_cooldown_end_ms && (
<Button varient="tonal" onClick={() => setShowChallengePayoutsModal(true)}>
{existingChallengeForUser ? "Update challenge" : "Challenge payouts"}
</Button>
)}
{canPayoutsBeSet && <Button onClick={handleSetPayouts}> Set Payouts </Button>}
{canPayoutsBeProcessed && <Button onClick={handleProcessPayouts}>Process Payouts</Button>}
{canPayoutsBeSet && (
<Button key={"set-payout-btn"} onClick={handleSetPayouts}>
Set Payouts
</Button>
)}
{canPayoutsBeProcessed && (
<Button key={"process-payout-btn"} onClick={handleProcessPayouts}>
Process Payouts
</Button>
)}
</ButtonsWrapper>
<Referral>
<CopyIcon textToCopy={potLink} />
Expand Down
9 changes: 5 additions & 4 deletions src/pages/Pot/components/HeaderStatus/statsList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ const statsList = (potDetail: PotDetail) => {
application_end_ms,
public_round_start_ms,
public_round_end_ms,
cooldown_end_ms,
cooldown_end_ms: _cooldown_end_ms,
all_paid_out,
} = potDetail;

const now = Date.now();
const cooldown_end_ms = _cooldown_end_ms ?? now + 1000;

const stats = [
{
Expand All @@ -31,11 +32,11 @@ const statsList = (potDetail: PotDetail) => {
},
{
label: "Challenge period",
daysLeft: cooldown_end_ms,
daysLeft: _cooldown_end_ms,
started: now >= public_round_end_ms,
completed: now > cooldown_end_ms && !!cooldown_end_ms,
completed: now > cooldown_end_ms && !!_cooldown_end_ms,
progress:
now > cooldown_end_ms && !!cooldown_end_ms
now > cooldown_end_ms && !!_cooldown_end_ms
? 1
: (cooldown_end_ms - now) / (public_round_end_ms - cooldown_end_ms),
},
Expand Down
Loading

0 comments on commit d64a98a

Please sign in to comment.