@@ -26,7 +26,7 @@ import {
2626 PopoverTrigger ,
2727} from '@/components/ui/popover'
2828
29- import { useCallback , useEffect , useMemo , useState } from 'react'
29+ import { useCallback , useEffect , useState } from 'react'
3030import { getListUsers } from '@/lib/api/user'
3131import { User } from '@/lib/types/user'
3232import { Book } from '@/lib/types/book'
@@ -58,16 +58,9 @@ const FormSchema = z.object({
5858 } ) ,
5959} )
6060
61- // pass token from page since session cookie is http only
62- export const FormNewBorrow : React . FC < { token : string } > = ( { token } ) => {
61+ export const FormNewBorrow : React . FC = ( ) => {
6362 const router = useRouter ( )
6463
65- const headers = useMemo ( ( ) => {
66- const h = new Headers ( )
67- h . set ( 'Authorization' , `Bearer ${ token } ` )
68- return h
69- } , [ token ] )
70-
7164 const form = useForm < z . infer < typeof FormSchema > > ( {
7265 resolver : zodResolver ( FormSchema ) ,
7366 } )
@@ -144,17 +137,12 @@ export const FormNewBorrow: React.FC<{ token: string }> = ({ token }) => {
144137 const selectedUser = form . watch ( 'user_id' )
145138
146139 useEffect ( ( ) => {
147- getListSubs (
148- {
149- limit : 20 ,
150- user_id : selectedUser ,
151- membership_name : subQ ,
152- is_active : true ,
153- } ,
154- {
155- headers,
156- }
157- ) . then ( ( res ) => {
140+ getListSubs ( {
141+ limit : 20 ,
142+ user_id : selectedUser ,
143+ membership_name : subQ ,
144+ is_active : true ,
145+ } ) . then ( ( res ) => {
158146 if ( 'error' in res ) {
159147 toast ( {
160148 title : 'Error' ,
@@ -164,21 +152,16 @@ export const FormNewBorrow: React.FC<{ token: string }> = ({ token }) => {
164152 }
165153 setSubs ( res . data )
166154 } )
167- } , [ subQ , selectedUser , headers ] )
155+ } , [ subQ , selectedUser ] )
168156
169157 const [ staffQ , setStaffQ ] = useState ( '' )
170158 const [ staffs , setStaffs ] = useState < Staff [ ] > ( [ ] )
171159
172160 useEffect ( ( ) => {
173- getListStaffs (
174- {
175- limit : 20 ,
176- name : staffQ ,
177- } ,
178- {
179- headers,
180- }
181- ) . then ( ( res ) => {
161+ getListStaffs ( {
162+ limit : 20 ,
163+ name : staffQ ,
164+ } ) . then ( ( res ) => {
182165 if ( 'error' in res ) {
183166 toast ( {
184167 title : 'Error' ,
@@ -188,7 +171,7 @@ export const FormNewBorrow: React.FC<{ token: string }> = ({ token }) => {
188171 }
189172 setStaffs ( res . data )
190173 } )
191- } , [ staffQ , headers ] )
174+ } , [ staffQ ] )
192175
193176 return (
194177 < div className = "grid place-items-center" >
0 commit comments