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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
| import { get, post } from './base'
| import {
| useMutation,
| useQuery,
| } from '@tanstack/react-query'
| import { useInvalid } from './use-base'
| import type { EducationAddParams } from '@/app/education-apply/types'
|
| const NAME_SPACE = 'education'
|
| export const useEducationVerify = () => {
| return useMutation({
| mutationKey: [NAME_SPACE, 'education-verify'],
| mutationFn: () => {
| return get<{ token: string }>('/account/education/verify', {}, { silent: true })
| },
| })
| }
|
| export const useEducationAdd = ({
| onSuccess,
| }: {
| onSuccess?: () => void
| }) => {
| return useMutation({
| mutationKey: [NAME_SPACE, 'education-add'],
| mutationFn: (params: EducationAddParams) => {
| return post<{ message: string }>('/account/education', {
| body: params,
| })
| },
| onSuccess,
| })
| }
|
| type SearchParams = {
| keywords?: string
| page?: number
| limit?: number
| }
| export const useEducationAutocomplete = () => {
| return useMutation({
| mutationFn: (searchParams: SearchParams) => {
| const {
| keywords = '',
| page = 0,
| limit = 40,
| } = searchParams
| return get<{ data: string[]; has_next: boolean; curr_page: number }>(`/account/education/autocomplete?keywords=${keywords}&page=${page}&limit=${limit}`)
| },
| })
| }
|
| export const useEducationStatus = (disable?: boolean) => {
| return useQuery({
| enabled: !disable,
| queryKey: [NAME_SPACE, 'education-status'],
| queryFn: () => {
| return get<{ result: boolean }>('/account/education')
| },
| retry: false,
| })
| }
|
| export const useInvalidateEducationStatus = () => {
| return useInvalid([NAME_SPACE, 'education-status'])
| }
|
|