mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 04:46:40 +07:00
fixed ramda imports to reduce bundle size
This commit is contained in:
parent
a497912049
commit
097b091abd
47 changed files with 208 additions and 91 deletions
|
@ -1,11 +1,10 @@
|
|||
import React, { useCallback, VFC } from 'react';
|
||||
|
||||
import { path } from 'ramda';
|
||||
|
||||
import { Icon } from '~/components/input/Icon';
|
||||
import { PlayerState } from '~/constants/player';
|
||||
import { IFile } from '~/types';
|
||||
import { PlayerProgress } from '~/types/player';
|
||||
import { path } from '~/utils/ramda';
|
||||
|
||||
import styles from './styles.module.scss';
|
||||
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
import React, { FC, useCallback, useState } from 'react';
|
||||
|
||||
import { path } from 'ramda';
|
||||
import { Manager, Popper, Reference } from 'react-popper';
|
||||
|
||||
import { Avatar } from '~/components/common/Avatar';
|
||||
import { useRandomPhrase } from '~/constants/phrases';
|
||||
import { IUser } from '~/types/auth';
|
||||
import { path } from '~/utils/ramda';
|
||||
|
||||
import styles from './styles.module.scss';
|
||||
|
||||
|
|
|
@ -2,8 +2,6 @@ import React, { createElement, FC, Fragment, memo, useCallback, useMemo, useStat
|
|||
|
||||
import classnames from 'classnames';
|
||||
import classNames from 'classnames';
|
||||
import { append, assocPath, path } from 'ramda';
|
||||
import reduce from 'ramda/es/reduce';
|
||||
|
||||
import { CommentForm } from '~/components/comment/CommentForm';
|
||||
import { Group } from '~/components/containers/Group';
|
||||
|
@ -13,14 +11,12 @@ import { UploadType } from '~/constants/uploads';
|
|||
import { PRESETS } from '~/constants/urls';
|
||||
import { IComment, IFile } from '~/types';
|
||||
import { formatCommentText, getPrettyDate, getURL } from '~/utils/dom';
|
||||
import { append, assocPath, path, reduce } from '~/utils/ramda';
|
||||
|
||||
import { CommentMenu } from '../CommentMenu';
|
||||
|
||||
import styles from './styles.module.scss';
|
||||
|
||||
|
||||
|
||||
|
||||
interface IProps {
|
||||
nodeId: number;
|
||||
comment: IComment;
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
import React, { FC } from 'react';
|
||||
|
||||
import classNames from 'classnames';
|
||||
import { path } from 'ramda';
|
||||
|
||||
import { CommentAvatar } from '~/components/comment/CommentAvatar';
|
||||
import { IUser } from '~/types/auth';
|
||||
import { path } from '~/utils/ramda';
|
||||
import { DivProps } from '~/utils/types';
|
||||
|
||||
import styles from './styles.module.scss';
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
import React, { FC, useCallback, useMemo } from 'react';
|
||||
|
||||
import { values } from 'ramda';
|
||||
|
||||
import { UploadDropzone } from '~/components/upload/UploadDropzone';
|
||||
import { UploadType } from '~/constants/uploads';
|
||||
import { useNodeAudios } from '~/hooks/node/useNodeAudios';
|
||||
|
@ -9,13 +7,13 @@ import { useNodeFormContext } from '~/hooks/node/useNodeFormFormik';
|
|||
import { useNodeImages } from '~/hooks/node/useNodeImages';
|
||||
import { NodeEditorProps } from '~/types/node';
|
||||
import { useUploaderContext } from '~/utils/context/UploaderContextProvider';
|
||||
import { values } from '~/utils/ramda';
|
||||
|
||||
import { AudioGrid } from '../AudioGrid';
|
||||
import { ImageGrid } from '../ImageGrid';
|
||||
|
||||
import styles from './styles.module.scss';
|
||||
|
||||
|
||||
type IProps = NodeEditorProps;
|
||||
|
||||
const AudioEditor: FC<IProps> = () => {
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
import React, { createElement, FC } from 'react';
|
||||
|
||||
import { has } from 'ramda';
|
||||
|
||||
import { NODE_PANEL_COMPONENTS } from '~/constants/node';
|
||||
import { useNodeFormContext } from '~/hooks/node/useNodeFormFormik';
|
||||
import { has } from '~/utils/ramda';
|
||||
|
||||
import styles from './styles.module.scss';
|
||||
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
import React, { FC } from 'react';
|
||||
|
||||
import { values } from 'ramda';
|
||||
|
||||
import { ImageGrid } from '~/components/editors/ImageGrid';
|
||||
import { UploadDropzone } from '~/components/upload/UploadDropzone';
|
||||
import { NodeEditorProps } from '~/types/node';
|
||||
import { useUploaderContext } from '~/utils/context/UploaderContextProvider';
|
||||
import { values } from '~/utils/ramda';
|
||||
|
||||
import styles from './styles.module.scss';
|
||||
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
import React, { FC, useCallback } from 'react';
|
||||
|
||||
import { path } from 'ramda';
|
||||
|
||||
import { Textarea } from '~/components/input/Textarea';
|
||||
import { useRandomPhrase } from '~/constants/phrases';
|
||||
import { useNodeFormContext } from '~/hooks/node/useNodeFormFormik';
|
||||
import { NodeEditorProps } from '~/types/node';
|
||||
import { path } from '~/utils/ramda';
|
||||
|
||||
import styles from './styles.module.scss';
|
||||
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
import React, { FC, useCallback, useMemo } from 'react';
|
||||
|
||||
import classnames from 'classnames';
|
||||
import { path } from 'ramda';
|
||||
|
||||
import { InputText } from '~/components/input/InputText';
|
||||
import { useNodeFormContext } from '~/hooks/node/useNodeFormFormik';
|
||||
import { NodeEditorProps } from '~/types/node';
|
||||
import { getYoutubeThumb } from '~/utils/dom';
|
||||
import { path } from '~/utils/ramda';
|
||||
|
||||
import styles from './styles.module.scss';
|
||||
|
||||
|
|
|
@ -1,16 +1,14 @@
|
|||
import React, { FC, useMemo } from 'react';
|
||||
|
||||
import { path } from 'ramda';
|
||||
|
||||
import { Markdown } from '~/components/containers/Markdown';
|
||||
import { Paragraph } from '~/components/placeholders/Paragraph';
|
||||
import { INodeComponentProps } from '~/constants/node';
|
||||
import { useGotoNode } from '~/hooks/node/useGotoNode';
|
||||
import { formatTextParagraphs } from '~/utils/dom';
|
||||
import { path } from '~/utils/ramda';
|
||||
|
||||
import styles from './styles.module.scss';
|
||||
|
||||
|
||||
const LabText: FC<INodeComponentProps> = ({ node, isLoading }) => {
|
||||
const content = useMemo(() => formatTextParagraphs(path(['blocks', 0, 'text'], node) || ''), [
|
||||
node,
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
import React, { FC } from 'react';
|
||||
|
||||
import { path } from 'ramda';
|
||||
|
||||
import { INodeComponentProps } from '~/constants/node';
|
||||
import { PRESETS } from '~/constants/urls';
|
||||
import { useNodeImages } from '~/hooks/node/useNodeImages';
|
||||
import { getURL } from '~/utils/dom';
|
||||
import { path } from '~/utils/ramda';
|
||||
|
||||
import styles from './styles.module.scss';
|
||||
|
||||
|
|
|
@ -1,15 +1,14 @@
|
|||
import React, { FC, memo } from 'react';
|
||||
|
||||
import classNames from 'classnames';
|
||||
import range from 'ramda/es/range';
|
||||
|
||||
import { Group } from '~/components/containers/Group';
|
||||
import cell_style from '~/components/node/NodeRelatedItem/styles.module.scss';
|
||||
import { Placeholder } from '~/components/placeholders/Placeholder';
|
||||
import { range } from '~/utils/ramda';
|
||||
|
||||
import styles from './styles.module.scss';
|
||||
|
||||
|
||||
interface IProps {}
|
||||
|
||||
const NodeRelatedPlaceholder: FC<IProps> = memo(() => {
|
||||
|
|
|
@ -1,15 +1,14 @@
|
|||
import React, { FC, useMemo } from 'react';
|
||||
|
||||
import classNames from 'classnames';
|
||||
import { path } from 'ramda';
|
||||
|
||||
import { INodeComponentProps } from '~/constants/node';
|
||||
import markdown from '~/styles/common/markdown.module.scss';
|
||||
import { formatTextParagraphs } from '~/utils/dom';
|
||||
import { path } from '~/utils/ramda';
|
||||
|
||||
import styles from './styles.module.scss';
|
||||
|
||||
|
||||
interface IProps extends INodeComponentProps {}
|
||||
|
||||
const NodeTextBlock: FC<IProps> = ({ node }) => {
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
import React, { FC, useMemo } from 'react';
|
||||
|
||||
import { path } from 'ramda';
|
||||
|
||||
import { INodeComponentProps } from '~/constants/node';
|
||||
import { path } from '~/utils/ramda';
|
||||
|
||||
import styles from './styles.module.scss';
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import React, { FC } from 'react';
|
||||
|
||||
import classNames from 'classnames';
|
||||
import { has } from 'ramda';
|
||||
|
||||
import { Filler } from '~/components/containers/Filler';
|
||||
import { Group } from '~/components/containers/Group';
|
||||
|
@ -13,7 +12,7 @@ import { ProfileAccounts } from '~/containers/profile/ProfileAccounts';
|
|||
import { usePatchUser } from '~/hooks/auth/usePatchUser';
|
||||
import { useUser } from '~/hooks/auth/useUser';
|
||||
import { useProfileForm } from '~/hooks/profile/useProfileForm';
|
||||
|
||||
import { has } from '~/utils/ramda';
|
||||
|
||||
import styles from './styles.module.scss';
|
||||
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
import React, { FC, useCallback, useMemo, useRef } from 'react';
|
||||
|
||||
import { values } from 'ramda';
|
||||
|
||||
import { EMPTY_NODE, NODE_TYPES } from '~/constants/node';
|
||||
import { EditorDialog } from '~/containers/dialogs/EditorDialog';
|
||||
import { useCreateNode } from '~/hooks/node/useCreateNode';
|
||||
import { INode } from '~/types';
|
||||
import { DialogComponentProps } from '~/types/modal';
|
||||
import { values } from '~/utils/ramda';
|
||||
|
||||
export interface EditorCreateDialogProps extends DialogComponentProps {
|
||||
type: typeof NODE_TYPES[keyof typeof NODE_TYPES];
|
||||
|
|
|
@ -2,7 +2,6 @@ import React, { createElement, FC, useCallback, useMemo, useState } from 'react'
|
|||
|
||||
import { FormikProvider } from 'formik';
|
||||
import { observer } from 'mobx-react-lite';
|
||||
import { prop } from 'ramda';
|
||||
|
||||
import { CoverBackdrop } from '~/components/containers/CoverBackdrop';
|
||||
import { BetterScrollDialog } from '~/components/dialogs/BetterScrollDialog';
|
||||
|
@ -16,7 +15,7 @@ import { useNodeFormFormik } from '~/hooks/node/useNodeFormFormik';
|
|||
import { INode } from '~/types';
|
||||
import { DialogComponentProps } from '~/types/modal';
|
||||
import { UploaderContextProvider } from '~/utils/context/UploaderContextProvider';
|
||||
|
||||
import { prop } from '~/utils/ramda';
|
||||
|
||||
import styles from './styles.module.scss';
|
||||
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
import React, { FC } from 'react';
|
||||
|
||||
import { observer } from 'mobx-react-lite';
|
||||
import { has } from 'ramda';
|
||||
|
||||
import { ModalWrapper } from '~/components/dialogs/ModalWrapper';
|
||||
import { DIALOG_CONTENT } from '~/constants/modal';
|
||||
import { useModalStore } from '~/store/modal/useModalStore';
|
||||
import { has } from '~/utils/ramda';
|
||||
|
||||
type IProps = {};
|
||||
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
import React, { FC } from 'react';
|
||||
|
||||
import { values } from 'ramda';
|
||||
import Masonry from 'react-masonry-css';
|
||||
|
||||
import { InfiniteScroll } from '~/components/containers/InfiniteScroll';
|
||||
import { LabNode } from '~/components/lab/LabNode';
|
||||
import { EMPTY_NODE, NODE_TYPES } from '~/constants/node';
|
||||
import { useLabContext } from '~/utils/context/LabContextProvider';
|
||||
import { values } from '~/utils/ramda';
|
||||
|
||||
import styles from './styles.module.scss';
|
||||
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
import React, { FC, HTMLAttributes, useCallback, useMemo, useState } from 'react';
|
||||
|
||||
import { uniq } from 'ramda';
|
||||
|
||||
import { TagField } from '~/components/containers/TagField';
|
||||
import { Tag } from '~/components/tags/Tag';
|
||||
import { TagInput } from '~/containers/tags/TagInput';
|
||||
import { ITag } from '~/types';
|
||||
import { uniq } from '~/utils/ramda';
|
||||
import { separateTags } from '~/utils/tag';
|
||||
|
||||
type IProps = HTMLAttributes<HTMLDivElement> & {
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
import { useEffect } from 'react';
|
||||
|
||||
import { includes, path, values } from 'ramda';
|
||||
|
||||
import { EventMessageType } from '~/constants/events';
|
||||
import { Dialog } from '~/constants/modal';
|
||||
import { useAuth } from '~/hooks/auth/useAuth';
|
||||
import { useOAuth } from '~/hooks/auth/useOAuth';
|
||||
import { useModal } from '~/hooks/modal/useModal';
|
||||
import { includes, path, values } from '~/utils/ramda';
|
||||
|
||||
/** reacts to events passed by window.postMessage */
|
||||
export const useMessageEventReactions = () => {
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import { useCallback, useMemo } from 'react';
|
||||
|
||||
import { path } from 'ramda';
|
||||
import useSWR from 'swr';
|
||||
|
||||
import { apiAttachSocial, apiDropSocial, apiGetSocials, apiLoginWithSocial } from '~/api/auth';
|
||||
|
@ -10,6 +9,7 @@ import { useAuth } from '~/hooks/auth/useAuth';
|
|||
import { useModal } from '~/hooks/modal/useModal';
|
||||
import { OAuthProvider } from '~/types/auth';
|
||||
import { showErrorToast } from '~/utils/errors/showToast';
|
||||
import { path } from '~/utils/ramda';
|
||||
|
||||
export const useOAuth = () => {
|
||||
const { isUser, setToken } = useAuth();
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
import { useCallback, useEffect, useRef } from 'react';
|
||||
|
||||
import { FormikHelpers, useFormik, useFormikContext } from 'formik';
|
||||
import { hasPath, path } from 'ramda';
|
||||
import { array, object, string } from 'yup';
|
||||
|
||||
import { IComment, INode } from '~/types';
|
||||
import { Uploader } from '~/utils/context/UploaderContextProvider';
|
||||
import { showErrorToast } from '~/utils/errors/showToast';
|
||||
import { hasPath, path } from '~/utils/ramda';
|
||||
|
||||
const validationSchema = object().shape({
|
||||
text: string(),
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
import { useCallback, useMemo } from 'react';
|
||||
|
||||
import { flatten, isNil } from 'ramda';
|
||||
import useSWRInfinite, { SWRInfiniteKeyLoader } from 'swr/infinite';
|
||||
|
||||
import { apiGetNodeComments } from '~/api/node';
|
||||
import { API } from '~/constants/api';
|
||||
import { COMMENTS_DISPLAY } from '~/constants/node';
|
||||
import { IComment } from '~/types';
|
||||
import { flatten, isNil } from '~/utils/ramda';
|
||||
|
||||
const getKey: (nodeId: number) => SWRInfiniteKeyLoader = (nodeId: number) => (
|
||||
pageIndex,
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
import { useMemo } from 'react';
|
||||
|
||||
import { has } from 'ramda';
|
||||
|
||||
import { ERROR_LITERAL } from '~/constants/errors';
|
||||
import { has } from '~/utils/ramda';
|
||||
|
||||
export const useTranslatedError = (error: string | undefined) => {
|
||||
return useMemo(() => {
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import { useCallback } from 'react';
|
||||
|
||||
import { useLocalObservable } from 'mobx-react-lite';
|
||||
import { keys } from 'ramda';
|
||||
import uuid from 'uuid4';
|
||||
|
||||
import { apiUploadFile } from '~/api/uploads';
|
||||
|
@ -9,7 +8,7 @@ import { UploadSubject, UploadTarget } from '~/constants/uploads';
|
|||
import { UploaderStore } from '~/store/uploader/UploaderStore';
|
||||
import { IFile } from '~/types';
|
||||
import { showErrorToast } from '~/utils/errors/showToast';
|
||||
|
||||
import { keys } from '~/utils/ramda';
|
||||
|
||||
export const useUploader = (
|
||||
subject: UploadSubject,
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
import { useCallback, useState } from 'react';
|
||||
|
||||
import { runInAction } from 'mobx';
|
||||
import { uniq } from 'ramda';
|
||||
|
||||
import { getNodeDiff } from '~/api/node';
|
||||
import { useFlowStore } from '~/store/flow/useFlowStore';
|
||||
import { showErrorToast } from '~/utils/errors/showToast';
|
||||
import { uniq } from '~/utils/ramda';
|
||||
|
||||
export const useFlowLoader = () => {
|
||||
const [isSyncing, setIsSyncing] = useState(false);
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import { useCallback, useMemo } from 'react';
|
||||
|
||||
import { flatten, last, uniqBy } from 'ramda';
|
||||
import useSWRInfinite, { SWRInfiniteKeyLoader } from 'swr/infinite';
|
||||
|
||||
import { getLabNodes } from '~/api/lab';
|
||||
|
@ -8,6 +7,7 @@ import { useAuth } from '~/hooks/auth/useAuth';
|
|||
import { useLabStore } from '~/store/lab/useLabStore';
|
||||
import { INode } from '~/types';
|
||||
import { GetLabNodesRequest, ILabNode } from '~/types/lab';
|
||||
import { flatten, last, uniqBy } from '~/utils/ramda';
|
||||
|
||||
const getKey: (isUser: boolean) => SWRInfiniteKeyLoader = isUser => (index, prev: ILabNode[]) => {
|
||||
if (!isUser) return null;
|
||||
|
|
|
@ -1,9 +1,14 @@
|
|||
import { createElement, FC, useCallback, useMemo } from 'react';
|
||||
|
||||
import { isNil, prop } from 'ramda';
|
||||
|
||||
import { INodeComponentProps, LAB_PREVIEW_LAYOUT, NODE_COMPONENTS, NODE_HEADS, NODE_INLINES } from '~/constants/node';
|
||||
import {
|
||||
INodeComponentProps,
|
||||
LAB_PREVIEW_LAYOUT,
|
||||
NODE_COMPONENTS,
|
||||
NODE_HEADS,
|
||||
NODE_INLINES,
|
||||
} from '~/constants/node';
|
||||
import { INode } from '~/types';
|
||||
import { isNil, prop } from '~/utils/ramda';
|
||||
|
||||
// useNodeBlocks returns head, block and inline blocks of node
|
||||
export const useNodeBlocks = (node: INode, isLoading: boolean) => {
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
import { useCallback, useEffect, useMemo, useState } from 'react';
|
||||
|
||||
import { flatten } from 'ramda';
|
||||
import useSWRInfinite, { SWRInfiniteKeyLoader } from 'swr/infinite';
|
||||
|
||||
import { getSearchResults } from '~/api/flow';
|
||||
import { INode } from '~/types';
|
||||
import { GetSearchResultsRequest } from '~/types/flow';
|
||||
import { flatten } from '~/utils/ramda';
|
||||
|
||||
const RESULTS_COUNT = 20;
|
||||
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
import { useCallback, useMemo } from 'react';
|
||||
|
||||
import { flatten, isNil } from 'ramda';
|
||||
import useSWRInfinite, { SWRInfiniteKeyLoader } from 'swr/infinite';
|
||||
|
||||
import { apiGetNodesOfTag } from '~/api/tags';
|
||||
import { API } from '~/constants/api';
|
||||
import { INode } from '~/types';
|
||||
import { flatten, isNil } from '~/utils/ramda';
|
||||
|
||||
const PAGE_SIZE = 10;
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { autorun, makeAutoObservable, runInAction } from 'mobx';
|
||||
import { keys, values, without } from 'ramda';
|
||||
|
||||
import { EmbedMetadata } from '~/types/metadata';
|
||||
import { keys, values, without } from '~/utils/ramda';
|
||||
|
||||
const MAX_QUEUE_SIZE = 25;
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import { makeAutoObservable, runInAction } from 'mobx';
|
||||
import { has, omit, values } from 'ramda';
|
||||
|
||||
import { ERROR_LITERAL, ERRORS } from '~/constants/errors';
|
||||
import { UploadType } from '~/constants/uploads';
|
||||
import { IFile, UUID } from '~/types';
|
||||
import { has, omit, values } from '~/utils/ramda';
|
||||
import { getFileType, uploadGetThumb } from '~/utils/uploader';
|
||||
|
||||
export interface UploadStatus {
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import axios, { AxiosError, AxiosResponse } from 'axios';
|
||||
import { assocPath } from 'ramda';
|
||||
|
||||
import { API } from '~/constants/api';
|
||||
import { getMOBXStore } from '~/store';
|
||||
import { assocPath } from '~/utils/ramda';
|
||||
|
||||
export const api = axios.create({
|
||||
baseURL: API.BASE,
|
||||
|
|
|
@ -4,7 +4,6 @@ import format from 'date-fns/format';
|
|||
import formatDistanceToNow from 'date-fns/formatDistanceToNow';
|
||||
import isAfter from 'date-fns/isAfter';
|
||||
import ru from 'date-fns/locale/ru';
|
||||
import { pipe } from 'ramda';
|
||||
|
||||
import { COMMENT_BLOCK_DETECTORS, COMMENT_BLOCK_TYPES, ICommentBlock } from '~/constants/comment';
|
||||
import { PRESETS } from '~/constants/urls';
|
||||
|
@ -20,6 +19,7 @@ import {
|
|||
formatTextSanitizeYoutube,
|
||||
formatTextTodos,
|
||||
} from '~/utils/formatText';
|
||||
import { pipe } from '~/utils/ramda';
|
||||
import { splitTextByYoutube, splitTextOmitEmpty } from '~/utils/splitText';
|
||||
|
||||
function polarToCartesian(centerX, centerY, radius, angleInDegrees) {
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import { has, path } from 'ramda';
|
||||
|
||||
import { ERROR_LITERAL, ERRORS } from '~/constants/errors';
|
||||
import { has, path } from '~/utils/ramda';
|
||||
|
||||
export const getErrorMessage = (error: unknown): string | undefined => {
|
||||
if (error === undefined) {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { hasPath, path } from 'ramda';
|
||||
import { hasPath, path } from '~/utils/ramda';
|
||||
|
||||
export const getValidationErrors = (error: unknown): Record<string, string> | undefined => {
|
||||
if (hasPath(['response', 'data', 'errors'], error)) {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { isAfter, isValid, parseISO } from 'date-fns';
|
||||
import { curry, insert, nth, path, remove } from 'ramda';
|
||||
|
||||
import { IComment, ICommentGroup } from '~/types';
|
||||
import { curry, insert, nth, path, remove } from '~/utils/ramda';
|
||||
|
||||
export const moveArrItem = curry((at, to, list) => insert(to, nth(at, list), remove(at, 1, list)));
|
||||
export const objFromArray = (array: any[], key: string) =>
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
import { path } from 'ramda';
|
||||
|
||||
import { Role } from '~/constants/auth';
|
||||
import { NODE_TYPES } from '~/constants/node';
|
||||
import { ICommentGroup, INode } from '~/types';
|
||||
import { IUser } from '~/types/auth';
|
||||
import { path } from '~/utils/ramda';
|
||||
|
||||
export const canEditNode = (node?: Partial<INode>, user?: Partial<IUser>): boolean =>
|
||||
path(['role'], user) === Role.Admin || path(['user', 'id'], node) === path(['id'], user);
|
||||
|
|
|
@ -1,11 +1,18 @@
|
|||
import React, { createContext, FC, useCallback, useContext, useEffect, useRef, useState } from 'react';
|
||||
|
||||
import { path } from 'ramda';
|
||||
import React, {
|
||||
createContext,
|
||||
FC,
|
||||
useCallback,
|
||||
useContext,
|
||||
useEffect,
|
||||
useRef,
|
||||
useState,
|
||||
} from 'react';
|
||||
|
||||
import { PlayerState } from '~/constants/player';
|
||||
import { IFile } from '~/types';
|
||||
import { PlayerProgress } from '~/types/player';
|
||||
import { getURL } from '~/utils/dom';
|
||||
import { path } from '~/utils/ramda';
|
||||
|
||||
interface AudioPlayerProps {
|
||||
file?: IFile;
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
import React, { createContext, FC, useContext, useMemo } from 'react';
|
||||
|
||||
import { observer } from 'mobx-react-lite';
|
||||
import { uniq } from 'ramda';
|
||||
|
||||
import { useFlow } from '~/hooks/flow/useFlow';
|
||||
import { FlowDisplay, IFlowNode, INode } from '~/types';
|
||||
import { GetNodeDiffResult } from '~/types/node';
|
||||
import { uniq } from '~/utils/ramda';
|
||||
|
||||
export interface FlowProviderProps {
|
||||
fallbackData?: GetNodeDiffResult;
|
||||
|
|
24
src/utils/ramda.ts
Normal file
24
src/utils/ramda.ts
Normal file
|
@ -0,0 +1,24 @@
|
|||
export { default as has } from 'ramda/es/has';
|
||||
export { default as path } from 'ramda/es/path';
|
||||
export { default as append } from 'ramda/es/append';
|
||||
export { default as assocPath } from 'ramda/es/assocPath';
|
||||
export { default as reduce } from 'ramda/es/reduce';
|
||||
export { default as values } from 'ramda/es/values';
|
||||
export { default as range } from 'ramda/es/range';
|
||||
export { default as prop } from 'ramda/es/prop';
|
||||
export { default as includes } from 'ramda/es/includes';
|
||||
export { default as hasPath } from 'ramda/es/hasPath';
|
||||
export { default as isNil } from 'ramda/es/isNil';
|
||||
export { default as flatten } from 'ramda/es/flatten';
|
||||
export { default as keys } from 'ramda/es/keys';
|
||||
export { default as uniq } from 'ramda/es/uniq';
|
||||
export { default as last } from 'ramda/es/last';
|
||||
export { default as uniqBy } from 'ramda/es/uniqBy';
|
||||
export { default as omit } from 'ramda/es/omit';
|
||||
export { default as curry } from 'ramda/es/curry';
|
||||
export { default as pipe } from 'ramda/es/pipe';
|
||||
export { default as without } from 'ramda/es/without';
|
||||
export { default as nth } from 'ramda/es/nth';
|
||||
export { default as insert } from 'ramda/es/insert';
|
||||
export { default as isEmpty } from 'ramda/es/isEmpty';
|
||||
export { default as remove } from 'ramda/es/remove';
|
|
@ -1,4 +1,4 @@
|
|||
import { flatten, isEmpty } from 'ramda';
|
||||
import { flatten, isEmpty } from '~/utils/ramda';
|
||||
|
||||
export const splitTextByYoutube = (strings: string[]): string[] =>
|
||||
flatten(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue