mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 04:46:40 +07:00
(nextjs) added eslint and import sorting
This commit is contained in:
parent
e5f8d5a551
commit
0838bf7ee6
330 changed files with 1576 additions and 896 deletions
|
@ -1,6 +1,6 @@
|
|||
import { useLoginLogoutRestore } from '~/hooks/auth/useLoginLogoutRestore';
|
||||
import { useUser } from '~/hooks/auth/useUser';
|
||||
import { useAuthStore } from '~/store/auth/useAuthStore';
|
||||
import { useLoginLogoutRestore } from '~/hooks/auth/useLoginLogoutRestore';
|
||||
|
||||
export const useAuth = () => {
|
||||
const { user } = useUser();
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import { useCallback } from 'react';
|
||||
|
||||
import { useUser } from '~/hooks/auth/useUser';
|
||||
|
||||
export const useLastSeenBoris = () => {
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
import { Asserts, object, string } from 'yup';
|
||||
import { ERRORS } from '~/constants/errors';
|
||||
import { useCallback } from 'react';
|
||||
|
||||
import { FormikConfig, useFormik } from 'formik';
|
||||
import { Asserts, object, string } from 'yup';
|
||||
|
||||
import { ERRORS } from '~/constants/errors';
|
||||
import { IUser } from '~/types/auth';
|
||||
import { showErrorToast } from '~/utils/errors/showToast';
|
||||
import { getValidationErrors } from '~/utils/errors/getValidationErrors';
|
||||
import { showErrorToast } from '~/utils/errors/showToast';
|
||||
|
||||
const validationSchema = object({
|
||||
username: string().required(ERRORS.REQUIRED),
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
import { useAuthStore } from '~/store/auth/useAuthStore';
|
||||
import { useCallback } from 'react';
|
||||
|
||||
import { apiUserLogin } from '~/api/auth';
|
||||
import { getRandomPhrase } from '~/constants/phrases';
|
||||
import { useAuthStore } from '~/store/auth/useAuthStore';
|
||||
import { showToastInfo } from '~/utils/toast';
|
||||
|
||||
export const useLoginLogoutRestore = () => {
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
import { useEffect } from 'react';
|
||||
import { EventMessageType } from '~/constants/events';
|
||||
|
||||
import { includes, path, values } from 'ramda';
|
||||
import { useOAuth } from '~/hooks/auth/useOAuth';
|
||||
|
||||
import { EventMessageType } from '~/constants/events';
|
||||
import { Dialog } from '~/constants/modal';
|
||||
import { useModal } from '~/hooks/modal/useModal';
|
||||
import { useAuth } from '~/hooks/auth/useAuth';
|
||||
import { useOAuth } from '~/hooks/auth/useOAuth';
|
||||
import { useModal } from '~/hooks/modal/useModal';
|
||||
|
||||
/** reacts to events passed by window.postMessage */
|
||||
export const useMessageEventReactions = () => {
|
||||
|
|
|
@ -1,13 +1,15 @@
|
|||
import { useCallback, useMemo } from 'react';
|
||||
import { OAuthProvider } from '~/types/auth';
|
||||
import { API } from '~/constants/api';
|
||||
import { apiAttachSocial, apiDropSocial, apiGetSocials, apiLoginWithSocial } from '~/api/auth';
|
||||
import { useModal } from '~/hooks/modal/useModal';
|
||||
import { Dialog } from '~/constants/modal';
|
||||
import { showErrorToast } from '~/utils/errors/showToast';
|
||||
|
||||
import { path } from 'ramda';
|
||||
import useSWR from 'swr';
|
||||
|
||||
import { apiAttachSocial, apiDropSocial, apiGetSocials, apiLoginWithSocial } from '~/api/auth';
|
||||
import { API } from '~/constants/api';
|
||||
import { Dialog } from '~/constants/modal';
|
||||
import { useAuth } from '~/hooks/auth/useAuth';
|
||||
import { useModal } from '~/hooks/modal/useModal';
|
||||
import { OAuthProvider } from '~/types/auth';
|
||||
import { showErrorToast } from '~/utils/errors/showToast';
|
||||
|
||||
export const useOAuth = () => {
|
||||
const { isUser, setToken } = useAuth();
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
import { useUploader } from '~/hooks/data/useUploader';
|
||||
import { UploadSubject, UploadTarget } from '~/constants/uploads';
|
||||
import { useCallback } from 'react';
|
||||
import { showErrorToast } from '~/utils/errors/showToast';
|
||||
|
||||
import { apiUpdateUser } from '~/api/auth';
|
||||
import { ApiUpdateUserRequest } from '~/api/auth/types';
|
||||
import { UploadSubject, UploadTarget } from '~/constants/uploads';
|
||||
import { useUser } from '~/hooks/auth/useUser';
|
||||
import { useUploader } from '~/hooks/data/useUploader';
|
||||
import { showErrorToast } from '~/utils/errors/showToast';
|
||||
|
||||
export const usePatchUser = () => {
|
||||
const { update } = useUser();
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { apiCheckRestoreCode } from '~/api/auth';
|
||||
import useSWR from 'swr';
|
||||
|
||||
import { apiCheckRestoreCode } from '~/api/auth';
|
||||
import { API } from '~/constants/api';
|
||||
import { getErrorMessage } from '~/utils/errors/getErrorMessage';
|
||||
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
import { Asserts, object, string } from 'yup';
|
||||
import { FormikConfig, useFormik } from 'formik';
|
||||
import { useCallback } from 'react';
|
||||
import { showErrorToast } from '~/utils/errors/showToast';
|
||||
import { getValidationErrors } from '~/utils/errors/getValidationErrors';
|
||||
|
||||
import { FormikConfig, useFormik } from 'formik';
|
||||
import { Asserts, object, string } from 'yup';
|
||||
|
||||
import { ERRORS } from '~/constants/errors';
|
||||
import { IUser } from '~/types/auth';
|
||||
import { useAuthStore } from '~/store/auth/useAuthStore';
|
||||
import { IUser } from '~/types/auth';
|
||||
import { getValidationErrors } from '~/utils/errors/getValidationErrors';
|
||||
import { showErrorToast } from '~/utils/errors/showToast';
|
||||
|
||||
const validationSchema = object({
|
||||
newPassword: string()
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import { useEffect } from 'react';
|
||||
import { useModal } from '~/hooks/modal/useModal';
|
||||
|
||||
import { Dialog } from '~/constants/modal';
|
||||
import { useModal } from '~/hooks/modal/useModal';
|
||||
import { useNavigation } from '~/hooks/navigation/useNavigation';
|
||||
|
||||
/** redirects to the password redirect modal */
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
import { Asserts, object, string } from 'yup';
|
||||
import { ERRORS } from '~/constants/errors';
|
||||
import { FormikConfig, useFormik } from 'formik';
|
||||
import { useCallback } from 'react';
|
||||
import { showErrorToast } from '~/utils/errors/showToast';
|
||||
|
||||
import { FormikConfig, useFormik } from 'formik';
|
||||
import { Asserts, object, string } from 'yup';
|
||||
|
||||
import { ERRORS } from '~/constants/errors';
|
||||
import { getValidationErrors } from '~/utils/errors/getValidationErrors';
|
||||
import { showErrorToast } from '~/utils/errors/showToast';
|
||||
|
||||
const validationSchema = object({
|
||||
field: string().required(ERRORS.REQUIRED),
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
import { Asserts, object, string } from 'yup';
|
||||
import { ERRORS } from '~/constants/errors';
|
||||
import { FormikConfig, useFormik } from 'formik';
|
||||
import { useCallback } from 'react';
|
||||
import { showErrorToast } from '~/utils/errors/showToast';
|
||||
|
||||
import { FormikConfig, useFormik } from 'formik';
|
||||
import { Asserts, object, string } from 'yup';
|
||||
|
||||
import { ERRORS } from '~/constants/errors';
|
||||
import { getValidationErrors } from '~/utils/errors/getValidationErrors';
|
||||
import { showErrorToast } from '~/utils/errors/showToast';
|
||||
|
||||
const validationSchema = object({
|
||||
username: string().required(ERRORS.REQUIRED),
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
import useSWR from 'swr';
|
||||
import { useAuthStore } from '~/store/auth/useAuthStore';
|
||||
import { API } from '~/constants/api';
|
||||
import { apiAuthGetUser } from '~/api/auth';
|
||||
import { EMPTY_USER } from '~/constants/auth';
|
||||
import { showErrorToast } from '~/utils/errors/showToast';
|
||||
import { useCallback } from 'react';
|
||||
|
||||
import useSWR from 'swr';
|
||||
|
||||
import { apiAuthGetUser } from '~/api/auth';
|
||||
import { API } from '~/constants/api';
|
||||
import { EMPTY_USER } from '~/constants/auth';
|
||||
import { useAuthStore } from '~/store/auth/useAuthStore';
|
||||
import { IUser } from '~/types/auth';
|
||||
import { showErrorToast } from '~/utils/errors/showToast';
|
||||
|
||||
export const useUser = () => {
|
||||
const { token, setUser } = useAuthStore();
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
import { IUser } from '~/types/auth';
|
||||
import { useRandomPhrase } from '~/constants/phrases';
|
||||
import { differenceInDays, parseISO } from 'date-fns';
|
||||
|
||||
import { useRandomPhrase } from '~/constants/phrases';
|
||||
import { INACTIVE_ACCOUNT_DAYS } from '~/constants/user';
|
||||
import { IUser } from '~/types/auth';
|
||||
|
||||
const today = new Date();
|
||||
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
import { useCallback, useEffect } from 'react';
|
||||
|
||||
import isBefore from 'date-fns/isBefore';
|
||||
import { IComment } from '~/types';
|
||||
|
||||
import { useRandomPhrase } from '~/constants/phrases';
|
||||
import { useBorisStats } from '~/hooks/boris/useBorisStats';
|
||||
import { useLastSeenBoris } from '~/hooks/auth/useLastSeenBoris';
|
||||
import { useAuth } from '~/hooks/auth/useAuth';
|
||||
import { useLastSeenBoris } from '~/hooks/auth/useLastSeenBoris';
|
||||
import { useBorisStats } from '~/hooks/boris/useBorisStats';
|
||||
import { IComment } from '~/types';
|
||||
|
||||
export const useBoris = (comments: IComment[]) => {
|
||||
const title = useRandomPhrase('BORIS_TITLE');
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
import useSWR from 'swr';
|
||||
import { API } from '~/constants/api';
|
||||
|
||||
import { getBorisBackendStats, getGithubIssues } from '~/api/boris';
|
||||
import { BorisUsageStats } from '~/types/boris';
|
||||
import { API } from '~/constants/api';
|
||||
import { initialBackendStats } from '~/constants/boris/constants';
|
||||
import { BorisUsageStats } from '~/types/boris';
|
||||
|
||||
export const useBorisStats = () => {
|
||||
const { data: backend = initialBackendStats, isValidating: isValidatingBackend } = useSWR(
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import { useMemo } from 'react';
|
||||
|
||||
import { normalizeBrightColor } from '~/utils/color';
|
||||
import { stringToColour } from '~/utils/dom';
|
||||
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
import { useMemo } from 'react';
|
||||
|
||||
import { adjustHue } from 'color2k';
|
||||
|
||||
import { normalizeBrightColor } from '~/utils/color';
|
||||
import { stringToColour } from '~/utils/dom';
|
||||
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
import { IComment, INode } from '~/types';
|
||||
import { useCallback, useEffect, useRef } from 'react';
|
||||
|
||||
import { FormikHelpers, useFormik, useFormikContext } from 'formik';
|
||||
import { array, object, string } from 'yup';
|
||||
import { showErrorToast } from '~/utils/errors/showToast';
|
||||
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';
|
||||
|
||||
const validationSchema = object().shape({
|
||||
text: string(),
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
import { API } from '~/constants/api';
|
||||
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 { useCallback, useMemo } from 'react';
|
||||
import { IComment } from '~/types';
|
||||
|
||||
const getKey: (nodeId: number) => SWRInfiniteKeyLoader = (nodeId: number) => (
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
import { useCallback } from 'react';
|
||||
import { IComment } from '~/types';
|
||||
import { useGetComments } from '~/hooks/comments/useGetComments';
|
||||
|
||||
import { apiLockComment, apiPostComment } from '~/api/node';
|
||||
import { useGetComments } from '~/hooks/comments/useGetComments';
|
||||
import { IComment } from '~/types';
|
||||
import { showErrorToast } from '~/utils/errors/showToast';
|
||||
|
||||
export const useNodeComments = (nodeId: number) => {
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
import { ERROR_LITERAL } from '~/constants/errors';
|
||||
import { has } from 'ramda';
|
||||
import { useMemo } from 'react';
|
||||
|
||||
import { has } from 'ramda';
|
||||
|
||||
import { ERROR_LITERAL } from '~/constants/errors';
|
||||
|
||||
export const useTranslatedError = (error: string | undefined) => {
|
||||
return useMemo(() => {
|
||||
if (!error) {
|
||||
|
|
|
@ -1,13 +1,16 @@
|
|||
import { UploadSubject, UploadTarget } from '~/constants/uploads';
|
||||
import { IFile } from '~/types';
|
||||
import { useCallback } from 'react';
|
||||
import { apiUploadFile } from '~/api/uploads';
|
||||
import { keys } from 'ramda';
|
||||
|
||||
import { useLocalObservable } from 'mobx-react-lite';
|
||||
import { UploaderStore } from '~/store/uploader/UploaderStore';
|
||||
import { showErrorToast } from '~/utils/errors/showToast';
|
||||
import { keys } from 'ramda';
|
||||
import uuid from 'uuid4';
|
||||
|
||||
import { apiUploadFile } from '~/api/uploads';
|
||||
import { UploadSubject, UploadTarget } from '~/constants/uploads';
|
||||
import { UploaderStore } from '~/store/uploader/UploaderStore';
|
||||
import { IFile } from '~/types';
|
||||
import { showErrorToast } from '~/utils/errors/showToast';
|
||||
|
||||
|
||||
export const useUploader = (
|
||||
subject: UploadSubject,
|
||||
target: UploadTarget,
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* Handles blur by detecting clicks outside refs.
|
||||
*/
|
||||
import { useCallback, useEffect, useRef, useState } from 'react';
|
||||
|
||||
import { useCloseOnEscape } from '~/hooks';
|
||||
|
||||
export const useClickOutsideFocus = () => {
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
import { useEffect } from 'react';
|
||||
|
||||
import { useFlowLoader } from '~/hooks/flow/useFlowLoader';
|
||||
import { useFlowStore } from '~/store/flow/useFlowStore';
|
||||
import { hideLoader } from '~/utils/dom/hideLoader';
|
||||
import { useFlowLoader } from '~/hooks/flow/useFlowLoader';
|
||||
|
||||
/** simply waits for all data to settle and then show the app */
|
||||
export const useGlobalLoader = () => {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import { useCallback } from 'react';
|
||||
|
||||
import { getImageFromPaste } from '~/utils/uploader';
|
||||
|
||||
// useInputPasteUpload attaches event listener to input, that calls onUpload if user pasted any image
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import { useMemo } from 'react';
|
||||
|
||||
import { Modifier } from 'react-popper';
|
||||
|
||||
const sameWidth = {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import { useCallback } from 'react';
|
||||
|
||||
import { useScrollHeight } from '~/hooks/dom/useScrollHeight';
|
||||
|
||||
export const useScrollToBottom = () => {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import { useEffect } from 'react';
|
||||
|
||||
import { NEW_COMMENT_CLASSNAME } from '~/constants/comment';
|
||||
|
||||
export const useScrollToTop = (deps?: any[]) => {
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
import { useFlowLayout } from '~/hooks/flow/useFlowLayout';
|
||||
import { useMemo } from 'react';
|
||||
|
||||
import { useFlowLayout } from '~/hooks/flow/useFlowLayout';
|
||||
import { useFlowLoader } from '~/hooks/flow/useFlowLoader';
|
||||
import { useFlowStore } from '~/store/flow/useFlowStore';
|
||||
import { useFlowSetCellView } from '~/hooks/flow/useFlowSetCellView';
|
||||
import { useGetLabStats } from '~/hooks/lab/useGetLabStats';
|
||||
import { useFlowStore } from '~/store/flow/useFlowStore';
|
||||
|
||||
export const useFlow = () => {
|
||||
const { loadMore, isSyncing } = useFlowLoader();
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import { useCallback } from 'react';
|
||||
|
||||
import { FlowDisplay, INode } from '~/types';
|
||||
|
||||
export const useFlowCellControls = (
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import { useCallback } from 'react';
|
||||
import { usePersistedState } from '~/hooks/data/usePersistedState';
|
||||
|
||||
import { experimentalFeatures } from '~/constants/features';
|
||||
import { usePersistedState } from '~/hooks/data/usePersistedState';
|
||||
|
||||
enum Layout {
|
||||
Fluid = 'fluid',
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
import { useCallback, useState } from 'react';
|
||||
import { getNodeDiff } from '~/api/node';
|
||||
import { uniq } from 'ramda';
|
||||
import { useFlowStore } from '~/store/flow/useFlowStore';
|
||||
|
||||
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';
|
||||
|
||||
export const useFlowLoader = () => {
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
import { useFlowStore } from '~/store/flow/useFlowStore';
|
||||
import { useCallback } from 'react';
|
||||
|
||||
import { postCellView } from '~/api/flow';
|
||||
import { useFlowStore } from '~/store/flow/useFlowStore';
|
||||
import { FlowDisplay } from '~/types';
|
||||
import { showErrorToast } from '~/utils/errors/showToast';
|
||||
import { postCellView } from '~/api/flow';
|
||||
|
||||
export const useFlowSetCellView = () => {
|
||||
const { updateNode } = useFlowStore();
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
import useSWRInfinite, { SWRInfiniteKeyLoader } from 'swr/infinite';
|
||||
import { GetLabNodesRequest, ILabNode } from '~/types/lab';
|
||||
import { getLabNodes } from '~/api/lab';
|
||||
import { flatten, last, uniqBy } from 'ramda';
|
||||
import { useLabStore } from '~/store/lab/useLabStore';
|
||||
import { useCallback, useMemo } from 'react';
|
||||
import { INode } from '~/types';
|
||||
|
||||
import { flatten, last, uniqBy } from 'ramda';
|
||||
import useSWRInfinite, { SWRInfiniteKeyLoader } from 'swr/infinite';
|
||||
|
||||
import { getLabNodes } from '~/api/lab';
|
||||
import { useAuth } from '~/hooks/auth/useAuth';
|
||||
import { useLabStore } from '~/store/lab/useLabStore';
|
||||
import { INode } from '~/types';
|
||||
import { GetLabNodesRequest, ILabNode } from '~/types/lab';
|
||||
|
||||
const getKey: (isUser: boolean) => SWRInfiniteKeyLoader = isUser => (index, prev: ILabNode[]) => {
|
||||
if (!isUser) return null;
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
import useSWR from 'swr';
|
||||
import { API } from '~/constants/api';
|
||||
import { getLabStats, getLabUpdates } from '~/api/lab';
|
||||
import { useLabStore } from '~/store/lab/useLabStore';
|
||||
import { useCallback, useMemo } from 'react';
|
||||
|
||||
import useSWR from 'swr';
|
||||
|
||||
import { getLabStats, getLabUpdates } from '~/api/lab';
|
||||
import { API } from '~/constants/api';
|
||||
import { useAuth } from '~/hooks/auth/useAuth';
|
||||
import { useLabStore } from '~/store/lab/useLabStore';
|
||||
|
||||
const refreshInterval = 1000 * 60 * 5; // 5 minutes
|
||||
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
import useSWR from 'swr';
|
||||
import { API } from '~/constants/api';
|
||||
import { apiGetUserMessages } from '~/api/messages';
|
||||
import { IMessage } from '~/types';
|
||||
import { useMemo } from 'react';
|
||||
|
||||
import useSWR from 'swr';
|
||||
|
||||
import { apiGetUserMessages } from '~/api/messages';
|
||||
import { API } from '~/constants/api';
|
||||
import { IMessage } from '~/types';
|
||||
|
||||
const getKey = (username: string): string | null => {
|
||||
return username ? `${API.USER.MESSAGES}/${username}` : null;
|
||||
};
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import { useMetadataProvider } from '~/utils/providers/MetadataProvider';
|
||||
import { useEffect } from 'react';
|
||||
|
||||
import { useMetadataProvider } from '~/utils/providers/MetadataProvider';
|
||||
|
||||
export const useYoutubeMetadata = (id: string) => {
|
||||
const { queue, enqueue, metadata, pending } = useMetadataProvider();
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import { useModalStore } from '~/store/modal/useModalStore';
|
||||
import { useCallback } from 'react';
|
||||
|
||||
import { Dialog, DIALOG_CONTENT } from '~/constants/modal';
|
||||
import { useModalStore } from '~/store/modal/useModalStore';
|
||||
import { DialogComponentProps } from '~/types/modal';
|
||||
|
||||
export type DialogContentProps = {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import { useCallback } from 'react';
|
||||
import { DialogContentProps, useModal } from '~/hooks/modal/useModal';
|
||||
|
||||
import { Dialog } from '~/constants/modal';
|
||||
import { DialogContentProps, useModal } from '~/hooks/modal/useModal';
|
||||
|
||||
export const useShowModal = <T extends Dialog>(dialog: T) => {
|
||||
const modal = useModal();
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
import { useCallback } from 'react';
|
||||
import { IFile } from '~/types';
|
||||
import { useShowModal } from '~/hooks/modal/useShowModal';
|
||||
|
||||
import { Dialog } from '~/constants/modal';
|
||||
import { useShowModal } from '~/hooks/modal/useShowModal';
|
||||
import { IFile } from '~/types';
|
||||
|
||||
export const useImageModal = () => {
|
||||
const showModal = useShowModal(Dialog.Photoswipe);
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
import { useCallback } from 'react';
|
||||
import { CONFIG } from '~/utils/config';
|
||||
|
||||
import { useRouter } from 'next/router';
|
||||
import { useHistory } from 'react-router';
|
||||
|
||||
import { CONFIG } from '~/utils/config';
|
||||
|
||||
export const useNavigation = () => {
|
||||
const nextRouter = useRouter();
|
||||
const craHistory = useHistory();
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
import { useCallback } from 'react';
|
||||
import { INode } from '~/types';
|
||||
|
||||
import { apiPostNode } from '~/api/node';
|
||||
import { useFlowStore } from '~/store/flow/useFlowStore';
|
||||
import { useGetLabNodes } from '~/hooks/lab/useGetLabNodes';
|
||||
import { useFlowStore } from '~/store/flow/useFlowStore';
|
||||
import { INode } from '~/types';
|
||||
|
||||
export const useCreateNode = () => {
|
||||
const flow = useFlowStore();
|
||||
|
|
|
@ -1,9 +1,13 @@
|
|||
import { INode } from '~/types';
|
||||
import useSWR from 'swr';
|
||||
import { ApiGetNodeRelatedResult } from '~/types/node';
|
||||
import { API } from '~/constants/api';
|
||||
import { useCallback } from 'react';
|
||||
|
||||
import useSWR from 'swr';
|
||||
|
||||
import { apiGetNodeRelated } from '~/api/node';
|
||||
import { API } from '~/constants/api';
|
||||
import { INode } from '~/types';
|
||||
import { ApiGetNodeRelatedResult } from '~/types/node';
|
||||
|
||||
|
||||
|
||||
export const useGetNodeRelated = (id?: INode['id']) => {
|
||||
const { data, isValidating, mutate } = useSWR<ApiGetNodeRelatedResult>(API.NODE.RELATED(id), () =>
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
import { INode } from '~/types';
|
||||
import { useCallback } from 'react';
|
||||
|
||||
import { URLS } from '~/constants/urls';
|
||||
import { useNavigation } from '~/hooks/navigation/useNavigation';
|
||||
import { INode } from '~/types';
|
||||
|
||||
// useGotoNode returns fn, that navigates to node
|
||||
export const useGotoNode = (id: INode['id']) => {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { IComment } from '~/types';
|
||||
import { useMemo } from 'react';
|
||||
|
||||
import { IComment } from '~/types';
|
||||
import { groupCommentsByUser } from '~/utils/fn';
|
||||
|
||||
export const useGrouppedComments = (
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
import useSWR from 'swr';
|
||||
import { ApiGetNodeResponse } from '~/types/node';
|
||||
import { API } from '~/constants/api';
|
||||
import { useOnNodeSeen } from '~/hooks/node/useOnNodeSeen';
|
||||
import { apiGetNode } from '~/api/node';
|
||||
import { useCallback } from 'react';
|
||||
import { INode } from '~/types';
|
||||
|
||||
import useSWR from 'swr';
|
||||
|
||||
import { apiGetNode } from '~/api/node';
|
||||
import { API } from '~/constants/api';
|
||||
import { EMPTY_NODE } from '~/constants/node';
|
||||
import { useOnNodeSeen } from '~/hooks/node/useOnNodeSeen';
|
||||
import { INode } from '~/types';
|
||||
import { ApiGetNodeResponse } from '~/types/node';
|
||||
|
||||
export const useLoadNode = (id: number, fallbackData?: ApiGetNodeResponse) => {
|
||||
const { data, isValidating, mutate } = useSWR<ApiGetNodeResponse>(
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
import { INode } from '~/types';
|
||||
import { useCallback } from 'react';
|
||||
|
||||
import { apiLockNode, apiPostNodeHeroic, apiPostNodeLike } from '~/api/node';
|
||||
import { showErrorToast } from '~/utils/errors/showToast';
|
||||
import { useModal } from '~/hooks/modal/useModal';
|
||||
import { Dialog } from '~/constants/modal';
|
||||
import { useModal } from '~/hooks/modal/useModal';
|
||||
import { INode } from '~/types';
|
||||
import { showErrorToast } from '~/utils/errors/showToast';
|
||||
|
||||
export const useNodeActions = (node: INode, update: (node: Partial<INode>) => Promise<unknown>) => {
|
||||
const { showModal } = useModal();
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import { INode } from '~/types';
|
||||
import { useMemo } from 'react';
|
||||
|
||||
import { UploadType } from '~/constants/uploads';
|
||||
import { INode } from '~/types';
|
||||
|
||||
export const useNodeAudios = (node: INode) => {
|
||||
return useMemo(() => node.files.filter(file => file && file.type === UploadType.Audio), [
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
import { INode } from '~/types';
|
||||
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 { INode } from '~/types';
|
||||
|
||||
// useNodeBlocks returns head, block and inline blocks of node
|
||||
export const useNodeBlocks = (node: INode, isLoading: boolean) => {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { INode } from '~/types';
|
||||
import { usePageCover } from '~/components/containers/PageCoverProvider/usePageCover';
|
||||
import { INode } from '~/types';
|
||||
|
||||
export const useNodeCoverImage = (node: INode) => {
|
||||
usePageCover(node.cover);
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
import { INode } from '~/types';
|
||||
import { useCallback, useRef } from 'react';
|
||||
|
||||
import { FormikConfig, FormikHelpers, useFormik, useFormikContext } from 'formik';
|
||||
import { object } from 'yup';
|
||||
import { showErrorToast } from '~/utils/errors/showToast';
|
||||
|
||||
import { INode } from '~/types';
|
||||
import { Uploader } from '~/utils/context/UploaderContextProvider';
|
||||
import { getValidationErrors } from '~/utils/errors/getValidationErrors';
|
||||
import { showErrorToast } from '~/utils/errors/showToast';
|
||||
|
||||
const validationSchema = object().shape({});
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import { INode } from '~/types';
|
||||
import { useMemo } from 'react';
|
||||
|
||||
import { UploadType } from '~/constants/uploads';
|
||||
import { INode } from '~/types';
|
||||
|
||||
export const useNodeImages = (node: INode) => {
|
||||
return useMemo(() => node.files.filter(file => file && file.type === UploadType.Image), [
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { useRouteMatch } from 'react-router';
|
||||
import { useRouter } from 'next/router';
|
||||
import { useRouteMatch } from 'react-router';
|
||||
|
||||
import { CONFIG } from '~/utils/config';
|
||||
|
||||
export const useNodePageParams = () => {
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
import { useMemo } from 'react';
|
||||
import { canEditNode, canLikeNode, canStarNode } from '~/utils/node';
|
||||
import { INode } from '~/types';
|
||||
|
||||
import { useUser } from '~/hooks/auth/useUser';
|
||||
import { INode } from '~/types';
|
||||
import { canEditNode, canLikeNode, canStarNode } from '~/utils/node';
|
||||
|
||||
export const useNodePermissions = (node?: INode) => {
|
||||
const { user } = useUser();
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
import { useCallback } from 'react';
|
||||
import { ITag } from '~/types';
|
||||
import { useLoadNode } from '~/hooks/node/useLoadNode';
|
||||
|
||||
import { apiDeleteNodeTag, apiPostNodeTags } from '~/api/node';
|
||||
import { useGetNodeRelated } from '~/hooks/node/useGetNodeRelated';
|
||||
import { useShowModal } from '~/hooks/modal/useShowModal';
|
||||
import { Dialog } from '~/constants/modal';
|
||||
import { useShowModal } from '~/hooks/modal/useShowModal';
|
||||
import { useGetNodeRelated } from '~/hooks/node/useGetNodeRelated';
|
||||
import { useLoadNode } from '~/hooks/node/useLoadNode';
|
||||
import { ITag } from '~/types';
|
||||
|
||||
export const useNodeTags = (id: number) => {
|
||||
const showModal = useShowModal(Dialog.TagSidebar);
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
import { INode } from '~/types';
|
||||
import { useEffect } from 'react';
|
||||
import { useFlowStore } from '~/store/flow/useFlowStore';
|
||||
|
||||
import { useGetLabStats } from '~/hooks/lab/useGetLabStats';
|
||||
import { useFlowStore } from '~/store/flow/useFlowStore';
|
||||
import { INode } from '~/types';
|
||||
|
||||
// useOnNodeSeen updates node seen status across all needed places
|
||||
export const useOnNodeSeen = (node?: INode) => {
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
import { useLoadNode } from '~/hooks/node/useLoadNode';
|
||||
import { useCallback } from 'react';
|
||||
import { INode } from '~/types';
|
||||
|
||||
import { apiPostNode } from '~/api/node';
|
||||
import { useFlowStore } from '~/store/flow/useFlowStore';
|
||||
import { useGetLabNodes } from '~/hooks/lab/useGetLabNodes';
|
||||
import { useLoadNode } from '~/hooks/node/useLoadNode';
|
||||
import { useFlowStore } from '~/store/flow/useFlowStore';
|
||||
import { INode } from '~/types';
|
||||
|
||||
export const useUpdateNode = (id: number) => {
|
||||
const { update } = useLoadNode(id);
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
import useSWR from 'swr';
|
||||
import { API } from '~/constants/api';
|
||||
import { apiAuthGetUserProfile } from '~/api/auth';
|
||||
import { EMPTY_USER } from '~/constants/auth';
|
||||
import { useCallback } from 'react';
|
||||
|
||||
import useSWR from 'swr';
|
||||
|
||||
import { apiAuthGetUserProfile } from '~/api/auth';
|
||||
import { API } from '~/constants/api';
|
||||
import { EMPTY_USER } from '~/constants/auth';
|
||||
import { IUser } from '~/types/auth';
|
||||
|
||||
const getKey = (username?: string): string | null => {
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
import { IUser } from '~/types/auth';
|
||||
import { Asserts, object, string } from 'yup';
|
||||
import { ERRORS } from '~/constants/errors';
|
||||
import { FormikConfig, useFormik } from 'formik';
|
||||
import { useCallback, useRef } from 'react';
|
||||
import { showToastSuccess } from '~/utils/toast';
|
||||
|
||||
import { FormikConfig, useFormik } from 'formik';
|
||||
import { Asserts, object, string } from 'yup';
|
||||
|
||||
import { ERRORS } from '~/constants/errors';
|
||||
import { getRandomPhrase } from '~/constants/phrases';
|
||||
import { showErrorToast } from '~/utils/errors/showToast';
|
||||
import { IUser } from '~/types/auth';
|
||||
import { getValidationErrors } from '~/utils/errors/getValidationErrors';
|
||||
import { showErrorToast } from '~/utils/errors/showToast';
|
||||
import { showToastSuccess } from '~/utils/toast';
|
||||
|
||||
const validationSchema = object({
|
||||
username: string()
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
import { useCallback, useEffect, useMemo, useState } from 'react';
|
||||
import useSWRInfinite, { SWRInfiniteKeyLoader } from 'swr/infinite';
|
||||
|
||||
import { flatten } from 'ramda';
|
||||
import useSWRInfinite, { SWRInfiniteKeyLoader } from 'swr/infinite';
|
||||
|
||||
import { getSearchResults } from '~/api/flow';
|
||||
import { INode } from '~/types';
|
||||
import { GetSearchResultsRequest } from '~/types/flow';
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
import useSWR from 'swr';
|
||||
import { API } from '~/constants/api';
|
||||
import { apiGetTagSuggestions } from '~/api/tags';
|
||||
import { useEffect, useMemo, useState } from 'react';
|
||||
|
||||
import useSWR from 'swr';
|
||||
|
||||
import { apiGetTagSuggestions } from '~/api/tags';
|
||||
import { API } from '~/constants/api';
|
||||
|
||||
export const useTagAutocomplete = (input: string, exclude: string[]): string[] => {
|
||||
const [search, setSearch] = useState('');
|
||||
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
import { INode } from '~/types';
|
||||
import { API } from '~/constants/api';
|
||||
import { useCallback, useMemo } from 'react';
|
||||
|
||||
import { flatten, isNil } from 'ramda';
|
||||
import useSWRInfinite, { SWRInfiniteKeyLoader } from 'swr/infinite';
|
||||
import { useCallback, useMemo } from 'react';
|
||||
|
||||
import { apiGetNodesOfTag } from '~/api/tags';
|
||||
import { API } from '~/constants/api';
|
||||
import { INode } from '~/types';
|
||||
|
||||
const PAGE_SIZE = 10;
|
||||
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
import useSWR from 'swr';
|
||||
import { useAuth } from '~/hooks/auth/useAuth';
|
||||
|
||||
import { apiAuthGetUpdates } from '~/api/auth';
|
||||
import { API } from '~/constants/api';
|
||||
import { useAuth } from '~/hooks/auth/useAuth';
|
||||
|
||||
export const useUpdates = () => {
|
||||
const { isUser } = useAuth();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue