Глобальный рефакторинг компонетов
This commit is contained in:
parent
ba9806a85a
commit
27804e9345
9 changed files with 89 additions and 33 deletions
79
frontend/src/globalInterfaces.ts
Normal file
79
frontend/src/globalInterfaces.ts
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
export interface Post {
|
||||
id: string;
|
||||
slug: string;
|
||||
title: string;
|
||||
description: string;
|
||||
author: string;
|
||||
category: string;
|
||||
categoryColor: string;
|
||||
date: string;
|
||||
readTime: string;
|
||||
image: string;
|
||||
content?: string;
|
||||
draft: boolean;
|
||||
}
|
||||
|
||||
export interface EmailOptions {
|
||||
to: string;
|
||||
subject: string;
|
||||
html: string;
|
||||
}
|
||||
|
||||
export interface Review {
|
||||
id: number;
|
||||
name: string;
|
||||
car: string;
|
||||
text: string;
|
||||
rating: number;
|
||||
avatar: { initial: string; color: string; };
|
||||
date: string;
|
||||
votesCount: number;
|
||||
isHelpful: boolean;
|
||||
}
|
||||
|
||||
export interface Case {
|
||||
id: number;
|
||||
title: string;
|
||||
category: CaseCategory;
|
||||
description: string;
|
||||
result: string;
|
||||
clientStory: string;
|
||||
amount: string;
|
||||
duration: string;
|
||||
image: string;
|
||||
tags: string[];
|
||||
featured?: boolean;
|
||||
}
|
||||
|
||||
export type CaseCategory =
|
||||
| "insurance"
|
||||
| "rights"
|
||||
| "accident"
|
||||
| "court"
|
||||
| "consultation";
|
||||
|
||||
export interface DocumentItem {
|
||||
id: string;
|
||||
title: string;
|
||||
description: string;
|
||||
fileSize: string;
|
||||
fileType: 'pdf' | 'docx' | 'xlsx' | 'zip';
|
||||
downloadUrl: string;
|
||||
category: string;
|
||||
tags?: string[];
|
||||
}
|
||||
|
||||
export interface NavLink {
|
||||
name: string;
|
||||
url: string;
|
||||
}
|
||||
|
||||
export interface CompanyInfo {
|
||||
name: string;
|
||||
fullName: string;
|
||||
phone: string;
|
||||
phoneClean: string;
|
||||
email: string;
|
||||
address: string;
|
||||
workHours: string;
|
||||
}
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
import nodemailer from 'nodemailer';
|
||||
import type { EmailOptions } from '../globalInterfaces';
|
||||
|
||||
const SMTP_HOST = import.meta.env.SMTP_HOST || 'localhost';
|
||||
const SMTP_PORT = import.meta.env.SMTP_PORT || 1025;
|
||||
|
|
@ -20,12 +21,6 @@ function getTransporter() {
|
|||
return transporter;
|
||||
}
|
||||
|
||||
export interface EmailOptions {
|
||||
to: string;
|
||||
subject: string;
|
||||
html: string;
|
||||
}
|
||||
|
||||
export async function sendEmail(options: EmailOptions): Promise<boolean> {
|
||||
try {
|
||||
console.log('Sending email to:', options.to);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import PocketBase from 'pocketbase';
|
||||
import type { Post } from '../globalInterfaces';
|
||||
|
||||
const PB_URL = import.meta.env.POCKETBASE_URL || 'http://127.0.0.1:8090';
|
||||
|
||||
|
|
@ -6,21 +7,6 @@ export const pb = new PocketBase(PB_URL);
|
|||
|
||||
pb.collection('_superusers').authRefresh().catch(() => {});
|
||||
|
||||
export interface Post {
|
||||
id: string;
|
||||
slug: string;
|
||||
title: string;
|
||||
description: string;
|
||||
author: string;
|
||||
category: string;
|
||||
categoryColor: string;
|
||||
date: string;
|
||||
readTime: string;
|
||||
image: string;
|
||||
content?: string;
|
||||
draft: boolean;
|
||||
}
|
||||
|
||||
export async function getPosts(options?: {
|
||||
page?: number;
|
||||
perPage?: number;
|
||||
|
|
@ -71,11 +57,11 @@ export async function getAllCategories(): Promise<string[]> {
|
|||
fields: 'category',
|
||||
});
|
||||
|
||||
const categories = (result || []).map((post: any) => post.category).filter(Boolean);
|
||||
const categories = (result || []).map((post) => post.category as string).filter(Boolean);
|
||||
return ['Все', ...new Set(categories)];
|
||||
}
|
||||
|
||||
export function getPostImageUrl(post: any): string {
|
||||
export function getPostImageUrl(post: { image?: string }): string {
|
||||
if (post.image) {
|
||||
const fileUrl = pb.files.getUrl(post, post.image);
|
||||
if (fileUrl.startsWith('/')) {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import type { APIRoute } from 'astro';
|
||||
import PocketBase from 'pocketbase';
|
||||
import { pb } from '../../../lib/pb';
|
||||
import { sendEmail, getSiteUrl } from '../../../lib/email';
|
||||
|
||||
function generateResetPasswordHtml(firstName: string, resetLink: string): string {
|
||||
|
|
@ -62,7 +62,6 @@ function generateResetPasswordHtml(firstName: string, resetLink: string): string
|
|||
|
||||
export const POST: APIRoute = async ({ request }) => {
|
||||
try {
|
||||
const pb = new PocketBase(import.meta.env.POCKETBASE_URL);
|
||||
const data = await request.json();
|
||||
|
||||
const { email } = data;
|
||||
|
|
|
|||
|
|
@ -1,9 +1,8 @@
|
|||
import type { APIRoute } from 'astro';
|
||||
import PocketBase from 'pocketbase';
|
||||
import { pb } from '../../../lib/pb';
|
||||
|
||||
export const POST: APIRoute = async ({ request }) => {
|
||||
try {
|
||||
const pb = new PocketBase(import.meta.env.POCKETBASE_URL);
|
||||
const data = await request.json();
|
||||
|
||||
const { token, userId, password } = data;
|
||||
|
|
|
|||
|
|
@ -1,9 +1,8 @@
|
|||
import type { APIRoute } from 'astro';
|
||||
import PocketBase from 'pocketbase';
|
||||
import { pb } from '../../../lib/pb';
|
||||
|
||||
export const POST: APIRoute = async ({ request, cookies }) => {
|
||||
try {
|
||||
const pb = new PocketBase(import.meta.env.POCKETBASE_URL);
|
||||
const data = await request.json();
|
||||
|
||||
const { email, password } = data;
|
||||
|
|
|
|||
|
|
@ -1,10 +1,9 @@
|
|||
import type { APIRoute } from 'astro';
|
||||
import PocketBase from 'pocketbase';
|
||||
import { pb } from '../../../lib/pb';
|
||||
import { sendEmail, generateVerifyEmailHtml, getSiteUrl } from '../../../lib/email';
|
||||
|
||||
export const POST: APIRoute = async ({ request, redirect }) => {
|
||||
try {
|
||||
const pb = new PocketBase(import.meta.env.POCKETBASE_URL);
|
||||
const data = await request.json();
|
||||
|
||||
console.log('Registration attempt:', { email: data.email, firstName: data.firstName, lastName: data.lastName });
|
||||
|
|
|
|||
|
|
@ -1,9 +1,8 @@
|
|||
import type { APIRoute } from 'astro';
|
||||
import PocketBase from 'pocketbase';
|
||||
import { pb } from '../../lib/pb';
|
||||
|
||||
export const POST: APIRoute = async ({ request }) => {
|
||||
try {
|
||||
const pb = new PocketBase(import.meta.env.POCKETBASE_URL);
|
||||
const data = await request.json();
|
||||
|
||||
const { name, phone, service } = data;
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
"include": [".astro/types.d.ts", "**/*"],
|
||||
"exclude": ["dist"],
|
||||
"compilerOptions": {
|
||||
"ignoreDeprecations": "6.0",
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
"@styles/*": ["src/styles/*"],
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue