mainstack-payments 0.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/.env.sample +1 -0
  2. package/.eslintignore +5 -0
  3. package/.eslintrc.json +95 -0
  4. package/.github/PULL_REQUEST_TEMPLATE.md +15 -0
  5. package/.husky/commit-msg +4 -0
  6. package/.husky/pre-commit +6 -0
  7. package/.prettierignore +7 -0
  8. package/.prettierrc +9 -0
  9. package/.vscode/extensions.json +10 -0
  10. package/README.md +113 -0
  11. package/build/_redirects +1 -0
  12. package/build/mainstack-payments.js +97183 -0
  13. package/build/manifest.json +15 -0
  14. package/build/robots.txt +3 -0
  15. package/build/style.css +6 -0
  16. package/build/vite.svg +1 -0
  17. package/commitlint.config.cjs +1 -0
  18. package/index.html +31 -0
  19. package/package.json +86 -0
  20. package/public/_redirects +1 -0
  21. package/public/manifest.json +15 -0
  22. package/public/robots.txt +3 -0
  23. package/public/vite.svg +1 -0
  24. package/src/api/config.ts +36 -0
  25. package/src/api/index.ts +84 -0
  26. package/src/app.tsx +39 -0
  27. package/src/assets/images/tired-emoji.png +0 -0
  28. package/src/assets/styles/index.css +26 -0
  29. package/src/assets/themes/baseThemes.ts +30 -0
  30. package/src/components/CheckoutForm.tsx +426 -0
  31. package/src/components/DrawerModal.tsx +63 -0
  32. package/src/components/Payment.tsx +772 -0
  33. package/src/components/PaystackPaymentErrorModal.tsx +120 -0
  34. package/src/components/PaystackPaymentModal.tsx +120 -0
  35. package/src/components/WalletPay.tsx +160 -0
  36. package/src/constants/index.ts +3 -0
  37. package/src/enums/currenciesEnums.ts +7 -0
  38. package/src/hooks/usePayment.ts +60 -0
  39. package/src/index.ts +3 -0
  40. package/src/pages/Home.tsx +97 -0
  41. package/src/pages/Index.tsx +23 -0
  42. package/src/pages/Login.tsx +13 -0
  43. package/src/pages/Page404.tsx +13 -0
  44. package/src/pages/PaymentRedirect.tsx +15 -0
  45. package/src/routes/index.tsx +8 -0
  46. package/src/types/index.ts +48 -0
  47. package/src/utils/countries-flag.json +1752 -0
  48. package/src/utils/countries_flag.json +1502 -0
  49. package/src/utils/countries_with_flags_and_currencies.json +4004 -0
  50. package/src/utils/formatUnderscoreText.ts +5 -0
  51. package/src/utils/index.ts +4 -0
  52. package/src/utils/stringifyPrice.ts +37 -0
  53. package/src/utils/validations.ts +44 -0
  54. package/tsconfig.json +35 -0
  55. package/vite.config.ts +36 -0
