├── apps
├── reflio-affiliate
│ ├── README.md
│ ├── .eslintrc.js
│ ├── public
│ │ ├── og.png
│ │ ├── favicon.ico
│ │ ├── vercel-logo.png
│ │ ├── favicon-16x16.png
│ │ ├── favicon-32x32.png
│ │ ├── mstile-150x150.png
│ │ ├── standard-embed.png
│ │ ├── apple-touch-icon.png
│ │ ├── grayscale-embed.png
│ │ ├── platform-screenshot.jpg
│ │ ├── android-chrome-192x192.png
│ │ ├── android-chrome-256x256.png
│ │ ├── android-chrome-512x512.png
│ │ ├── girlsinmarketing-logo.png
│ │ ├── fonts
│ │ │ ├── TTInterfaces-Bold.woff
│ │ │ ├── TTInterfaces-Bold.woff2
│ │ │ ├── TTInterfaces-Medium.woff
│ │ │ ├── TTInterfaces-Medium.woff2
│ │ │ ├── TTInterfaces-Regular.woff
│ │ │ └── TTInterfaces-Regular.woff2
│ │ ├── browserconfig.xml
│ │ ├── site.webmanifest
│ │ └── safari-pinned-tab.svg
│ ├── next-env.d.ts
│ ├── next.config.js
│ ├── pages
│ │ ├── index.js
│ │ ├── signin.js
│ │ ├── signup.js
│ │ ├── dashboard
│ │ │ ├── campaigns
│ │ │ │ └── index.js
│ │ │ └── index.js
│ │ ├── _document.js
│ │ ├── api
│ │ │ ├── public
│ │ │ │ ├── campaign.js
│ │ │ │ └── campaign-image.tsx
│ │ │ └── affiliate
│ │ │ │ ├── campaigns.js
│ │ │ │ ├── invites.js
│ │ │ │ ├── referrals.js
│ │ │ │ ├── commissions.js
│ │ │ │ ├── campaign-join.js
│ │ │ │ ├── handle-invite.js
│ │ │ │ ├── company-assets.js
│ │ │ │ └── change-code.js
│ │ ├── _app.js
│ │ └── invite
│ │ │ └── [handle]
│ │ │ ├── index.js
│ │ │ └── [campaignId].js
│ ├── templates
│ │ ├── VercelLogo.tsx
│ │ ├── AdminNavbar
│ │ │ ├── AdminDesktopNav.js
│ │ │ └── AdminNavItems.js
│ │ ├── Auth.js
│ │ ├── CampaignInvite.js
│ │ └── SEOMeta.tsx
│ ├── utils
│ │ ├── supabase-admin.js
│ │ ├── email-builder-inner.js
│ │ ├── email-builder-server.js
│ │ ├── supabase-client.js
│ │ ├── UserAffiliateContext.js
│ │ └── useUser.js
│ ├── postcss.config.js
│ ├── .gitignore
│ ├── next-seo.config.js
│ ├── tsconfig.json
│ └── package.json
└── reflio
│ ├── .eslintrc.js
│ ├── public
│ ├── og.png
│ ├── favicon.ico
│ ├── reflio-logo.png
│ ├── favicon-16x16.png
│ ├── favicon-32x32.png
│ ├── mstile-150x150.png
│ ├── standard-embed.png
│ ├── apple-touch-icon.png
│ ├── invite-screenshot.webp
│ ├── affiliate-screenshot.webp
│ ├── android-chrome-192x192.png
│ ├── android-chrome-256x256.png
│ ├── platform-screenshot.webp
│ ├── testimonials
│ │ ├── _thunk_.jpeg
│ │ ├── foliofed.jpeg
│ │ ├── briansaetre.jpeg
│ │ └── maxwellcdavis.jpeg
│ ├── fonts
│ │ ├── TTInterfaces-Bold.woff
│ │ ├── TTInterfaces-Bold.woff2
│ │ ├── TTInterfaces-Medium.woff
│ │ ├── TTInterfaces-Medium.woff2
│ │ ├── TTInterfaces-Regular.woff
│ │ └── TTInterfaces-Regular.woff2
│ ├── browserconfig.xml
│ ├── site.webmanifest
│ └── safari-pinned-tab.svg
│ ├── types
│ └── index.d.ts
│ ├── pages
│ ├── signin.tsx
│ ├── signup.tsx
│ ├── api
│ │ ├── auth.tsx
│ │ ├── affiliates
│ │ │ ├── index.js
│ │ │ ├── [id]
│ │ │ │ ├── edit.js
│ │ │ │ └── index.js
│ │ │ └── invite.js
│ │ ├── get-account-details.js
│ │ ├── get-stripe-id.js
│ │ ├── subscribe.js
│ │ ├── team
│ │ │ ├── usage.js
│ │ │ └── invoice.js
│ │ ├── v1
│ │ │ ├── commission
│ │ │ │ └── create.js
│ │ │ ├── referral
│ │ │ │ └── manual-signup.js
│ │ │ ├── signup-referral.js
│ │ │ ├── campaign-details.js
│ │ │ ├── retrieve-referral.js
│ │ │ ├── verify-company.js
│ │ │ └── record-referral.js
│ │ ├── create-portal-link.js
│ │ ├── referrals
│ │ │ └── create.js
│ │ ├── embedData.js
│ │ ├── create-checkout-session.js
│ │ └── customer-events.js
│ ├── dashboard
│ │ ├── [companyId]
│ │ │ ├── setup
│ │ │ │ ├── index.js
│ │ │ │ └── campaign.js
│ │ │ ├── referrals
│ │ │ │ ├── index.tsx
│ │ │ │ ├── expired.tsx
│ │ │ │ ├── converted.tsx
│ │ │ │ ├── signed-up.tsx
│ │ │ │ └── visited-link.tsx
│ │ │ ├── commissions
│ │ │ │ ├── due.js
│ │ │ │ ├── paid.js
│ │ │ │ ├── index.js
│ │ │ │ ├── trials.js
│ │ │ │ └── pending.js
│ │ │ ├── index.js
│ │ │ └── campaigns
│ │ │ │ ├── new.js
│ │ │ │ └── [campaignId]
│ │ │ │ └── edit.js
│ │ ├── index.js
│ │ ├── team.js
│ │ └── stripe-verify.js
│ ├── changelog.tsx
│ ├── commercial.tsx
│ ├── _document.tsx
│ ├── pricing.js
│ ├── _error.tsx
│ ├── _error.wizardcopy.tsx
│ ├── 404.tsx
│ ├── _app.tsx
│ └── sentry_sample_error.tsx
│ ├── sentry.properties
│ ├── next-env.d.ts
│ ├── utils
│ ├── stripe-client.js
│ ├── stripe.js
│ ├── email-builder-server.js
│ ├── email-builder-inner.js
│ ├── supabase-admin.js
│ ├── supabase-client.ts
│ ├── sendEmail.js
│ ├── CampaignContext.js
│ ├── setupStepCheck.js
│ └── AffiliateContext.js
│ ├── postcss.config.js
│ ├── .gitignore
│ ├── next.config.js
│ ├── types.ts
│ ├── sentry.client.config.js
│ ├── sentry.server.config.js
│ ├── tsconfig.json
│ ├── middleware.ts
│ ├── templates
│ ├── Auth.js
│ └── SEOMeta.tsx
│ ├── package.json
│ └── LICENSE
├── packages
├── ui
│ ├── node_modules
│ │ └── .bin
│ │ │ ├── next
│ │ │ ├── tsc
│ │ │ ├── yarn
│ │ │ ├── yarnpkg
│ │ │ ├── eslint
│ │ │ ├── parcel
│ │ │ ├── tailwind
│ │ │ ├── tailwindcss
│ │ │ ├── tsserver
│ │ │ ├── autoprefixer
│ │ │ └── concurrently
│ ├── tailwind.config.js
│ ├── fonts
│ │ ├── TTInterfaces-Bold.woff
│ │ ├── TTInterfaces-Bold.woff2
│ │ ├── TTInterfaces-Medium.woff
│ │ ├── TTInterfaces-Medium.woff2
│ │ ├── TTInterfaces-Regular.woff
│ │ └── TTInterfaces-Regular.woff2
│ ├── src
│ │ ├── Icons
│ │ │ ├── Open.js
│ │ │ ├── LoomIcon.js
│ │ │ ├── Github.js
│ │ │ ├── Twitter.js
│ │ │ ├── DownArrow.js
│ │ │ ├── Stripe.js
│ │ │ ├── Google.js
│ │ │ ├── AnimIcon.js
│ │ │ └── StripeConnect.js
│ │ ├── Card.js
│ │ ├── SimpleNav.js
│ │ ├── LoadingDots.js
│ │ ├── StripeDisconnectNotice.js
│ │ ├── AdminNavbar
│ │ │ └── AdminDesktopNav.js
│ │ ├── LoadingTile.js
│ │ ├── Footer.js
│ │ ├── Button.js
│ │ ├── DueCommissions.js
│ │ ├── Testimonials.js
│ │ ├── Modal.js
│ │ ├── CompanyLogoUpload.tsx
│ │ ├── Features.js
│ │ └── PricingSnippet.js
│ ├── .gitignore
│ ├── tsconfig.json
│ └── package.json
├── tailwind-config
│ ├── node_modules
│ │ └── .bin
│ │ │ ├── tailwind
│ │ │ └── tailwindcss
│ ├── package.json
│ ├── .gitignore
│ └── tailwind.config.js
└── eslint-config-custom
│ ├── node_modules
│ └── .bin
│ │ └── eslint-config-prettier
│ ├── index.js
│ ├── package.json
│ └── .gitignore
├── .eslintrc.js
├── turbo.json
├── package.json
├── .gitignore
├── .github
└── ISSUE_TEMPLATE
│ ├── feature_request.md
│ └── bug_report.md
├── .env.example
└── README.md
/apps/reflio-affiliate/README.md:
--------------------------------------------------------------------------------
1 | # Reflio
--------------------------------------------------------------------------------
/packages/ui/node_modules/.bin/next:
--------------------------------------------------------------------------------
1 | ../../../../node_modules/next/dist/bin/next
--------------------------------------------------------------------------------
/packages/ui/node_modules/.bin/tsc:
--------------------------------------------------------------------------------
1 | ../../../../node_modules/typescript/bin/tsc
--------------------------------------------------------------------------------
/packages/ui/node_modules/.bin/yarn:
--------------------------------------------------------------------------------
1 | ../../../../node_modules/yarn/bin/yarn.js
--------------------------------------------------------------------------------
/packages/ui/node_modules/.bin/yarnpkg:
--------------------------------------------------------------------------------
1 | ../../../../node_modules/yarn/bin/yarn.js
--------------------------------------------------------------------------------
/packages/ui/node_modules/.bin/eslint:
--------------------------------------------------------------------------------
1 | ../../../../node_modules/eslint/bin/eslint.js
--------------------------------------------------------------------------------
/packages/ui/node_modules/.bin/parcel:
--------------------------------------------------------------------------------
1 | ../../../../node_modules/parcel-bundler/bin/cli.js
--------------------------------------------------------------------------------
/packages/ui/node_modules/.bin/tailwind:
--------------------------------------------------------------------------------
1 | ../../../../node_modules/tailwindcss/lib/cli.js
--------------------------------------------------------------------------------
/packages/ui/node_modules/.bin/tailwindcss:
--------------------------------------------------------------------------------
1 | ../../../../node_modules/tailwindcss/lib/cli.js
--------------------------------------------------------------------------------
/packages/ui/node_modules/.bin/tsserver:
--------------------------------------------------------------------------------
1 | ../../../../node_modules/typescript/bin/tsserver
--------------------------------------------------------------------------------
/apps/reflio/.eslintrc.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | root: true,
3 | extends: ["custom"],
4 | };
--------------------------------------------------------------------------------
/packages/tailwind-config/node_modules/.bin/tailwind:
--------------------------------------------------------------------------------
1 | ../../../../node_modules/tailwindcss/lib/cli.js
--------------------------------------------------------------------------------
/packages/ui/node_modules/.bin/autoprefixer:
--------------------------------------------------------------------------------
1 | ../../../../node_modules/autoprefixer/bin/autoprefixer
--------------------------------------------------------------------------------
/apps/reflio/public/og.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/steven-tey/reflio/HEAD/apps/reflio/public/og.png
--------------------------------------------------------------------------------
/packages/tailwind-config/node_modules/.bin/tailwindcss:
--------------------------------------------------------------------------------
1 | ../../../../node_modules/tailwindcss/lib/cli.js
--------------------------------------------------------------------------------
/apps/reflio-affiliate/.eslintrc.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | root: true,
3 | extends: ["custom"],
4 | };
--------------------------------------------------------------------------------
/packages/ui/node_modules/.bin/concurrently:
--------------------------------------------------------------------------------
1 | ../../../../node_modules/concurrently/dist/bin/concurrently.js
--------------------------------------------------------------------------------
/apps/reflio/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/steven-tey/reflio/HEAD/apps/reflio/public/favicon.ico
--------------------------------------------------------------------------------
/apps/reflio-affiliate/public/og.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/steven-tey/reflio/HEAD/apps/reflio-affiliate/public/og.png
--------------------------------------------------------------------------------
/apps/reflio/public/reflio-logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/steven-tey/reflio/HEAD/apps/reflio/public/reflio-logo.png
--------------------------------------------------------------------------------
/apps/reflio/public/favicon-16x16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/steven-tey/reflio/HEAD/apps/reflio/public/favicon-16x16.png
--------------------------------------------------------------------------------
/apps/reflio/public/favicon-32x32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/steven-tey/reflio/HEAD/apps/reflio/public/favicon-32x32.png
--------------------------------------------------------------------------------
/apps/reflio/public/mstile-150x150.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/steven-tey/reflio/HEAD/apps/reflio/public/mstile-150x150.png
--------------------------------------------------------------------------------
/apps/reflio/public/standard-embed.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/steven-tey/reflio/HEAD/apps/reflio/public/standard-embed.png
--------------------------------------------------------------------------------
/apps/reflio/types/index.d.ts:
--------------------------------------------------------------------------------
1 | export {};
2 |
3 | declare global {
4 | interface Window {
5 | Reform: any;
6 | }
7 | }
--------------------------------------------------------------------------------
/packages/eslint-config-custom/node_modules/.bin/eslint-config-prettier:
--------------------------------------------------------------------------------
1 | ../../../../node_modules/eslint-config-prettier/bin/cli.js
--------------------------------------------------------------------------------
/packages/ui/tailwind.config.js:
--------------------------------------------------------------------------------
1 | const config = require("tailwind-config/tailwind.config.js");
2 |
3 | module.exports = config;
--------------------------------------------------------------------------------
/apps/reflio-affiliate/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/steven-tey/reflio/HEAD/apps/reflio-affiliate/public/favicon.ico
--------------------------------------------------------------------------------
/apps/reflio/public/apple-touch-icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/steven-tey/reflio/HEAD/apps/reflio/public/apple-touch-icon.png
--------------------------------------------------------------------------------
/packages/ui/fonts/TTInterfaces-Bold.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/steven-tey/reflio/HEAD/packages/ui/fonts/TTInterfaces-Bold.woff
--------------------------------------------------------------------------------
/apps/reflio/public/invite-screenshot.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/steven-tey/reflio/HEAD/apps/reflio/public/invite-screenshot.webp
--------------------------------------------------------------------------------
/packages/ui/fonts/TTInterfaces-Bold.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/steven-tey/reflio/HEAD/packages/ui/fonts/TTInterfaces-Bold.woff2
--------------------------------------------------------------------------------
/packages/ui/fonts/TTInterfaces-Medium.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/steven-tey/reflio/HEAD/packages/ui/fonts/TTInterfaces-Medium.woff
--------------------------------------------------------------------------------
/apps/reflio-affiliate/public/vercel-logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/steven-tey/reflio/HEAD/apps/reflio-affiliate/public/vercel-logo.png
--------------------------------------------------------------------------------
/apps/reflio/public/affiliate-screenshot.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/steven-tey/reflio/HEAD/apps/reflio/public/affiliate-screenshot.webp
--------------------------------------------------------------------------------
/apps/reflio/public/android-chrome-192x192.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/steven-tey/reflio/HEAD/apps/reflio/public/android-chrome-192x192.png
--------------------------------------------------------------------------------
/apps/reflio/public/android-chrome-256x256.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/steven-tey/reflio/HEAD/apps/reflio/public/android-chrome-256x256.png
--------------------------------------------------------------------------------
/apps/reflio/public/platform-screenshot.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/steven-tey/reflio/HEAD/apps/reflio/public/platform-screenshot.webp
--------------------------------------------------------------------------------
/apps/reflio/public/testimonials/_thunk_.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/steven-tey/reflio/HEAD/apps/reflio/public/testimonials/_thunk_.jpeg
--------------------------------------------------------------------------------
/apps/reflio/public/testimonials/foliofed.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/steven-tey/reflio/HEAD/apps/reflio/public/testimonials/foliofed.jpeg
--------------------------------------------------------------------------------
/packages/ui/fonts/TTInterfaces-Medium.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/steven-tey/reflio/HEAD/packages/ui/fonts/TTInterfaces-Medium.woff2
--------------------------------------------------------------------------------
/packages/ui/fonts/TTInterfaces-Regular.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/steven-tey/reflio/HEAD/packages/ui/fonts/TTInterfaces-Regular.woff
--------------------------------------------------------------------------------
/packages/ui/fonts/TTInterfaces-Regular.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/steven-tey/reflio/HEAD/packages/ui/fonts/TTInterfaces-Regular.woff2
--------------------------------------------------------------------------------
/apps/reflio-affiliate/public/favicon-16x16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/steven-tey/reflio/HEAD/apps/reflio-affiliate/public/favicon-16x16.png
--------------------------------------------------------------------------------
/apps/reflio-affiliate/public/favicon-32x32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/steven-tey/reflio/HEAD/apps/reflio-affiliate/public/favicon-32x32.png
--------------------------------------------------------------------------------
/apps/reflio-affiliate/public/mstile-150x150.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/steven-tey/reflio/HEAD/apps/reflio-affiliate/public/mstile-150x150.png
--------------------------------------------------------------------------------
/apps/reflio-affiliate/public/standard-embed.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/steven-tey/reflio/HEAD/apps/reflio-affiliate/public/standard-embed.png
--------------------------------------------------------------------------------
/apps/reflio/public/fonts/TTInterfaces-Bold.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/steven-tey/reflio/HEAD/apps/reflio/public/fonts/TTInterfaces-Bold.woff
--------------------------------------------------------------------------------
/apps/reflio-affiliate/public/apple-touch-icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/steven-tey/reflio/HEAD/apps/reflio-affiliate/public/apple-touch-icon.png
--------------------------------------------------------------------------------
/apps/reflio-affiliate/public/grayscale-embed.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/steven-tey/reflio/HEAD/apps/reflio-affiliate/public/grayscale-embed.png
--------------------------------------------------------------------------------
/apps/reflio/public/fonts/TTInterfaces-Bold.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/steven-tey/reflio/HEAD/apps/reflio/public/fonts/TTInterfaces-Bold.woff2
--------------------------------------------------------------------------------
/apps/reflio/public/fonts/TTInterfaces-Medium.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/steven-tey/reflio/HEAD/apps/reflio/public/fonts/TTInterfaces-Medium.woff
--------------------------------------------------------------------------------
/apps/reflio/public/fonts/TTInterfaces-Medium.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/steven-tey/reflio/HEAD/apps/reflio/public/fonts/TTInterfaces-Medium.woff2
--------------------------------------------------------------------------------
/apps/reflio/public/fonts/TTInterfaces-Regular.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/steven-tey/reflio/HEAD/apps/reflio/public/fonts/TTInterfaces-Regular.woff
--------------------------------------------------------------------------------
/apps/reflio/public/testimonials/briansaetre.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/steven-tey/reflio/HEAD/apps/reflio/public/testimonials/briansaetre.jpeg
--------------------------------------------------------------------------------
/apps/reflio/public/testimonials/maxwellcdavis.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/steven-tey/reflio/HEAD/apps/reflio/public/testimonials/maxwellcdavis.jpeg
--------------------------------------------------------------------------------
/apps/reflio-affiliate/public/platform-screenshot.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/steven-tey/reflio/HEAD/apps/reflio-affiliate/public/platform-screenshot.jpg
--------------------------------------------------------------------------------
/apps/reflio/public/fonts/TTInterfaces-Regular.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/steven-tey/reflio/HEAD/apps/reflio/public/fonts/TTInterfaces-Regular.woff2
--------------------------------------------------------------------------------
/apps/reflio-affiliate/public/android-chrome-192x192.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/steven-tey/reflio/HEAD/apps/reflio-affiliate/public/android-chrome-192x192.png
--------------------------------------------------------------------------------
/apps/reflio-affiliate/public/android-chrome-256x256.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/steven-tey/reflio/HEAD/apps/reflio-affiliate/public/android-chrome-256x256.png
--------------------------------------------------------------------------------
/apps/reflio-affiliate/public/android-chrome-512x512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/steven-tey/reflio/HEAD/apps/reflio-affiliate/public/android-chrome-512x512.png
--------------------------------------------------------------------------------
/apps/reflio-affiliate/public/girlsinmarketing-logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/steven-tey/reflio/HEAD/apps/reflio-affiliate/public/girlsinmarketing-logo.png
--------------------------------------------------------------------------------
/apps/reflio-affiliate/public/fonts/TTInterfaces-Bold.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/steven-tey/reflio/HEAD/apps/reflio-affiliate/public/fonts/TTInterfaces-Bold.woff
--------------------------------------------------------------------------------
/apps/reflio-affiliate/public/fonts/TTInterfaces-Bold.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/steven-tey/reflio/HEAD/apps/reflio-affiliate/public/fonts/TTInterfaces-Bold.woff2
--------------------------------------------------------------------------------
/apps/reflio-affiliate/public/fonts/TTInterfaces-Medium.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/steven-tey/reflio/HEAD/apps/reflio-affiliate/public/fonts/TTInterfaces-Medium.woff
--------------------------------------------------------------------------------
/apps/reflio-affiliate/public/fonts/TTInterfaces-Medium.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/steven-tey/reflio/HEAD/apps/reflio-affiliate/public/fonts/TTInterfaces-Medium.woff2
--------------------------------------------------------------------------------
/apps/reflio-affiliate/public/fonts/TTInterfaces-Regular.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/steven-tey/reflio/HEAD/apps/reflio-affiliate/public/fonts/TTInterfaces-Regular.woff
--------------------------------------------------------------------------------
/apps/reflio/pages/signin.tsx:
--------------------------------------------------------------------------------
1 | import Auth from '@/templates/Auth';
2 |
3 | export default function SignIn() {
4 | return (
5 |
6 | );
7 | }
--------------------------------------------------------------------------------
/apps/reflio/pages/signup.tsx:
--------------------------------------------------------------------------------
1 | import Auth from '@/templates/Auth';
2 |
3 | export default function SignUp() {
4 | return (
5 |
6 | );
7 | }
--------------------------------------------------------------------------------
/apps/reflio-affiliate/public/fonts/TTInterfaces-Regular.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/steven-tey/reflio/HEAD/apps/reflio-affiliate/public/fonts/TTInterfaces-Regular.woff2
--------------------------------------------------------------------------------
/packages/eslint-config-custom/index.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | extends: ["next", "prettier"],
3 | rules: {
4 | "@next/next/no-html-link-for-pages": "off",
5 | "react/jsx-key": "off",
6 | },
7 | };
--------------------------------------------------------------------------------
/packages/tailwind-config/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "tailwind-config",
3 | "version": "0.0.0",
4 | "private": true,
5 | "main": "index.js",
6 | "devDependencies": {
7 | "tailwindcss": "^3.0.22"
8 | }
9 | }
--------------------------------------------------------------------------------
/apps/reflio/sentry.properties:
--------------------------------------------------------------------------------
1 | defaults.url=https://sentry.io/
2 | defaults.org=reflio
3 | defaults.project=production
4 | cli.executable=../../../../../.npm/_npx/16312/lib/node_modules/@sentry/wizard/node_modules/@sentry/cli/bin/sentry-cli
--------------------------------------------------------------------------------
/apps/reflio/next-env.d.ts:
--------------------------------------------------------------------------------
1 | ///
2 | ///
3 |
4 | // NOTE: This file should not be edited
5 | // see https://nextjs.org/docs/basic-features/typescript for more information.
6 |
--------------------------------------------------------------------------------
/apps/reflio-affiliate/next-env.d.ts:
--------------------------------------------------------------------------------
1 | ///
2 | ///
3 |
4 | // NOTE: This file should not be edited
5 | // see https://nextjs.org/docs/basic-features/typescript for more information.
6 |
--------------------------------------------------------------------------------
/.eslintrc.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | root: true,
3 | // This tells ESLint to load the config from the package `eslint-config-custom`
4 | extends: ["custom"],
5 | settings: {
6 | next: {
7 | rootDir: ["apps/*/"],
8 | },
9 | },
10 | };
--------------------------------------------------------------------------------
/apps/reflio-affiliate/next.config.js:
--------------------------------------------------------------------------------
1 | require("dotenv").config({ path: "../../.env" });
2 |
3 | const withTM = require("next-transpile-modules")(["ui"]);
4 |
5 | module.exports = withTM({
6 | images: {
7 | domains: ['s2.googleusercontent.com'],
8 | }
9 | });
--------------------------------------------------------------------------------
/apps/reflio-affiliate/pages/index.js:
--------------------------------------------------------------------------------
1 | import Auth from '@/templates/Auth';
2 | import SEOMeta from '@/templates/SEOMeta';
3 |
4 | export default function Index() {
5 | return (
6 | <>
7 |
8 |
9 | >
10 | );
11 | };
--------------------------------------------------------------------------------
/apps/reflio-affiliate/pages/signin.js:
--------------------------------------------------------------------------------
1 | import Auth from '@/templates/Auth';
2 | import SEOMeta from '@/templates/SEOMeta';
3 |
4 | export default function SignIn() {
5 | return (
6 | <>
7 |
8 |
9 | >
10 | );
11 | }
--------------------------------------------------------------------------------
/apps/reflio-affiliate/pages/signup.js:
--------------------------------------------------------------------------------
1 | import Auth from '@/templates/Auth';
2 | import SEOMeta from '@/templates/SEOMeta';
3 |
4 | export default function SignUp() {
5 | return (
6 | <>
7 |
8 |
9 | >
10 | );
11 | }
--------------------------------------------------------------------------------
/apps/reflio/pages/api/auth.tsx:
--------------------------------------------------------------------------------
1 | import type { NextApiRequest, NextApiResponse } from 'next'
2 |
3 | export default function handler(_: NextApiRequest, res: NextApiResponse) {
4 | res.setHeader('WWW-authenticate', 'Basic realm="Secure Area"')
5 |
6 | res.statusCode = 401
7 | res.end(`Auth Required.`)
8 | }
--------------------------------------------------------------------------------
/apps/reflio/public/browserconfig.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | #09031a
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/apps/reflio-affiliate/public/browserconfig.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | #09031a
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/apps/reflio-affiliate/templates/VercelLogo.tsx:
--------------------------------------------------------------------------------
1 | import Image from "next/image";
2 | import logo from "../public/vercel-logo.png";
3 |
4 | export function VercelLogo({ size = 180 }: { size?: number }) {
5 | return
6 |
7 |
8 | }
--------------------------------------------------------------------------------
/apps/reflio/pages/dashboard/[companyId]/setup/index.js:
--------------------------------------------------------------------------------
1 | import setupStepCheck from '@/utils/setupStepCheck';
2 | import LoadingTile from '@/components/LoadingTile';
3 |
4 | export default function SetupPage() {
5 | setupStepCheck('normal');
6 |
7 | return (
8 |
9 |
10 |
11 | );
12 | }
--------------------------------------------------------------------------------
/apps/reflio/pages/dashboard/[companyId]/referrals/index.tsx:
--------------------------------------------------------------------------------
1 | import { SEOMeta } from '@/templates/SEOMeta';
2 | import { ReferralsTemplate } from '@/components/ReferralsTemplate';
3 |
4 | export default function ReferralsPage() {
5 | return (
6 | <>
7 |
8 |
9 | >
10 | );
11 | }
--------------------------------------------------------------------------------
/apps/reflio/pages/dashboard/index.js:
--------------------------------------------------------------------------------
1 | import { LoadingTile } from '@/components/LoadingTile';
2 | import SEOMeta from '@/templates/SEOMeta';
3 |
4 | export default function DashboardPage() {
5 | return (
6 | <>
7 |
8 |
9 |
10 |
11 | >
12 | );
13 | }
--------------------------------------------------------------------------------
/apps/reflio/pages/dashboard/[companyId]/commissions/due.js:
--------------------------------------------------------------------------------
1 | import { SEOMeta } from '@/templates/SEOMeta';
2 | import { CommissionsTemplate } from '@/components/CommissionsTemplate';
3 |
4 | export default function CommissionsDuePage() {
5 | return (
6 | <>
7 |
8 |
9 | >
10 | );
11 | }
--------------------------------------------------------------------------------
/apps/reflio/pages/dashboard/[companyId]/referrals/expired.tsx:
--------------------------------------------------------------------------------
1 | import { SEOMeta } from '@/templates/SEOMeta';
2 | import { ReferralsTemplate } from '@/components/ReferralsTemplate';
3 |
4 | export default function ReferralsPageExpired() {
5 | return (
6 | <>
7 |
8 |
9 | >
10 | );
11 | }
--------------------------------------------------------------------------------
/apps/reflio/pages/dashboard/[companyId]/commissions/paid.js:
--------------------------------------------------------------------------------
1 | import { SEOMeta } from '@/templates/SEOMeta';
2 | import { CommissionsTemplate } from '@/components/CommissionsTemplate';
3 |
4 | export default function CommissionsPaidPage() {
5 | return (
6 | <>
7 |
8 |
9 | >
10 | );
11 | }
--------------------------------------------------------------------------------
/apps/reflio/pages/dashboard/[companyId]/referrals/converted.tsx:
--------------------------------------------------------------------------------
1 | import { SEOMeta } from '@/templates/SEOMeta';
2 | import { ReferralsTemplate } from '@/components/ReferralsTemplate';
3 |
4 | export default function ReferralsPageConverted() {
5 | return (
6 | <>
7 |
8 |
9 | >
10 | );
11 | }
--------------------------------------------------------------------------------
/apps/reflio/pages/dashboard/[companyId]/referrals/signed-up.tsx:
--------------------------------------------------------------------------------
1 | import { SEOMeta } from '@/templates/SEOMeta';
2 | import { ReferralsTemplate } from '@/components/ReferralsTemplate';
3 |
4 | export default function ReferralsPageSignedUp() {
5 | return (
6 | <>
7 |
8 |
9 | >
10 | );
11 | }
--------------------------------------------------------------------------------
/packages/eslint-config-custom/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "eslint-config-custom",
3 | "version": "0.0.0",
4 | "main": "index.js",
5 | "license": "MIT",
6 | "dependencies": {
7 | "eslint-config-next": "^12.2.2",
8 | "eslint-config-prettier": "^8.5.0",
9 | "eslint-plugin-react": "7.30.1"
10 | },
11 | "publishConfig": {
12 | "access": "public"
13 | }
14 | }
--------------------------------------------------------------------------------
/apps/reflio/pages/dashboard/[companyId]/commissions/index.js:
--------------------------------------------------------------------------------
1 | import { SEOMeta } from '@/templates/SEOMeta';
2 | import { CommissionsTemplate } from '@/components/CommissionsTemplate';
3 |
4 | export default function CommissionsPage() {
5 | return (
6 | <>
7 |
8 |
9 | >
10 | );
11 | }
--------------------------------------------------------------------------------
/apps/reflio/pages/dashboard/[companyId]/commissions/trials.js:
--------------------------------------------------------------------------------
1 | import { SEOMeta } from '@/templates/SEOMeta';
2 | import { CommissionsTemplate } from '@/components/CommissionsTemplate';
3 |
4 | export default function CommissionsTrialPage() {
5 | return (
6 | <>
7 |
8 |
9 | >
10 | );
11 | }
--------------------------------------------------------------------------------
/apps/reflio/pages/dashboard/[companyId]/commissions/pending.js:
--------------------------------------------------------------------------------
1 | import { SEOMeta } from '@/templates/SEOMeta';
2 | import { CommissionsTemplate } from '@/components/CommissionsTemplate';
3 |
4 | export default function CommissionsPendingPage() {
5 | return (
6 | <>
7 |
8 |
9 | >
10 | );
11 | }
--------------------------------------------------------------------------------
/apps/reflio/pages/dashboard/[companyId]/referrals/visited-link.tsx:
--------------------------------------------------------------------------------
1 | import { SEOMeta } from '@/templates/SEOMeta';
2 | import { ReferralsTemplate } from '@/components/ReferralsTemplate';
3 |
4 | export default function ReferralsPageVisitedLink() {
5 | return (
6 | <>
7 |
8 |
9 | >
10 | );
11 | }
--------------------------------------------------------------------------------
/apps/reflio/utils/stripe-client.js:
--------------------------------------------------------------------------------
1 | import { loadStripe } from '@stripe/stripe-js';
2 |
3 | let stripePromise;
4 |
5 | export const getStripe = () => {
6 | if (!stripePromise) {
7 | stripePromise = loadStripe(
8 | process.env.NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY_LIVE ??
9 | process.env.NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY
10 | );
11 | }
12 |
13 | return stripePromise;
14 | };
15 |
--------------------------------------------------------------------------------
/turbo.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://turborepo.org/schema.json",
3 | "baseBranch": "origin/main",
4 | "pipeline": {
5 | "build": {
6 | "dependsOn": ["^build"],
7 | "outputs": ["dist/**", ".next/**"]
8 | },
9 | "lint": {
10 | "outputs": []
11 | },
12 | "dev": {
13 | "cache": false
14 | },
15 | "clean": {
16 | "cache": false
17 | }
18 | }
19 | }
--------------------------------------------------------------------------------
/apps/reflio-affiliate/pages/dashboard/campaigns/index.js:
--------------------------------------------------------------------------------
1 | import SEOMeta from '@/templates/SEOMeta';
2 | import CampaignsList from '@/components/CampaignsList';
3 |
4 | const CampaignsPage = () => {
5 | return (
6 | <>
7 |
8 |
9 |
10 |
11 | >
12 | );
13 | };
14 |
15 | export default CampaignsPage;
--------------------------------------------------------------------------------
/apps/reflio-affiliate/utils/supabase-admin.js:
--------------------------------------------------------------------------------
1 | import { createClient } from '@supabase/supabase-js';
2 |
3 | export const supabaseAdmin = createClient(
4 | process.env.NEXT_PUBLIC_SUPABASE_URL,
5 | process.env.SUPABASE_SERVICE_ROLE_KEY
6 | );
7 |
8 | export const getUser = async (token) => {
9 | const { data, error } = await supabaseAdmin.auth.api.getUser(token);
10 |
11 | if (error) {
12 | throw error;
13 | }
14 |
15 | return data;
16 | };
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "private": true,
3 | "workspaces": [
4 | "apps/*",
5 | "packages/*"
6 | ],
7 | "scripts": {
8 | "dev": "turbo dev",
9 | "build": "turbo build",
10 | "start": "turbo start",
11 | "lint": "turbo lint"
12 | },
13 | "devDependencies": {
14 | "eslint": "^8.19.0",
15 | "eslint-config-custom": "*",
16 | "prettier": "^2.7.1",
17 | "prettier-plugin-tailwindcss": "^0.1.12",
18 | "turbo": "latest"
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/packages/ui/src/Icons/Open.js:
--------------------------------------------------------------------------------
1 | export const Open = ({ ...props }) => {
2 | return (
3 |
10 |
16 |
17 | );
18 | };
19 |
20 | export default Open;
--------------------------------------------------------------------------------
/apps/reflio/postcss.config.js:
--------------------------------------------------------------------------------
1 | // If you want to use other PostCSS plugins, see the following:
2 | // https://tailwindcss.com/docs/using-with-preprocessors
3 |
4 | const config = require("tailwind-config/tailwind.config.js").default;
5 |
6 | module.exports = {
7 | plugins: {
8 | // Specifying the config is not necessary in most cases, but it is included
9 | // here to share the same config across the entire monorepo
10 | tailwindcss: { config },
11 | autoprefixer: {},
12 | },
13 | };
--------------------------------------------------------------------------------
/apps/reflio/utils/stripe.js:
--------------------------------------------------------------------------------
1 | import Stripe from 'stripe';
2 |
3 | export const stripe = new Stripe(
4 | process.env.STRIPE_SECRET_KEY_LIVE ?? process.env.STRIPE_SECRET_KEY,
5 | {
6 | // https://github.com/stripe/stripe-node#configuration
7 | apiVersion: '2020-08-27',
8 | // Register this as an official Stripe plugin.
9 | // https://stripe.com/docs/building-plugins#setappinfo
10 | appInfo: {
11 | name: 'Reflio',
12 | version: '1.0.0'
13 | }
14 | }
15 | );
16 |
--------------------------------------------------------------------------------
/apps/reflio-affiliate/postcss.config.js:
--------------------------------------------------------------------------------
1 | // If you want to use other PostCSS plugins, see the following:
2 | // https://tailwindcss.com/docs/using-with-preprocessors
3 |
4 | const config = require("tailwind-config/tailwind.config.js").default;
5 |
6 | module.exports = {
7 | plugins: {
8 | // Specifying the config is not necessary in most cases, but it is included
9 | // here to share the same config across the entire monorepo
10 | tailwindcss: { config },
11 | autoprefixer: {},
12 | },
13 | };
--------------------------------------------------------------------------------
/apps/reflio/public/site.webmanifest:
--------------------------------------------------------------------------------
1 | {
2 | "name": "",
3 | "short_name": "",
4 | "icons": [
5 | {
6 | "src": "/android-chrome-192x192.png",
7 | "sizes": "192x192",
8 | "type": "image/png"
9 | },
10 | {
11 | "src": "/android-chrome-256x256.png",
12 | "sizes": "256x256",
13 | "type": "image/png"
14 | }
15 | ],
16 | "theme_color": "#ffffff",
17 | "background_color": "#ffffff",
18 | "display": "standalone"
19 | }
20 |
--------------------------------------------------------------------------------
/apps/reflio-affiliate/public/site.webmanifest:
--------------------------------------------------------------------------------
1 | {
2 | "name": "",
3 | "short_name": "",
4 | "icons": [
5 | {
6 | "src": "/android-chrome-192x192.png",
7 | "sizes": "192x192",
8 | "type": "image/png"
9 | },
10 | {
11 | "src": "/android-chrome-256x256.png",
12 | "sizes": "256x256",
13 | "type": "image/png"
14 | }
15 | ],
16 | "theme_color": "#ffffff",
17 | "background_color": "#ffffff",
18 | "display": "standalone"
19 | }
20 |
--------------------------------------------------------------------------------
/apps/reflio-affiliate/.gitignore:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2 |
3 | # dependencies
4 | /node_modules
5 | /.pnp
6 | .pnp.js
7 |
8 | # testing
9 | /coverage
10 |
11 | # next.js
12 | /.next/
13 | /.cache/
14 | /out/
15 |
16 | # production
17 | /build
18 |
19 | # misc
20 | .DS_Store
21 | *.pem
22 |
23 | # debug
24 | npm-debug.log*
25 | yarn-debug.log*
26 | yarn-error.log*
27 |
28 | # local env files
29 | .env.local
30 | .env.development.local
31 | .env.test.local
32 | .env.production.local
33 |
34 | # vercel
35 | .vercel
36 |
--------------------------------------------------------------------------------
/apps/reflio-affiliate/utils/email-builder-inner.js:
--------------------------------------------------------------------------------
1 | export default function emailBuilderInner(parsedDoc, type, subject, content, settings) {
2 | if(parsedDoc === null) return false;
3 |
4 | let templateEmail = parsedDoc.serialize(parsedDoc);
5 |
6 | if(type === 'invite'){
7 | templateEmail = templateEmail.replace(/{{subject}}/g, subject);
8 | templateEmail = templateEmail.replace(/{{content}}/g, content);
9 | templateEmail = templateEmail.replace(/{{inviteURL}}/g, `${process.env.NEXT_PUBLIC_SITE_URL}/dashboard`);
10 | }
11 |
12 |
13 | return templateEmail;
14 | }
--------------------------------------------------------------------------------
/packages/ui/src/Card.js:
--------------------------------------------------------------------------------
1 | export const Card = (props) => {
2 |
3 | let styles = 'shadow-lg rounded-xl max-w-3xl border-4';
4 |
5 | if(props.secondary){
6 | styles = styles + ' bg-secondary border-secondary-2';
7 | } else {
8 | styles = styles + ' bg-white border-gray-200';
9 | }
10 |
11 | if(props.className){
12 | styles = styles + ' ' + props.className;
13 | }
14 |
15 | return(
16 |
17 |
18 | {props.children}
19 |
20 |
21 | )
22 | };
23 |
24 | export default Card;
--------------------------------------------------------------------------------
/apps/reflio-affiliate/utils/email-builder-server.js:
--------------------------------------------------------------------------------
1 | import emailBuilderInner from '@/utils/email-builder-inner';
2 |
3 | export default function emailBuilderServer(type, subject, content, settings) {
4 | let emailType = 'default';
5 |
6 | if(type === 'invite'){
7 | emailType = 'inviteAffiliate';
8 | }
9 |
10 | const defaultEmail = require(`../emails/${emailType}.js`).default;
11 | let templateEmail = defaultEmail();
12 | const jsdom = require("jsdom").JSDOM;
13 | const parsedDoc = new jsdom(templateEmail);
14 |
15 | return emailBuilderInner(parsedDoc, type, subject, content, settings);
16 | }
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2 |
3 | # dependencies
4 | /node_modules
5 | /.pnp
6 | .pnp.js
7 |
8 | # testing
9 | /coverage
10 |
11 | # next.js
12 | /.next/
13 | /.cache/
14 | /out/
15 | .next/**
16 | dist/**
17 | build/**
18 |
19 | # production
20 | /build
21 |
22 | # misc
23 | .DS_Store
24 | *.pem
25 |
26 | # debug
27 | npm-debug.log*
28 | yarn-debug.log*
29 | yarn-error.log*
30 |
31 | # local env files
32 | .env
33 | .env.local
34 | .env.development.local
35 | .env.test.local
36 | .env.production.local
37 |
38 | # vercel
39 | .vercel
40 |
41 | #Turbo
42 | .turbo
43 |
--------------------------------------------------------------------------------
/apps/reflio/.gitignore:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2 |
3 | # dependencies
4 | /node_modules
5 | /.pnp
6 | .pnp.js
7 |
8 | # testing
9 | /coverage
10 |
11 | # next.js
12 | /.next/
13 | /.cache/
14 | /out/
15 |
16 | # production
17 | /build
18 |
19 | # misc
20 | .DS_Store
21 | *.pem
22 |
23 | # debug
24 | npm-debug.log*
25 | yarn-debug.log*
26 | yarn-error.log*
27 |
28 | # local env files
29 | .env.local
30 | .env.development.local
31 | .env.test.local
32 | .env.production.local
33 |
34 | # vercel
35 | .vercel
36 |
37 | # Sentry
38 | .sentryclirc
39 |
40 | # Sentry
41 | .sentryclirc
42 |
--------------------------------------------------------------------------------
/packages/ui/.gitignore:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2 |
3 | # dependencies
4 | /node_modules
5 | /.pnp
6 | .pnp.js
7 |
8 | # testing
9 | /coverage
10 |
11 | # next.js
12 | /.next/
13 | /.cache/
14 | /out/
15 |
16 | # production
17 | /build
18 |
19 | # misc
20 | .DS_Store
21 | *.pem
22 |
23 | # debug
24 | npm-debug.log*
25 | yarn-debug.log*
26 | yarn-error.log*
27 |
28 | # local env files
29 | .env.local
30 | .env.development.local
31 | .env.test.local
32 | .env.production.local
33 |
34 | # vercel
35 | .vercel
36 |
37 | # Sentry
38 | .sentryclirc
39 |
40 | # Sentry
41 | .sentryclirc
42 |
--------------------------------------------------------------------------------
/packages/tailwind-config/.gitignore:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2 |
3 | # dependencies
4 | /node_modules
5 | /.pnp
6 | .pnp.js
7 |
8 | # testing
9 | /coverage
10 |
11 | # next.js
12 | /.next/
13 | /.cache/
14 | /out/
15 |
16 | # production
17 | /build
18 |
19 | # misc
20 | .DS_Store
21 | *.pem
22 |
23 | # debug
24 | npm-debug.log*
25 | yarn-debug.log*
26 | yarn-error.log*
27 |
28 | # local env files
29 | .env.local
30 | .env.development.local
31 | .env.test.local
32 | .env.production.local
33 |
34 | # vercel
35 | .vercel
36 |
37 | # Sentry
38 | .sentryclirc
39 |
40 | # Sentry
41 | .sentryclirc
42 |
--------------------------------------------------------------------------------
/packages/ui/src/SimpleNav.js:
--------------------------------------------------------------------------------
1 | import { Logo } from './Icons/Logo';
2 | import Link from 'next/link';
3 | import { useUser } from '@/utils/useUser';
4 |
5 | export const SimpleNav = (props) => {
6 | const { signOut } = useUser();
7 |
8 | return(
9 |
10 |
11 |
12 |
13 | signOut()}
15 | href="#"
16 | className="underline text-lg"
17 | >
18 | Sign out
19 |
20 |
21 | )
22 | };
23 |
24 | export default SimpleNav;
--------------------------------------------------------------------------------
/packages/eslint-config-custom/.gitignore:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2 |
3 | # dependencies
4 | /node_modules
5 | /.pnp
6 | .pnp.js
7 |
8 | # testing
9 | /coverage
10 |
11 | # next.js
12 | /.next/
13 | /.cache/
14 | /out/
15 |
16 | # production
17 | /build
18 |
19 | # misc
20 | .DS_Store
21 | *.pem
22 |
23 | # debug
24 | npm-debug.log*
25 | yarn-debug.log*
26 | yarn-error.log*
27 |
28 | # local env files
29 | .env.local
30 | .env.development.local
31 | .env.test.local
32 | .env.production.local
33 |
34 | # vercel
35 | .vercel
36 |
37 | # Sentry
38 | .sentryclirc
39 |
40 | # Sentry
41 | .sentryclirc
42 |
--------------------------------------------------------------------------------
/apps/reflio/utils/email-builder-server.js:
--------------------------------------------------------------------------------
1 | import emailBuilderInner from './email-builder-inner';
2 |
3 | export default function emailBuilderServer(type, logoUrl, subject, content, settings, campaignId, companyHandle) {
4 | let emailType = 'default';
5 |
6 | if(type === 'invite'){
7 | emailType = 'inviteAffiliate';
8 | }
9 |
10 | const defaultEmail = require(`@/components/emails/${emailType}.js`).default;
11 | let templateEmail = defaultEmail();
12 | const jsdom = require("jsdom").JSDOM;
13 | const parsedDoc = new jsdom(templateEmail);
14 |
15 | return emailBuilderInner(parsedDoc, type, logoUrl, subject, content, settings, campaignId, companyHandle);
16 | }
--------------------------------------------------------------------------------
/apps/reflio/next.config.js:
--------------------------------------------------------------------------------
1 | require("dotenv").config({ path: "../../.env" });
2 |
3 | const withTM = require("next-transpile-modules")(["ui"]);
4 |
5 | if(process.env.SENTRY_AUTH_TOKEN){
6 | const { withSentryConfig } = require('@sentry/nextjs');
7 |
8 | const sentryWebpackPluginOptions = {
9 | authToken: process.env.SENTRY_AUTH_TOKEN,
10 | silent: true
11 | };
12 |
13 | module.exports = withTM(withSentryConfig({
14 | images: {
15 | domains: ['s2.googleusercontent.com'],
16 | },
17 | sentryWebpackPluginOptions
18 | }));
19 | } else {
20 | module.exports = withTM({
21 | images: {
22 | domains: ['s2.googleusercontent.com'],
23 | }
24 | });
25 | }
26 |
--------------------------------------------------------------------------------
/packages/ui/src/Icons/LoomIcon.js:
--------------------------------------------------------------------------------
1 | export const LoomIcon = ({ ...props }) => {
2 | return(
3 |
8 |
9 |
10 | );
11 | };
12 |
13 | export default LoomIcon;
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature_request.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Feature request
3 | about: Suggest an idea for this project
4 | title: ''
5 | labels: ''
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Is your feature request related to a problem? Please describe.**
11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12 |
13 | **Describe the solution you'd like**
14 | A clear and concise description of what you want to happen.
15 |
16 | **Describe alternatives you've considered**
17 | A clear and concise description of any alternative solutions or features you've considered.
18 |
19 | **Additional context**
20 | Add any other context or screenshots about the feature request here.
21 |
--------------------------------------------------------------------------------
/apps/reflio-affiliate/pages/_document.js:
--------------------------------------------------------------------------------
1 | import Document, { Html, Head, Main, NextScript } from 'next/document';
2 |
3 | class MyDocument extends Document {
4 | static async getInitialProps(ctx) {
5 | const initialProps = await Document.getInitialProps(ctx)
6 | return { ...initialProps }
7 | }
8 | render() {
9 | return (
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 | );
20 | }
21 | }
22 |
23 | export default MyDocument;
--------------------------------------------------------------------------------
/apps/reflio/utils/email-builder-inner.js:
--------------------------------------------------------------------------------
1 | export default function emailBuilderInner(parsedDoc, type, logoUrl, subject, content, settings, campaignId, companyHandle) {
2 | if(parsedDoc === null) return false;
3 |
4 | let templateEmail = parsedDoc.serialize(parsedDoc);
5 |
6 | if(type === 'invite'){
7 | templateEmail = templateEmail.replace(/{{logoUrl}}/g, logoUrl !== null ? logoUrl : 'https://reflio.com/reflio-logo.png');
8 | templateEmail = templateEmail.replace(/{{subject}}/g, subject);
9 | templateEmail = templateEmail.replace(/{{content}}/g, content);
10 | templateEmail = templateEmail.replace(/{{inviteURL}}/g, `${process.env.NEXT_PUBLIC_AFFILIATE_SITE_URL}/signup`);
11 | }
12 |
13 |
14 | return templateEmail;
15 | }
--------------------------------------------------------------------------------
/apps/reflio/types.ts:
--------------------------------------------------------------------------------
1 | import Stripe from 'stripe';
2 |
3 | export interface Product {
4 | id: string /* primary key */;
5 | active?: boolean;
6 | name?: string;
7 | description?: string;
8 | image?: string;
9 | metadata?: Stripe.Metadata;
10 | }
11 |
12 | export interface ProductWithPrice extends Product {
13 | prices?: Price[];
14 | }
15 |
16 | export interface Price {
17 | id: string;
18 | product_id?: string;
19 | active?: boolean;
20 | description?: string;
21 | unit_amount?: number;
22 | currency?: string;
23 | type?: Stripe.Price.Type;
24 | interval?: Stripe.Price.Recurring.Interval;
25 | interval_count?: number;
26 | trial_period_days?: number | null;
27 | metadata?: Stripe.Metadata;
28 | products?: Product;
29 | }
--------------------------------------------------------------------------------
/apps/reflio-affiliate/pages/api/public/campaign.js:
--------------------------------------------------------------------------------
1 | import { getPublicCampaign } from '@/utils/useDatabase';
2 |
3 | const publicCampaign = async (req, res) => {
4 | if (req.method === 'POST') {
5 | const { companyHandle, campaignId } = req.body;
6 |
7 | try {
8 |
9 | const campaign = await getPublicCampaign(companyHandle, campaignId);
10 |
11 | return res.status(200).json({ campaign });
12 |
13 | } catch (err) {
14 | console.log(err);
15 | res
16 | .status(500)
17 | .json({ error: { statusCode: 500, message: err.message } });
18 | }
19 | } else {
20 | res.setHeader('Allow', 'POST');
21 | res.status(405).end('Method Not Allowed');
22 | }
23 | };
24 |
25 | export default publicCampaign;
26 |
--------------------------------------------------------------------------------
/apps/reflio/utils/supabase-admin.js:
--------------------------------------------------------------------------------
1 | import { createClient } from '@supabase/supabase-js';
2 |
3 | export const supabaseAdmin = createClient(
4 | process.env.NEXT_PUBLIC_SUPABASE_URL,
5 | process.env.SUPABASE_SERVICE_ROLE_KEY
6 | );
7 |
8 | export const getUser = async (token) => {
9 | let dataToReturn = null;
10 |
11 | const { data, error } = await supabaseAdmin.auth.api.getUser(token);
12 |
13 | if (error) {
14 | throw error;
15 | }
16 |
17 | if(data){
18 | dataToReturn = data;
19 |
20 | const userData = await supabaseAdmin.from('users').select('*').eq('id', data?.id).single();
21 |
22 | if(userData?.data?.team_id){
23 | dataToReturn.team_id = userData?.data?.team_id;
24 | }
25 | }
26 |
27 | return dataToReturn;
28 | };
--------------------------------------------------------------------------------
/apps/reflio-affiliate/pages/dashboard/index.js:
--------------------------------------------------------------------------------
1 | import SEOMeta from '@/templates/SEOMeta';
2 | import AffiliateInvites from '@/components/AffiliateInvites';
3 | import CampaignsList from '@/components/CampaignsList';
4 |
5 | const DashboardPage = () => {
6 | return (
7 | <>
8 |
9 |
10 |
11 |
Dashboard
12 |
13 |
14 |
20 | >
21 | );
22 | };
23 |
24 | export default DashboardPage;
--------------------------------------------------------------------------------
/apps/reflio/sentry.client.config.js:
--------------------------------------------------------------------------------
1 | // This file configures the initialization of Sentry on the browser.
2 | // The config you add here will be used whenever a page is visited.
3 | // https://docs.sentry.io/platforms/javascript/guides/nextjs/
4 |
5 | import * as Sentry from '@sentry/nextjs';
6 |
7 | if(process.env.SENTRY_AUTH_TOKEN){
8 | Sentry.init({
9 | dsn: process.env.NEXT_PUBLIC_SENTRY_DSN,
10 | // Adjust this value in production, or use tracesSampler for greater control
11 | tracesSampleRate: 1.0,
12 | // ...
13 | // Note: if you want to override the automatic release value, do not set a
14 | // `release` value here - use the environment variable `SENTRY_RELEASE`, so
15 | // that it will also get attached to your source maps
16 | });
17 | }
18 |
--------------------------------------------------------------------------------
/.env.example:
--------------------------------------------------------------------------------
1 | #REQUIRED FOR BUILD
2 | NEXT_PUBLIC_SUPABASE_URL=
3 | NEXT_PUBLIC_SUPABASE_ANON_KEY=
4 | SUPABASE_SERVICE_ROLE_KEY=
5 | NEXT_PUBLIC_SITE_URL=http://localhost:3000
6 | NEXT_PUBLIC_AFFILIATE_SITE_URL=http://localhost:3001
7 |
8 | #Stripe - OPTIONAL / NOT REQUIRED FOR BUILD
9 | NEXT_PUBLIC_SUPABASE_STORAGE_URL=
10 | NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=
11 | STRIPE_SECRET_KEY=
12 | STRIPE_WEBHOOK_SECRET=
13 | STRIPE_CUSTOMER_WEBHOOK_SECRET=
14 | NEXT_PUBLIC_CLIENT_ID=
15 |
16 | #Mail - OPTIONAL / NOT REQUIRED FOR BUILD
17 | SIB_API_KEY=
18 |
19 | #Misc - OPTIONAL / NOT REQUIRED FOR BUILD
20 | NEXT_PUBLIC_SENTRY_DSN=
21 | SENTRY_AUTH_TOKEN=
22 | NEXT_PUBLIC_LOGSNAG_TOKEN=
23 |
24 | #AWS (DynamoDB) - OPTIONAL / NOT REQUIRED FOR BUILD
25 | AWS_ACCESS_KEY_ID=
26 | AWS_SECRET_ACCESS_KEY=
--------------------------------------------------------------------------------
/apps/reflio/pages/changelog.tsx:
--------------------------------------------------------------------------------
1 | import { SEOMeta } from '@/templates/SEOMeta';
2 |
3 | export const Changelog = () => {
4 | return(
5 | <>
6 |
7 |
8 |
9 |
10 |
Changelog
11 |
Your source for recent updates to Reflio
12 |
13 |
14 |
15 | No updates yet.
16 |
17 |
18 |
19 |
20 | >
21 | );
22 |
23 | }
24 |
25 | export default Changelog;
--------------------------------------------------------------------------------
/apps/reflio/sentry.server.config.js:
--------------------------------------------------------------------------------
1 | // This file configures the initialization of Sentry on the server.
2 | // The config you add here will be used whenever the server handles a request.
3 | // https://docs.sentry.io/platforms/javascript/guides/nextjs/
4 |
5 | import * as Sentry from '@sentry/nextjs';
6 |
7 | if(process.env.SENTRY_AUTH_TOKEN){
8 | Sentry.init({
9 | dsn: process.env.NEXT_PUBLIC_SENTRY_DSN,
10 | // Adjust this value in production, or use tracesSampler for greater control
11 | tracesSampleRate: 1.0,
12 | // ...
13 | // Note: if you want to override the automatic release value, do not set a
14 | // `release` value here - use the environment variable `SENTRY_RELEASE`, so
15 | // that it will also get attached to your source maps
16 | });
17 | }
18 |
--------------------------------------------------------------------------------
/apps/reflio/pages/api/affiliates/index.js:
--------------------------------------------------------------------------------
1 | import { supabaseAdmin } from '@/utils/supabase-admin';
2 |
3 | export default async function Endpoint(req, res) {
4 | const { data, error } = await supabaseAdmin
5 | .from('affiliates')
6 | .select('invite_email,name,vercel_username,affiliate_id')
7 | .not('name', 'is', null)
8 | .not('vercel_username', 'is', null)
9 | .eq('accepted', true)
10 | .neq('vercel_username', '');
11 | if (error) {
12 | console.error(error);
13 | res.status(500).json({ error: 'Internal server error.' });
14 | return;
15 | }
16 | res.json({
17 | affiliates: data.map((user) => {
18 | return {
19 | id: user.affiliate_id,
20 | name: user.name,
21 | username: user.vercel_username
22 | };
23 | })
24 | });
25 | }
26 |
--------------------------------------------------------------------------------
/apps/reflio/pages/api/get-account-details.js:
--------------------------------------------------------------------------------
1 | import { stripe } from '@/utils/stripe';
2 | import { withSentry } from '@sentry/nextjs';
3 |
4 | const getAccountDetails = async (req, res) => {
5 | if (req.method === 'POST') {
6 | try {
7 | const account = await stripe.accounts.retrieve({
8 | stripeAccount: req.body.accountId
9 | });
10 |
11 | return res.status(200).json({ data: account });
12 | } catch (err) {
13 | // console.log(err);
14 | res
15 | .status(500)
16 | .json({ error: { statusCode: 500, message: err.message } });
17 | }
18 | } else {
19 | res.setHeader('Allow', 'POST');
20 | res.status(405).end('Method Not Allowed');
21 | }
22 | };
23 |
24 | export default process.env.SENTRY_AUTH_TOKEN ? withSentry(getAccountDetails) : getAccountDetails;
--------------------------------------------------------------------------------
/apps/reflio/pages/dashboard/[companyId]/index.js:
--------------------------------------------------------------------------------
1 | import { useRouter } from 'next/router';
2 | import { useCompany } from '@/utils/CompanyContext';
3 | import LoadingTile from '@/components/LoadingTile';
4 | import { SEOMeta } from '@/templates/SEOMeta';
5 |
6 | export default function InnerDashboardPage() {
7 | const router = useRouter();
8 | const { activeCompany } = useCompany();
9 |
10 | if(activeCompany?.stripe_account_data === null || activeCompany?.stripe_id === null){
11 | router.replace(`/dashboard/${router?.query?.companyId}/setup`);
12 | } else {
13 | router.replace(`/dashboard/${router?.query?.companyId}/analytics`);
14 | }
15 |
16 | return (
17 | <>
18 |
19 |
20 |
21 |
22 | >
23 | );
24 | }
--------------------------------------------------------------------------------
/packages/ui/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es5",
4 | "lib": ["dom", "dom.iterable", "esnext"],
5 | "allowJs": true,
6 | "skipLibCheck": true,
7 | "strict": true,
8 | "forceConsistentCasingInFileNames": true,
9 | "noEmit": true,
10 | "esModuleInterop": true,
11 | "module": "esnext",
12 | "moduleResolution": "node",
13 | "resolveJsonModule": true,
14 | "isolatedModules": true,
15 | "jsx": "preserve",
16 | "incremental": true,
17 | "baseUrl": ".",
18 | "paths": {
19 | "@/components/*": ["./src/*"],
20 | "@/utils/*": ["../../apps/reflio/utils/*"],
21 | "@/affiliate-utils/*": ["../../apps/reflio-affiliate/utils/*"],
22 | }
23 | },
24 | "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", "**/*.js", "**/*.jsx", "src/AffiliateInvites.js"],
25 | "exclude": ["node_modules"]
26 | }
--------------------------------------------------------------------------------
/apps/reflio-affiliate/next-seo.config.js:
--------------------------------------------------------------------------------
1 | export default {
2 | title: 'Reflio: Create a privacy-friendly referral program for your SaaS.',
3 | description: 'Create a privacy-friendly referral program for your SaaS. GDPR Friendly. Based in the UK. European-owned infrastructure.',
4 | keywords: 'Reflio, Referral software, create referral program, stripe referral program',
5 | openGraph: {
6 | type: 'website',
7 | locale: 'en_GB',
8 | url: 'https://www.affiliates.reflio.com',
9 | site_name: 'Reflio',
10 | },
11 | twitter: {
12 | handle: '@useReflio',
13 | site: 'https://reflio.com',
14 | cardType: 'summary_large_image',
15 | },
16 | images: [
17 | {
18 | url: process.env.NEXT_PUBLIC_AFFILIATE_SITE_URL+'/og.pnf',
19 | width: 2400,
20 | height: 1350,
21 | alt: 'Og Image',
22 | type: 'image/png',
23 | }
24 | ]
25 | };
--------------------------------------------------------------------------------
/apps/reflio-affiliate/utils/supabase-client.js:
--------------------------------------------------------------------------------
1 | import { createClient } from '@supabase/supabase-js';
2 |
3 | export const supabase = createClient(
4 | process.env.NEXT_PUBLIC_SUPABASE_URL,
5 | process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY
6 | );
7 |
8 | export const getActiveProductsWithPrices = async () => {
9 | const { data, error } = await supabase
10 | .from('products')
11 | .select('*, prices(*)')
12 | .eq('active', true)
13 | .eq('prices.active', true)
14 | .order('metadata->index')
15 | .order('unit_amount', { foreignTable: 'prices' });
16 |
17 | if (error) {
18 | console.log(error.message);
19 | throw error;
20 | }
21 |
22 | return data || [];
23 | };
24 |
25 | export const updateUserName = async (user, name) => {
26 | await supabase
27 | .from('users')
28 | .update({
29 | full_name: name
30 | })
31 | .eq('id', user.id);
32 | };
33 |
--------------------------------------------------------------------------------
/apps/reflio/pages/api/get-stripe-id.js:
--------------------------------------------------------------------------------
1 | import { stripe } from '@/utils/stripe';
2 | import { withSentry } from '@sentry/nextjs';
3 |
4 | const getAccountIdFromToken = async (req, res) => {
5 | if (req.method === 'POST') {
6 | try {
7 | const response = await stripe.oauth.token({
8 | grant_type: 'authorization_code',
9 | code: req.body.stripeCode
10 | });
11 | console.log(response)
12 | return res.status(200).json({ stripe_id: response?.stripe_user_id });
13 | } catch (err) {
14 | // console.log(err);
15 | res
16 | .status(500)
17 | .json({ error: { statusCode: 500, message: err.message } });
18 | }
19 | } else {
20 | res.setHeader('Allow', 'POST');
21 | res.status(405).end('Method Not Allowed');
22 | }
23 | };
24 |
25 | export default process.env.SENTRY_AUTH_TOKEN ? withSentry(getAccountIdFromToken) : getAccountIdFromToken;
--------------------------------------------------------------------------------
/packages/ui/src/LoadingDots.js:
--------------------------------------------------------------------------------
1 | export const LoadingDots = ({ small }) => {
2 | return (
3 |
9 |
13 |
17 |
23 |
24 | );
25 | };
26 |
27 | export default LoadingDots;
--------------------------------------------------------------------------------
/packages/ui/src/StripeDisconnectNotice.js:
--------------------------------------------------------------------------------
1 | import { useCompany } from '@/utils/CompanyContext';
2 |
3 | export const StripeDisconnectNotice = (props) => {
4 | const { activeCompany } = useCompany();
5 |
6 | if(activeCompany && activeCompany !== null && activeCompany?.company_id && activeCompany?.stripe_id === null && activeCompany?.stripe_account_data !== null){
7 | return(
8 |
9 |
10 |
Your Stripe account is no longer connected and is not sending data. Please reconnect your account so that no data is missed, and referral data is tracked.
11 |
12 |
13 | )
14 | } else {
15 | return false;
16 | }
17 | };
18 |
19 | export default StripeDisconnectNotice;
--------------------------------------------------------------------------------
/apps/reflio/pages/api/subscribe.js:
--------------------------------------------------------------------------------
1 | import { withSentry } from '@sentry/nextjs';
2 |
3 | const emailSubscribe = async (req, res) => {
4 | if(!req.body.email) return false;
5 |
6 | if (req.method === 'POST') {
7 | const MailerLite = require('mailerlite-api-v2-node').default
8 | const mailerLite = MailerLite(process.env.MAILERLITE_KEY)
9 | const email = req.body.email;
10 |
11 | try {
12 | const result = await mailerLite.addSubscriber({email: email})
13 |
14 | return res.status(200).json({ result });
15 |
16 | } catch (err) {
17 | console.log(err);
18 | res
19 | .status(500)
20 | .json({ error: { statusCode: 500, message: err.message } });
21 | }
22 | } else {
23 | res.setHeader('Allow', 'POST');
24 | res.status(405).end('Method Not Allowed');
25 | }
26 | };
27 |
28 | export default process.env.SENTRY_AUTH_TOKEN ? withSentry(emailSubscribe) : emailSubscribe;
--------------------------------------------------------------------------------
/packages/ui/src/AdminNavbar/AdminDesktopNav.js:
--------------------------------------------------------------------------------
1 | import { Logo } from "@/components/Icons/Logo";
2 | import Link from "next/link";
3 | import { AdminNavItems } from "./AdminNavItems";
4 |
5 | export const AdminDesktopNav = () => {
6 | return (
7 | <>
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 | >
21 | );
22 | };
23 |
24 | export default AdminDesktopNav;
25 |
--------------------------------------------------------------------------------
/apps/reflio/pages/api/affiliates/[id]/edit.js:
--------------------------------------------------------------------------------
1 | import { supabaseAdmin } from '@/utils/supabase-admin';
2 |
3 | export default async function Endpoint(req, res) {
4 | const id = req.query.id;
5 | if (typeof id !== 'string') {
6 | return res.status(400).json({ error: 'Invalid id.' });
7 | }
8 | const {
9 | companyId,
10 | name,
11 | vercel_username,
12 | campaignId,
13 | inviteEmail
14 | } = req.body;
15 |
16 | //Update affiliate
17 | const { error } = await supabaseAdmin
18 | .from('affiliates')
19 | .update({
20 | name: name,
21 | vercel_username: vercel_username,
22 | invite_email: inviteEmail,
23 |
24 | })
25 | .eq('company_id', companyId)
26 | .eq('campaign_id', campaignId)
27 | .eq('vercel_username', id);
28 |
29 | if (error) {
30 | return res.status(500).json({ response: 'error' });
31 | }
32 |
33 | return res.status(200).json({ response: 'success' });
34 | }
--------------------------------------------------------------------------------
/apps/reflio/pages/commercial.tsx:
--------------------------------------------------------------------------------
1 | import { useEffect } from 'react';
2 | import { SEOMeta } from '@/templates/SEOMeta';
3 |
4 | export const Commercial = () => {
5 |
6 | useEffect(() => {
7 | const el = document.createElement('script')
8 | el.src = 'https://embed.reform.app/v1/embed.js'
9 | document.head.appendChild(el);
10 |
11 | el.onload = () => {
12 | if(typeof window.Reform !== 'undefined'){
13 | window.Reform('init', {
14 | url: 'https://forms.reform.app/45Dbqq/commercial/b04o3s',
15 | target: '#my-reform',
16 | })
17 | }
18 | }
19 | }, [])
20 |
21 | return(
22 | <>
23 |
24 |
31 | >
32 | );
33 | };
34 |
35 | export default Commercial;
--------------------------------------------------------------------------------
/apps/reflio-affiliate/pages/api/affiliate/campaigns.js:
--------------------------------------------------------------------------------
1 | import { getUser } from '@/utils/supabase-admin';
2 | import { getAffiliatePrograms } from '@/utils/useDatabase';
3 |
4 | const affiliatePrograms = async (req, res) => {
5 | if (req.method === 'POST') {
6 | const token = req.headers.token;
7 |
8 | try {
9 | const user = await getUser(token);
10 |
11 | if(user){
12 |
13 | const {affilateData} = await getAffiliatePrograms(user?.id);
14 |
15 | return res.status(200).json({ affilateData });
16 |
17 | } else {
18 | res.status(500).json({ error: { statusCode: 500, message: 'Not a valid UUID' } });
19 | }
20 | } catch (err) {
21 | console.log(err);
22 | res
23 | .status(500)
24 | .json({ error: { statusCode: 500, message: err.message } });
25 | }
26 | } else {
27 | res.setHeader('Allow', 'POST');
28 | res.status(405).end('Method Not Allowed');
29 | }
30 | };
31 |
32 | export default affiliatePrograms;
33 |
--------------------------------------------------------------------------------
/apps/reflio-affiliate/pages/api/affiliate/invites.js:
--------------------------------------------------------------------------------
1 | import { getUser } from '@/utils/supabase-admin';
2 | import { getAffiliateProgramInvites } from '@/utils/useDatabase';
3 |
4 | const affiliateInvites = async (req, res) => {
5 | if (req.method === 'POST') {
6 | const token = req.headers.token;
7 |
8 | try {
9 | const user = await getUser(token);
10 |
11 | if(user){
12 |
13 | const invites = await getAffiliateProgramInvites(user?.email);
14 |
15 | return res.status(200).json({ invites });
16 |
17 | } else {
18 | res.status(500).json({ error: { statusCode: 500, message: 'Not a valid UUID' } });
19 | }
20 | } catch (err) {
21 | console.log(err);
22 | res
23 | .status(500)
24 | .json({ error: { statusCode: 500, message: err.message } });
25 | }
26 | } else {
27 | res.setHeader('Allow', 'POST');
28 | res.status(405).end('Method Not Allowed');
29 | }
30 | };
31 |
32 | export default affiliateInvites;
33 |
--------------------------------------------------------------------------------
/apps/reflio-affiliate/pages/api/affiliate/referrals.js:
--------------------------------------------------------------------------------
1 | import { getUser } from '@/utils/supabase-admin';
2 | import { getAffiliateReferrals } from '@/utils/useDatabase';
3 |
4 | const affiliateReferrals = async (req, res) => {
5 | if (req.method === 'POST') {
6 | const token = req.headers.token;
7 |
8 | try {
9 | const user = await getUser(token);
10 |
11 | if(user){
12 |
13 | const { referralsData } = await getAffiliateReferrals(user?.id);
14 |
15 | return res.status(200).json({ referralsData });
16 |
17 | } else {
18 | res.status(500).json({ error: { statusCode: 500, message: 'Not a valid UUID' } });
19 | }
20 | } catch (err) {
21 | console.log(err);
22 | res
23 | .status(500)
24 | .json({ error: { statusCode: 500, message: err.message } });
25 | }
26 | } else {
27 | res.setHeader('Allow', 'POST');
28 | res.status(405).end('Method Not Allowed');
29 | }
30 | };
31 |
32 | export default affiliateReferrals;
--------------------------------------------------------------------------------
/apps/reflio/pages/_document.tsx:
--------------------------------------------------------------------------------
1 | import Document, { Head, Html, Main, NextScript } from 'next/document';
2 |
3 | class MyDocument extends Document {
4 | render() {
5 | return (
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 | );
22 | }
23 | }
24 |
25 | export default MyDocument;
--------------------------------------------------------------------------------
/apps/reflio-affiliate/pages/api/affiliate/commissions.js:
--------------------------------------------------------------------------------
1 | import { getUser } from '@/utils/supabase-admin';
2 | import { getAffiliateCommissions } from '@/utils/useDatabase';
3 |
4 | const affiliateCommissions= async (req, res) => {
5 | if (req.method === 'POST') {
6 | const token = req.headers.token;
7 |
8 | try {
9 | const user = await getUser(token);
10 |
11 | if(user){
12 |
13 | const { commissionsData } = await getAffiliateCommissions(user?.id);
14 |
15 | return res.status(200).json({ commissionsData });
16 |
17 | } else {
18 | res.status(500).json({ error: { statusCode: 500, message: 'Not a valid UUID' } });
19 | }
20 | } catch (err) {
21 | console.log(err);
22 | res
23 | .status(500)
24 | .json({ error: { statusCode: 500, message: err.message } });
25 | }
26 | } else {
27 | res.setHeader('Allow', 'POST');
28 | res.status(405).end('Method Not Allowed');
29 | }
30 | };
31 |
32 | export default affiliateCommissions;
--------------------------------------------------------------------------------
/apps/reflio-affiliate/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es5",
4 | "lib": ["dom", "dom.iterable", "esnext"],
5 | "allowJs": true,
6 | "skipLibCheck": true,
7 | "strict": true,
8 | "forceConsistentCasingInFileNames": true,
9 | "noEmit": true,
10 | "esModuleInterop": true,
11 | "module": "esnext",
12 | "moduleResolution": "node",
13 | "resolveJsonModule": true,
14 | "isolatedModules": true,
15 | "jsx": "preserve",
16 | "incremental": true,
17 | "baseUrl": ".",
18 | "paths": {
19 | "@/dist/*": ["../../packages/ui/dist/*"],
20 | "@/components/*": ["../../packages/ui/src/*"],
21 | "@/templates/*": ["./templates/*"],
22 | "@/utils/*": ["utils/*"],
23 | "@/affiliate-utils/*": ["utils/*"],
24 | "@/public/js/*": ["public/js/*"]
25 | }
26 | },
27 | "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", "**/*.js", "**/*.jsx", "../../packages/ui/src/AffiliateInvites.js"],
28 | "exclude": ["node_modules"]
29 | }
--------------------------------------------------------------------------------
/apps/reflio/pages/dashboard/team.js:
--------------------------------------------------------------------------------
1 | import SEOMeta from '@/templates/SEOMeta';
2 | import LoadingDots from '@/components/LoadingDots';
3 |
4 | export default function TeamPage() {
5 | return (
6 | <>
7 |
8 |
13 |
14 |
17 |
18 |
19 |
20 |
Team features are coming soon.
21 |
22 |
23 | >
24 | );
25 | }
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/bug_report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Bug report
3 | about: Create a report to help us improve
4 | title: ''
5 | labels: ''
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Describe the bug**
11 | A clear and concise description of what the bug is.
12 |
13 | **To Reproduce**
14 | Steps to reproduce the behavior:
15 | 1. Go to '...'
16 | 2. Click on '....'
17 | 3. Scroll down to '....'
18 | 4. See error
19 |
20 | **Expected behavior**
21 | A clear and concise description of what you expected to happen.
22 |
23 | **Screenshots**
24 | If applicable, add screenshots to help explain your problem.
25 |
26 | **Desktop (please complete the following information):**
27 | - OS: [e.g. iOS]
28 | - Browser [e.g. chrome, safari]
29 | - Version [e.g. 22]
30 |
31 | **Smartphone (please complete the following information):**
32 | - Device: [e.g. iPhone6]
33 | - OS: [e.g. iOS8.1]
34 | - Browser [e.g. stock browser, safari]
35 | - Version [e.g. 22]
36 |
37 | **Additional context**
38 | Add any other context about the problem here.
39 |
--------------------------------------------------------------------------------
/apps/reflio-affiliate/pages/api/affiliate/campaign-join.js:
--------------------------------------------------------------------------------
1 | import { getUser } from '@/utils/supabase-admin';
2 | import { handleCampaignJoin } from '@/utils/useDatabase';
3 |
4 | const campaignJoin = async (req, res) => {
5 | if (req.method === 'POST') {
6 | const token = req.headers.token;
7 | const { companyId, campaignId } = req.body;
8 |
9 | try {
10 | const user = await getUser(token);
11 |
12 | if(user){
13 | const status = await handleCampaignJoin(user, companyId, campaignId);
14 |
15 | return res.status(200).json({ status });
16 |
17 | } else {
18 | res.status(500).json({ error: { statusCode: 500, message: 'Not a valid UUID' } });
19 | }
20 | } catch (err) {
21 | console.log(err);
22 | res
23 | .status(500)
24 | .json({ error: { statusCode: 500, message: err.message } });
25 | }
26 | } else {
27 | res.setHeader('Allow', 'POST');
28 | res.status(405).end('Method Not Allowed');
29 | }
30 | };
31 |
32 | export default campaignJoin;
--------------------------------------------------------------------------------
/apps/reflio-affiliate/templates/AdminNavbar/AdminDesktopNav.js:
--------------------------------------------------------------------------------
1 | import Link from 'next/link';
2 | import { AffiliateLogo } from '@/components/Icons/AffiliateLogo';
3 | import { AdminNavItems } from '@/templates/AdminNavbar/AdminNavItems';
4 | import { VercelLogo } from '../VercelLogo';
5 |
6 | export const AdminDesktopNav = () => {
7 | return (
8 | <>
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 | >
22 | );
23 | };
24 |
25 | export default AdminDesktopNav;
26 |
--------------------------------------------------------------------------------
/apps/reflio/pages/api/affiliates/[id]/index.js:
--------------------------------------------------------------------------------
1 | import { supabaseAdmin } from '@/utils/supabase-admin';
2 |
3 | export default async function Endpoint(req, res) {
4 | const id = req.query.id;
5 | if (typeof id !== 'string') {
6 | res.status(400).json({ error: 'Invalid id.' });
7 | return;
8 | }
9 |
10 | const { data, error } = await supabaseAdmin
11 | .from('affiliates')
12 | .select('invite_email,name,vercel_username,affiliate_id')
13 | .not('name', 'is', null)
14 | .eq('vercel_username', id)
15 | .eq('accepted', true);
16 |
17 | if (error) {
18 | console.error(error);
19 | res.status(500).json({ error: 'Internal server error.' });
20 | return;
21 | }
22 |
23 | if (data.length === 0) {
24 | res.status(404).json({ error: 'Affiliate not found.' });
25 | return;
26 | }
27 |
28 | const affiliate = data[0];
29 |
30 | res.json({
31 | affiliate: {
32 | id: affiliate.affiliate_id,
33 | name: affiliate.name,
34 | username: affiliate.vercel_username
35 | }
36 | });
37 | }
38 |
--------------------------------------------------------------------------------
/apps/reflio/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es5",
4 | "lib": ["dom", "dom.iterable", "esnext"],
5 | "allowJs": true,
6 | "skipLibCheck": true,
7 | "strict": true,
8 | "forceConsistentCasingInFileNames": true,
9 | "noEmit": true,
10 | "esModuleInterop": true,
11 | "module": "esnext",
12 | "moduleResolution": "node",
13 | "resolveJsonModule": true,
14 | "isolatedModules": true,
15 | "jsx": "preserve",
16 | "incremental": true,
17 | "baseUrl": ".",
18 | "paths": {
19 | "@/dist/*": ["../../packages/ui/dist/*"],
20 | "@/components/*": ["../../packages/ui/src/*"],
21 | "@/templates/*": ["./templates/*"],
22 | "@/forms/*": ["./forms/*"],
23 | "@/utils/*": ["utils/*"],
24 | "@/affiliate-utils/*": ["../reflio-affiliate/utils/*"],
25 | "@/public/js/*": ["public/js/*"]
26 | },
27 | "typeRoots": ["./types"]
28 | },
29 | "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", "**/*.js", "**/*.jsx"],
30 | "exclude": ["node_modules"]
31 | }
--------------------------------------------------------------------------------
/apps/reflio-affiliate/pages/api/affiliate/handle-invite.js:
--------------------------------------------------------------------------------
1 | import { getUser } from '@/utils/supabase-admin';
2 | import { handleAffiliateInvite } from '@/utils/useDatabase';
3 |
4 | const handleInvite = async (req, res) => {
5 | if (req.method === 'POST') {
6 | const token = req.headers.token;
7 | const { handleType, affiliateId, username } = req.body;
8 |
9 | try {
10 | const user = await getUser(token);
11 |
12 | if(user){
13 |
14 | const status = await handleAffiliateInvite(user, handleType, affiliateId, username);
15 |
16 | return res.status(200).json({ status });
17 |
18 | } else {
19 | res.status(500).json({ error: { statusCode: 500, message: 'Not a valid UUID' } });
20 | }
21 | } catch (err) {
22 | console.log(err);
23 | res
24 | .status(500)
25 | .json({ error: { statusCode: 500, message: err.message } });
26 | }
27 | } else {
28 | res.setHeader('Allow', 'POST');
29 | res.status(405).end('Method Not Allowed');
30 | }
31 | };
32 |
33 | export default handleInvite;
--------------------------------------------------------------------------------
/apps/reflio/utils/supabase-client.ts:
--------------------------------------------------------------------------------
1 | import { createClient } from '@supabase/supabase-js';
2 | import { ProductWithPrice } from 'types';
3 |
4 | const supabaseUrl = String(process.env.NEXT_PUBLIC_SUPABASE_URL);
5 | const supabaseAnonKey = String(process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY);
6 |
7 | export const supabase = createClient(
8 | supabaseUrl,
9 | supabaseAnonKey
10 | );
11 |
12 | export const getActiveProductsWithPrices = async (): Promise< ProductWithPrice[] > => {
13 | const { data, error } = await supabase
14 | .from('products')
15 | .select('*, prices(*)')
16 | .eq('active', true)
17 | .eq('prices.active', true)
18 | .order('metadata->index')
19 | .order('unit_amount', { foreignTable: 'prices' });
20 |
21 | if (error) {
22 | console.log(error.message);
23 | throw error;
24 | }
25 |
26 | return (data as any) || [];
27 | };
28 |
29 | export const updateUserName = async (user: any, name: any) => {
30 | await supabase
31 | .from('users')
32 | .update({
33 | full_name: name
34 | })
35 | .eq('id', user.id);
36 | };
37 |
--------------------------------------------------------------------------------
/packages/ui/src/LoadingTile.js:
--------------------------------------------------------------------------------
1 | export const LoadingTile = () => {
2 | return (
3 |
4 |
5 |
11 |
15 |
19 |
25 |
26 |
27 |
28 | );
29 | };
30 |
31 | export default LoadingTile;
--------------------------------------------------------------------------------
/packages/ui/src/Icons/Github.js:
--------------------------------------------------------------------------------
1 | export const Github = ({ ...props }) => {
2 | return (
3 |
12 |
13 |
14 | )
15 | };
16 |
17 | export default Github;
--------------------------------------------------------------------------------
/apps/reflio/pages/api/team/usage.js:
--------------------------------------------------------------------------------
1 | import { getUser } from '@/utils/supabase-admin';
2 | import { billingUsageDetails } from '@/utils/useDatabase';
3 | import { withSentry } from '@sentry/nextjs';
4 |
5 | const teamUsage = async (req, res) => {
6 | if (req.method === 'POST') {
7 | const token = req.headers.token;
8 | const { teamId } = req.body;
9 |
10 | try {
11 | const user = await getUser(token);
12 |
13 | if(user){
14 | const data = await billingUsageDetails(teamId);
15 |
16 | if(data !== "error"){
17 | return res.status(200).json({ response: data });
18 | }
19 | }
20 |
21 | return res.status(500).json({ response: 'error' });
22 |
23 | } catch (err) {
24 | console.log(err);
25 | res
26 | .status(500)
27 | .json({ error: { statusCode: 500, message: err.message } });
28 | }
29 | } else {
30 | res.setHeader('Allow', 'POST');
31 | res.status(405).end('Method Not Allowed');
32 | }
33 | };
34 |
35 | export default process.env.SENTRY_AUTH_TOKEN ? withSentry(teamUsage) : teamUsage;
--------------------------------------------------------------------------------
/apps/reflio/public/safari-pinned-tab.svg:
--------------------------------------------------------------------------------
1 |
2 |
4 |
7 |
8 | Created by potrace 1.14, written by Peter Selinger 2001-2017
9 |
10 |
12 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/apps/reflio-affiliate/public/safari-pinned-tab.svg:
--------------------------------------------------------------------------------
1 |
2 |
4 |
7 |
8 | Created by potrace 1.14, written by Peter Selinger 2001-2017
9 |
10 |
12 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/apps/reflio-affiliate/pages/api/affiliate/company-assets.js:
--------------------------------------------------------------------------------
1 | import { getUser } from '@/utils/supabase-admin';
2 | import { getCompanyAssets } from '@/utils/useDatabase';
3 |
4 | const companyAssets = async (req, res) => {
5 | if (req.method === 'POST') {
6 | const token = req.headers.token;
7 | const { company_id, affiliate_id } = req.body;
8 |
9 | try {
10 | const user = await getUser(token);
11 |
12 | if(user){
13 |
14 | const assets = await getCompanyAssets(user?.id, affiliate_id, company_id);
15 |
16 | console.log('assets 2:')
17 | console.log(assets)
18 |
19 | return res.status(200).json({ assets: assets });
20 |
21 | } else {
22 | res.status(500).json({ error: { statusCode: 500, message: 'Not a valid UUID' } });
23 | }
24 | } catch (err) {
25 | console.log(err);
26 | res
27 | .status(500)
28 | .json({ error: { statusCode: 500, message: err.message } });
29 | }
30 | } else {
31 | res.setHeader('Allow', 'POST');
32 | res.status(405).end('Method Not Allowed');
33 | }
34 | };
35 |
36 | export default companyAssets;
--------------------------------------------------------------------------------
/apps/reflio/pages/api/team/invoice.js:
--------------------------------------------------------------------------------
1 | import { getUser } from '@/utils/supabase-admin';
2 | import { billingGenerateInvoice } from '@/utils/useDatabase';
3 | import { withSentry } from '@sentry/nextjs';
4 |
5 | const teamInvoice = async (req, res) => {
6 | if (req.method === 'POST') {
7 | const token = req.headers.token;
8 | const { currency, commissions } = req.body;
9 |
10 | try {
11 | const user = await getUser(token);
12 |
13 | if(user){
14 | const data = await billingGenerateInvoice(user, currency, commissions);
15 |
16 | if(data !== "error"){
17 | return res.status(200).json({ response: data });
18 | }
19 | }
20 |
21 | return res.status(500).json({ response: 'error' });
22 |
23 | } catch (err) {
24 | console.log(err);
25 | res
26 | .status(500)
27 | .json({ error: { statusCode: 500, message: err.message } });
28 | }
29 | } else {
30 | res.setHeader('Allow', 'POST');
31 | res.status(405).end('Method Not Allowed');
32 | }
33 | };
34 |
35 | export default process.env.SENTRY_AUTH_TOKEN ? withSentry(teamInvoice) : teamInvoice;
--------------------------------------------------------------------------------
/packages/ui/src/Icons/Twitter.js:
--------------------------------------------------------------------------------
1 | export const Twitter = ({ ...props }) => {
2 | return (
3 |
8 |
12 |
13 | );
14 | };
15 |
16 | export default Twitter;
--------------------------------------------------------------------------------
/apps/reflio/pages/dashboard/[companyId]/campaigns/new.js:
--------------------------------------------------------------------------------
1 | import { useRouter } from 'next/router';
2 | import CampaignForm from '@/forms/CampaignForm';
3 | import { SEOMeta } from '@/templates/SEOMeta';
4 | import Button from '@/components/Button';
5 | import {
6 | ArrowNarrowLeftIcon
7 | } from '@heroicons/react/outline';
8 |
9 | export default function CreateCampaignPage() {
10 | const router = useRouter();
11 |
12 | return (
13 | <>
14 |
15 |
16 |
17 |
18 |
23 |
24 | Back to campaigns
25 |
26 |
27 |
28 |
29 |
Create a new campaign
30 |
31 |
32 |
33 | >
34 | );
35 | }
--------------------------------------------------------------------------------
/apps/reflio/pages/api/v1/commission/create.js:
--------------------------------------------------------------------------------
1 | import { manualCommissionCreate } from '@/utils/useDatabase';
2 | import { withSentry } from '@sentry/nextjs';
3 |
4 | const createCommission = async (req, res) => {
5 | if (req.method === 'POST') {
6 | const { referralReference } = req.body;
7 | const trialPayment = req.body.trialPayment || false;
8 |
9 | try {
10 | const commission = await manualCommissionCreate(referralReference, {
11 | commission_sale_value: trialPayment === true ? '0' : '10',
12 | line_items: trialPayment === true ? 'Trial' : null
13 | });
14 |
15 | if (commission !== 'error') {
16 | return res.status(200).json({ response: commission });
17 | }
18 |
19 | return res.status(500).json({ response: 'error' });
20 | } catch (err) {
21 | console.log(err);
22 | res
23 | .status(500)
24 | .json({ error: { statusCode: 500, message: err.message } });
25 | }
26 | } else {
27 | res.setHeader('Allow', 'POST');
28 | res.status(405).end('Method Not Allowed');
29 | }
30 | };
31 |
32 | export default process.env.SENTRY_AUTH_TOKEN
33 | ? withSentry(createCommission)
34 | : createCommission;
35 |
--------------------------------------------------------------------------------
/apps/reflio/middleware.ts:
--------------------------------------------------------------------------------
1 | import { NextRequest, NextResponse } from 'next/server';
2 |
3 | const VERCEL_BYPASS_TOKEN = process.env.VERCEL_BYPASS_TOKEN;
4 | const VERCEL_BYPASS_PASSWORD = process.env.VERCEL_BYPASS_PASSWORD;
5 |
6 | if (!VERCEL_BYPASS_TOKEN || !VERCEL_BYPASS_PASSWORD)
7 | throw new Error('Vercel bypass token or password is not defined in env.');
8 |
9 | export const config = {
10 | matcher: ['/(.*)']
11 | };
12 |
13 | export function middleware(req: NextRequest) {
14 | const url = req.nextUrl;
15 | try {
16 | const auth = req.headers.get('authorization');
17 | if (auth) {
18 | const [authType, authValue] = auth.split(' ');
19 | if (authType === 'Basic') {
20 | const password = atob(authValue).split(':')[1];
21 | if (password && password === VERCEL_BYPASS_PASSWORD) {
22 | return NextResponse.next();
23 | }
24 | }
25 | if (authType === 'Bearer') {
26 | if (authValue && authValue === VERCEL_BYPASS_TOKEN) {
27 | return NextResponse.next();
28 | }
29 | }
30 | }
31 | } catch (e) {
32 | console.error(e);
33 | }
34 | url.pathname = '/api/auth';
35 | return NextResponse.rewrite(url);
36 | }
37 |
--------------------------------------------------------------------------------
/apps/reflio-affiliate/pages/_app.js:
--------------------------------------------------------------------------------
1 | /* eslint-disable react-hooks/exhaustive-deps */
2 | import { useEffect } from 'react';
3 | import "@/dist/styles.css";
4 | import Layout from '@/templates/Layout';
5 | import { useRouter } from 'next/router';
6 | import SEOMeta from '@/templates/SEOMeta';
7 | import { UserContextProvider } from '@/utils/useUser';
8 | import { UserAffiliateContextProvider } from '@/utils/UserAffiliateContext';
9 |
10 | export default function MyApp({ Component, pageProps }) {
11 | const router = useRouter();
12 |
13 | useEffect(() => {
14 | document.body.classList?.remove('loading');
15 |
16 | if(router?.asPath?.indexOf("&token_type=bearer&type=recovery") > 0) {
17 | let access_token = router?.asPath?.split("access_token=")[1].split("&")[0];
18 | router.push('/reset-password?passwordReset=true&access_token='+access_token+'');
19 | }
20 | }, []);
21 |
22 | return (
23 | <>
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 | >
33 | );
34 | }
--------------------------------------------------------------------------------
/apps/reflio/pages/api/v1/referral/manual-signup.js:
--------------------------------------------------------------------------------
1 | import { manualReferralSignup } from '@/utils/useDatabase';
2 | import { withSentry } from '@sentry/nextjs';
3 |
4 | const manualSignupReferral = async (req, res) => {
5 | if (req.method === 'POST') {
6 | // const token = req.headers.token;
7 | let body = req.body;
8 | try {
9 | body = JSON.parse(body);
10 | } catch (error) {
11 | console.log('Could not parse body');
12 | }
13 |
14 | try {
15 | const signup = await manualReferralSignup(
16 | body.referralIdentifier,
17 | body.referralId
18 | );
19 |
20 | if (signup !== 'error') {
21 | return res.status(200).json({ response: signup });
22 | }
23 |
24 | return res.status(500).json({ response: 'error' });
25 | } catch (err) {
26 | console.log(err);
27 | res
28 | .status(500)
29 | .json({ error: { statusCode: 500, message: err.message } });
30 | }
31 | } else {
32 | res.setHeader('Allow', 'POST');
33 | res.status(405).end('Method Not Allowed');
34 | }
35 | };
36 |
37 | export default process.env.SENTRY_AUTH_TOKEN
38 | ? withSentry(manualSignupReferral)
39 | : manualSignupReferral;
40 |
--------------------------------------------------------------------------------
/apps/reflio-affiliate/pages/api/affiliate/change-code.js:
--------------------------------------------------------------------------------
1 | import { getUser } from '@/utils/supabase-admin';
2 | import { changeReferralCode } from '@/utils/useDatabase';
3 |
4 | const changeCode = async (req, res) => {
5 | if (req.method === 'POST') {
6 | const token = req.headers.token;
7 | const { affiliateId, companyId, userCode } = req.body;
8 |
9 | if(!affiliateId || !companyId || !userCode){
10 | res.status(500).json({ error: { statusCode: 500, message: 'Invalid props' } });
11 | }
12 |
13 | try {
14 | const user = await getUser(token);
15 |
16 | if(user){
17 | const code = await changeReferralCode(user?.id, affiliateId, companyId, userCode);
18 |
19 | return res.status(200).json({ response: code });
20 |
21 | } else {
22 | res.status(500).json({ error: { statusCode: 500, message: 'Not a valid UUID' } });
23 | }
24 | } catch (err) {
25 | console.log(err);
26 | res
27 | .status(500)
28 | .json({ error: { statusCode: 500, message: err.message } });
29 | }
30 | } else {
31 | res.setHeader('Allow', 'POST');
32 | res.status(405).end('Method Not Allowed');
33 | }
34 | };
35 |
36 | export default changeCode;
--------------------------------------------------------------------------------
/apps/reflio/pages/api/create-portal-link.js:
--------------------------------------------------------------------------------
1 | import { stripe } from '@/utils/stripe';
2 | import { getUser } from '@/utils/supabase-admin';
3 | import { createOrRetrieveCustomer } from '@/utils/useDatabase';
4 | import { getURL } from '@/utils/helpers';
5 | import { withSentry } from '@sentry/nextjs';
6 |
7 | const createPortalLink = async (req, res) => {
8 | if (req.method === 'POST') {
9 | const token = req.headers.token;
10 |
11 | try {
12 | const user = await getUser(token);
13 | const customer = await createOrRetrieveCustomer({
14 | teamId: user.team_id,
15 | email: user.email
16 | });
17 |
18 | const { url } = await stripe.billingPortal.sessions.create({
19 | customer,
20 | return_url: `${getURL()}/dashboard`
21 | });
22 |
23 | return res.status(200).json({ url });
24 | } catch (err) {
25 | console.log(err);
26 | res
27 | .status(500)
28 | .json({ error: { statusCode: 500, message: err.message } });
29 | }
30 | } else {
31 | res.setHeader('Allow', 'POST');
32 | res.status(405).end('Method Not Allowed');
33 | }
34 | };
35 |
36 | export default process.env.SENTRY_AUTH_TOKEN ? withSentry(createPortalLink) : createPortalLink;
--------------------------------------------------------------------------------
/apps/reflio/pages/api/referrals/create.js:
--------------------------------------------------------------------------------
1 | import { getUser } from '@/utils/supabase-admin';
2 | import { referralCreate } from '@/utils/useDatabase';
3 | import { withSentry } from '@sentry/nextjs';
4 |
5 | const createReferral = async (req, res) => {
6 | if (req.method === 'POST') {
7 | const token = req.headers.token;
8 | const { companyId, campaignId, affiliateId, emailAddress, stripeAccountId, paymentIntentId } = req.body;
9 |
10 | try {
11 | const user = await getUser(token);
12 |
13 | if(user){
14 | const create = await referralCreate(user, companyId, campaignId, affiliateId, emailAddress, stripeAccountId, paymentIntentId);
15 |
16 | if(create !== "error"){
17 | return res.status(200).json({ response: create });
18 | }
19 | }
20 |
21 | return res.status(500).json({ response: 'error' });
22 |
23 | } catch (err) {
24 | console.log(err);
25 | res
26 | .status(500)
27 | .json({ error: { statusCode: 500, message: err.message } });
28 | }
29 | } else {
30 | res.setHeader('Allow', 'POST');
31 | res.status(405).end('Method Not Allowed');
32 | }
33 | };
34 |
35 | export default process.env.SENTRY_AUTH_TOKEN ? withSentry(createReferral) : createReferral;
--------------------------------------------------------------------------------
/apps/reflio/pages/api/embedData.js:
--------------------------------------------------------------------------------
1 | import { getCampaignData } from '@/utils/useDatabase';
2 | import Cors from 'cors';
3 | import { withSentry } from '@sentry/nextjs';
4 |
5 | // Initializing the cors middleware
6 | const cors = Cors({
7 | methods: ['HEAD', 'POST']
8 | });
9 |
10 | // Helper method to wait for a middleware to execute before continuing
11 | // And to throw an error when an error happens in a middleware
12 | function runMiddleware(req, res, fn) {
13 | return new Promise((resolve, reject) => {
14 | fn(req, res, (result) => {
15 | if (result instanceof Error) {
16 | return reject(result)
17 | }
18 |
19 | return resolve(result)
20 | })
21 | })
22 | }
23 |
24 | const embedData = async (req, res) => {
25 |
26 | // Run the middleware
27 | await runMiddleware(req, res, cors);
28 |
29 | const body = req.body;
30 |
31 | try {
32 |
33 | const embedData = await getCampaignData(body?.company_id);
34 |
35 | return res.json({ embed_data: embedData });
36 |
37 | } catch (error) {
38 |
39 | console.log(error);
40 |
41 | return res.status(500).json({ error: { statusCode: 500, error: true } });
42 |
43 | }
44 |
45 | };
46 |
47 | export default process.env.SENTRY_AUTH_TOKEN ? withSentry(embedData) : embedData;
--------------------------------------------------------------------------------
/apps/reflio/utils/sendEmail.js:
--------------------------------------------------------------------------------
1 | import emailBuilderServer from './email-builder-server';
2 |
3 | export const sendEmail = async (logoUrl, subject, content, to, type, settings, campaignId, companyHandle) => {
4 | const SibApiV3Sdk = require('sib-api-v3-sdk');
5 | let defaultClient = SibApiV3Sdk.ApiClient.instance;
6 | let apiKey = defaultClient.authentications['api-key'];
7 | apiKey.apiKey = process.env.SIB_API_KEY;
8 | let apiInstance = new SibApiV3Sdk.TransactionalEmailsApi();
9 | let sendSmtpEmail = new SibApiV3Sdk.SendSmtpEmail();
10 |
11 | const emailHtml = emailBuilderServer(type, logoUrl, subject, content, settings, campaignId, companyHandle);
12 |
13 | sendSmtpEmail.subject = subject;
14 | sendSmtpEmail.htmlContent = emailHtml;
15 | sendSmtpEmail.sender = {"name": settings, "email":"affiliate@reflio.com"};
16 | sendSmtpEmail.to = [{"email": to}];
17 |
18 | if(type === 'invite'){
19 | sendSmtpEmail.params = {"parameter":"AffiliateInvite","subject":"AffiliateInvite"};
20 | }
21 |
22 | await apiInstance.sendTransacEmail(sendSmtpEmail).then(function(data) {
23 | console.log('running email')
24 | return "success";
25 | }, function(error) {
26 | console.log(error);
27 | return "error";
28 | });
29 |
30 | return "success";
31 | };
--------------------------------------------------------------------------------
/packages/ui/src/Icons/DownArrow.js:
--------------------------------------------------------------------------------
1 | export const DownArrow = ({ ...props }) => {
2 | return(
3 |
13 |
14 |
15 |
16 |
17 | )
18 | };
19 |
20 | export default DownArrow;
--------------------------------------------------------------------------------
/apps/reflio-affiliate/templates/Auth.js:
--------------------------------------------------------------------------------
1 | /* eslint-disable react-hooks/exhaustive-deps */
2 | import { useRouter } from 'next/router';
3 | import { useEffect, useState } from 'react';
4 | import LoadingDots from '@/components/LoadingDots';
5 | import { useUser } from '@/utils/useUser';
6 | import { SEOMeta } from '@/templates/SEOMeta';
7 | import { AffiliateLogo } from '@/components/Icons/AffiliateLogo';
8 | import AuthForm from '@/components/AuthForm';
9 | import { VercelLogo } from './VercelLogo';
10 |
11 | const AuthTemplate = ({ type }) => {
12 | const router = useRouter();
13 | const { user } = useUser();
14 |
15 | let authState =
16 | type === 'signin' ? 'Sign in' : type === 'signup' ? 'Sign up' : 'Sign in';
17 |
18 | useEffect(() => {
19 | if (user) {
20 | router.replace('/dashboard');
21 | }
22 | }, [user]);
23 |
24 | if (!user)
25 | return (
26 | <>
27 |
35 | >
36 | );
37 |
38 | return (
39 | <>
40 |
41 |
42 |
43 | >
44 | );
45 | };
46 |
47 | export default AuthTemplate;
48 |
--------------------------------------------------------------------------------
/apps/reflio-affiliate/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "reflio-affiliate",
3 | "version": "1.0.0",
4 | "private": true,
5 | "scripts": {
6 | "dev": "next -p 3001",
7 | "build": "next build",
8 | "start": "next start"
9 | },
10 | "dependencies": {
11 | "@babel/preset-env": "^7.16.11",
12 | "@headlessui/react": "^1.4.0",
13 | "@heroicons/react": "^1.0.3",
14 | "@supabase/supabase-js": "^1.25.1",
15 | "@vercel/og": "^0.0.19",
16 | "add": "^2.0.6",
17 | "autoprefixer": "^10.4.2",
18 | "babel-plugin-static-fs": "^3.0.0",
19 | "chrome-aws-lambda": "^10.1.0",
20 | "dotenv": "^16.0.1",
21 | "eslint-config-custom": "*",
22 | "eslint-config-next": "^13.0.0",
23 | "next": "^13.0.0",
24 | "next-api-og-image": "^4.2.1",
25 | "next-transpile-modules": "^9.0.0",
26 | "postcss": "^8.4.4",
27 | "react": "^18.2.0",
28 | "react-copy-to-clipboard": "^5.1.0",
29 | "react-dom": "^18.2.0",
30 | "react-hot-toast": "^2.1.1",
31 | "tailwind-config": "*",
32 | "tailwindcss": "^3.0.22",
33 | "ui": "*",
34 | "yarn": "^1.22.11"
35 | },
36 | "prettier": {
37 | "arrowParens": "always",
38 | "singleQuote": true,
39 | "tabWidth": 2,
40 | "trailingComma": "none"
41 | },
42 | "engines": {
43 | "node": "^16"
44 | },
45 | "devDependencies": {
46 | "@types/node": "^18.11.0",
47 | "@types/react": "^18.0.21",
48 | "typescript": "^4.8.4"
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/apps/reflio-affiliate/pages/invite/[handle]/index.js:
--------------------------------------------------------------------------------
1 | import CampaignInvite from '@/templates/CampaignInvite';
2 | import { postData } from '@/utils/helpers';
3 | import SEOMeta from '@/templates/SEOMeta';
4 | import { useRouter } from 'next/router';
5 |
6 | function CampaignInviteIndex({ publicCampaignData }){
7 | const router = useRouter();
8 |
9 | let campaignImageUrl = `/api/public/campaign-image?companyHandle=${router?.query?.handle}`
10 |
11 | return(
12 | <>
13 |
18 |
19 | >
20 | )
21 | };
22 |
23 | export async function getServerSideProps({ query }) {
24 |
25 | const { handle } = query
26 |
27 | const { campaign } = await postData({
28 | url: `${process.env.NEXT_PUBLIC_AFFILIATE_SITE_URL}/api/public/campaign`,
29 | data: {
30 | "companyHandle": handle ? handle : null,
31 | "campaignId": null
32 | }
33 | });
34 |
35 | return { props: { publicCampaignData: campaign } }
36 | }
37 |
38 | export default CampaignInviteIndex;
--------------------------------------------------------------------------------
/packages/ui/src/Icons/Stripe.js:
--------------------------------------------------------------------------------
1 | export const Stripe = ({ ...props }) => {
2 | return (
3 |
12 |
17 |
18 | );
19 | };
20 |
21 | export default Stripe;
--------------------------------------------------------------------------------
/apps/reflio/templates/Auth.js:
--------------------------------------------------------------------------------
1 | /* eslint-disable react-hooks/exhaustive-deps */
2 | import { useRouter } from 'next/router';
3 | import { useEffect, useState } from 'react';
4 | import LoadingDots from '@/components/LoadingDots';
5 | import { useUser } from '@/utils/useUser';
6 | import { SEOMeta } from '@/templates/SEOMeta';
7 | import AuthForm from '@/components/AuthForm';
8 | import Testimonials from '@/components/Testimonials';
9 |
10 | const AuthTemplate = ({ type }) => {
11 | const router = useRouter();
12 | const { user } = useUser();
13 |
14 | let authState = type === 'signin' ? "Sign in" : type === "signup" ? "Sign up" : "Sign in";
15 |
16 | useEffect(() => {
17 | if (user) {
18 | router.replace('/dashboard');
19 | }
20 | }, [user]);
21 |
22 | if (!user)
23 | return (
24 | <>
25 |
26 |
31 |
36 | >
37 | );
38 |
39 | return (
40 | <>
41 |
42 |
43 |
44 |
45 | >
46 | );
47 | };
48 |
49 | export default AuthTemplate;
--------------------------------------------------------------------------------
/apps/reflio-affiliate/pages/invite/[handle]/[campaignId].js:
--------------------------------------------------------------------------------
1 | import CampaignInvite from '@/templates/CampaignInvite';
2 | import { postData } from '@/utils/helpers';
3 | import SEOMeta from '@/templates/SEOMeta';
4 | import { useRouter } from 'next/router';
5 |
6 | function CampaignInviteIndex({ publicCampaignData }){
7 | const router = useRouter();
8 |
9 | let campaignImageUrl = `/api/public/campaign-image?companyHandle=${router?.query?.handle}&campaignId=${router?.query?.campaignId}`
10 |
11 | return(
12 | <>
13 |
18 |
19 | >
20 | )
21 | };
22 |
23 | export async function getServerSideProps({ query }) {
24 |
25 | const { handle, campaignId } = query
26 |
27 | const { campaign } = await postData({
28 | url: `${process.env.NEXT_PUBLIC_AFFILIATE_SITE_URL}/api/public/campaign`,
29 | data: {
30 | "companyHandle": handle ? handle : null,
31 | "campaignId": campaignId ? campaignId : null
32 | }
33 | });
34 |
35 | return { props: { publicCampaignData: campaign } }
36 | }
37 |
38 |
39 | export default CampaignInviteIndex;
--------------------------------------------------------------------------------
/apps/reflio/pages/api/v1/signup-referral.js:
--------------------------------------------------------------------------------
1 | import { referralSignup } from '@/utils/useDatabase';
2 | import Cors from 'cors';
3 | import { withSentry } from '@sentry/nextjs';
4 |
5 | // Initializing the cors middleware
6 | const cors = Cors({
7 | methods: ['GET', 'POST', 'HEAD'],
8 | });
9 |
10 | // Helper method to wait for a middleware to execute before continuing
11 | // And to throw an error when an error happens in a middleware
12 | function runMiddleware(req, res, fn) {
13 | return new Promise((resolve, reject) => {
14 | fn(req, res, (result) => {
15 | if (result instanceof Error) {
16 | return reject(result)
17 | }
18 |
19 | return resolve(result)
20 | })
21 | })
22 | }
23 |
24 | const sigupReferral = async (req, res) => {
25 |
26 | // Run the middleware
27 | await runMiddleware(req, res, cors);
28 |
29 | let body = req.body;
30 | try {
31 | body = JSON.parse(body);
32 | } catch (error) {
33 | console.log("Could not parse body")
34 | }
35 |
36 | try {
37 | if(body?.referralId && body?.cookieDate && body?.email){
38 | const signup = await referralSignup(body?.referralId, body?.cookieDate, body?.email);
39 | return res.status(200).json({ statusCode: 200, signup_details: signup });
40 | }
41 |
42 | return res.status(500).json({ statusCode: 500 });
43 |
44 | } catch (error) {
45 | console.log(error);
46 | return res.status(500).json({ error: { statusCode: 500 } });
47 |
48 | }
49 | };
50 |
51 | export default process.env.SENTRY_AUTH_TOKEN ? withSentry(sigupReferral) : sigupReferral;
--------------------------------------------------------------------------------
/apps/reflio/pages/dashboard/[companyId]/campaigns/[campaignId]/edit.js:
--------------------------------------------------------------------------------
1 | import { useRouter } from 'next/router';
2 | import { useCampaign } from '@/utils/CampaignContext';
3 | import CampaignForm from '@/forms/CampaignForm';
4 | import { SEOMeta } from '@/templates/SEOMeta';
5 | import Button from '@/components/Button';
6 | import {
7 | ArrowNarrowLeftIcon
8 | } from '@heroicons/react/outline';
9 | import LoadingTile from '@/components/LoadingTile';
10 |
11 | export default function EditCampaignPage() {
12 | const router = useRouter();
13 | const { activeCampaign } = useCampaign();
14 |
15 | return (
16 | <>
17 |
18 |
19 |
20 |
21 |
26 |
27 | Back to campaigns
28 |
29 |
30 |
31 |
32 |
Edit campaign
33 | {
34 | activeCampaign !== null && activeCampaign !== 'none' ?
35 |
36 | :
37 |
38 |
39 |
40 | }
41 |
42 |
43 | >
44 | );
45 | }
--------------------------------------------------------------------------------
/apps/reflio/pages/api/v1/campaign-details.js:
--------------------------------------------------------------------------------
1 | import { campaignInfo } from 'utils/useDatabase';
2 | import Cors from 'cors';
3 | import { withSentry } from '@sentry/nextjs';
4 |
5 | // Initializing the cors middleware
6 | const cors = Cors({
7 | methods: ['GET', 'POST', 'HEAD'],
8 | });
9 |
10 | // Helper method to wait for a middleware to execute before continuing
11 | // And to throw an error when an error happens in a middleware
12 | function runMiddleware(req, res, fn) {
13 | return new Promise((resolve, reject) => {
14 | fn(req, res, (result) => {
15 | if (result instanceof Error) {
16 | return reject(result)
17 | }
18 |
19 | return resolve(result)
20 | })
21 | })
22 | }
23 |
24 | const campaignDetails = async (req, res) => {
25 |
26 | // Run the middleware
27 | await runMiddleware(req, res, cors);
28 |
29 | let body = req.body;
30 | try {
31 | body = JSON.parse(body);
32 | } catch (error) {
33 | console.log("Could not parse body")
34 | }
35 |
36 | try {
37 | if(body?.referralCode && body?.companyId){
38 | const details = await campaignInfo(body?.referralCode, body?.companyId);
39 | return res.status(200).json({ statusCode: 200, campaign_details: details });
40 | }
41 |
42 | return res.status(500).json({ statusCode: 500, verified: false });
43 |
44 | } catch (error) {
45 | console.log(error);
46 | return res.status(500).json({ error: { statusCode: 500, verified: false } });
47 |
48 | }
49 | };
50 |
51 | export default process.env.SENTRY_AUTH_TOKEN ? withSentry(campaignDetails) : campaignDetails;
--------------------------------------------------------------------------------
/apps/reflio/pages/api/v1/retrieve-referral.js:
--------------------------------------------------------------------------------
1 | import { getReferralFromId } from '@/utils/useDatabase';
2 | import Cors from 'cors';
3 | import { withSentry } from '@sentry/nextjs';
4 |
5 | // Initializing the cors middleware
6 | const cors = Cors({
7 | methods: ['GET', 'POST', 'HEAD'],
8 | });
9 |
10 | // Helper method to wait for a middleware to execute before continuing
11 | // And to throw an error when an error happens in a middleware
12 | function runMiddleware(req, res, fn) {
13 | return new Promise((resolve, reject) => {
14 | fn(req, res, (result) => {
15 | if (result instanceof Error) {
16 | return reject(result)
17 | }
18 |
19 | return resolve(result)
20 | })
21 | })
22 | }
23 |
24 | const retrieveReferral = async (req, res) => {
25 |
26 | // Run the middleware
27 | await runMiddleware(req, res, cors);
28 |
29 | let body = req.body;
30 | try {
31 | body = JSON.parse(body);
32 | } catch (error) {
33 | console.log("Could not parse body")
34 | }
35 |
36 | try {
37 | if(body?.referralId && body?.companyId){
38 | const retrieve = await getReferralFromId(body?.referralId, body?.companyId);
39 | return res.status(200).json({ statusCode: 200, referral_details: retrieve });
40 | }
41 |
42 | return res.status(500).json({ statusCode: 500, verified: false });
43 |
44 | } catch (error) {
45 | console.log(error);
46 | return res.status(500).json({ error: { statusCode: 500, verified: false } });
47 |
48 | }
49 | };
50 |
51 | export default process.env.SENTRY_AUTH_TOKEN ? withSentry(retrieveReferral) : retrieveReferral;
--------------------------------------------------------------------------------
/apps/reflio/pages/pricing.js:
--------------------------------------------------------------------------------
1 | import { useEffect, useState, useRef } from 'react';
2 | import Pricing from '@/components/Pricing';
3 | import { getActiveProductsWithPrices } from '@/utils/supabase-client';
4 | import { SEOMeta } from '@/templates/SEOMeta';
5 | import LoadingTile from '@/components/LoadingTile';
6 | import Features from '@/components/Features';
7 | import Testimonials from '@/components/Testimonials';
8 |
9 | export default function Products() {
10 |
11 | const [products, setProducts] = useState(null);
12 |
13 | const getProducts = async () => {
14 | setProducts(await getActiveProductsWithPrices());
15 | };
16 |
17 | useEffect(() => {
18 | {
19 | products == null &&
20 | getProducts();
21 | }
22 | }, [products]);
23 |
24 | return(
25 | <>
26 |
29 |
30 |
31 |
32 |
Pricing
33 |
34 |
35 | {
36 | products !== null ?
37 |
38 | :
39 |
40 |
41 |
42 | }
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 | >
53 | );
54 |
55 | }
--------------------------------------------------------------------------------
/apps/reflio/pages/_error.tsx:
--------------------------------------------------------------------------------
1 | /**
2 | * NOTE: This requires `@sentry/nextjs` version 7.3.0 or higher.
3 | *
4 | * NOTE: If using this with `next` version 12.2.0 or lower, uncomment the
5 | * penultimate line in `CustomErrorComponent`.
6 | *
7 | * This page is loaded by Nextjs:
8 | * - on the server, when data-fetching methods throw or reject
9 | * - on the client, when `getInitialProps` throws or rejects
10 | * - on the client, when a React lifecycle method throws or rejects, and it's
11 | * caught by the built-in Nextjs error boundary
12 | *
13 | * See:
14 | * - https://nextjs.org/docs/basic-features/data-fetching/overview
15 | * - https://nextjs.org/docs/api-reference/data-fetching/get-initial-props
16 | * - https://reactjs.org/docs/error-boundaries.html
17 | */
18 |
19 | import * as Sentry from '@sentry/nextjs';
20 | import { NextPageContext } from 'next';
21 | import NextErrorComponent from 'next/error';
22 |
23 | const CustomErrorComponent = (props: { statusCode: any; }) => {
24 | // If you're using a Nextjs version prior to 12.2.1, uncomment this to
25 | // compensate for https://github.com/vercel/next.js/issues/8592
26 | // Sentry.captureUnderscoreErrorException(props);
27 |
28 | return ;
29 | };
30 |
31 | CustomErrorComponent.getInitialProps = async (contextData: NextPageContext) => {
32 | // In case this is running in a serverless function, await this in order to give Sentry
33 | // time to send the error before the lambda exits
34 | await Sentry.captureUnderscoreErrorException(contextData);
35 |
36 | // This will contain the status code of the response
37 | return NextErrorComponent.getInitialProps(contextData);
38 | };
39 |
40 | export default CustomErrorComponent;
41 |
--------------------------------------------------------------------------------
/apps/reflio/pages/_error.wizardcopy.tsx:
--------------------------------------------------------------------------------
1 | /**
2 | * NOTE: This requires `@sentry/nextjs` version 7.3.0 or higher.
3 | *
4 | * NOTE: If using this with `next` version 12.2.0 or lower, uncomment the
5 | * penultimate line in `CustomErrorComponent`.
6 | *
7 | * This page is loaded by Nextjs:
8 | * - on the server, when data-fetching methods throw or reject
9 | * - on the client, when `getInitialProps` throws or rejects
10 | * - on the client, when a React lifecycle method throws or rejects, and it's
11 | * caught by the built-in Nextjs error boundary
12 | *
13 | * See:
14 | * - https://nextjs.org/docs/basic-features/data-fetching/overview
15 | * - https://nextjs.org/docs/api-reference/data-fetching/get-initial-props
16 | * - https://reactjs.org/docs/error-boundaries.html
17 | */
18 |
19 | import * as Sentry from '@sentry/nextjs';
20 | import { NextPageContext } from 'next';
21 | import NextErrorComponent from 'next/error';
22 |
23 | const CustomErrorComponent = (props: { statusCode: any; }) => {
24 | // If you're using a Nextjs version prior to 12.2.1, uncomment this to
25 | // compensate for https://github.com/vercel/next.js/issues/8592
26 | // Sentry.captureUnderscoreErrorException(props);
27 |
28 | return ;
29 | };
30 |
31 | CustomErrorComponent.getInitialProps = async (contextData: NextPageContext) => {
32 | // In case this is running in a serverless function, await this in order to give Sentry
33 | // time to send the error before the lambda exits
34 | await Sentry.captureUnderscoreErrorException(contextData);
35 |
36 | // This will contain the status code of the response
37 | return NextErrorComponent.getInitialProps(contextData);
38 | };
39 |
40 | export default CustomErrorComponent;
41 |
--------------------------------------------------------------------------------
/apps/reflio/pages/api/create-checkout-session.js:
--------------------------------------------------------------------------------
1 | import { stripe } from '@/utils/stripe';
2 | import { getUser } from '@/utils/supabase-admin';
3 | import { createOrRetrieveCustomer } from '@/utils/useDatabase';
4 | import { getURL } from '@/utils/helpers';
5 | import { withSentry } from '@sentry/nextjs';
6 |
7 | const createCheckoutSession = async (req, res) => {
8 | if (req.method === 'POST') {
9 | const token = req.headers.token;
10 | const { price, quantity = 1, metadata = {} } = req.body;
11 |
12 | try {
13 | const user = await getUser(token);
14 | const customer = await createOrRetrieveCustomer({
15 | id: user.id,
16 | teamId: user.team_id,
17 | email: user.email
18 | });
19 |
20 | const session = await stripe.checkout.sessions.create({
21 | payment_method_types: ['card'],
22 | billing_address_collection: 'required',
23 | customer,
24 | line_items: [
25 | {
26 | price,
27 | quantity
28 | }
29 | ],
30 | mode: 'subscription',
31 | allow_promotion_codes: true,
32 | subscription_data: {
33 | trial_from_plan: true,
34 | metadata
35 | },
36 | success_url: `${getURL()}/dashboard`,
37 | cancel_url: `${getURL()}/`
38 | });
39 |
40 | return res.status(200).json({ sessionId: session.id });
41 | } catch (err) {
42 | console.log(err);
43 | res
44 | .status(500)
45 | .json({ error: { statusCode: 500, message: err.message } });
46 | }
47 | } else {
48 | res.setHeader('Allow', 'POST');
49 | res.status(405).end('Method Not Allowed');
50 | }
51 | };
52 |
53 | export default process.env.SENTRY_AUTH_TOKEN ? withSentry(createCheckoutSession) : createCheckoutSession;
--------------------------------------------------------------------------------
/apps/reflio/templates/SEOMeta.tsx:
--------------------------------------------------------------------------------
1 | import Head from 'next/head';
2 |
3 | type SEOMetaProps = {
4 | title?: string;
5 | description?: string;
6 | keywords?: string;
7 | img?: string;
8 | }
9 |
10 | export const SEOMeta: React.FC = ({ title, description, keywords, img }) => {
11 |
12 | let setTitle = "Reflio: Create a privacy-friendly referral program for your SaaS.";
13 | let setDescription = "Create a privacy-friendly referral program for your SaaS. GDPR Friendly. Based in the UK. European-owned infrastructure.";
14 | let setKeywords = "Reflio, Referral software, create referral program, stripe referral program";
15 | let setImg = "/og.png";
16 |
17 | if(title){
18 | setTitle = title;
19 | }
20 |
21 | if(description){
22 | setDescription = description;
23 | }
24 |
25 | if(keywords){
26 | setKeywords = keywords;
27 | }
28 |
29 | if(img){
30 | setImg = img;
31 | }
32 |
33 | setTitle = setTitle + " | Reflio";
34 |
35 | return (
36 |
37 |
38 |
39 |
40 |
41 |
42 | {/* Twitter */}
43 |
44 |
45 |
46 | {/* Open Graph */}
47 |
48 |
49 |
50 |
51 |
52 | {setTitle}
53 |
54 | )
55 | };
56 |
57 | export default SEOMeta;
--------------------------------------------------------------------------------
/packages/ui/src/Icons/Google.js:
--------------------------------------------------------------------------------
1 | export const Google = ({ ...props }) => {
2 | return (
3 |
4 |
8 |
12 |
16 |
20 |
24 |
28 |
32 |
33 | )
34 | };
35 |
36 | export default Google;
--------------------------------------------------------------------------------
/packages/ui/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "ui",
3 | "version": "0.0.0",
4 | "main": "./dist/index.js",
5 | "types": "./dist/index.d.ts",
6 | "exports": {
7 | ".": "./dist",
8 | "./styles.css": "./dist/styles.css"
9 | },
10 | "scripts": {
11 | "build": "tailwindcss -i ./src/styles.css -o ./dist/styles.css",
12 | "dev": "tailwindcss -i ./src/styles.css -o ./dist/styles.css --watch",
13 | "clean": "rm -rf dist"
14 | },
15 | "dependencies": {
16 | "@babel/preset-env": "^7.16.11",
17 | "@headlessui/react": "^1.4.0",
18 | "@heroicons/react": "^1.0.3",
19 | "@stripe/stripe-js": "1.11.0",
20 | "@supabase/supabase-js": "^1.25.1",
21 | "add": "^2.0.6",
22 | "autoprefixer": "^10.4.2",
23 | "babel-plugin-static-fs": "^3.0.0",
24 | "classnames": "2.2.6",
25 | "concurrently": "^7.2.2",
26 | "cors": "^2.8.5",
27 | "eslint": "^8.19.0",
28 | "eslint-config-custom": "*",
29 | "file-loader": "^6.2.0",
30 | "html-loader": "^3.0.0",
31 | "jsdom": "^19.0.0",
32 | "mailerlite-api-v2-node": "^1.2.0",
33 | "next": "13.0.0",
34 | "next-remove-imports": "^1.0.6",
35 | "next-transpile-modules": "^9.0.0",
36 | "parcel-bundler": "^1.12.5",
37 | "react": "^18.2.0",
38 | "react-3d-hover": "^1.1.1",
39 | "react-code-blocks": "^0.0.9-0",
40 | "react-confetti": "^6.0.1",
41 | "react-copy-to-clipboard": "^5.1.0",
42 | "react-dom": "^18.2.0",
43 | "react-hot-toast": "^2.1.1",
44 | "react-tooltip": "^4.2.21",
45 | "react-use": "^17.3.2",
46 | "sass-loader": "^12.2.0",
47 | "sib-api-v3-sdk": "^8.3.0",
48 | "stripe": "8.132.0",
49 | "swr": "0.4.0",
50 | "tailwind-config": "*",
51 | "tailwindcss": "^3.0.22",
52 | "yarn": "^1.22.11"
53 | },
54 | "devDependencies": {
55 | "@types/node": "^18.11.0",
56 | "@types/react": "^18.0.21",
57 | "typescript": "^4.8.4"
58 | },
59 | "engines": {
60 | "node": "^16"
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Reflio
6 |
7 | Create an affiliate program for your SaaS in minutes, from $0/month.
8 |
9 | Reflio »
10 |
11 | > NOTE: Reflio is under active development and is currently in public beta .
12 |
13 | Reflio puts digital privacy first and is proudly open-source. All referrals are processed through European-owned infrastructure, and our company is registered in the UK.
14 |
15 |
16 |
17 |
18 |
19 | ## Features / USPs
20 |
21 | - Start an affiliate program in minutes
22 | - Track referrals for Stripe subscriptions or one-time payments
23 | - Automatic payment/refund sync from Stripe
24 | - Cross sub-domain tracking
25 | - Automated GDPR & Privacy compliance for users located in the EU
26 | - Fast embed script (<13kb)
27 | - Free plan available. Pricing from $0/month (with a 9% commission fee)
28 | - One central dashboard for your affiliates
29 | - Get your own customizable affiliate signup page
30 |
31 | ## Contributing / Developer Guide
32 |
33 | All contributions are greatly appreciated. Please see our [Contributing Guide](https://github.com/Reflio-com/reflio/blob/main/CONTRIBUTING.md).
34 |
35 | ## License
36 |
37 | This repository is licensed under [AGPLv3](https://github.com/Reflio-com/reflio/blob/main/LICENSE). To comply with AGPLv3, if you plan to distribute our codebase, please keep the source code public, in a public repository. If you are cloning the code into a private repository (non-public access), and the code is also being used for commercial purposes, please [acquire a commercial license here](https://reflio.com/commercial).
38 |
--------------------------------------------------------------------------------
/packages/ui/src/Footer.js:
--------------------------------------------------------------------------------
1 | import { Logo } from '@/components/Icons/Logo';
2 | import { Github } from '@/components/Icons/Github';
3 |
4 | export const Footer = () => {
5 | return (
6 |
7 |
10 |
11 |
12 |
13 |
14 |
15 | Create a privacy-friendly affiliate program for your SaaS in minutes, from $0 month.
16 |
17 |
18 |
26 |
27 |
28 |
© 2022 Reflio (McIlroy Limited).
29 |
35 |
36 |
37 |
38 | );
39 | }
40 |
41 | export default Footer;
--------------------------------------------------------------------------------
/apps/reflio/utils/CampaignContext.js:
--------------------------------------------------------------------------------
1 | import { useRouter } from 'next/router';
2 | import { useState, useEffect, createContext, useContext } from 'react';
3 | import { getCampaigns, useUser } from './useUser';
4 | import { useCompany } from './CompanyContext';
5 |
6 | export const CampaignContext = createContext();
7 |
8 | export const CampaignContextProvider = (props) => {
9 | const { user, userFinderLoaded } = useUser();
10 | const { activeCompany } = useCompany();
11 | const [userCampaignDetails, setUserCampaignDetails] = useState(null);
12 | const [activeCampaign, setActiveCampaign] = useState('none');
13 | const router = useRouter();
14 | let value;
15 |
16 | useEffect(() => {
17 | if (userFinderLoaded && getCampaigns && user && userCampaignDetails === null && activeCompany?.company_id) {
18 | getCampaigns(activeCompany?.company_id).then(results => {
19 | setUserCampaignDetails(Array.isArray(results) ? results : [results])
20 |
21 | let newActiveCampaign = null;
22 |
23 | if(router?.query?.campaignId && results?.filter(campaign => campaign?.campaign_id === router?.query?.campaignId)?.length && activeCampaign === 'none' && results){
24 | newActiveCampaign = results?.filter(campaign => campaign?.campaign_id === router?.query?.campaignId);
25 | if( Array.isArray(newActiveCampaign) && newActiveCampaign !== null){
26 | newActiveCampaign = newActiveCampaign[0];
27 | }
28 | }
29 |
30 | if(newActiveCampaign !== null){
31 | setActiveCampaign(newActiveCampaign);
32 | } else {
33 | setActiveCampaign(null);
34 | }
35 | });
36 | }
37 | });
38 |
39 | value = {
40 | activeCampaign,
41 | userCampaignDetails
42 | };
43 |
44 | return ;
45 | }
46 |
47 | export const useCampaign = () => {
48 | const context = useContext(CampaignContext);
49 | if (context === undefined) {
50 | throw new Error(`useUser must be used within a CampaignsContextProvider.`);
51 | }
52 | return context;
53 | };
--------------------------------------------------------------------------------
/packages/ui/src/Button.js:
--------------------------------------------------------------------------------
1 | import dynamic from 'next/dynamic';
2 |
3 | export const Button = (props) => {
4 | const Link = dynamic(() => import('next/link'));
5 |
6 | let styles = 'relative inline-flex items-center justify-center font-semibold rounded-full focus:outline-none focus:ring-2 focus:ring-offset-2 transition-all';
7 |
8 | //Sizing styles
9 | if(props.small){
10 | styles = styles + ' px-4 py-2 text-sm md:text-base'
11 | } else if(props.xsmall){
12 | styles = styles + ' px-4 py-2 text-sm md:text-xs'
13 | } else if(props.medium){
14 | styles = styles + ' px-6 py-3 text-sm md:text-lg'
15 | } else if(props.xlarge){
16 | styles = styles + ' px-8 py-4 text-sm md:text-2xl'
17 | } else {
18 | styles = styles + ' px-8 py-3 text-sm md:text-xl'
19 | }
20 |
21 | //Color styles
22 | if(props.secondary){
23 | styles = styles + ' text-white bg-secondary hover:bg-secondary-2'
24 | } else if(props.gray){
25 | styles = styles + ' text-gray-800 bg-gray-300 hover:bg-gray-400'
26 | } else if(props.white){
27 | styles = styles + ' bg-white hover:bg-gray-100'
28 | } else if(props.red){
29 | styles = styles + ' text-white bg-red-500 hover:bg-red-600'
30 | } else {
31 | styles = styles + ' bg-primary hover:bg-primary-2'
32 | }
33 |
34 | if(props.mobileFull){
35 | styles = styles + ' w-full sm:w-auto x'
36 | }
37 |
38 | if(props.href){
39 | return(
40 |
47 | {props.children && props.children}
48 |
49 | )
50 | } else {
51 | return(
52 |
57 | {props.children && props.children}
58 |
59 | )
60 | }
61 | };
62 |
63 | export default Button;
--------------------------------------------------------------------------------
/apps/reflio/pages/api/v1/verify-company.js:
--------------------------------------------------------------------------------
1 | import { getCompanyFromExternal } from '@/utils/useDatabase';
2 | import Cors from 'cors';
3 | import { withSentry } from '@sentry/nextjs';
4 |
5 | // Initializing the cors middleware
6 | const cors = Cors({
7 | methods: ['GET', 'HEAD'],
8 | });
9 |
10 | // Helper method to wait for a middleware to execute before continuing
11 | // And to throw an error when an error happens in a middleware
12 | function runMiddleware(req, res, fn) {
13 | return new Promise((resolve, reject) => {
14 | fn(req, res, (result) => {
15 | if (result instanceof Error) {
16 | return reject(result)
17 | }
18 |
19 | return resolve(result)
20 | })
21 | })
22 | }
23 |
24 | const verifyCompany = async (req, res) => {
25 |
26 | // Run the middleware
27 | await runMiddleware(req, res, cors);
28 |
29 | const headers = req.headers;
30 | const body = req.body;
31 | let filteredReferer = null;
32 |
33 | if(headers?.origin) {
34 | filteredReferer = headers.origin.replace(/(^\w+:|^)\/\//, '').replace('www.', '');
35 |
36 | } else if(headers?.host) {
37 | filteredReferer = headers.host.replace(/(^\w+:|^)\/\//, '').replace('www.', '');
38 |
39 | } else {
40 | return res.status(500).json({ statusCode: 500, referer: false, error: "No host or origin" });
41 | }
42 |
43 | try {
44 | if(filteredReferer !== null){
45 |
46 | const projectVerify = await getCompanyFromExternal(filteredReferer);
47 |
48 | if(projectVerify === "success"){
49 | return res.status(200).json({ statusCode: 200, verified: true });
50 |
51 | } else {
52 | return res.status(500).json({ statusCode: 500, error: projectVerify });
53 |
54 | }
55 | }
56 |
57 | return res.status(500).json({ statusCode: 500, verified: false, referer: filteredReferer });
58 |
59 | } catch (error) {
60 | console.log(error);
61 | return res.status(500).json({ error: { statusCode: 500, verified: false, referer: filteredReferer } });
62 |
63 | }
64 | };
65 |
66 | export default process.env.SENTRY_AUTH_TOKEN ? withSentry(verifyCompany) : verifyCompany;
--------------------------------------------------------------------------------
/packages/ui/src/DueCommissions.js:
--------------------------------------------------------------------------------
1 | import { useState } from 'react';
2 | import { getSales } from '@/utils/useUser';
3 | import { useCompany } from '@/utils/CompanyContext';
4 | import { checkUTCDateExpired } from '@/utils/helpers';
5 | import { ExclamationIcon } from '@heroicons/react/solid';
6 | import { useRouter } from 'next/router';
7 | import LoadingDots from '@/components/LoadingDots';
8 |
9 | export const DueCommissions = (props) => {
10 | const { activeCompany } = useCompany();
11 | const [commissions, setCommissions] = useState([]);
12 | const router = useRouter();
13 |
14 | if(commissions?.length === 0 && activeCompany?.company_id){
15 | getSales(activeCompany?.company_id, null, "due").then(results => {
16 | console.log(results);
17 |
18 | if(results !== "error" && results?.data?.length){
19 | setCommissions(results);
20 | }
21 |
22 | if(results === "error"){
23 | console.warn("There was an error when getting data");
24 | }
25 |
26 | if(results?.data?.length === 0){
27 | setCommissions({"data": [], "count": 0});
28 | }
29 | })
30 | }
31 |
32 | if(commissions?.data?.filter(commission => commission?.paid_at === null && checkUTCDateExpired(commission?.commission_due_date) === true)?.length > 0){
33 | return (
34 |
44 | );
45 | } else {
46 | return false;
47 | }
48 | };
49 |
50 | export default DueCommissions;
--------------------------------------------------------------------------------
/apps/reflio/utils/setupStepCheck.js:
--------------------------------------------------------------------------------
1 | import { useRouter } from 'next/router';
2 | import { useCompany } from './CompanyContext';
3 | import { useCampaign } from './CampaignContext';
4 |
5 | export default function setupStepCheck(type) {
6 | const router = useRouter();
7 | const { activeCompany } = useCompany();
8 | const { userCampaignDetails } = useCampaign();
9 |
10 | const replaceUrl = (url) => {
11 | if(router.asPath === `/dashboard/${router?.query?.companyId}${url}`) return false;
12 |
13 | console.log('ok')
14 | console.log(`/dashboard/${router?.query?.companyId}${url}`)
15 |
16 | router.replace(`/dashboard/${router?.query?.companyId}${url}`);
17 | }
18 |
19 | if(activeCompany){
20 | if(type === 'light'){
21 | if(activeCompany?.stripe_account_data === null || activeCompany?.stripe_id === null){
22 | replaceUrl('/setup/stripe');
23 | }
24 |
25 | if(activeCompany?.stripe_account_data !== null && activeCompany?.stripe_id !== null && activeCompany?.company_currency === null){
26 | replaceUrl('/setup/currency');
27 | }
28 |
29 | } else {
30 | if(activeCompany?.stripe_account_data === null || activeCompany?.stripe_id === null){
31 | replaceUrl('/setup/stripe');
32 | }
33 |
34 | if(activeCompany?.stripe_account_data !== null && activeCompany?.stripe_id !== null && activeCompany?.company_currency === null){
35 | replaceUrl('/setup/currency');
36 | }
37 |
38 | if(activeCompany?.stripe_account_data !== null && activeCompany?.stripe_id !== null && activeCompany?.company_currency !== null && userCampaignDetails?.length === 0){
39 | replaceUrl('/setup/campaign');
40 | }
41 |
42 | if(activeCompany?.stripe_account_data !== null && activeCompany?.stripe_id !== null && activeCompany?.company_currency !== null && userCampaignDetails !== null && userCampaignDetails?.length > 0 && activeCompany?.domain_verified !== true){
43 | replaceUrl('/setup/add');
44 | }
45 |
46 | if(activeCompany?.domain_verified === true){
47 | replaceUrl('/setup/verify');
48 | }
49 | }
50 | }
51 | }
--------------------------------------------------------------------------------
/apps/reflio-affiliate/templates/CampaignInvite.js:
--------------------------------------------------------------------------------
1 | /* eslint-disable @next/next/no-img-element */
2 | import { useState } from 'react';
3 | import { useRouter } from 'next/router';
4 | import { useUser } from '@/utils/useUser';
5 | import { useUserAffiliate } from '@/utils/UserAffiliateContext';
6 | import {
7 | ArrowNarrowLeftIcon
8 | } from '@heroicons/react/outline';
9 | import CampaignInvitePageBlock from '@/components/CampaignInvitePageBlock';
10 |
11 | export default function CampaignInvite({ publicCampaignData }) {
12 | const router = useRouter();
13 | const { user, session } = useUser();
14 | const { userAffiliateDetails } = useUserAffiliate();
15 | const [loading, setLoading] = useState(false);
16 | const [campaignAlreadyJoined, setCampaignAlreadyJoined] = useState(false);
17 |
18 | if(campaignAlreadyJoined === false && user && publicCampaignData !== null && userAffiliateDetails !== null && userAffiliateDetails?.length > 0 && JSON.stringify(userAffiliateDetails).includes(publicCampaignData?.campaign_id)){
19 | setCampaignAlreadyJoined(true);
20 | }
21 |
22 | if(router?.asPath.includes('campaignRedirect=true')){
23 | if (typeof window !== "undefined") {
24 | localStorage.removeItem('join_campaign_details');
25 | }
26 | }
27 |
28 | return(
29 | <>
30 |
31 | {
32 | user &&
33 |
41 | }
42 |
43 |
51 |
52 |
53 | >
54 | )
55 | }
--------------------------------------------------------------------------------
/apps/reflio/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "reflio",
3 | "version": "1.0.0",
4 | "private": true,
5 | "scripts": {
6 | "dev": "next dev",
7 | "build": "next build",
8 | "start": "next start",
9 | "js": "uglifyjs ./scripts/reflio.js -c --mangle --no-annotations --webkit -o ./public/js/reflio.min.js"
10 | },
11 | "dependencies": {
12 | "@babel/preset-env": "^7.16.11",
13 | "@headlessui/react": "^1.4.0",
14 | "@heroicons/react": "^1.0.3",
15 | "@sentry/nextjs": "^7.8.1",
16 | "@stripe/stripe-js": "1.11.0",
17 | "@supabase/supabase-js": "^1.25.1",
18 | "@tremor/react": "^1.8.0",
19 | "add": "^2.0.6",
20 | "autoprefixer": "^10.4.2",
21 | "babel-plugin-static-fs": "^3.0.0",
22 | "classnames": "2.2.6",
23 | "cors": "^2.8.5",
24 | "dotenv": "^16.0.1",
25 | "eslint-config-custom": "*",
26 | "eslint-config-next": "^13.0.0",
27 | "file-loader": "^6.2.0",
28 | "html-loader": "^3.0.0",
29 | "jsdom": "^19.0.0",
30 | "mailerlite-api-v2-node": "^1.2.0",
31 | "next": "^13.0.0",
32 | "next-remove-imports": "^1.0.6",
33 | "next-transpile-modules": "^9.0.0",
34 | "node-fetch": "2.6.1",
35 | "parcel-bundler": "^1.12.5",
36 | "postcss": "^8.4.4",
37 | "react": "^18.2.0",
38 | "react-3d-hover": "^1.1.1",
39 | "react-code-blocks": "^0.0.9-0",
40 | "react-confetti": "^6.0.1",
41 | "react-copy-to-clipboard": "^5.1.0",
42 | "react-csv": "^2.2.2",
43 | "react-dom": "^18.2.0",
44 | "react-drag-drop-files": "^2.3.8",
45 | "react-hot-toast": "^2.1.1",
46 | "react-tooltip": "^4.2.21",
47 | "react-use": "^17.3.2",
48 | "recharts": "^2.1.13",
49 | "sass-loader": "^12.2.0",
50 | "sib-api-v3-sdk": "^8.4.0",
51 | "stripe": "8.132.0",
52 | "swr": "0.4.0",
53 | "tailwind-config": "*",
54 | "tailwindcss": "^3.0.22",
55 | "ui": "*",
56 | "yarn": "^1.22.11"
57 | },
58 | "devDependencies": {
59 | "@types/node": "^18.11.0",
60 | "@types/react": "^18.0.21",
61 | "typescript": "^4.8.4"
62 | },
63 | "prettier": {
64 | "arrowParens": "always",
65 | "singleQuote": true,
66 | "tabWidth": 2,
67 | "trailingComma": "none"
68 | },
69 | "engines": {
70 | "node": "^16"
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/apps/reflio/utils/AffiliateContext.js:
--------------------------------------------------------------------------------
1 | import { useRouter } from 'next/router';
2 | import { useState, useEffect, createContext, useContext } from 'react';
3 | import { getAffiliates, useUser } from './useUser';
4 | import { useCompany } from './CompanyContext';
5 | import { useCampaign } from './CampaignContext';
6 |
7 | export const AffiliateContext = createContext();
8 |
9 | export const AffiliateContextProvider = (props) => {
10 | const { user, userFinderLoaded } = useUser();
11 | const { activeCompany } = useCompany();
12 | const { userCampaignDetails } = useCampaign();
13 | const [userAffiliateDetails, setUserAffiliateDetails] = useState(null);
14 | const [mergedAffiliateDetails, setMergedAffiliateDetails] = useState(null);
15 | let value;
16 |
17 | useEffect(() => {
18 | if (userFinderLoaded && getAffiliates && user && userAffiliateDetails === null && activeCompany?.company_id) {
19 | getAffiliates(activeCompany?.company_id).then(results => {
20 | setUserAffiliateDetails(Array.isArray(results) ? results : [results])
21 | });
22 | }
23 | });
24 |
25 | if(mergedAffiliateDetails === null && userCampaignDetails !== null && userCampaignDetails?.length && userAffiliateDetails !== null && userAffiliateDetails?.length && activeCompany?.company_id ){
26 | let clonedAffiliateDetails = userAffiliateDetails;
27 |
28 | clonedAffiliateDetails?.map(affiliate =>{
29 | userCampaignDetails?.map(campaign =>{
30 | if(affiliate?.campaign_id === campaign?.campaign_id){
31 | affiliate.campaign_name = campaign.campaign_name;
32 | }
33 | })
34 | });
35 |
36 | setMergedAffiliateDetails(clonedAffiliateDetails);
37 | }
38 |
39 | if(userAffiliateDetails !== null && userAffiliateDetails?.length === 0 && mergedAffiliateDetails === null){
40 | setMergedAffiliateDetails([]);
41 | }
42 |
43 | value = {
44 | userAffiliateDetails,
45 | mergedAffiliateDetails
46 | };
47 |
48 | return ;
49 | }
50 |
51 | export const useAffiliate = () => {
52 | const context = useContext(AffiliateContext);
53 | if (context === undefined) {
54 | throw new Error(`useUser must be used within a AffiliatesContextProvider.`);
55 | }
56 | return context;
57 | };
--------------------------------------------------------------------------------
/packages/ui/src/Testimonials.js:
--------------------------------------------------------------------------------
1 | /* eslint-disable jsx-a11y/alt-text */
2 | /* eslint-disable @next/next/no-img-element */
3 |
4 | export const Testimonials = (props) => {
5 | return(
6 |
7 |
8 | {
9 | !props.small &&
10 |
11 |
12 |
13 | Great stuff - a space that needs a cost effective product!
14 |
15 |
@maxwellcdavis
16 |
17 | }
18 |
19 |
20 |
21 | Reflio.com by @richiemcilroy is privacy conscious and doesn't break the bank. It's still in beta but I'm excited about it.
22 |
23 |
@foliofed
24 |
25 |
26 |
27 |
28 | Fun idea. I've been looking for an affordable service like this too. Wasn't impressed by the market's current offerings the last time I looked. Great domain name too!
29 |
30 |
@BrianSaetre
31 |
32 | {
33 | !props.small &&
34 |
35 |
36 |
37 | Richie, I've just seen this thread on Reflio. Great idea and it looks mint!
38 |
39 |
@_thunk_
40 |
41 | }
42 |
43 |
44 | )
45 | };
46 |
47 | export default Testimonials;
--------------------------------------------------------------------------------
/packages/tailwind-config/tailwind.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | content: [
3 | "../ui/src/**/*.{js,ts,jsx,tsx}",
4 | "../../apps/reflio/pages/**/*.{js,ts,jsx,tsx}",
5 | "../../apps/reflio/templates/**/*.{js,ts,jsx,tsx}",
6 | "../../apps/reflio/forms/**/*.{js,ts,jsx,tsx}",
7 | "../../apps/reflio-affiliate/pages/**/*.{js,ts,jsx,tsx}",
8 | "../../apps/reflio-affiliate/templates/**/*.{js,ts,jsx,tsx}"
9 | ],
10 | theme: {
11 | fontWeight: {
12 | hairline: 300,
13 | 'extra-light': 300,
14 | thin: 300,
15 | light: 300,
16 | normal: 300,
17 | medium: 400,
18 | semibold: 500,
19 | bold: 500,
20 | extrabold: 500,
21 | 'extra-bold': 500,
22 | black: 500,
23 | },
24 | extend: {
25 | maxWidth: {
26 | '8xl': '1920px'
27 | },
28 | fontFamily: {
29 | primary: ["TT Interfaces"]
30 | },
31 | colors: {
32 | primary: 'var(--primary)',
33 | 'primary-2': 'var(--primary-2)',
34 | 'primary-3': 'var(--primary-3)',
35 | secondary: 'var(--secondary)',
36 | 'secondary-2': 'var(--secondary-2)',
37 | 'secondary-3': 'var(--secondary-3)',
38 | 'hover-1': 'var(--hover-1)',
39 | 'hover-2': 'var(--hover-2)',
40 | 'accents-0': 'var(--accents-0)',
41 | 'accents-1': 'var(--accents-1)',
42 | 'accents-2': 'var(--accents-2)',
43 | 'accents-3': 'var(--accents-3)',
44 | 'accents-4': 'var(--accents-4)',
45 | 'accents-5': 'var(--accents-5)',
46 | 'accents-6': 'var(--accents-6)',
47 | 'accents-7': 'var(--accents-7)',
48 | 'accents-8': 'var(--accents-8)',
49 | 'accents-9': 'var(--accents-9)',
50 | },
51 | textColor: {
52 | primary: 'var(--text-primary)',
53 | secondary: 'var(--text-secondary)'
54 | },
55 | boxShadow: {
56 | 'outline-2': '0 0 0 2px var(--accents-2)',
57 | magical:
58 | 'rgba(0, 0, 0, 0.02) 0px 30px 30px, rgba(0, 0, 0, 0.03) 0px 0px 8px, rgba(0, 0, 0, 0.05) 0px 1px 0px'
59 | },
60 | lineHeight: {
61 | 'extra-loose': '2.2'
62 | },
63 | animation: {
64 | 'pulse-fast': 'pulse 0.75s linear infinite',
65 | }
66 | }
67 | },
68 | variants: {
69 | extend: {
70 | bg: ['disabled'],
71 | }
72 | }
73 | };
74 |
--------------------------------------------------------------------------------
/packages/ui/src/Icons/AnimIcon.js:
--------------------------------------------------------------------------------
1 | export const AnimIcon = ({ ...props }) => {
2 | return(
3 |
9 |
14 |
19 |
20 | );
21 | }
22 |
23 | export default AnimIcon;
--------------------------------------------------------------------------------
/apps/reflio/pages/api/affiliates/invite.js:
--------------------------------------------------------------------------------
1 | import { getUser } from '@/utils/supabase-admin';
2 | import { inviteAffiliate } from '@/utils/useDatabase';
3 | import { sendEmail } from '@/utils/sendEmail';
4 | import { withSentry } from '@sentry/nextjs';
5 |
6 | const inviteUser = async (req, res) => {
7 | if (req.method === 'POST') {
8 | const token = req.headers.token;
9 | const {
10 | companyId,
11 | name,
12 | vercel_username,
13 | companyHandle,
14 | companyName,
15 | campaignId,
16 | emailInvites,
17 | logoUrl,
18 | emailSubject,
19 | emailContent
20 | } = req.body;
21 |
22 | try {
23 | const user = await getUser(token);
24 | let emailInvitesSplit = null;
25 |
26 | if (emailInvites && emailInvites?.includes(',')) {
27 | emailInvitesSplit = emailInvites.split(',');
28 | if (emailInvitesSplit?.length >= 30) {
29 | return res.status(500).json({ response: 'limit reached' });
30 | }
31 | }
32 |
33 | if (user) {
34 | if (emailInvitesSplit === null) {
35 | const invite = await inviteAffiliate(
36 | user,
37 | companyId,
38 | campaignId,
39 | emailInvites,
40 | name,
41 | vercel_username
42 | );
43 |
44 | if (invite === 'success') {
45 | return res.status(200).json({ response: 'success' });
46 | }
47 | } else {
48 | await Promise.all(
49 | emailInvitesSplit?.map(async (inviteEmail) => {
50 | await inviteAffiliate(
51 | user,
52 | companyId,
53 | campaignId,
54 | inviteEmail,
55 | name,
56 | vercel_username
57 | );
58 | })
59 | );
60 | return res.status(200).json({ response: 'success' });
61 | }
62 |
63 | return res.status(500).json({ response: 'error' });
64 | } else {
65 | return res.status(500).json({ response: 'error' });
66 | }
67 | } catch (err) {
68 | console.log(err);
69 | res
70 | .status(500)
71 | .json({ error: { statusCode: 500, message: err.message } });
72 | }
73 | } else {
74 | res.setHeader('Allow', 'POST');
75 | res.status(405).end('Method Not Allowed');
76 | }
77 | };
78 |
79 | export default process.env.SENTRY_AUTH_TOKEN
80 | ? withSentry(inviteUser)
81 | : inviteUser;
82 |
--------------------------------------------------------------------------------
/apps/reflio-affiliate/templates/SEOMeta.tsx:
--------------------------------------------------------------------------------
1 | import Head from 'next/head';
2 |
3 | type SEOMetaProps = {
4 | title?: string;
5 | description?: string;
6 | keywords?: string;
7 | img?: string;
8 | }
9 |
10 | export const SEOMeta: React.FC = ({ title, description, keywords, img }) => {
11 | let setTitle = title ?? "Reflio: Create a privacy-friendly referral program for your SaaS.";
12 | let setDescription = description ?? "Create a privacy-friendly referral program for your SaaS. GDPR Friendly. Based in the UK. European-owned infrastructure.";
13 | let setKeywords = keywords ?? "Reflio, Referral software, create referral program, stripe referral program";
14 | let setImg = img ?? "/og.png";
15 |
16 | setTitle = setTitle + " | Reflio Affiliates";
17 |
18 | return (
19 |
20 |
21 |
22 |
23 |
24 |
25 | {/* Twitter */}
26 |
27 |
28 |
29 |
30 | {/* Open Graph */}
31 |
32 |
33 |
34 |
35 |
36 |
37 | {setTitle}
38 |
39 |
45 |
51 |
52 |
53 |
54 | )
55 | }
56 |
57 | export default SEOMeta;
--------------------------------------------------------------------------------
/packages/ui/src/Modal.js:
--------------------------------------------------------------------------------
1 | import { Fragment } from 'react';
2 | import { Dialog, Transition } from '@headlessui/react';
3 | import {
4 | XIcon
5 | } from '@heroicons/react/outline';
6 |
7 | export const Modal = (props) => {
8 | return(
9 |
10 |
11 |
12 |
21 |
22 |
23 |
24 | {/* This element is to trick the browser into centering the modal contents. */}
25 |
26 |
27 |
28 |
37 |
38 |
39 | {props?.setModalOpen(false)}}
43 | >
44 | Close
45 |
46 |
47 |
48 |
49 | {props?.children}
50 |
51 |
52 |
53 |
54 |
55 |
56 | )
57 | };
58 |
59 | export default Modal;
--------------------------------------------------------------------------------
/packages/ui/src/Icons/StripeConnect.js:
--------------------------------------------------------------------------------
1 | export const StripeConnect = ({ ...props }) => {
2 | return (
3 |
4 |
5 |
6 |
7 |
8 | );
9 | };
10 |
11 | export default StripeConnect;
--------------------------------------------------------------------------------
/apps/reflio-affiliate/utils/UserAffiliateContext.js:
--------------------------------------------------------------------------------
1 | /* eslint-disable react-hooks/exhaustive-deps */
2 | import { useRouter } from 'next/router';
3 | import { useState, useEffect, createContext, useContext } from 'react';
4 | import { useUser } from '@/utils/useUser';
5 | import { postData } from '@/utils/helpers';
6 |
7 | export const UserAffiliateContext = createContext();
8 |
9 | export const UserAffiliateContextProvider = (props) => {
10 | const router = useRouter();
11 | const { user, userFinderLoaded, session } = useUser();
12 | const [userAffiliateDetails, setUserAffiliateDetails] = useState(null);
13 | const [userAffiliateInvites, setUserAffiliateInvites] = useState(null);
14 | const [referralDetails, setReferralDetails] = useState(null);
15 | const [loadingAffiliates, setLoadingAffiliates] = useState(false);
16 | const [loadingAffiliateInvites, setLoadingAffiliateInvites] = useState(false);
17 | let value;
18 |
19 | const affiliatePrograms = async () => {
20 | try {
21 | const { affilateData, referralsData } = await postData({
22 | url: '/api/affiliate/campaigns',
23 | token: session.access_token
24 | });
25 |
26 | setUserAffiliateDetails(affilateData);
27 | setReferralDetails(referralsData);
28 |
29 |
30 | } catch (error) {
31 | console.log(error)
32 | }
33 | };
34 |
35 | const affiliateInvites = async () => {
36 | try {
37 | const { invites } = await postData({
38 | url: '/api/affiliate/invites',
39 | token: session.access_token
40 | });
41 |
42 | setUserAffiliateInvites(invites);
43 |
44 | } catch (error) {
45 | console.log(error)
46 | }
47 | };
48 |
49 | useEffect(() => {
50 | if (userFinderLoaded && user && userAffiliateDetails === null && loadingAffiliates === false) {
51 | setLoadingAffiliates(true);
52 | affiliatePrograms();
53 | }
54 |
55 | if (userFinderLoaded && user && userAffiliateInvites === null && loadingAffiliateInvites === false) {
56 | setLoadingAffiliateInvites(true);
57 | affiliateInvites();
58 | }
59 | });
60 |
61 | if(router?.asPath?.includes('inviteRefresh=true')){
62 | window.location.href = process.env.NEXT_PUBLIC_AFFILIATE_SITE_URL;
63 | }
64 |
65 | value = {
66 | userAffiliateDetails,
67 | userAffiliateInvites,
68 | referralDetails
69 | };
70 |
71 | return ;
72 | }
73 |
74 | export const useUserAffiliate = () => {
75 | const context = useContext(UserAffiliateContext);
76 | if (context === undefined) {
77 | throw new Error(`useUser must be used within a UserAffiliateContextProvider.`);
78 | }
79 | return context;
80 | };
--------------------------------------------------------------------------------
/apps/reflio/pages/api/customer-events.js:
--------------------------------------------------------------------------------
1 | import { stripe } from '@/utils/stripe';
2 | import {
3 | deleteIntegrationFromDB,
4 | editCommission,
5 | createCommission,
6 | updateCustomer
7 | } from 'utils/stripe-helpers';
8 | import { withSentry } from '@sentry/nextjs';
9 |
10 | // Stripe requires the raw body to construct the event.
11 | export const config = {
12 | api: {
13 | bodyParser: false
14 | }
15 | };
16 |
17 | async function buffer(readable) {
18 | const chunks = [];
19 | for await (const chunk of readable) {
20 | chunks.push(
21 | typeof chunk === "string" ? Buffer.from(chunk) : chunk
22 | );
23 | }
24 | return Buffer.concat(chunks);
25 | }
26 |
27 | const relevantEvents = new Set([
28 | 'account.application.deauthorized',
29 | 'account.updated',
30 | 'charge.succeeded',
31 | 'charge.refunded',
32 | 'charge.refund.updated',
33 | 'charge.updated',
34 | 'customer.created'
35 | ]);
36 |
37 | const customerEvents = async (req, res) => {
38 | if (req.method === 'POST') {
39 | const buf = await buffer(req);
40 | const sig = req.headers['stripe-signature'];
41 | const webhookSecret = process.env.STRIPE_CUSTOMER_WEBHOOK_SECRET;
42 | let event;
43 |
44 | try {
45 | event = stripe.webhooks.constructEvent(buf, sig, webhookSecret);
46 | } catch (err) {
47 | console.log(`❌ Error message: ${err.message}`);
48 | return res.status(400).send(`Webhook Error: ${err.message}`);
49 | }
50 |
51 |
52 | if (relevantEvents.has(event.type)) {
53 | try {
54 | switch (event.type) {
55 | case 'charge.refunded':
56 | await editCommission(event);
57 | break;
58 | case 'charge.refund.updated':
59 | await editCommission(event);
60 | break;
61 | case 'charge.updated':
62 | await editCommission(event);
63 | break;
64 | case 'charge.succeeded':
65 | await createCommission(event, null, null);
66 | break;
67 | case 'customer.created':
68 | await updateCustomer(event);
69 | break;
70 | case 'account.application.deauthorized':
71 | if(event.data.object?.name === 'Reflio'){
72 | await deleteIntegrationFromDB(event?.account);
73 | break;
74 | } else {
75 | break;
76 | }
77 | }
78 | } catch (error) {
79 | console.log(error);
80 | return res.json({ error: 'Webhook handler failed. View logs.' });
81 | }
82 | }
83 |
84 | res.json({ received: true });
85 | } else {
86 | res.setHeader('Allow', 'POST');
87 | res.status(405).end('Method Not Allowed');
88 | }
89 | };
90 |
91 | export default process.env.SENTRY_AUTH_TOKEN ? withSentry(customerEvents) : customerEvents;
--------------------------------------------------------------------------------
/apps/reflio/pages/dashboard/[companyId]/setup/campaign.js:
--------------------------------------------------------------------------------
1 | import { useRouter } from 'next/router';
2 | import SetupProgress from '@/components/SetupProgress';
3 | import { SEOMeta } from '@/templates/SEOMeta';
4 | import Button from '@/components/Button';
5 | import { useCompany } from '@/utils/CompanyContext';
6 | import { useCampaign } from '@/utils/CampaignContext';
7 | import CampaignForm from '@/forms/CampaignForm';
8 | import { priceString } from '@/utils/helpers';
9 |
10 | export default function AddCompany() {
11 | const router = useRouter();
12 | const { activeCompany } = useCompany();
13 | const { userCampaignDetails } = useCampaign();
14 |
15 | return (
16 | <>
17 |
18 |
23 |
24 |
25 |
Create a campaign
26 |
27 |
28 |
29 | {
30 | userCampaignDetails !== null && userCampaignDetails?.length > 0 ?
31 |
32 |
Your first campaign is ready.
33 |
34 |
Campaign name:
35 |
{userCampaignDetails[0]?.campaign_name}
36 |
37 |
38 |
Commission:
39 | {
40 | userCampaignDetails[0]?.commission_type === "percentage" ?
41 |
{userCampaignDetails[0]?.commission_value}%
42 | :
43 |
{priceString(userCampaignDetails[0]?.commission_value, activeCompany?.company_currency)}
44 | }
45 |
{userCampaignDetails[0]?.commi}
46 |
47 |
50 |
51 |
56 | Next step
57 |
58 |
59 |
60 | :
61 |
62 | }
63 |
64 | >
65 | );
66 | }
--------------------------------------------------------------------------------
/apps/reflio/LICENSE:
--------------------------------------------------------------------------------
1 | The Reflio Enterprise Edition (EE) license (the “EE License”)
2 | Copyright (c) 2022-present Reflio (McIlroy Limited)
3 |
4 | With regard to the Reflio Software:
5 |
6 | This software and associated documentation files (the "Software") may only be
7 | used in production, if you (and any entity that you represent) have agreed to,
8 | and are in compliance with, the Reflio Subscription Terms available
9 | at https://reflio.com/terms (the “EE Terms”), or other agreements governing
10 | the use of the Software, as mutually agreed by you and Reflio (McIlroy Limited),
11 | and otherwise have a valid Reflio Enterprise Edition subscription ("EE Subscription")
12 | for the correct number of hosts as defined in the EE Terms ("Hosts"). Subject to the foregoing sentence,
13 | you are free to modify this Software and publish patches to the Software. You agree
14 | that Reflio and/or its licensors (as applicable) retain all right, title and interest in
15 | and to all such modifications and/or patches, and all such modifications and/or
16 | patches may only be used, copied, modified, displayed, distributed, or otherwise
17 | exploited with a valid EE Subscription for the correct number of hosts.
18 | Notwithstanding the foregoing, you may copy and modify the Software for development
19 | and testing purposes, without requiring a subscription. You agree that Reflio and/or
20 | its licensors (as applicable) retain all right, title and interest in and to all such
21 | modifications. You are not granted any other rights beyond what is expressly stated herein.
22 | Subject to the foregoing, it is forbidden to copy, merge, publish, distribute, sublicense,
23 | and/or sell the Software.
24 |
25 | This EE License applies only to the part of this Software that is not distributed under
26 | the AGPLv3 license. Any part of this Software distributed under the AGPLv3 license or which
27 | is served client-side as an image, font, cascading stylesheet (CSS), file which produces
28 | or is compiled, arranged, augmented, or combined into client-side JavaScript, in whole or
29 | in part, is copyrighted under the AGPLv3 license. The full text of this EE License shall
30 | be included in all copies or substantial portions of the Software.
31 |
32 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
33 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
34 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
35 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
36 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
37 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
38 | SOFTWARE.
39 |
40 | For all third party components incorporated into the Reflio Software, those
41 | components are licensed under the original license provided by the owner of the
42 | applicable component.
43 |
--------------------------------------------------------------------------------
/packages/ui/src/CompanyLogoUpload.tsx:
--------------------------------------------------------------------------------
1 | import { useState, useRef } from 'react';
2 | import { uploadLogoImage } from '@/utils/useUser';
3 | import { useRouter } from 'next/router';
4 | import { useCompany } from '@/utils/CompanyContext';
5 | import toast from 'react-hot-toast';
6 |
7 | export const CompanyLogoUpload = () => {
8 | const router = useRouter();
9 | const { activeCompany } = useCompany();
10 | const [logoError, setLogoError] = useState(false);
11 | const fileInput = useRef(null);
12 |
13 | const handleFileClick = () => {
14 | if(fileInput.current){
15 | fileInput.current.click()
16 | }
17 | }
18 |
19 | const handleFileUpload = async (e: any) => {
20 | if(e.target.files[0].size < 2000000){
21 | if(e.target.files[0].name?.includes("jpg") || e.target.files[0].name?.includes("jpeg") || e.target.files[0].name?.includes("png")){
22 | await uploadLogoImage(router?.query?.companyId, e.target.files[0]).then((result: any) => {
23 | if(result !== "error"){
24 | setLogoError(false);
25 | router.replace(window.location.href);
26 | } else {
27 | toast.error('There was an error when uploading your image. Please make sure that it is either a JPG or PNG file and is less than 2mb.');
28 | }
29 | });
30 | }
31 | } else {
32 | setLogoError(true);
33 | return false;
34 | }
35 | };
36 |
37 | return(
38 | <>
39 | Company Logo
40 |
41 |
42 | {
43 | activeCompany?.company_image !== null &&
44 |
45 | }
46 |
54 |
handleFileClick()}
58 | >
59 | Upload File
60 |
61 |
62 |
63 | Must be a PNG or JPEG file and less than 2mb.
64 |
65 | {
66 | logoError &&
67 |
68 | There was an error when uploading your file.
69 |
70 | }
71 |
72 | >
73 | )
74 | };
75 |
76 | export default CompanyLogoUpload;
--------------------------------------------------------------------------------
/packages/ui/src/Features.js:
--------------------------------------------------------------------------------
1 | import {
2 | EyeOffIcon,
3 | LightningBoltIcon,
4 | SparklesIcon,
5 | CurrencyDollarIcon,
6 | GlobeIcon,
7 | CreditCardIcon,
8 | EyeIcon
9 | } from '@heroicons/react/outline';
10 |
11 | export const Features = () => {
12 |
13 | const features = [
14 | {
15 | name: 'Pricing from $0/month',
16 | description: "We're indie hacker friendly. Being indie hackers ourselves, we know that all new projects start from $0 MRR. Reflio starts from just $0/month with a 9% fee per successful referral.",
17 | active: true,
18 | icon: CurrencyDollarIcon
19 | },
20 | {
21 | name: 'Get started in minutes',
22 | description: 'Quickly connect your SaaS product to Reflio with pre-written code examples. You can instantly take advantage of word of mouth referrals to get higher quality sign ups to your app via your existing users.',
23 | active: true,
24 | icon: SparklesIcon
25 | },
26 | {
27 | name: 'Subscriptions or one-time charges',
28 | description: 'Reflio works with both subscriptions and one-time payments in Stripe. Future subscription payments that came from a referral are handled automatically and re-collected in your dashboard.',
29 | active: true,
30 | icon: CreditCardIcon
31 | },
32 | {
33 | name: 'Cross subdomain tracking',
34 | description: "Is your SaaS on a subdomain? Don't worry. We'll automatically track across your main domain to your sub domain with no extra work on your end.",
35 | active: true,
36 | icon: GlobeIcon
37 | },
38 | {
39 | name: "Automated GDPR & Privacy compliance mode",
40 | description: 'All data is processed through European-owned infrastructure, and our company is registered in the UK. With Reflio, you can choose for referrals located in the EU to automatically be required to confirm their consent before a cookie is set.',
41 | active: true,
42 | icon: EyeOffIcon
43 | },
44 | {
45 | name: 'Our embed script is fast',
46 | description: "Being under <13kb, our embed code is up to 5x faster than some of our competitors, meaning we're better for your SEO than they are.",
47 | active: true,
48 | icon: LightningBoltIcon
49 | },
50 | ];
51 |
52 | return(
53 |
54 |
55 | {features.map((feature) => (
56 |
57 |
58 | {
59 | feature.icon &&
60 |
61 | }
62 | {feature.name}
63 |
64 |
{feature.description}
65 |
66 | ))}
67 |
68 |
69 | );
70 | };
71 |
72 | export default Features;
--------------------------------------------------------------------------------
/apps/reflio-affiliate/pages/api/public/campaign-image.tsx:
--------------------------------------------------------------------------------
1 | import { ImageResponse } from '@vercel/og';
2 | import { postData, priceString } from '@/utils/helpers';
3 | import { NextRequest } from 'next/server';
4 |
5 | export const config = {
6 | runtime: 'experimental-edge',
7 | };
8 |
9 | const ogImageGenerate = async (companyHandle: any, campaignId: any) => {
10 | const { campaign } = await postData({
11 | url: `${process.env.NEXT_PUBLIC_AFFILIATE_SITE_URL}/api/public/campaign`,
12 | token: null,
13 | data: {
14 | "companyHandle": companyHandle ? companyHandle : null,
15 | "campaignId": campaignId ? campaignId : null
16 | }
17 | });
18 |
19 | return campaign;
20 | };
21 |
22 | export default async function handler(req: NextRequest) {
23 | const { searchParams } = new URL(req.url);
24 | const hasCompanyHandle = searchParams.has('companyHandle');
25 | const hasCampaignId = searchParams.has('campaignId');
26 | const companyHandle = hasCompanyHandle ? searchParams.get('companyHandle')?.slice(0, 100) : null;
27 | const campaignId = hasCampaignId ? searchParams.get('campaignId')?.slice(0, 100) : null;
28 | const campaign = companyHandle !== null ? await ogImageGenerate(companyHandle, campaignId) : null;
29 |
30 | return new ImageResponse(
31 | (
32 | // Modified based on https://tailwindui.com/components/marketing/sections/cta-sections
33 |
34 | {
35 | campaign?.company_name ?
36 |
37 | {
38 | campaign?.company_image !== null ?
39 |
40 |
41 |
42 | :
43 |
{campaign?.company_name}
44 | }
45 |
46 |
{campaign?.campaign_name}
47 |
48 |
{campaign?.commission_type === 'percentage' ? `${campaign?.commission_value}% commission on all paid referrals.` : `${priceString(campaign?.commission_value, campaign?.company_currency)} commission on all paid referrals.`}
49 |
50 | :
51 |
52 |
Get started with Reflio
53 |
54 | }
55 |
56 | ),
57 | {
58 | width: 1200,
59 | height: 630,
60 | },
61 | );
62 | }
--------------------------------------------------------------------------------
/packages/ui/src/PricingSnippet.js:
--------------------------------------------------------------------------------
1 | export const PricingSnippet = (props) => {
2 | return(
3 |
4 |
5 |
6 |
7 |
8 | Pricing
9 |
10 |
No hidden fees. No complicated plans.
11 |
12 |
13 |
14 |
PRO ($14/month)
15 |
Perfect for establised web apps and production environments.
16 |
17 | Unlimited submissions
18 | Unlimited companies
19 | Custom embed styling
20 | Remove Reflio companying
21 | Automatically collect user console errors
22 |
23 |
27 | Get Started
28 |
29 |
30 |
31 |
Free
32 |
100% free to setup and start collecting submissions. Suitable for indie makers and smaller companies.
33 |
34 | 15 free submissions
35 | 1 free company
36 |
37 |
41 | Get Started
42 |
43 |
44 |
45 |
46 |
47 |
48 | );
49 | };
50 |
51 | export default PricingSnippet;
--------------------------------------------------------------------------------
/apps/reflio/pages/404.tsx:
--------------------------------------------------------------------------------
1 | /* This example requires Tailwind CSS v2.0+ */
2 | import { ChevronRightIcon } from '@heroicons/react/solid'
3 | import { BookOpenIcon, CurrencyDollarIcon, TemplateIcon } from '@heroicons/react/outline'
4 |
5 | const links = [
6 | { title: 'Dashboard', href: '/dashboard', description: 'Your dashboard to control campaigns, affiliates and commissions.', icon: TemplateIcon },
7 | { title: 'Pricing', href: '/pricing', description: 'View our different pricing plans and see which one most suits your business.', icon: CurrencyDollarIcon },
8 | { title: 'Resources', href: '/resources', description: 'Learn how to integrate Reflio into your website', icon: BookOpenIcon }
9 | ];
10 |
11 | export default function FourOhFour() {
12 | return (
13 |
14 |
15 |
16 |
Error 404
17 |
18 | This page does not exist.
19 |
20 |
The page you are looking for could not be found.
21 |
22 |
23 |
Popular pages
24 |
25 | {links.map((link, linkIdx) => (
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
41 |
{link.description}
42 |
43 |
44 |
45 |
46 |
47 | ))}
48 |
49 |
55 |
56 |
57 |
58 | )
59 | }
--------------------------------------------------------------------------------
/apps/reflio/pages/_app.tsx:
--------------------------------------------------------------------------------
1 | import type { AppProps } from "next/app";
2 | import dynamic from 'next/dynamic';
3 | import Head from 'next/head';
4 | import { useEffect } from 'react';
5 | import "@/dist/styles.css";
6 | import '@tremor/react/dist/esm/tremor.css';
7 | import Layout from '@/templates/Layout';
8 | import { useRouter } from 'next/router';
9 | import SEOMeta from '@/templates/SEOMeta';
10 |
11 | export default function MyApp({ Component, pageProps: { ...pageProps }, }: AppProps<{}>) {
12 | const UserContextProvider = dynamic(() =>
13 | import("@/utils/useUser").then((module) => module.UserContextProvider)
14 | );
15 | const CompanyContextProvider = dynamic(() =>
16 | import("@/utils/CompanyContext").then((module) => module.CompanyContextProvider)
17 | );
18 | const CampaignContextProvider = dynamic(() =>
19 | import("@/utils/CampaignContext").then((module) => module.CampaignContextProvider)
20 | );
21 | const AffiliateContextProvider = dynamic(() =>
22 | import("@/utils/AffiliateContext").then((module) => module.AffiliateContextProvider)
23 | );
24 | const router = useRouter();
25 |
26 | useEffect(() => {
27 | document.body.classList?.remove('loading');
28 |
29 | if(router?.asPath?.indexOf("&token_type=bearer&type=recovery") > 0) {
30 | let access_token = router?.asPath?.split("access_token=")[1].split("&")[0];
31 | router.push('/reset-password?passwordReset=true&access_token='+access_token+'');
32 | }
33 | });
34 |
35 | return (
36 | <>
37 | {
38 | typeof window !== "undefined" && window.location.href.includes('/dashboard/') &&
39 |
40 |
45 |
46 | }
47 |
48 |
49 | {
50 | router.pathname.indexOf('/dashboard') > -1 ?
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 | :
63 |
64 |
65 |
66 |
67 |
68 | }
69 |
70 | >
71 | );
72 | };
--------------------------------------------------------------------------------
/apps/reflio/pages/sentry_sample_error.tsx:
--------------------------------------------------------------------------------
1 | import Head from 'next/head'
2 |
3 | const boxStyles = { padding: '12px', border: '1px solid #eaeaea', borderRadius: '10px' };
4 | export default function Home() {
5 | return (
6 |
7 |
8 |
Sentry Onboarding
9 |
10 |
11 |
12 |
19 |
20 |
23 |
24 |
25 |
26 |
27 |
28 | Get started by sending us a sample error
29 |
30 | {
36 | throw new Error("Sentry Frontend Error");
37 | }}>
38 | Throw error
39 |
40 |
41 |
42 | For more information, see https://docs.sentry.io/platforms/javascript/guides/nextjs/
43 |
44 |
45 |
46 | )
47 | }
48 |
--------------------------------------------------------------------------------
/apps/reflio/pages/api/v1/record-referral.js:
--------------------------------------------------------------------------------
1 | import {
2 | verifyReferral,
3 | fireRecordImpression,
4 | createReferral
5 | } from '@/utils/useDatabase';
6 | import Cors from 'cors';
7 | import { withSentry } from '@sentry/nextjs';
8 | import { supabaseAdmin } from '@/utils/supabase-admin';
9 |
10 | // Initializing the cors middleware
11 | const cors = Cors({
12 | methods: ['POST']
13 | });
14 |
15 | // Helper method to wait for a middleware to execute before continuing
16 | // And to throw an error when an error happens in a middleware
17 | function runMiddleware(req, res, fn) {
18 | return new Promise((resolve, reject) => {
19 | fn(req, res, (result) => {
20 | if (result instanceof Error) {
21 | return reject(result);
22 | }
23 |
24 | return resolve(result);
25 | });
26 | });
27 | }
28 |
29 | const COMPANY_ID = '19cpdhnsxl2nwc0';
30 |
31 | const recordImpression = async (req, res) => {
32 | console.log('Impression API Call');
33 |
34 | // Run the middleware
35 | await runMiddleware(req, res, cors);
36 |
37 | let body = req.body;
38 | try {
39 | body = JSON.parse(body);
40 | } catch (error) {
41 | console.log('Could not parse body');
42 | }
43 |
44 | try {
45 | console.log('Trying...');
46 |
47 | if (body?.vercel_username) {
48 | console.log('Has items');
49 |
50 | const vercel_username = body.vercel_username;
51 |
52 | const { data } = await supabaseAdmin
53 | .from('affiliates')
54 | .select('affiliate_id')
55 | .eq('vercel_username', vercel_username);
56 |
57 | if (!data)
58 | return res.status(500).json({ statusCode: 500, verified: false });
59 |
60 | if (data.length <= 0)
61 | return res.status(404).json({ statusCode: 404, verified: false });
62 |
63 | const { affiliate_id } = data[0];
64 |
65 | const referralVerify = await verifyReferral(affiliate_id, COMPANY_ID);
66 |
67 | if (
68 | referralVerify !== 'error' &&
69 | referralVerify?.affiliate_id &&
70 | referralVerify?.campaign_id
71 | ) {
72 | console.log('Referral verified...');
73 |
74 | const impression = await fireRecordImpression(
75 | referralVerify?.affiliate_id
76 | );
77 |
78 | console.log('Impression:');
79 | console.log(impression);
80 |
81 | if (impression === 'success') {
82 | const referral = await createReferral(referralVerify);
83 |
84 | if (referral !== 'error') {
85 | return res
86 | .status(200)
87 | .json({ statusCode: 200, referral_details: referral });
88 | }
89 | }
90 | }
91 | }
92 |
93 | return res.status(500).json({ statusCode: 500, verified: false });
94 | } catch (error) {
95 | console.log(error);
96 | return res
97 | .status(500)
98 | .json({ error: { statusCode: 500, verified: false } });
99 | }
100 | };
101 |
102 | export default process.env.SENTRY_AUTH_TOKEN
103 | ? withSentry(recordImpression)
104 | : recordImpression;
105 |
--------------------------------------------------------------------------------
/apps/reflio-affiliate/utils/useUser.js:
--------------------------------------------------------------------------------
1 | import { useEffect, useState, createContext, useContext } from 'react';
2 | import { supabase } from './supabase-client';
3 |
4 | export const UserContext = createContext();
5 |
6 | export const UserContextProvider = (props) => {
7 | const [userLoaded, setUserLoaded] = useState(false);
8 | const [session, setSession] = useState(null);
9 | const [user, setUser] = useState(null);
10 | const [userFinderLoaded, setUserFinderLoaded] = useState(false);
11 | const [userDetails, setUserDetails] = useState(null);
12 |
13 | useEffect(() => {
14 | const session = supabase.auth.session();
15 | setSession(session);
16 | setUser(session?.user ?? null);
17 | const { data: authListener } = supabase.auth.onAuthStateChange(
18 | async (event, session) => {
19 | setSession(session);
20 | setUser(session?.user ?? null);
21 | }
22 | );
23 |
24 | setUserFinderLoaded(true);
25 |
26 | return () => {
27 | authListener.unsubscribe();
28 | };
29 | }, []);
30 |
31 | const getUserDetails = () => supabase.from('users').select('*').eq('id', user?.id).single();
32 | useEffect(() => {
33 | if (user) {
34 | Promise.allSettled([getUserDetails()]).then(
35 | (results) => {
36 | setUserDetails(results[0].value.data);
37 | setUserLoaded(true);
38 | setUserFinderLoaded(true);
39 | }
40 | );
41 | }
42 | }, [user]);
43 |
44 | const value = {
45 | session,
46 | user,
47 | userDetails,
48 | userLoaded,
49 | userFinderLoaded,
50 | signIn: (options) => supabase.auth.signIn({email: options.email}, {shouldCreateUser: options.shouldCreateUser, redirectTo: options.redirectTo}),
51 | signInWithPassword: (options) => supabase.auth.signIn({email: options.email, password: options.password}, {shouldCreateUser: options.shouldCreateUser, redirectTo: options.redirectTo}),
52 | signUp: (options) => supabase.auth.signUp({email: options.email, password: options.password}, {redirectTo: options.redirectTo}),
53 | forgotPassword: (email) => supabase.auth.api.resetPasswordForEmail(email),
54 | signOut: () => {
55 | setUserDetails(null);
56 | return supabase.auth.signOut();
57 | }
58 | };
59 | return ;
60 | };
61 |
62 | export const useUser = () => {
63 | const context = useContext(UserContext);
64 | if (context === undefined) {
65 | throw new Error(`useUser must be used within a UserContextProvider.`);
66 | }
67 | return context;
68 | };
69 |
70 | //Reset Password
71 | export const resetPassword = async (token, password) => {
72 | const { error, data } = await supabase.auth.api
73 | .updateUser(token, { password : password })
74 |
75 | if(error){
76 | return error;
77 | } else {
78 | return data
79 | }
80 | };
81 |
82 | export const paypalEmail = async (id, email) => {
83 | const { data, error } = await supabase
84 | .from('users')
85 | .update({
86 | paypal_email: email,
87 | })
88 | .match({ id: id })
89 |
90 | if (error) {
91 | return "error";
92 | } else {
93 | return "success";
94 | }
95 | };
--------------------------------------------------------------------------------
/apps/reflio/pages/dashboard/stripe-verify.js:
--------------------------------------------------------------------------------
1 | import { useState } from 'react';
2 | import { useRouter } from 'next/router';
3 | import { useUser, newStripeAccount } from '@/utils/useUser';
4 | import SetupProgress from '@/components/SetupProgress';
5 | import { useCompany } from '@/utils/CompanyContext';
6 | import { SEOMeta } from '@/templates/SEOMeta';
7 | import LoadingDots from '@/components/LoadingDots';
8 |
9 | export default function Onboarding() {
10 | const router = useRouter();
11 | const { user } = useUser();
12 | const { activeCompany } = useCompany();
13 | const [pageLoaded, setPageLoaded] = useState(false);
14 | const [runningStripeFunction, setRunningStripeFunction] = useState(false);
15 | const [error, setError] = useState(null);
16 |
17 | const handleAddStripeAccount = async (stripeId) => {
18 | setRunningStripeFunction(true);
19 |
20 | try {
21 | const tokenConfirm = await fetch('/api/get-stripe-id', {
22 | method: 'POST',
23 | headers: { "Content-Type": "application/json" },
24 | body: JSON.stringify({
25 | stripeCode: stripeId
26 | })
27 | }).then(function(response) {
28 | return response.json();
29 |
30 | }).then(function(data) {
31 | return data;
32 | });
33 |
34 | if(tokenConfirm?.stripe_id){
35 | const addStripeAccount = await newStripeAccount(user?.id, tokenConfirm?.stripe_id, activeCompany?.company_id);
36 |
37 | if(addStripeAccount === "success"){
38 | router.replace(`/dashboard/${activeCompany?.company_id}/setup/currency`);
39 | } else {
40 | if(addStripeAccount === "error"){
41 | setError("There was an error when connecting your Stripe account. Please try again later.")
42 | }
43 | }
44 | }
45 |
46 | } catch (error) {
47 | console.error(error);
48 | }
49 | };
50 |
51 | if(router?.query?.code && runningStripeFunction === false && user?.id && activeCompany?.company_id){
52 | handleAddStripeAccount(router?.query?.code);
53 | }
54 |
55 | return(
56 | <>
57 |
58 |
63 |
64 |
65 |
Verifying stripe account...
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 | {
74 | error !== null &&
75 |
81 | }
82 |
83 |
84 | >
85 | );
86 | }
--------------------------------------------------------------------------------
/apps/reflio-affiliate/templates/AdminNavbar/AdminNavItems.js:
--------------------------------------------------------------------------------
1 | import { Fragment } from 'react';
2 | import { useUser } from '@/utils/useUser';
3 | import { useRouter } from 'next/router';
4 | import { classNames } from '@/utils/helpers';
5 | import { Listbox, Transition } from '@headlessui/react';
6 | import { CheckIcon, SelectorIcon } from '@heroicons/react/solid';
7 | import {
8 | CogIcon,
9 | UserGroupIcon,
10 | CurrencyDollarIcon,
11 | TemplateIcon,
12 | SparklesIcon
13 | } from '@heroicons/react/outline';
14 |
15 | export const AdminNavItems = () => {
16 | const { signOut } = useUser();
17 | const router = useRouter();
18 |
19 | const navigation = [
20 | { name: 'Dashboard', href: `/dashboard`, icon: TemplateIcon },
21 | // { name: 'My Campaigns', href: `/dashboard/campaigns`, icon: UserGroupIcon },
22 | { name: 'Referrals', href: `/dashboard/referrals`, icon: SparklesIcon },
23 | {
24 | name: 'Commissions',
25 | href: `/dashboard/commissions`,
26 | icon: CurrencyDollarIcon
27 | }
28 | // { name: 'Campaign Finder', href: `/dashboard/campaigns/finder`, icon: SearchIcon },
29 | // { name: 'Settings', href: `/dashboard/settings`, icon: CogIcon }
30 | ];
31 |
32 | const secondaryNavigation = [{ name: 'Changelog', href: '/changelog' }];
33 |
34 | return (
35 | <>
36 |
40 |
60 |
61 |
62 | {/* {secondaryNavigation.map((item) => (
63 |
71 | {item.name}
72 |
73 | ))} */}
74 |
signOut()}
76 | className={
77 | 'text-md items-center rounded-md px-2 py-2 font-semibold'
78 | }
79 | >
80 | Sign out
81 |
82 |
83 |
84 |
85 | >
86 | );
87 | };
88 |
89 | export default AdminNavItems;
90 |
--------------------------------------------------------------------------------