Skip to content

Commit

Permalink
chore(verifying-listings): change rule to any review more than 2 week…
Browse files Browse the repository at this point in the history
…s instead of just latest
  • Loading branch information
JayeshVP24 committed Oct 15, 2024
1 parent f0f0497 commit 797be7f
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export function UnderVerificationModal({ onClose, isOpen }: Props) {
We need to verify your listing before it gets published
</Text>
<Text color="brand.slate.500">
{`Its important for us to verify work opportunities added by new sponsors to maintain trust, and keep the platform free of any bad actors. We will try our best to verify your listing within 24 hours. `}
{`It's important for us to verify certain work opportunities to maintain trust, and keep the platform free of any bad actors. We will try our best to verify your listing within 24 hours. `}
</Text>
<Text color="brand.slate.500">
{`Once verified, your listing will be published automatically. If we need any information, we will get in touch with you. `}
Expand Down
19 changes: 12 additions & 7 deletions src/pages/api/listings/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,21 +116,26 @@ async function handler(req: NextApiRequestWithSponsor, res: NextApiResponse) {

// sponsor is unverified and latest listing is in review for more than 2 weeks
if (!isVerifying && !sponsor.isVerified) {
const latestBounty = await prisma.bounties.findFirst({
const twoWeeksAgo = dayjs().subtract(2, 'weeks');

const overdueBounty = await prisma.bounties.findFirst({
select: {
id: true,
},
where: {
sponsorId: userSponsorId,
isArchived: false,
isPublished: true,
isActive: true,
status: 'OPEN',
isWinnersAnnounced: false,
deadline: {
lt: twoWeeksAgo.toDate(),
},
},
orderBy: { deadline: 'desc' },
select: { deadline: true, isWinnersAnnounced: true },
});

if (latestBounty && !latestBounty.isWinnersAnnounced) {
const twoWeeksAgo = dayjs().subtract(2, 'weeks');
isVerifying = dayjs(latestBounty.deadline).isBefore(twoWeeksAgo);
}
isVerifying = !!overdueBounty;
}
}
}
Expand Down
18 changes: 11 additions & 7 deletions src/pages/api/listings/update/[id].ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,22 +220,26 @@ async function bounty(req: NextApiRequestWithSponsor, res: NextApiResponse) {

// sponsor is unverified and latest listing is in review for more than 2 weeks
if (!isVerifying && !sponsor.isVerified) {
const latestBounty = await prisma.bounties.findFirst({
const twoWeeksAgo = dayjs().subtract(2, 'weeks');

const overdueBounty = await prisma.bounties.findFirst({
select: {
id: true,
},
where: {
sponsorId: userSponsorId,
isArchived: false,
isPublished: true,
isActive: true,
status: 'OPEN',
isWinnersAnnounced: false,
deadline: {
lt: twoWeeksAgo.toDate(),
},
},
orderBy: { deadline: 'desc' },
select: { deadline: true, isWinnersAnnounced: true },
});

if (latestBounty && !latestBounty.isWinnersAnnounced) {
const twoWeeksAgo = dayjs().subtract(2, 'weeks');
isVerifying = dayjs(latestBounty.deadline).isBefore(twoWeeksAgo);
}
isVerifying = !!overdueBounty;
}
}
}
Expand Down

0 comments on commit 797be7f

Please sign in to comment.