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.

WIP auto-approve UI

Tim Wilson50d656495876
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/applications/applications-menu.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/applications/applications-menu.tsx
new file mode 100644
index 0000000000..b6d926fd08
--- /dev/null
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/applications/applications-menu.tsx
@@ -0,0 +1,62 @@
+"use client";
+
+import { useConfirmModal } from "@/ui/modals/confirm-modal";
+import { ThreeDots } from "@/ui/shared/icons";
+import { Button, LoadingSpinner, MenuItem, Popover, UserCheck } from "@dub/ui";
+import { Command } from "cmdk";
+import { useState } from "react";
+import { toast } from "sonner";
+
+export function ApplicationsMenu() {
+ const [isOpen, setIsOpen] = useState(false);
+ const isLoading = false;
+
+ const { confirmModal, setShowConfirmModal } = useConfirmModal({
+ title: "Confirm auto-approve",
+ description:
+ "Current and future applications will be automatically approved.",
+ onConfirm: () => {
+ toast.info("WIP");
+ },
+ });
+
+ return (
+ <>
+ {confirmModal}
+ <Popover
+ openPopover={isOpen}
+ setOpenPopover={setIsOpen}
+ content={
+ <Command tabIndex={0} loop className="focus:outline-none">
+ <Command.List className="flex w-screen flex-col gap-1 p-1.5 text-sm focus-visible:outline-none sm:w-auto sm:min-w-[200px]">
+ <MenuItem
+ as={Command.Item}
+ icon={<UserCheck className="size-4 shrink-0 text-green-600" />}
+ onSelect={() => {
+ setShowConfirmModal(true);
+ setIsOpen(false);
+ }}
+ >
+ Enable auto-approve
+ </MenuItem>
+ </Command.List>
+ </Command>
+ }
+ align="end"
+ >
+ <Button
+ type="button"
+ className="h-8 whitespace-nowrap px-2"
+ variant="secondary"
+ icon={
+ isLoading ? (
+ <LoadingSpinner className="size-4 shrink-0" />
+ ) : (
+ <ThreeDots className="size-4 shrink-0" />
+ )
+ }
+ />
+ </Popover>
+ </>
+ );
+}
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/applications/page.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/applications/page.tsx
index 4aeca79afd..0a8afa7464 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/applications/page.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/applications/page.tsx
@@ -1,10 +1,11 @@
import { PageContent } from "@/ui/layout/page-content";
import { PageWidthWrapper } from "@/ui/layout/page-width-wrapper";
+import { ApplicationsMenu } from "./applications-menu";
import { ProgramPartnersApplicationsPageClient } from "./page-client";
export default function ProgramPartnersApplications() {
return (
- <PageContent title="Applications">
+ <PageContent title="Applications" controls={<ApplicationsMenu />}>
<PageWidthWrapper>
<ProgramPartnersApplicationsPageClient />
</PageWidthWrapper>
diff --git a/apps/web/ui/modals/confirm-modal.tsx b/apps/web/ui/modals/confirm-modal.tsx
new file mode 100644
index 0000000000..03f47a0ce1
--- /dev/null
+++ b/apps/web/ui/modals/confirm-modal.tsx
@@ -0,0 +1,84 @@
+import { Button, Modal } from "@dub/ui";
+import { Dispatch, ReactNode, SetStateAction, useState } from "react";
+
+type PromptModelProps = {
+ title: string;
+ description?: ReactNode;
+
+ onCancel?: () => void;
+ cancelText?: string;
+
+ onConfirm: () => Promise<void> | void;
+ confirmText?: string;
+};
+
+/**
+ * A generic confirmation modal
+ */
+function ConfirmModal({
+ showConfirmModal,
+ setShowConfirmModal,
+ title,
+ description,
+ onCancel,
+ cancelText = "Cancel",
+ onConfirm,
+ confirmText = "Confirm",
+}: {
+ showConfirmModal: boolean;
+ setShowConfirmModal: Dispatch<SetStateAction<boolean>>;
+} & PromptModelProps) {
+ const [isLoading, setIsLoading] = useState(false);
+
+ return (
+ <Modal showModal={showConfirmModal} setShowModal={setShowConfirmModal}>
+ <div className="p-5 text-left">
+ <h3 className="text-content-emphasis text-base font-semibold">
+ {title}
+ </h3>
+ {description && (
+ <p className="text-content-subtle mt-1 text-sm">{description}</p>
+ )}
+ </div>
+
+ <div className="border-border-subtle flex items-center justify-end gap-2 border-t px-5 py-4">
+ <Button
+ variant="secondary"
+ className="h-8 w-fit px-3"
+ text={cancelText}
+ onClick={() => {
+ onCancel?.();
+ setShowConfirmModal(false);
+ }}
+ />
+ <Button
+ variant="primary"
+ className="h-8 w-fit px-3"
+ text={confirmText}
+ loading={isLoading}
+ onClick={async () => {
+ setIsLoading(true);
+ await onConfirm();
+ setIsLoading(false);
+ setShowConfirmModal(false);
+ }}
+ />
+ </div>
+ </Modal>
+ );
+}
+
+export function useConfirmModal(props: PromptModelProps) {
+ const [showConfirmModal, setShowConfirmModal] = useState(false);
+
+ return {
+ setShowConfirmModal,
+ confirmModal: (
+ <ConfirmModal
+ showConfirmModal={showConfirmModal}
+ setShowConfirmModal={setShowConfirmModal}
+ {...props}
+ />
+ ),
+ };
+}