Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

Update bounty-submission-details-sheet.tsx

Steven Tey90ed7b127c00
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/[bountyId]/bounty-submission-details-sheet.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/[bountyId]/bounty-submission-details-sheet.tsx
index 80b6a408ee..4d2a988fad 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/[bountyId]/bounty-submission-details-sheet.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/[bountyId]/bounty-submission-details-sheet.tsx
@@ -10,6 +10,7 @@ import { useConfirmModal } from "@/ui/modals/confirm-modal";
import { PartnerInfoSection } from "@/ui/partners/partner-info-section";
import { useRejectBountySubmissionModal } from "@/ui/partners/reject-bounty-submission-modal";
import { ButtonLink } from "@/ui/placeholders/button-link";
+import { AmountInput } from "@/ui/shared/amount-input";
import { X } from "@/ui/shared/icons";
import {
Button,
@@ -21,7 +22,7 @@ import {
import { currencyFormatter, formatDate, getPrettyUrl } from "@dub/utils";
import Linkify from "linkify-react";
import { useAction } from "next-safe-action/hooks";
-import { Dispatch, SetStateAction, useState } from "react";
+import { Dispatch, SetStateAction, useMemo, useState } from "react";
import { toast } from "sonner";
import { BOUNTY_SUBMISSION_STATUS_BADGES } from "./bounty-submission-status-badges";
@@ -40,6 +41,8 @@ function BountySubmissionDetailsSheetContent({
const { setShowRejectModal, RejectBountySubmissionModal } =
useRejectBountySubmissionModal(submission);
+ const [rewardAmount, setRewardAmount] = useState<number | null>(null);
+
const {
executeAsync: approveBountySubmission,
isPending: isApprovingBountySubmission,
@@ -69,10 +72,23 @@ function BountySubmissionDetailsSheetContent({
await approveBountySubmission({
workspaceId,
submissionId: submission.id,
+ rewardAmount: rewardAmount ? rewardAmount * 100 : null,
});
},
});
+ const isValidForm = useMemo(() => {
+ if (bounty?.rewardAmount) {
+ return true;
+ }
+
+ if (!rewardAmount) {
+ return false;
+ }
+
+ return true;
+ }, [bounty, rewardAmount]);
+
if (!submission || !partner) {
return null;
}
@@ -273,7 +289,7 @@ function BountySubmissionDetailsSheetContent({
</div>
<div className="sticky bottom-0 z-10 border-t border-neutral-200 bg-white">
- <div className="flex items-center justify-between gap-2 p-5">
+ <div className="flex items-center justify-between gap-2 border-t border-neutral-200 p-5">
{submission.status === "approved" ? (
<a
href={`/${workspaceSlug}/program/commissions?partnerId=${partner.id}&type=custom`}
@@ -283,28 +299,51 @@ function BountySubmissionDetailsSheetContent({
<Button variant="secondary" text="View commissions" />
</a>
) : (
- <>
- <Button
- type="button"
- variant="danger"
- text="Reject"
- disabledTooltip={
- submission.status === "rejected"
- ? "Bounty submission already rejected."
- : undefined
- }
- disabled={isApprovingBountySubmission}
- onClick={() => setShowRejectModal(true)}
- />
+ <div className="flex w-full flex-col gap-4">
+ {!bounty?.rewardAmount && (
+ <div>
+ <label className="text-sm font-medium text-neutral-800">
+ Reward
+ </label>
+ <div className="mt-2">
+ <AmountInput
+ required
+ amountType="flat"
+ placeholder="0"
+ value={rewardAmount || ""}
+ onChange={(e) => {
+ const val = e.target.value;
+ setRewardAmount(val === "" ? null : parseFloat(val));
+ }}
+ />
+ </div>
+ </div>
+ )}
+
+ <div className="flex w-full gap-4">
+ <Button
+ type="button"
+ variant="danger"
+ text="Reject"
+ disabledTooltip={
+ submission.status === "rejected"
+ ? "Bounty submission already rejected."
+ : undefined
+ }
+ disabled={isApprovingBountySubmission}
+ onClick={() => setShowRejectModal(true)}
+ />
- <Button
- type="submit"
- variant="primary"
- text="Approve"
- loading={isApprovingBountySubmission}
- onClick={() => setShowApproveBountySubmissionModal(true)}
- />
- </>
+ <Button
+ type="submit"
+ variant="primary"
+ text="Approve"
+ loading={isApprovingBountySubmission}
+ onClick={() => setShowApproveBountySubmissionModal(true)}
+ disabled={!isValidForm}
+ />
+ </div>
+ </div>
)}
</div>
</div>