1
0
Fork 0
mirror of https://github.com/muerwre/vault-frontend.git synced 2025-04-25 12:56:41 +07:00

removed redux completely

This commit is contained in:
Fedor Katurov 2022-01-09 19:03:01 +07:00
parent 26e6d8d41b
commit a4bb07e9cf
323 changed files with 2464 additions and 3348 deletions

163
src/types/index.ts Normal file
View file

@ -0,0 +1,163 @@
import { DetailedHTMLProps, InputHTMLAttributes, ReactElement } from 'react';
import { ERRORS } from '~/constants/errors';
import { IUser } from '~/types/auth';
export interface ITag {
ID: number;
title: string;
data: Record<string, string>;
user: IUser;
nodes: INode[];
readonly created_at: string;
readonly updated_at: string;
}
export type IInputTextProps = DetailedHTMLProps<
InputHTMLAttributes<HTMLInputElement>,
HTMLInputElement
> & {
handler?: (value: string) => void;
title?: string;
error?: string;
suffix?: ReactElement;
};
export type IIcon = string;
export type ValueOf<T> = T[keyof T];
export type UUID = string;
export type IUploadType = 'image' | 'text' | 'audio' | 'video' | 'other';
export interface IFile {
id?: number;
temp_id?: UUID;
user_id?: UUID;
node_id?: UUID;
name: string;
orig_name: string;
path: string;
full_path: string;
url: string;
size: number;
type?: IUploadType;
mime: string;
metadata?: {
id3title?: string;
id3artist?: string;
title?: string;
duration?: number;
width?: number;
height?: number;
dominant_color?: string;
};
createdAt?: string;
updatedAt?: string;
}
export interface IBlockText {
type: 'text';
text: string;
}
export interface IBlockEmbed {
type: 'video';
url: string;
}
export type IBlock = IBlockText | IBlockEmbed;
export type FlowDisplayVariant = 'single' | 'vertical' | 'horizontal' | 'quadro';
export interface FlowDisplay {
display: FlowDisplayVariant;
show_description: boolean;
dominant_color?: string;
}
export type INodeUser = Partial<IUser>;
export interface INode {
id?: number;
user?: INodeUser;
title: string;
files: IFile[];
cover?: IFile;
type?: string;
blocks: IBlock[];
thumbnail?: string;
description?: string;
is_liked?: boolean;
is_heroic?: boolean;
is_promoted?: boolean;
is_public?: boolean;
like_count?: number;
flow: FlowDisplay;
tags: ITag[];
created_at?: string;
updated_at?: string;
deleted_at?: string;
commented_at?: string;
}
export type IFlowNode = Pick<
INode,
'id' | 'flow' | 'description' | 'title' | 'thumbnail' | 'created_at'
>;
export interface IComment {
id: number;
text: string;
files: IFile[];
user?: IUser;
created_at?: string;
update_at?: string;
deleted_at?: string;
}
export type IMessage = Omit<IComment, 'user' | 'node'> & {
from: IUser;
to: IUser;
};
export interface ICommentGroup {
user: IUser;
comments: IComment[];
ids: IComment['id'][];
hasNew: boolean;
}
export type IUploadProgressHandler = (progress: ProgressEvent) => void;
export type IError = ValueOf<typeof ERRORS>;
export const NOTIFICATION_TYPES = {
message: 'message',
comment: 'comment',
node: 'node',
};
export type IMessageNotification = {
type: typeof NOTIFICATION_TYPES['message'];
content: Partial<IMessage>;
created_at: string;
};
export type ICommentNotification = {
type: typeof NOTIFICATION_TYPES['comment'];
content: Partial<IComment>;
created_at: string;
};
export type INotification = IMessageNotification | ICommentNotification;