Глобальный рефакторинг компонетов
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 nodemailer from 'nodemailer';
|
||||||
|
import type { EmailOptions } from '../globalInterfaces';
|
||||||
|
|
||||||
const SMTP_HOST = import.meta.env.SMTP_HOST || 'localhost';
|
const SMTP_HOST = import.meta.env.SMTP_HOST || 'localhost';
|
||||||
const SMTP_PORT = import.meta.env.SMTP_PORT || 1025;
|
const SMTP_PORT = import.meta.env.SMTP_PORT || 1025;
|
||||||
|
|
@ -20,12 +21,6 @@ function getTransporter() {
|
||||||
return transporter;
|
return transporter;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface EmailOptions {
|
|
||||||
to: string;
|
|
||||||
subject: string;
|
|
||||||
html: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function sendEmail(options: EmailOptions): Promise<boolean> {
|
export async function sendEmail(options: EmailOptions): Promise<boolean> {
|
||||||
try {
|
try {
|
||||||
console.log('Sending email to:', options.to);
|
console.log('Sending email to:', options.to);
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import PocketBase from 'pocketbase';
|
import PocketBase from 'pocketbase';
|
||||||
|
import type { Post } from '../globalInterfaces';
|
||||||
|
|
||||||
const PB_URL = import.meta.env.POCKETBASE_URL || 'http://127.0.0.1:8090';
|
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(() => {});
|
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?: {
|
export async function getPosts(options?: {
|
||||||
page?: number;
|
page?: number;
|
||||||
perPage?: number;
|
perPage?: number;
|
||||||
|
|
@ -71,11 +57,11 @@ export async function getAllCategories(): Promise<string[]> {
|
||||||
fields: 'category',
|
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)];
|
return ['Все', ...new Set(categories)];
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getPostImageUrl(post: any): string {
|
export function getPostImageUrl(post: { image?: string }): string {
|
||||||
if (post.image) {
|
if (post.image) {
|
||||||
const fileUrl = pb.files.getUrl(post, post.image);
|
const fileUrl = pb.files.getUrl(post, post.image);
|
||||||
if (fileUrl.startsWith('/')) {
|
if (fileUrl.startsWith('/')) {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import type { APIRoute } from 'astro';
|
import type { APIRoute } from 'astro';
|
||||||
import PocketBase from 'pocketbase';
|
import { pb } from '../../../lib/pb';
|
||||||
import { sendEmail, getSiteUrl } from '../../../lib/email';
|
import { sendEmail, getSiteUrl } from '../../../lib/email';
|
||||||
|
|
||||||
function generateResetPasswordHtml(firstName: string, resetLink: string): string {
|
function generateResetPasswordHtml(firstName: string, resetLink: string): string {
|
||||||
|
|
@ -62,7 +62,6 @@ function generateResetPasswordHtml(firstName: string, resetLink: string): string
|
||||||
|
|
||||||
export const POST: APIRoute = async ({ request }) => {
|
export const POST: APIRoute = async ({ request }) => {
|
||||||
try {
|
try {
|
||||||
const pb = new PocketBase(import.meta.env.POCKETBASE_URL);
|
|
||||||
const data = await request.json();
|
const data = await request.json();
|
||||||
|
|
||||||
const { email } = data;
|
const { email } = data;
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,8 @@
|
||||||
import type { APIRoute } from 'astro';
|
import type { APIRoute } from 'astro';
|
||||||
import PocketBase from 'pocketbase';
|
import { pb } from '../../../lib/pb';
|
||||||
|
|
||||||
export const POST: APIRoute = async ({ request }) => {
|
export const POST: APIRoute = async ({ request }) => {
|
||||||
try {
|
try {
|
||||||
const pb = new PocketBase(import.meta.env.POCKETBASE_URL);
|
|
||||||
const data = await request.json();
|
const data = await request.json();
|
||||||
|
|
||||||
const { token, userId, password } = data;
|
const { token, userId, password } = data;
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,8 @@
|
||||||
import type { APIRoute } from 'astro';
|
import type { APIRoute } from 'astro';
|
||||||
import PocketBase from 'pocketbase';
|
import { pb } from '../../../lib/pb';
|
||||||
|
|
||||||
export const POST: APIRoute = async ({ request, cookies }) => {
|
export const POST: APIRoute = async ({ request, cookies }) => {
|
||||||
try {
|
try {
|
||||||
const pb = new PocketBase(import.meta.env.POCKETBASE_URL);
|
|
||||||
const data = await request.json();
|
const data = await request.json();
|
||||||
|
|
||||||
const { email, password } = data;
|
const { email, password } = data;
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,9 @@
|
||||||
import type { APIRoute } from 'astro';
|
import type { APIRoute } from 'astro';
|
||||||
import PocketBase from 'pocketbase';
|
import { pb } from '../../../lib/pb';
|
||||||
import { sendEmail, generateVerifyEmailHtml, getSiteUrl } from '../../../lib/email';
|
import { sendEmail, generateVerifyEmailHtml, getSiteUrl } from '../../../lib/email';
|
||||||
|
|
||||||
export const POST: APIRoute = async ({ request, redirect }) => {
|
export const POST: APIRoute = async ({ request, redirect }) => {
|
||||||
try {
|
try {
|
||||||
const pb = new PocketBase(import.meta.env.POCKETBASE_URL);
|
|
||||||
const data = await request.json();
|
const data = await request.json();
|
||||||
|
|
||||||
console.log('Registration attempt:', { email: data.email, firstName: data.firstName, lastName: data.lastName });
|
console.log('Registration attempt:', { email: data.email, firstName: data.firstName, lastName: data.lastName });
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,8 @@
|
||||||
import type { APIRoute } from 'astro';
|
import type { APIRoute } from 'astro';
|
||||||
import PocketBase from 'pocketbase';
|
import { pb } from '../../lib/pb';
|
||||||
|
|
||||||
export const POST: APIRoute = async ({ request }) => {
|
export const POST: APIRoute = async ({ request }) => {
|
||||||
try {
|
try {
|
||||||
const pb = new PocketBase(import.meta.env.POCKETBASE_URL);
|
|
||||||
const data = await request.json();
|
const data = await request.json();
|
||||||
|
|
||||||
const { name, phone, service } = data;
|
const { name, phone, service } = data;
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
"include": [".astro/types.d.ts", "**/*"],
|
"include": [".astro/types.d.ts", "**/*"],
|
||||||
"exclude": ["dist"],
|
"exclude": ["dist"],
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
|
"ignoreDeprecations": "6.0",
|
||||||
"baseUrl": ".",
|
"baseUrl": ".",
|
||||||
"paths": {
|
"paths": {
|
||||||
"@styles/*": ["src/styles/*"],
|
"@styles/*": ["src/styles/*"],
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue