mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 12:56:41 +07:00
Отрефакторил бэк, исправил ошибки (#138)
* fixed paths to match refactored backend * fixed some paths according to new backend * fixed auth urls for new endpoints * fixed urls * fixed error handling * fixes * fixed error handling on user form * fixed error handling on oauth * using fallback: true on node pages * type button for comment attach buttons * fixed return types of social delete * changed the way we upload user avatars
This commit is contained in:
parent
1745cc636d
commit
080d59858c
42 changed files with 544 additions and 420 deletions
|
@ -5,7 +5,7 @@ import { rectSortingStrategy, SortableContext } from '@dnd-kit/sortable';
|
|||
import classNames from 'classnames';
|
||||
|
||||
import { DragOverlayItem } from '~/components/sortable/DragOverlayItem';
|
||||
import { useSortableActions } from '~/hooks/sortable';
|
||||
import { useSortableActions } from '~/hooks/sortable/useSortableActions';
|
||||
import { DivProps } from '~/utils/types';
|
||||
|
||||
import { SortableItem } from '../SortableItem';
|
||||
|
@ -16,7 +16,7 @@ interface SortableGridProps<
|
|||
ItemRendererProps extends {},
|
||||
LockedRendererProps extends {},
|
||||
Item extends {},
|
||||
Locked extends {}
|
||||
Locked extends {},
|
||||
> {
|
||||
items: Item[];
|
||||
locked: Locked[];
|
||||
|
@ -44,18 +44,18 @@ const SortableGrid = <RIP, RLP, I, L>({
|
|||
onSortEnd,
|
||||
size,
|
||||
}: SortableGridProps<RIP, RLP, I, L>) => {
|
||||
const { sensors, onDragEnd, onDragStart, draggingItem, ids } = useSortableActions(
|
||||
items,
|
||||
getID,
|
||||
onSortEnd
|
||||
);
|
||||
const { sensors, onDragEnd, onDragStart, draggingItem, ids } =
|
||||
useSortableActions(items, getID, onSortEnd);
|
||||
|
||||
const gridStyle = useMemo<DivProps['style']>(
|
||||
() =>
|
||||
size
|
||||
? { gridTemplateColumns: size && `repeat(auto-fill, minmax(${size}px, 1fr))` }
|
||||
? {
|
||||
gridTemplateColumns:
|
||||
size && `repeat(auto-fill, minmax(${size}px, 1fr))`,
|
||||
}
|
||||
: undefined,
|
||||
[size]
|
||||
[size],
|
||||
);
|
||||
|
||||
return (
|
||||
|
@ -67,30 +67,35 @@ const SortableGrid = <RIP, RLP, I, L>({
|
|||
>
|
||||
<SortableContext items={ids} strategy={rectSortingStrategy}>
|
||||
<div className={classNames(styles.grid, className)} style={gridStyle}>
|
||||
{items.map(item => (
|
||||
{items.map((item) => (
|
||||
<SortableItem
|
||||
key={getID(item)}
|
||||
id={getID(item)}
|
||||
className={
|
||||
draggingItem && getID(item) === getID(draggingItem) ? styles.dragging : undefined
|
||||
draggingItem && getID(item) === getID(draggingItem)
|
||||
? styles.dragging
|
||||
: undefined
|
||||
}
|
||||
>
|
||||
{createElement(renderItem, { ...renderItemProps, item })}
|
||||
</SortableItem>
|
||||
))}
|
||||
|
||||
{locked.map(item =>
|
||||
{locked.map((item) =>
|
||||
createElement(renderLocked, {
|
||||
...renderLockedProps,
|
||||
locked: item,
|
||||
key: getLockedID(item),
|
||||
})
|
||||
}),
|
||||
)}
|
||||
|
||||
<DragOverlay>
|
||||
{draggingItem ? (
|
||||
<DragOverlayItem>
|
||||
{createElement(renderItem, { ...renderItemProps, item: draggingItem })}
|
||||
{createElement(renderItem, {
|
||||
...renderItemProps,
|
||||
item: draggingItem,
|
||||
})}
|
||||
</DragOverlayItem>
|
||||
) : null}
|
||||
</DragOverlay>
|
||||
|
|
|
@ -1,12 +1,15 @@
|
|||
import React, { createElement, FC } from 'react';
|
||||
|
||||
import { closestCenter, DndContext, DragOverlay } from '@dnd-kit/core';
|
||||
import { SortableContext, verticalListSortingStrategy } from '@dnd-kit/sortable';
|
||||
import {
|
||||
SortableContext,
|
||||
verticalListSortingStrategy,
|
||||
} from '@dnd-kit/sortable';
|
||||
import classNames from 'classnames';
|
||||
|
||||
import { DragOverlayItem } from '~/components/sortable/DragOverlayItem';
|
||||
import { SortableItem } from '~/components/sortable/SortableItem';
|
||||
import { useSortableActions } from '~/hooks/sortable';
|
||||
import { useSortableActions } from '~/hooks/sortable/useSortableActions';
|
||||
|
||||
import styles from './styles.module.scss';
|
||||
|
||||
|
@ -14,7 +17,7 @@ interface SortableListProps<
|
|||
RenderItemProps extends {},
|
||||
RenderLockedProps extends {},
|
||||
Item extends {},
|
||||
Locked extends {}
|
||||
Locked extends {},
|
||||
> {
|
||||
items: Item[];
|
||||
locked: Locked[];
|
||||
|
@ -40,11 +43,8 @@ const SortableList = <RIP, RLP, I, L>({
|
|||
renderLockedProps,
|
||||
onSortEnd,
|
||||
}: SortableListProps<RIP, RLP, I, L>) => {
|
||||
const { sensors, onDragEnd, onDragStart, draggingItem, ids } = useSortableActions(
|
||||
items,
|
||||
getID,
|
||||
onSortEnd
|
||||
);
|
||||
const { sensors, onDragEnd, onDragStart, draggingItem, ids } =
|
||||
useSortableActions(items, getID, onSortEnd);
|
||||
|
||||
return (
|
||||
<DndContext
|
||||
|
@ -55,30 +55,39 @@ const SortableList = <RIP, RLP, I, L>({
|
|||
>
|
||||
<SortableContext items={ids} strategy={verticalListSortingStrategy}>
|
||||
<div className={classNames(styles.grid, className)}>
|
||||
{items.map(item => (
|
||||
{items.map((item) => (
|
||||
<SortableItem
|
||||
key={getID(item)}
|
||||
id={getID(item)}
|
||||
className={
|
||||
draggingItem && getID(item) === getID(draggingItem) ? styles.dragging : undefined
|
||||
draggingItem && getID(item) === getID(draggingItem)
|
||||
? styles.dragging
|
||||
: undefined
|
||||
}
|
||||
>
|
||||
{createElement(renderItem, { ...renderItemProps, item, key: getID(item) })}
|
||||
{createElement(renderItem, {
|
||||
...renderItemProps,
|
||||
item,
|
||||
key: getID(item),
|
||||
})}
|
||||
</SortableItem>
|
||||
))}
|
||||
|
||||
{locked.map(item =>
|
||||
{locked.map((item) =>
|
||||
createElement(renderLocked, {
|
||||
...renderLockedProps,
|
||||
locked: item,
|
||||
key: getLockedID(item),
|
||||
})
|
||||
}),
|
||||
)}
|
||||
|
||||
<DragOverlay>
|
||||
{draggingItem ? (
|
||||
<DragOverlayItem>
|
||||
{createElement(renderItem, { ...renderItemProps, item: draggingItem })}
|
||||
{createElement(renderItem, {
|
||||
...renderItemProps,
|
||||
item: draggingItem,
|
||||
})}
|
||||
</DragOverlayItem>
|
||||
) : null}
|
||||
</DragOverlay>
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
export * from './SortableImageGrid';
|
||||
export * from './SortableAudioGrid';
|
Loading…
Add table
Add a link
Reference in a new issue