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.

Preselect the requested group in bulk approve

Rafi43f4d1099658
diff --git a/apps/web/ui/modals/bulk-approve-program-applications-modal.tsx b/apps/web/ui/modals/bulk-approve-program-applications-modal.tsx
index 04390e2722..3cc54d8e31 100644
--- a/apps/web/ui/modals/bulk-approve-program-applications-modal.tsx
+++ b/apps/web/ui/modals/bulk-approve-program-applications-modal.tsx
@@ -24,8 +24,22 @@ type BulkApprovePartner = Pick<
"id" | "name" | "email" | "image"
> & {
applicationId?: string | null;
+ groupId?: string | null;
};
+// The group every selected application requested, or null if they differ
+function getRequestedGroupId(partners: BulkApprovePartner[]) {
+ const [first] = partners;
+
+ if (!first?.groupId) {
+ return null;
+ }
+
+ return partners.every(({ groupId }) => groupId === first.groupId)
+ ? first.groupId
+ : null;
+}
+
type BulkApproveProgramApplicationsModalOptions = {
partners: BulkApprovePartner[];
groupId?: string | null;
@@ -53,7 +67,8 @@ function BulkApproveProgramApplicationsModal({
useTrialLimitActivateModal();
const trialActive = isWorkspaceBillingTrialActive(trialEndsAt);
- const initialGroupId = groupId ?? program?.defaultGroupId ?? null;
+ const initialGroupId =
+ groupId ?? getRequestedGroupId(partners) ?? program?.defaultGroupId ?? null;
const [selectedGroupId, setSelectedGroupId] = useState<string | null>(
initialGroupId,
);