MCPcopy Create free account
hub / github.com/TaskingAI/TaskingAI / handleConfirm

Function handleConfirm

frontend/src/components/recordPage/index.tsx:362–434  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

360 setChunkOverlap(Number(localStorage.getItem('chunkOverlap')))
361 }
362 const handleConfirm = async () => {
363 if (type === 'text' && !contentValue) {
364 toast.error(`${t('projectChunkContentRequired')}`)
365 return
366 }
367 if (type === 'web' && websiteValue) {
368 const websiteValueRequired = /^https:\/\//.test(websiteValue)
369 if (!websiteValueRequired) {
370 toast.error('URL must start with https://')
371 return
372 }
373 }
374 if (type === 'web' && !websiteValue) {
375 return toast.error('URL is required')
376 }
377 if(type === 'file' && fileLoading && fileList.length !== 0) {
378 return toast.error('File is uploading')
379 }
380 if(type === 'file' && fileList.length === 0) {
381 return toast.error('File is required')
382 }
383 setConfirmLoading(true)
384 try {
385 const params = {
386 type: type,
387 title,
388 content: type === 'text' ? contentValue : undefined,
389 url: type === 'web' ? websiteValue : undefined,
390 file_id: type === 'file' ? fileId : undefined,
391 text_splitter: {
392 type: 'token',
393 chunk_size: chunkSize,
394 chunk_overlap: chunkOverlap
395 }
396
397 }
398 if (!recordId) {
399 try {
400 await createRecord(collectionId, params)
401 } catch (error) {
402 const apiError = error as ApiErrorResponse
403 const message = apiError.response.data.error.message
404 toast.error(message)
405 }
406 } else {
407 const param1 = {
408 ...params,
409 metadata: {}
410 }
411 try {
412 await updateRecord(collectionId, recordId, param1)
413
414 } catch (error) {
415 const apiError = error as ApiErrorResponse
416 const message = apiError.response.data.error.message
417 toast.error(message)
418 }
419 }

Callers 1

RecordPageFunction · 0.70

Calls 3

createRecordFunction · 0.90
updateRecordFunction · 0.90
fetchDataFunction · 0.70

Tested by

no test coverage detected