Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

3.6 KB
Raw Blame
import { createSignal } from 'solid-js';

const DAILY_LIMIT = 5;

export enum PaywallKey {
  PROJECT_LIMIT = 'PROJECT_LIMIT',
  FILE_LIMIT = 'FILE_LIMIT',
  IMAGE_LIMIT = 'IMAGE_LIMIT',
  CHAT_LIMIT = 'CHAT_LIMIT',
  O1_LIMIT = 'O1_LIMIT',
  CANVAS_CLIKED = 'CANVAS_CLIKED',
  SAVED_PROMPT = 'SAVED_PROMPT',
  REMOVE_SIGNATURE = 'REMOVE_SIGNATURE',
  MULTI_INBOX = 'MULTI_INBOX',
  TEAMS = 'TEAMS',
}

export type PaywallMessageMetadata = {
  title: string;
  description: string;
  learnMoreUrl?: string;
  learnMoreSubject?: string;
};

export const PaywallMessages: Record<PaywallKey, PaywallMessageMetadata> = {
  [PaywallKey.PROJECT_LIMIT]: {
    title: 'Folder limit reached',
    description:
      'Upgrade to create more folders and keep organizing your workspace.',
    learnMoreUrl: 'https://docs.macro.com/product/drive',
    learnMoreSubject: 'folders',
  },
  [PaywallKey.FILE_LIMIT]: {
    title: 'File limit reached',
    description: 'Upgrade for more storage and room for all of your documents.',
  },
  [PaywallKey.CHAT_LIMIT]: {
    title: 'Chat limit reached',
    description:
      'Upgrade to keep creating agent chats with access to every AI model.',
    learnMoreUrl: 'https://docs.macro.com/product/agents',
    learnMoreSubject: 'agents',
  },
  [PaywallKey.IMAGE_LIMIT]: {
    title: 'Image processing limit reached',
    description: `You’ve used ${DAILY_LIMIT} AI image processing requests today. Upgrade for higher limits.`,
    learnMoreUrl: 'https://docs.macro.com/product/agents',
    learnMoreSubject: 'agents',
  },
  [PaywallKey.O1_LIMIT]: {
    title: 'Smart models require Pro or Max',
    description: 'Upgrade to use Macro’s most capable AI models.',
    learnMoreUrl: 'https://docs.macro.com/product/agents',
    learnMoreSubject: 'agents',
  },
  [PaywallKey.CANVAS_CLIKED]: {
    title: 'AI canvases require Pro or Max',
    description:
      'Upgrade to generate diagrams, whiteboards, and visual drafts with AI.',
    learnMoreUrl: 'https://docs.macro.com/product/canvas',
    learnMoreSubject: 'canvases',
  },
  [PaywallKey.SAVED_PROMPT]: {
    title: 'Saved prompts require Pro or Max',
    description: 'Upgrade to save reusable prompts for faster workflows.',
    learnMoreUrl: 'https://docs.macro.com/product/snippets',
    learnMoreSubject: 'saved prompts',
  },
  [PaywallKey.REMOVE_SIGNATURE]: {
    title: 'Remove the Macro signature',
    description: 'Upgrade to send emails without the Macro signature.',
    learnMoreUrl: 'https://docs.macro.com/product/email',
    learnMoreSubject: 'email',
  },
  [PaywallKey.MULTI_INBOX]: {
    title: 'Connect more inboxes',
    description: 'Upgrade your plan to connect more than two inboxes.',
    learnMoreUrl: 'https://docs.macro.com/product/home',
    learnMoreSubject: 'multiple inboxes',
  },
  [PaywallKey.TEAMS]: {
    title: 'Collaborate with your team',
    description:
      'Upgrade to create a team, invite members, and manage access together.',
    learnMoreUrl: 'https://docs.macro.com/account/teams',
    learnMoreSubject: 'teams',
  },
};

const [paywallOpen, setPaywallOpen] = createSignal(false);
// export const [paywallOpen, setPaywallOpen] = createControlledOpenSignal(false);
const [limitReached, _setLimitReached] = createSignal(false);
const [paywallKey, setPaywallKey] = createSignal<PaywallKey | null>(null);

export const usePaywallState = () => {
  const showPaywall = (errorKey?: PaywallKey | null) => {
    if (errorKey) {
      setPaywallKey(errorKey);
    }
    setPaywallOpen(true);
  };

  const hidePaywall = () => {
    setPaywallOpen(false);
    setPaywallKey(null);
  };
  return { paywallOpen, showPaywall, hidePaywall, limitReached, paywallKey };
};