Merge branch 'refactoring'

This commit is contained in:
ifraimka1 committed 2025-04-18 14:49:43 +03:00
commit f82b47c042
17 files changed
+252 -179

No files matched your search

+14 -4
View File
@@ -1,8 +1,14 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import "./Field.styles.scss";
import cross from "@/shared/assets/images/cross.svg";
import fileUpload from "@/shared/assets/images/fileUpload.svg";
import { ForwardedRef, forwardRef } from "react";
import { UseFormRegisterReturn } from "react-hook-form";
import {
FieldError,
FieldErrorsImpl,
Merge,
UseFormRegisterReturn,
} from "react-hook-form";
type FieldType =
| "text"
| "email"
@@ -18,7 +24,11 @@ interface FieldProps {
placeholder?: string;
disabled?: boolean;
fileAttached?: boolean;
error?: string;
error?:
| string
| FieldError
| Merge<FieldError, FieldErrorsImpl<any>>
| undefined;
handleRemoveFile?: () => void;
register?: UseFormRegisterReturn;
}
@@ -27,7 +37,7 @@ const Field = forwardRef(
(
{
type,
name,
placeholder,
disabled = false,
fileAttached = false,
@@ -90,7 +100,7 @@ const Field = forwardRef(
{...register}
/>
)}
{error && <span className="error-message">{error}</span>}
{error && <span className="error-message">{String(error)}</span>}
</div>
);
}
+27 -27
View File
@@ -1,34 +1,34 @@
type Mods = Record<string, boolean | string>;
export function classNames(
cls: string,
mods?: Mods,
additional?: string[] | undefined[],
cls: string,
mods?: Mods,
additional?: string[] | undefined[]
): string {
if (additional && mods) {
return [
cls,
...additional.filter(Boolean),
Object.entries(mods)
.filter(([cls, value]) => Boolean(value))
.map(([className, value]) => className)
.join(' '),
].join(' ');
}
if (additional && !mods) {
return [cls, ...additional.filter(Boolean)].join(' ');
}
if (!additional && mods) {
return [
cls,
Object.entries(mods)
.filter(([cls, value]) => Boolean(value))
.map(([className, value]) => className),
].join(' ');
}
return [cls].join(' ');
if (additional && mods) {
return [
cls,
...additional.filter(Boolean),
Object.entries(mods)
.filter(([value]) => Boolean(value))
.map(([className]) => className)
.join(" "),
].join(" ");
}
if (additional && !mods) {
return [cls, ...additional.filter(Boolean)].join(" ");
}
if (!additional && mods) {
return [
cls,
Object.entries(mods)
.filter(([value]) => Boolean(value))
.map(([className]) => className),
].join(" ");
}
return [cls].join(" ");
}
classNames('remove-btn', { hovered: true, selectable: true, red: false }, [
'pdg',
classNames("remove-btn", { hovered: true, selectable: true, red: false }, [
"pdg",
]);
+33 -13
View File
@@ -19,7 +19,25 @@ declare namespace WPv2 {
raw: string;
rendered: string;
}
export interface PagingInfo {
total: number;
totalPages: number;
links: {
next?: string;
};
next?: {
_options: {
auth: boolean;
endpoint: string;
username: string;
password: string;
};
transport: Record<string, any>;
_params: Record<string, any>;
_supportedMethods: string[];
_path: Record<string, any>;
};
}
export interface Content {
raw: string;
rendered: string;
@@ -113,7 +131,9 @@ declare namespace WPv2 {
class_list: string[];
_links: Links;
}
export interface MediaWithPaging extends Array<Media> {
_paging: PagingInfo;
}
export interface Media {
id: number;
date: string;
@@ -181,15 +201,15 @@ declare namespace WPv2 {
offset?: number;
order?: "asc" | "desc";
orderby?:
| "author"
| "date"
| "id"
| "include"
| "modified"
| "parent"
| "relevance"
| "slug"
| "title";
| "author"
| "date"
| "id"
| "include"
| "modified"
| "parent"
| "relevance"
| "slug"
| "title";
slug?: string[];
status?: string[];
}
@@ -284,11 +304,11 @@ declare namespace App {
}
export interface Card extends WpPost {
preview: string | null;
preview?: string | null;
}
export interface LabCard extends Card {
previewText: string;
previewText?: string | null;
}
export interface PostsResult {