File size: 773 Bytes
c46e9ff
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/**
 * hooks/useTextRefinement.js
 * ───────────────────────────
 * React Query mutation for the /api/refine endpoint.
 */

import { useMutation } from '@tanstack/react-query'
import { refineText } from '../services/api'
import toast from 'react-hot-toast'

export function useTextRefinement() {
  return useMutation({
    mutationFn: ({ text, style = 'professional' }) => refineText(text, style),
    onError: (err) => {
      toast.error(err.message || 'Refinement failed.', {
        style: {
          background: 'var(--red-soft)',
          color: 'var(--red)',
          border: '1px solid var(--red)',
          fontFamily: "'DM Sans', sans-serif",
          fontSize: '13px',
        },
      })
    },
  })
}