constants.ts 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. export const HIDDEN_PRODUCT_TAG = "nextjs-frontend-hidden";
  2. export const DEFAULT_OPTION = "Default Title";
  3. /**
  4. * productJsonLd constant
  5. */
  6. export const BASE_SCHEMA_URL = "https://schema.org";
  7. export const PRODUCT_TYPE = "Product";
  8. export const PRODUCT_OFFER_TYPE = "AggregateOffer";
  9. /**
  10. * cookies constant
  11. */
  12. export const TOKEN = "token";
  13. export const BASE_URL = process.env.NEXT_PUBLIC_SITE_URL;
  14. export const baseUrl = process.env.NEXT_PUBLIC_BAGISTO_ENDPOINT;
  15. // -----Pagination--------//
  16. export const PAGE = "page";
  17. export const LIMIT = "limit";
  18. export const LOADING = "loading";
  19. export const QUERY = "q";
  20. export const SORT = "sort";
  21. /**
  22. * Placeholder Images
  23. */
  24. export const SIGNUP_IMG = "/image/sign-in.webp";
  25. export const SIGNIN_IMG = "/image/login.webp";
  26. export const FORGET_PASSWORD_IMG = "/image/forget-password.webp";
  27. export const NOT_IMAGE = "/image/placeholder.webp";
  28. export const LOGO_IMG = "/image/logo.png";
  29. export const variants = {
  30. hidden: { opacity: 0, y: 50 },
  31. visible: { opacity: 1, y: 0 },
  32. };
  33. export function getImageUrl(url?: string, baseUrl?: string, fallback: string = NOT_IMAGE) {
  34. if (!url) return fallback;
  35. if (url.startsWith("http://") || url.startsWith("https://")) {
  36. return url;
  37. }
  38. return `${baseUrl}${url.startsWith("/") ? url : `/${url}`}`;
  39. }
  40. export type SortOrderTypes = {
  41. key: string;
  42. title: string;
  43. value: string;
  44. sortKey: string;
  45. reverse: boolean;
  46. };
  47. export const SortByFields: SortOrderTypes[] = [
  48. {
  49. key: "name-asc",
  50. title: "From A-Z",
  51. value: "name-asc",
  52. sortKey: "TITLE",
  53. reverse: false,
  54. },
  55. {
  56. key: "name-desc",
  57. title: "From Z-A",
  58. value: "name-desc",
  59. sortKey: "TITLE",
  60. reverse: true,
  61. },
  62. {
  63. key: "newest",
  64. title: "Newest First",
  65. value: "newest",
  66. sortKey: "CREATED_AT",
  67. reverse: true,
  68. },
  69. {
  70. key: "oldest",
  71. title: "Oldest First",
  72. value: "oldest",
  73. sortKey: "CREATED_AT",
  74. reverse: false,
  75. },
  76. {
  77. key: "price-asc",
  78. title: "Cheapest First",
  79. value: "price-asc",
  80. sortKey: "PRICE",
  81. reverse: false,
  82. },
  83. {
  84. key: "price-desc",
  85. title: "Expensive First",
  86. value: "price-desc",
  87. sortKey: "PRICE",
  88. reverse: true,
  89. },
  90. ];
  91. export const GUEST_CART_TOKEN = "guest_cart_token";
  92. export const GUEST_CART_ID = "guest_cart_id";
  93. export const IS_GUEST = "is_guest";
  94. export const CURRENT_CURRENCY = "current_currency";
  95. export const CURRENT_LOCAL = "current_local";
  96. export const CURRENT_CHANNEL = "current_channel";
  97. export const NEXTAUTH_TOKEN = "next-auth.session-token";
  98. export const NEXTAUTH_SECURE_TOKEN = "__Secure-next-auth.session-token";
  99. export const ORDER_ID = "order_id";
  100. export const EMAIL_REGEX = /^(?![.-])(?!.*[.-]@)(?!.*\.\.)[a-zA-Z0-9._-]+@[a-zA-Z0-9-]+(\.[a-zA-Z]{2,})+$/;
  101. export const IS_VALID_INPUT = /^[a-zA-Z0-9\s]*$/;
  102. export const IS_VALID_ADDRESS = /^[a-zA-Z0-9\s,\/-]*$/;
  103. export const IS_VALID_PHONE = /^[0-9]{10}$/;
  104. export const IS_VALID_PHONECODE = /^(\+\d+\s|\+\d+\-\d+\s|\+\d+\-\d+and\d+\-\d+\s)/; // +23 / +1-234 / +1-809and1-829
  105. export const IS_VALID_FULL_PHONE = /^(\+\d+\s|\+\d+\-\d+\s|\+\d+\-\d+and\d+\-\d+\s)\d{9,12}$/;