All files / src/componentsV2/AccountProfile/NotificationCenter/hooks useGetAlertData.tsx

34.09% Statements 15/44
25% Branches 8/32
50% Functions 2/4
34.09% Lines 15/44

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 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277                                                                      1x 8x   8x 8x   1x             1x             1x             1x             1x             1x               1x             1x                                                                                                                                                                                                                                                                                                                                                   8x           8x         8x        
import {
  ArrowsClockwiseIcon,
  ArrowsLeftRightIcon,
  ArrowUUpLeftIcon,
  BankIcon,
  BellRingingIcon,
  BriefcaseIcon,
  CalendarBlankIcon,
  ChartLineIcon,
  ChartLineUpIcon,
  ChatCircleIcon,
  CheckIcon,
  CodeBlockIcon,
  FileTextIcon,
  ListMagnifyingGlassIcon,
  MinusIcon,
  MoneyIcon,
  PlusIcon,
  ShieldCheckIcon,
  ShoppingBagOpenIcon,
  UserIcon,
  CheckCircleIcon,
  XCircleIcon,
  EyeIcon,
  ReceiptIcon,
} from "@phosphor-icons/react";
import {
  TAlertMethods,
  TIsAssigned,
  TIsDisabeled,
} from "../GiveNotificationCenterTypes";
import { TParsedAlert } from "@components/ProfileMenu/modals/types";
import { CHARGEBACK_TEXT } from "@constants/stringConstants";
import { useGetFeatureFlagValues } from "FeatureFlags/useGetFeatureFlagValues";
 
