Commit b739e9b2 authored by AlexandrValgamov's avatar AlexandrValgamov
Browse files

Widget | feat: add utils

parent 35000071
Loading
Loading
Loading
Loading
+65 −0
Original line number Diff line number Diff line
export const REGEX_HEADER =
  /^\/(?:catalog\/\w+\/\d)?$|^\/(?:catalog\/\w+\/\w+)?$/;
export const REGEX_FOOTER =
  /^\/(?:catalog\/\w+\/\d)?$|^\/(?:catalog\/\w+\/\w+)?$/;
export const REGEX_FOOTER_ICON = /^\/catalog\/.*$/;
export const ANIMATION_TIME = 500;

export const AUTH_TITLES = {
  1: 'Познакомимся поближе, как мы можем к вам обращаться?',
  2: 'Когда вы родились?',
  3: 'Чем будете расплачиваться?',
  4: 'Еще не много',
};

export const PROTECTED_ROUTES = ['/logout', '/refresh', '/payment', '/users/'];

export const ERROR_MESSAGES = {
  404: {
    title: 'Упс, промашечка',
    subtitle: 'К сожалению, данная страница спрятана в Нарнии',
    iconSrc: '/not-found-widget.png',
  },
  500: {
    title: 'Упс, ошибочка',
    subtitle: 'К сожалению, возникли проблемы с серверами в Нарнии',
    iconSrc: '/server-error-widget.png',
  },
};

export const avatars = [
  '002-devil',
  '003-superhero',
  '004-superhero-1',
  '005-superhero-2',
  '006-superhero-3',
  '007-superhero-4',
  '008-superhero-5',
  '009-superhero-6',
  '010-superhero-7',
  '012-superhero-8',
  '013-clapperboard',
  '014-clapperboard-1',
  '015-superhero-9',
  '016-superhero-10',
  '017-superhero-11',
  '018-superhero-12',
  '019-superhero-13',
  '021-superhero-14',
  '023-negative',
  '024-villian-1',
  '025-superhero-15',
  '026-superhero-16',
  '027-superhero-17',
  '028-superhero-18',
  '029-villian-2',
  '030-villian-3',
  '031-superhero-19',
  '033-superhero-21',
  '034-tickets',
  '035-robot',
  '036-robot-1',
  '037-superhero-22',
  '038-superhero-23',
  'avatar',
];
+1 −0
Original line number Diff line number Diff line
export * from './constants';
+6 −0
Original line number Diff line number Diff line
export const formatPrice = (cost: number) =>
  new Intl.NumberFormat('ru-RU', {
    style: 'currency',
    currency: 'RUB',
    maximumFractionDigits: 0,
  }).format(cost);
+4 −0
Original line number Diff line number Diff line
import { type Catalog, type MenuCategory } from '@/interfaces';

export const getCategories = (data: Catalog): MenuCategory[] =>
  Object.values(data.categories || {});
+6 −0
Original line number Diff line number Diff line
export const getErrorMessage = (error: Error | null) => {
  if (error instanceof Error) {
    return error.message;
  }
  return 'Неизвестная ошибка';
};
Loading