🚚(frontend) move types and pad api hooks
Move types and pad api hooks to pad-management.
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
export * from './usePad';
|
||||
export * from './usePads';
|
||||
export * from './useUpdatePad';
|
||||
@@ -6,7 +6,7 @@ import {
|
||||
} from '@tanstack/react-query';
|
||||
|
||||
import { APIError, APIList, errorCauses, fetchAPI } from '@/api';
|
||||
import { Pad } from '@/features/pads/pad';
|
||||
import { Pad } from '@/features/pads/pad-management';
|
||||
|
||||
export enum PadsOrdering {
|
||||
BY_CREATED_ON = 'created_at',
|
||||
@@ -6,7 +6,7 @@ import {
|
||||
|
||||
import { APIError, errorCauses, fetchAPI } from '@/api';
|
||||
|
||||
import { KEY_LIST_PAD } from '../../pads-panel';
|
||||
import { KEY_LIST_PAD } from './usePads';
|
||||
|
||||
interface RemovePadProps {
|
||||
padId: string;
|
||||
|
||||
@@ -3,10 +3,13 @@ import { useMutation, useQueryClient } from '@tanstack/react-query';
|
||||
import { APIError, errorCauses, fetchAPI } from '@/api';
|
||||
import { Pad } from '@/features/pads';
|
||||
|
||||
export type PadParams = Pick<Pad, 'id'> &
|
||||
export type UpdatePadParams = Pick<Pad, 'id'> &
|
||||
Partial<Pick<Pad, 'content' | 'title' | 'is_public'>>;
|
||||
|
||||
export const updatePad = async ({ id, ...params }: PadParams): Promise<Pad> => {
|
||||
export const updatePad = async ({
|
||||
id,
|
||||
...params
|
||||
}: UpdatePadParams): Promise<Pad> => {
|
||||
const response = await fetchAPI(`documents/${id}/`, {
|
||||
method: 'PATCH',
|
||||
body: JSON.stringify({
|
||||
@@ -31,7 +34,7 @@ export function useUpdatePad({
|
||||
listInvalideQueries,
|
||||
}: UpdatePadProps = {}) {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation<Pad, APIError, PadParams>({
|
||||
return useMutation<Pad, APIError, UpdatePadParams>({
|
||||
mutationFn: updatePad,
|
||||
onSuccess: (data) => {
|
||||
listInvalideQueries?.forEach((queryKey) => {
|
||||
@@ -11,10 +11,10 @@ import { useRouter } from 'next/navigation';
|
||||
import { Box, Text, TextErrors } from '@/components';
|
||||
import useCunninghamTheme from '@/cunningham/useCunninghamTheme';
|
||||
|
||||
import { Pad } from '../../pad/types';
|
||||
import { useRemovePad } from '../api/useRemovePad';
|
||||
import IconPad from '../assets/icon-pad.svg';
|
||||
import IconRemove from '../assets/icon-trash.svg';
|
||||
import { Pad } from '../types';
|
||||
|
||||
interface ModalRemovePadProps {
|
||||
onClose: () => void;
|
||||
|
||||
@@ -11,11 +11,11 @@ import { useState } from 'react';
|
||||
|
||||
import { Box, Text } from '@/components';
|
||||
import useCunninghamTheme from '@/cunningham/useCunninghamTheme';
|
||||
import { KEY_PAD, Pad } from '@/features/pads/pad';
|
||||
import { KEY_LIST_PAD } from '@/features/pads/pads-panel';
|
||||
|
||||
import { KEY_LIST_PAD, KEY_PAD } from '../api';
|
||||
import { useUpdatePad } from '../api/useUpdatePad';
|
||||
import IconEdit from '../assets/icon-edit.svg';
|
||||
import { Pad } from '../types';
|
||||
|
||||
import { InputPadName } from './InputPadName';
|
||||
|
||||
|
||||
@@ -1 +1,3 @@
|
||||
export * from './api';
|
||||
export * from './components';
|
||||
export * from './types';
|
||||
|
||||
@@ -11,7 +11,8 @@ import { t } from 'i18next';
|
||||
import { useEffect, useState } from 'react';
|
||||
|
||||
import { Box, Text } from '@/components';
|
||||
import { Pad, usePadStore } from '@/features/pads/pad/';
|
||||
import { usePadStore } from '@/features/pads/pad/';
|
||||
import { Pad } from '@/features/pads/pad-management';
|
||||
|
||||
import { useCreatePdf } from '../api/useCreatePdf';
|
||||
import { downloadFile } from '../utils';
|
||||
|
||||
@@ -3,8 +3,11 @@ import React, { useMemo, useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import { Box, DropButton, IconOptions, Text } from '@/components';
|
||||
import { Pad } from '@/features/pads/pad';
|
||||
import { ModalRemovePad, ModalUpdatePad } from '@/features/pads/pad-management';
|
||||
import {
|
||||
ModalRemovePad,
|
||||
ModalUpdatePad,
|
||||
Pad,
|
||||
} from '@/features/pads/pad-management';
|
||||
|
||||
import { TemplatesOrdering, useTemplates } from '../api/useTemplates';
|
||||
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
export * from './usePad';
|
||||
@@ -6,10 +6,10 @@ import { WebrtcProvider } from 'y-webrtc';
|
||||
|
||||
import { Box } from '@/components';
|
||||
import { useAuthStore } from '@/core/auth';
|
||||
import { Pad } from '@/features/pads/pad-management';
|
||||
|
||||
import useSavePad from '../hook/useSavePad';
|
||||
import { usePadStore } from '../stores';
|
||||
import { Pad } from '../types';
|
||||
import { randomColor } from '../utils';
|
||||
|
||||
import { BlockNoteToolbar } from './BlockNoteToolbar';
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
import React from 'react';
|
||||
|
||||
import { Box, Card, Text } from '@/components';
|
||||
import { Pad } from '@/features/pads/pad-management';
|
||||
import { PadToolBox } from '@/features/pads/pad-tools';
|
||||
|
||||
import { Pad } from '../types';
|
||||
|
||||
import { BlockNoteEditor } from './BlockNoteEditor';
|
||||
|
||||
interface PadEditorProps {
|
||||
|
||||
@@ -2,7 +2,8 @@ import { useRouter } from 'next/router';
|
||||
import { useCallback, useEffect, useRef, useState } from 'react';
|
||||
import * as Y from 'yjs';
|
||||
|
||||
import { useUpdatePad } from '../api/useUpdatePad';
|
||||
import { useUpdatePad } from '@/features/pads/pad-management/';
|
||||
|
||||
import { toBase64 } from '../utils';
|
||||
|
||||
const useSavePad = (padId: string, doc: Y.Doc) => {
|
||||
|
||||
@@ -1,4 +1,2 @@
|
||||
export * from './api';
|
||||
export * from './components';
|
||||
export * from './stores';
|
||||
export * from './types';
|
||||
|
||||
@@ -4,8 +4,7 @@ import * as Y from 'yjs';
|
||||
import { create } from 'zustand';
|
||||
|
||||
import { signalingUrl } from '@/core';
|
||||
|
||||
import { Base64, Pad } from '../types';
|
||||
import { Base64, Pad } from '@/features/pads/pad-management';
|
||||
|
||||
export interface PadStore {
|
||||
padsStore: {
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
export * from './usePads';
|
||||
@@ -5,7 +5,7 @@ import { useTranslation } from 'react-i18next';
|
||||
import IconGroup from '@/assets/icons/icon-group.svg';
|
||||
import { Box, StyledLink, Text } from '@/components';
|
||||
import { useCunninghamTheme } from '@/cunningham';
|
||||
import { Pad } from '@/features/pads/pad';
|
||||
import { Pad } from '@/features/pads/pad-management';
|
||||
|
||||
import IconNone from '../assets/icon-none.svg';
|
||||
|
||||
|
||||
@@ -4,9 +4,8 @@ import { useTranslation } from 'react-i18next';
|
||||
|
||||
import { Box, Text } from '@/components';
|
||||
import { InfiniteScroll } from '@/components/InfiniteScroll';
|
||||
import { Pad } from '@/features/pads/pad';
|
||||
import { Pad, usePads } from '@/features/pads/pad-management';
|
||||
|
||||
import { usePads } from '../api';
|
||||
import { usePadPanelStore } from '../store';
|
||||
|
||||
import { PadItem } from './PadItem';
|
||||
|
||||
@@ -3,8 +3,8 @@ import { useTranslation } from 'react-i18next';
|
||||
|
||||
import { Box, BoxButton, StyledLink } from '@/components';
|
||||
import { useCunninghamTheme } from '@/cunningham';
|
||||
import { PadsOrdering } from '@/features/pads/pad-management';
|
||||
|
||||
import { PadsOrdering } from '../api';
|
||||
import IconAdd from '../assets/icon-add.svg';
|
||||
import IconSort from '../assets/icon-sort.svg';
|
||||
import { usePadPanelStore } from '../store';
|
||||
|
||||
@@ -1,2 +1 @@
|
||||
export * from './api';
|
||||
export * from './components';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { create } from 'zustand';
|
||||
|
||||
import { PadsOrdering } from '../api/usePads';
|
||||
import { PadsOrdering } from '@/features/pads/pad-management';
|
||||
|
||||
interface PadPanelStore {
|
||||
ordering: PadsOrdering;
|
||||
|
||||
@@ -5,7 +5,8 @@ import { ReactElement } from 'react';
|
||||
|
||||
import { Box } from '@/components';
|
||||
import { TextErrors } from '@/components/TextErrors';
|
||||
import { PadEditor, usePad } from '@/features/pads/pad';
|
||||
import { PadEditor } from '@/features/pads/pad';
|
||||
import { usePad } from '@/features/pads/pad-management';
|
||||
import { PadLayout } from '@/layouts';
|
||||
import { NextPageWithLayout } from '@/types/next';
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { ReactElement } from 'react';
|
||||
|
||||
import { Box } from '@/components';
|
||||
import { CardCreatePad } from '@/features/pads/';
|
||||
import { CardCreatePad } from '@/features/pads/pad-management';
|
||||
import { PadLayout } from '@/layouts';
|
||||
import { NextPageWithLayout } from '@/types/next';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user