const useGetAlertData = () => {
  const { isNewApprovalFlowEnabled } = useGetFeatureFlagValues();
 
  const getDisplayedData = ({ alert }: { alert: TParsedAlert }) => {
    switch (alert.name) {
      case "transfer_fail":
        return {
          icon: <ArrowsLeftRightIcon size={18} />,
          title: "Transfer Fail",
          description:
            "You will receive a notification when the transfer fails.",
        };
      case "transfer_return":
        return {
          icon: <ArrowsClockwiseIcon size={18} />,
          title: "Transfer Return",
          description:
            "You will receive a notification when the transfer is returned.",
        };
      case "new_member":
        return {
          icon: <UserIcon size={18} />,
          title: "New Member",
          description:
            "You will receive a notification when there is a new member.",
        };
      case "transfer":
        return {
          icon: <ArrowsLeftRightIcon size={18} />,
          title: "Money transfers",
          description:
            "You will receive a notification when a money transfer is initiated from your account.",
        };
      case "daily_transaction_summary":
        return {
          icon: <FileTextIcon size={18} />,
          title: "Daily report",
          description:
            "Every day, you will receive detailed transaction reports.",
        };
      case "monthly_transaction_summary":
        return {
          icon: <CalendarBlankIcon size={18} />,
          title: "Monthly report",
          description:
            "Every month, you will receive detailed transaction reports.",
        };
 
      case "refund":
        return {
          icon: <MoneyIcon size={18} />,
          title: "Refund",
          description:
            "You will receive a notification when the refund is processed.",
        };
      case "new_bank_account":
        return {
          icon: <BankIcon size={18} />,
          title: "New Bank Account",
          description:
            "You will receive a notification when a new bank account added.",
        };
 
      case "new_enterprise":
        return {
          icon: <BriefcaseIcon size={18} />,
          title: "New Provider",
          description:
            "You will receive a daily report with created Providers.",
        };
      case "new_merchant":
        return {
          icon: <ShoppingBagOpenIcon size={18} />,
          title: "New Merchant",
          description:
            "You will receive a daily report with created Merchants.",
        };
      case "merchant_mid_issue": {
        const approvalIssue = isNewApprovalFlowEnabled ? "MSP" : "MID";
 
        return {
          icon: <ShieldCheckIcon size={18} />,
          title: `${approvalIssue} issue`,
          description: `You will receive a notification for every new ${approvalIssue} issue.`,
        };
      }
 
      case "ofac_match":
        return {
          icon: <ListMagnifyingGlassIcon size={18} />,
          title: "OFAC Match",
          description:
            "You will receive a notification for any matches found with OFAC sanctions lists.",
        };
      case "negative_balance":
        return {
          icon: <MinusIcon size={18} />,
          title: "Negative balance",
          description:
            "You will receive a notification when any negative balance occurrences in your account.",
        };
      case "mrp_level_eq_1":
        return {
          icon: <ChartLineIcon size={18} />,
          title: "Merchant Risk Profile Medium Level",
          description:
            "You will receive a notification when the Merchant's risk level increases to medium.",
          // highlight: "Medium Level",
        };
      case "mrp_level_gt_1":
        return {
          icon: <ChartLineUpIcon size={18} />,
          title: "Merchant Risk Profile High Level and above ",
          description:
            "You will receive a notification when the Merchant's risk level increases to high or above.",
          // highlight: "High or above.",
        };
 
      case "merchant_owner_underwriting_approval":
        return {
          icon: <CheckIcon size={18} />,
          title: "Merchant Owner Underwriting Approval",
          description:
            "You will receive a notification when Merchant Owner has Underwriting Approval.",
        };
      case "merchant_underwriting_approval":
        return {
          icon: <CheckIcon size={18} />,
          title: "Merchant Underwriting Approval",
          description:
            "You will receive a notification when Merchant has Underwriting Approval.",
        };
      case "convo_mention_alert":
        return {
          icon: <ChatCircleIcon size={18} />,
          title: "Conversation Mention Alert",
          description:
            "You will receive a notification when you are mentioned in the conversation.",
        };
      case "bulk_merchant_creation":
        return {
          icon: <PlusIcon size={18} />,
          title: "Bulk Merchant Creation",
          description:
            "You will receive a notification when a bulk merchant creation has been initiated.",
        };
      case "website_monitoring": //check with BE we dont have this yet
        return {
          icon: <CodeBlockIcon size={18} />,
          title: "Website Monitoring",
          description:
            "You will receive a notification for merchants with potential website issues",
        };
      case "enterprise_transfer":
        return {
          icon: <FileTextIcon size={18} />,
          title: "Provider Transfers",
          description:
            "Every day, you will receive detailed transfer report for providers.",
        };
      case "submerchant_transfer":
        return {
          icon: <FileTextIcon size={18} />,
          title: "Merchant Transfers",
          description:
            "Every day, you will receive detailed transfer report for merchants.",
        };
      case "new_dispute":
        return {
          icon: <ArrowsClockwiseIcon size={18} />,
          title: "Dispute",
          description:
            "You will receive a notification when the dispute is created.",
        };
      case "transaction_notification":
        return {
          icon: <ReceiptIcon size={18} />,
          title: "Single Transaction",
          description:
            "Receive a copy of the customer’s email receipt for each transaction.",
        };
      case "chargeback_report":
        return {
          icon: <ArrowsClockwiseIcon size={18} />,
          title: "Daily Chargebacks Report",
          description:
            "Receive notifications for each chargeback, chargeback reversal, or a once-daily report with all activity.",
        };
      case "merchant_owner_ready_for_approval": //TODO: check the correct alerttype with BE, this replaces merchant_owner_underwriting_approval
        return {
          icon: <CheckIcon size={18} />,
          title: "Merchant Ready for Approval",
          description:
            "You will receive a notification or a daily aggregated email when a merchant is ready for sponsor approval..",
        };
      case "merchant_owner_sponsor_approval": //TODO: check the correct alerttype with BE
        return {
          icon: <CheckCircleIcon size={18} />,
          title: "Approved Merchant by Sponsor",
          description:
            "You will receive a notification for each approved merchant, or a daily aggregated email listing all approved merchants.",
        };
      case "merchant_owner_declined": //TODO: check the correct alerttype with BE
        return {
          icon: <XCircleIcon size={18} />,
          title: "Declined Merchants",
          description:
            "You will receive a notification for each declined merchant, or a daily aggregated email listing all declined merchants.",
        };
      case "merchant_owner_suspended": //TODO: check the correct alerttype with BE
        return {
          icon: <EyeIcon size={18} />,
          title: "Suspended Merchants",
          description:
            "You will receive a notification for each suspended merchant, or a daily aggregated email listing all suspended merchants.",
        };
 
      default:
        return {
          icon: <FileTextIcon size={18} />,
          title: alert.title,
          description: alert.subTitle,
        };
    }
  };
 
  const getIsDisabled = (methods: TAlertMethods[]): TIsDisabeled => {
    const isEmailDisabled = !methods?.includes("email");
    const isPushDisabled = !methods?.includes("push");
    return { isEmailDisabled, isPushDisabled };
  };
 
  const getIsAssigned = (assignedMethods: TAlertMethods[]): TIsAssigned => {
    const isEmailAssigned = assignedMethods?.includes("email");
    const isPushAssigned = assignedMethods?.includes("push");
    return { isEmailAssigned, isPushAssigned };
  };
  return { getDisplayedData, getIsDisabled, getIsAssigned };
};
 
export default useGetAlertData;