@@ -0,0 +1,5 @@
1
+ /** @format */
2
+
3
+ export const replaceUnderscores = (input: string): string => {
4
+ return input?.replace(/_/g, " ");
5
+ };
@@ -0,0 +1,4 @@
1
+ /** @format */
2
+
3
+ export { replaceUnderscores } from "./formatUnderscoreText";
4
+ export { stringifyPrice } from "./stringifyPrice";
@@ -0,0 +1,37 @@
1
+ /** @format */
2
+
3
+ const roundToTwo = (num: number) => {
4
+ return Math.round((num + Number.EPSILON) * 100) / 100;
5
+ };
6
+
7
+ export const stringifyPrice = (price: any | number | bigint) => {
8
+ const valToStringify =
9
+ price &&
10
+ roundToTwo(Number(price)) &&
11
+ roundToTwo(Number(price)).toString().split(".")[0];
12
+ const rev: any[] =
13
+ valToStringify && valToStringify.toString().split("").reverse();
14
+
15
+ const newPrice: any = [];
16
+ for (let i = 0; i < rev?.length; i++) {
17
+ if (
18
+ rev?.length > 3 &&
19
+ i + 1 !== rev?.length &&
20
+ (i + 1) % 3 === 0 &&
21
+ i + 1 >= 3
22
+ ) {
23
+ newPrice.push(rev[i], ",");
24
+ } else {
25
+ newPrice.push(rev[i]);
26
+ }
27
+ }
28
+
29
+ const secondString =
30
+ price && roundToTwo(Number(price)).toString().split(".")[1];
31
+ return `${newPrice.reverse().join("") || 0}${
32
+ secondString ? `.${(secondString || "")?.padEnd(2, "0") || "00"}` : ""
33
+ }`;
34
+ // return `${newPrice.reverse().join("")}`;
35
+ };
36
+
37
+ export { roundToTwo };
@@ -0,0 +1,44 @@
1
+ /** @format */
2
+
3
+ import * as yup from "yup";
4
+
5
+ export const VALIDATIONS = {
6
+ email: yup
7
+ .string()
8
+ .matches(
9
+ /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,
10
+ "Please enter a valid email"
11
+ )
12
+ .required("Please enter your email address"),
13
+ fullname: yup
14
+ .string()
15
+ .required("Please enter your fullname")
16
+ .matches(
17
+ /^[a-z- ]{3,40}$/i,
18
+ "Only 3 to 40 characters containing alphabets, numbers, _ and - are allowed"
19
+ ),
20
+ username: yup
21
+ .string()
22
+ .required("Please enter a username")
23
+ .matches(
24
+ /^(?![0-9._])(?!.*d_)(?!.*_d)[a-zA-Z0-9_]+$/,
25
+ "Only letters, numbers and _ are allowed"
26
+ )
27
+ .ensure(),
28
+ password: yup.string().required("Please enter a password"),
29
+ url: yup
30
+ .string()
31
+ .url("Must be a valid mainstack url")
32
+ .required("URL is required"),
33
+ name: yup
34
+ .string()
35
+ .required("Please enter name")
36
+ .matches(
37
+ /^(?![0-9._])(?!.*d_)(?!.*_d)\w+( \w+)*$/,
38
+ "Only letters, numbers and _ are allowed"
39
+ ),
40
+ firstname: yup.string().required("First name is required"),
41
+ lastname: yup.string().required("Last name is required"),
42
+ country: yup.string().required("Country is required"),
43
+ message: yup.string().required("Please type a message"),
44
+ };
package/tsconfig.json ADDED
@@ -0,0 +1,35 @@
1
+ {
2
+ "compilerOptions": {
3
+ "types": ["vite/client", "vite-plugin-svgr/client"],
4
+ "target": "es6",
5
+ "useDefineForClassFields": true,
6
+ "lib": ["DOM", "DOM.Iterable", "esnext"],
7
+ "allowJs": false,
8
+ "skipLibCheck": true,
9
+ "esModuleInterop": false,
10
+ "allowSyntheticDefaultImports": true,
11
+ "strict": true,
12
+ "forceConsistentCasingInFileNames": true,
13
+ "module": "esnext",
14
+ "moduleResolution": "node",
15
+ "resolveJsonModule": true,
16
+ "isolatedModules": true,
17
+ "noEmit": true,
18
+ "jsx": "react-jsx",
19
+ "composite": true,
20
+ "paths": {
21
+ // "*": ["./*"],
22
+ "@/*": ["./src/*"]
23
+ },
24
+ "baseUrl": "src"
25
+ },
26
+ "include": [
27
+ "src",
28
+ "vite.config.ts",
29
+ "**/*.ts",
30
+ "**/*.tsx",
31
+ "**/*.json",
32
+ "commitlint.config.cjs"
33
+ ],
34
+ "exclude": ["node_modules"]
35
+ }
package/vite.config.ts ADDED
@@ -0,0 +1,36 @@
1
+ /** @format */
2
+
3
+ import { defineConfig } from "vite";
4
+ import react from "@vitejs/plugin-react";
5
+ import viteTsconfigPaths from "vite-tsconfig-paths";
6
+ import svgrPlugin from "vite-plugin-svgr";
7
+ import envCompatible from "vite-plugin-env-compatible";
8
+ import path from "path";
9
+
10
+ // /** @type {import('vite').UserConfig} */
11
+ // export default {
12
+
13
+ // };
14
+ export default defineConfig({
15
+ envPrefix: "REACT_APP_",
16
+ plugins: [react(), viteTsconfigPaths(), svgrPlugin()],
17
+ server: {
18
+ open: true,
19
+ port: 3008,
20
+ },
21
+ resolve: {
22
+ alias: {
23
+ "@": path.resolve(__dirname, "./src"),
24
+ },
25
+ },
26
+ build: {
27
+ outDir: "build",
28
+ lib: {
29
+ entry: path.resolve(__dirname, "src/index.ts"),
30
+ formats: ["es"],
31
+ },
32
+ commonjsOptions: {
33
+ transformMixedEsModules: true,
34
+ },
35
+ },
36
+ });