добился какой то работы с API
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { parseExcelFile } from '@/services/excelSevice'
|
||||
import { parseExcelFile } from '@/services/fileApiSevice'
|
||||
import { Template } from '@/types/template'
|
||||
import React, { useState } from 'react'
|
||||
import { ExcelUploadPanel } from './ExcelUploadPanel'
|
||||
@@ -27,19 +27,27 @@ export const TemplateEditor: React.FC<TemplateEditorProps> = ({
|
||||
if (!file) return
|
||||
setIsLoading(true)
|
||||
try {
|
||||
const { data, mergedCells } = await parseExcelFile(file)
|
||||
const { fileId, data, mergedCells } = await parseExcelFile(
|
||||
file,
|
||||
template.id
|
||||
)
|
||||
setExcelData(data)
|
||||
setEditedTemplate(prev => ({
|
||||
...prev,
|
||||
|
||||
const updatedTemplate = {
|
||||
...template,
|
||||
excelFile: file,
|
||||
excelData: data,
|
||||
mergedCells,
|
||||
updatedAt: new Date(),
|
||||
}))
|
||||
}
|
||||
|
||||
setEditedTemplate(updatedTemplate)
|
||||
setDataVersion(v => v + 1)
|
||||
|
||||
console.log('✅ Файл загружен с ID:', fileId)
|
||||
} catch (err) {
|
||||
console.error(err)
|
||||
alert('Ошибка при чтении Excel файла')
|
||||
alert('Ошибка при загрузке Excel файла на сервер')
|
||||
} finally {
|
||||
setIsLoading(false)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user