mirror of
https://github.com/muerwre/orchidmap-front.git
synced 2025-04-25 19:16:41 +07:00
cleaned out user reducer
This commit is contained in:
parent
103097edbd
commit
af8d270460
13 changed files with 462 additions and 282 deletions
|
@ -1,6 +1,6 @@
|
|||
import axios from 'axios/index';
|
||||
import { API } from '$constants/api';
|
||||
import { IRootState, IRouteListItem, IRoute } from '$redux/user';
|
||||
import { IRootState, IRouteListItem } from '$redux/user';
|
||||
import { IUser } from '$constants/auth';
|
||||
import { CLIENT } from '$config/frontend';
|
||||
import { LatLngLiteral } from 'leaflet';
|
||||
|
@ -10,6 +10,7 @@ import {
|
|||
IResultWithStatus,
|
||||
configWithToken,
|
||||
} from './middleware';
|
||||
import { IRoute } from '$redux/map/types';
|
||||
|
||||
const arrayToObject = (array: any[], key: string): {} =>
|
||||
array.reduce((obj, el) => ({ ...obj, [el[key]]: el }), {});
|
||||
|
@ -63,7 +64,7 @@ export const getGuestToken = (): Promise<IResultWithStatus<{
|
|||
export const getStoredMap = ({
|
||||
name,
|
||||
}: {
|
||||
name: IRootState['address'];
|
||||
name: IRoute['address'];
|
||||
}): Promise<IResultWithStatus<{
|
||||
route: IRoute;
|
||||
error?: string;
|
||||
|
|
|
@ -1,7 +1,154 @@
|
|||
const ru = [' ','\\.',',',':','\\?','#','Я','я','Ю','ю','Ч','ч','Ш','ш','Щ','щ','Ж','ж','А','а','Б','б','В','в','Г','г','Д','д','Е','е','Ё','ё','З','з','И','и','Й','й','К','к','Л','л','М','м','Н','н', 'О','о','П','п','Р','р','С','с','Т','т','У','у','Ф','ф','Х','х','Ц','ц','Ы','ы','Ь','ь','Ъ','ъ','Э','э'];
|
||||
const en = ['_','','','','','','Ya','ya','Yu','yu','Ch','ch','Sh','sh','Sh','sh','Zh','zh','A','a','B','b','V','v','G','g','D','d','E','e','E','e','Z','z','I','i','J','j','K','k','L','l','M','m','N','n', 'O','o','P','p','R','r','S','s','T','t','U','u','F','f','H','h','C','c','Y','y','','','','','E', 'e'];
|
||||
const ru = [
|
||||
' ',
|
||||
'\\.',
|
||||
',',
|
||||
':',
|
||||
'\\?',
|
||||
'#',
|
||||
'Я',
|
||||
'я',
|
||||
'Ю',
|
||||
'ю',
|
||||
'Ч',
|
||||
'ч',
|
||||
'Ш',
|
||||
'ш',
|
||||
'Щ',
|
||||
'щ',
|
||||
'Ж',
|
||||
'ж',
|
||||
'А',
|
||||
'а',
|
||||
'Б',
|
||||
'б',
|
||||
'В',
|
||||
'в',
|
||||
'Г',
|
||||
'г',
|
||||
'Д',
|
||||
'д',
|
||||
'Е',
|
||||
'е',
|
||||
'Ё',
|
||||
'ё',
|
||||
'З',
|
||||
'з',
|
||||
'И',
|
||||
'и',
|
||||
'Й',
|
||||
'й',
|
||||
'К',
|
||||
'к',
|
||||
'Л',
|
||||
'л',
|
||||
'М',
|
||||
'м',
|
||||
'Н',
|
||||
'н',
|
||||
'О',
|
||||
'о',
|
||||
'П',
|
||||
'п',
|
||||
'Р',
|
||||
'р',
|
||||
'С',
|
||||
'с',
|
||||
'Т',
|
||||
'т',
|
||||
'У',
|
||||
'у',
|
||||
'Ф',
|
||||
'ф',
|
||||
'Х',
|
||||
'х',
|
||||
'Ц',
|
||||
'ц',
|
||||
'Ы',
|
||||
'ы',
|
||||
'Ь',
|
||||
'ь',
|
||||
'Ъ',
|
||||
'ъ',
|
||||
'Э',
|
||||
'э',
|
||||
];
|
||||
const en = [
|
||||
'_',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'Ya',
|
||||
'ya',
|
||||
'Yu',
|
||||
'yu',
|
||||
'Ch',
|
||||
'ch',
|
||||
'Sh',
|
||||
'sh',
|
||||
'Sh',
|
||||
'sh',
|
||||
'Zh',
|
||||
'zh',
|
||||
'A',
|
||||
'a',
|
||||
'B',
|
||||
'b',
|
||||
'V',
|
||||
'v',
|
||||
'G',
|
||||
'g',
|
||||
'D',
|
||||
'd',
|
||||
'E',
|
||||
'e',
|
||||
'E',
|
||||
'e',
|
||||
'Z',
|
||||
'z',
|
||||
'I',
|
||||
'i',
|
||||
'J',
|
||||
'j',
|
||||
'K',
|
||||
'k',
|
||||
'L',
|
||||
'l',
|
||||
'M',
|
||||
'm',
|
||||
'N',
|
||||
'n',
|
||||
'O',
|
||||
'o',
|
||||
'P',
|
||||
'p',
|
||||
'R',
|
||||
'r',
|
||||
'S',
|
||||
's',
|
||||
'T',
|
||||
't',
|
||||
'U',
|
||||
'u',
|
||||
'F',
|
||||
'f',
|
||||
'H',
|
||||
'h',
|
||||
'C',
|
||||
'c',
|
||||
'Y',
|
||||
'y',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'E',
|
||||
'e',
|
||||
];
|
||||
|
||||
export const removeGarbage = (text: string): string => text.replace(/[^A-Za-z\-_0-9]/ig, '_').replace(/_{2,}/ig, '_');
|
||||
export const removeGarbage = (text: string): string =>
|
||||
text.replace(/[^A-Za-z\-_0-9]/gi, '_').replace(/_{2,}/gi, '_');
|
||||
|
||||
export const toHours = (info: number): string => {
|
||||
const hrs = parseInt(String(info), 10);
|
||||
|
@ -10,10 +157,11 @@ export const toHours = (info: number): string => {
|
|||
return `${hrs}:${lmin}`;
|
||||
};
|
||||
|
||||
export const toTranslit = (string: string): string => (
|
||||
removeGarbage(ru.reduce((text, el, i) => (text.replace(new RegExp(ru[i], 'g'), en[i])), (String(string) || '')))
|
||||
);
|
||||
export const toTranslit = (string: string = ''): string =>
|
||||
removeGarbage(
|
||||
ru.reduce((text, el, i) => text.replace(new RegExp(ru[i], 'g'), en[i]), String(string) || '')
|
||||
);
|
||||
|
||||
export const parseDesc = (text: string): string => text.replace(/(\n{2,})/ig, "\n\n");
|
||||
export const parseDesc = (text: string = ''): string => text.replace(/(\n{2,})/gi, '\n\n');
|
||||
|
||||
// export const colorizeTitle = (text: string): string => text.replace(/(\[[^\]^]+\])/, ``)
|
||||
|
|
|
@ -3,7 +3,7 @@ import { COLORS, CLIENT } from '$config/frontend';
|
|||
import saveAs from 'file-saver';
|
||||
import { replaceProviderUrl } from '$constants/providers';
|
||||
import { STICKERS } from '$constants/stickers';
|
||||
import { ILatLng } from '$redux/map/types';
|
||||
import { ILatLng, IRoute } from '$redux/map/types';
|
||||
import { IStickerDump } from '$redux/map/types';
|
||||
import { IRootState } from '$redux/user';
|
||||
import {
|
||||
|
@ -469,5 +469,5 @@ export const composeStickers = async ({
|
|||
);
|
||||
};
|
||||
|
||||
export const downloadCanvas = (canvas: HTMLCanvasElement, title: IRootState['title']): void =>
|
||||
export const downloadCanvas = (canvas: HTMLCanvasElement, title: IRoute['title']): void =>
|
||||
canvas.toBlob(blob => saveAs(blob, title));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue