All files / src/features/Events/EventDetail/host useRevokeHostConfirm.tsx

100% Statements 7/7
50% Branches 1/2
100% Functions 3/3
100% Lines 7/7

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59          7x 7x                                         7x 122x 4x                                             3x       122x    
import NiceModal from "@ebay/nice-modal-react";
import GiveConfirmationPopUp from "@features/Merchants/MerchantSidePanel/Modals/GiveConfirmationPopUp";
import GiveText from "@shared/Text/GiveText";
import { EventHostRow } from "./host.types";
 
export const REVOKE_HOST_TITLE = "Revoke Access Confirmation";
export const REVOKE_HOST_SUBMIT = "Yes, Revoke";
 
type Params = {
  /** Runs only once the merchant confirms. */
  onConfirm: (row: EventHostRow) => void;
};
 
/**
 * The Revoke Access confirmation (frames 8119-271281 / 8124-60728).
 *
 * Revoking is not scoped to the event the merchant is looking at — it deletes
 * the membership, so the host loses every event at once and cannot come back
 * without a new invitation. That gap between what the button says and what it
 * does is the whole reason for the step, so the copy spells out all three
 * consequences, including the one that is NOT true (their GiveCash account
 * survives), which is the question a merchant would otherwise have to guess at.
 *
 * `GiveConfirmationPopUp` supplies the red trash badge and the mobile bottom
 * sheet; it is shown by component reference rather than by name because
 * GIVE_CONFIRMATION_POP_UP is only registered for the acquirer portal.
 */
export const useRevokeHostConfirm = ({ onConfirm }: Params) => {
  const confirmRevoke = (row: EventHostRow) =>
    NiceModal.show(GiveConfirmationPopUp, {
      modalType: "delete",
      title: REVOKE_HOST_TITLE,
      customSubmitBtnText: REVOKE_HOST_SUBMIT,
      description: (
        <GiveText variant="bodyS" color="secondary">
          Are you sure you want to revoke{" "}
          <GiveText
            component="span"
            variant="bodyS"
            color="primary"
            sx={{ fontWeight: 500 }}
          >
            {/* A host who never activated has no name on file — naming them by
                email is better than "'s host access" with nothing in front. */}
            {row.name || row.email}
          </GiveText>
          ’s host access? They will be removed from every event they are
          assigned to, and will need a new invitation to host again. Their
          GiveCash account is not deleted.
        </GiveText>
      ),
      actions: {
        handleSuccess: { onClick: () => onConfirm(row) },
      },
    });
 
  return { confirmRevoke };
};