internal fixes

This commit is contained in:
2025-05-24 15:12:37 +03:00
parent b755eda4b5
commit 88dc6932ec
8 changed files with 120 additions and 41 deletions

View File

@@ -244,4 +244,5 @@ export interface Lead {
moving_price: string
moving_date: string
comment: string
route?: number
}

View File

@@ -1,11 +1,18 @@
import { Lead } from '@/app/types'
import { getSession } from 'next-auth/react'
export const sendLead = async (data: Lead) => {
export const sendLead = async (data: Lead & { id?: number }) => {
const API_URL = process.env.NEXT_PUBLIC_API_URL
const session = await getSession()
if (!session?.accessToken) {
throw new Error('No access token found')
}
const headers: Record<string, string> = {
'Content-Type': 'application/json',
Accept: 'application/json',
Authorization: `Bearer ${session.accessToken}`,
}
try {
@@ -16,6 +23,7 @@ export const sendLead = async (data: Lead) => {
moving_price: data.moving_price,
moving_date: data.moving_date,
comment: data.comment,
route: data.id,
})
const response = await fetch(`${API_URL}/account/send_lead/`, {