File tree Expand file tree Collapse file tree 9 files changed +38
-17
lines changed
Expand file tree Collapse file tree 9 files changed +38
-17
lines changed File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ import {
2424 TableRow ,
2525} from '@/components/ui/table'
2626import { getListStaffs } from '@/lib/api/staff'
27+ import { Verify } from '@/lib/firebase/firebase'
2728import Link from 'next/link'
2829
2930export default async function Staffs ( {
@@ -39,14 +40,24 @@ export default async function Staffs({
3940 const skip = Number ( sp ?. skip ?? 0 )
4041 const limit = Number ( sp ?. limit ?? 20 )
4142 const library_id = sp ?. library_id
42- const res = await getListStaffs ( {
43- sort_by : 'created_at' ,
44- sort_in : 'desc' ,
45- limit : limit ,
46- skip : skip ,
47- ...( library_id ? { library_id } : { } ) ,
43+
44+ const headers = await Verify ( {
45+ from : '/staffs' ,
4846 } )
4947
48+ const res = await getListStaffs (
49+ {
50+ sort_by : 'created_at' ,
51+ sort_in : 'desc' ,
52+ limit : limit ,
53+ skip : skip ,
54+ ...( library_id ? { library_id } : { } ) ,
55+ } ,
56+ {
57+ headers,
58+ }
59+ )
60+
5061 if ( 'error' in res ) {
5162 console . log ( res )
5263 return < div > { JSON . stringify ( res . message ) } </ div >
Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ import {
2424} from '@/components/ui/table'
2525import { getListSubs } from '@/lib/api/subscription'
2626import { Verify } from '@/lib/firebase/firebase'
27+ import { formatDate } from '@/lib/utils'
2728import Link from 'next/link'
2829
2930export default async function Subscriptions ( {
@@ -111,10 +112,10 @@ export default async function Subscriptions({
111112 < TableCell > { s . membership ?. name } </ TableCell >
112113 < TableCell > { s . membership ?. library ?. name } </ TableCell >
113114 < TableCell >
114- < time dateTime = { s . expires_at } > { s . expires_at } </ time >
115+ < time dateTime = { s . expires_at } > { formatDate ( s . expires_at ) } </ time >
115116 </ TableCell >
116117 < TableCell >
117- < time dateTime = { s . created_at } > { s . created_at } </ time >
118+ < time dateTime = { s . created_at } > { formatDate ( s . created_at ) } </ time >
118119 </ TableCell >
119120 < TableCell > { s . active_loan_limit } </ TableCell >
120121 < TableCell > { s . loan_period } D</ TableCell >
Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ import {
2323 TableRow ,
2424} from '@/components/ui/table'
2525import { getListLibraries } from '@/lib/api/library'
26+ import { formatDate } from '@/lib/utils'
2627import Link from 'next/link'
2728
2829export default async function Libraries ( {
@@ -94,8 +95,8 @@ export default async function Libraries({
9495 < TableCell >
9596 < Link href = { `libraries/${ lib . id } ` } > { lib . name } </ Link >
9697 </ TableCell >
97- < TableCell > { lib . created_at } </ TableCell >
98- < TableCell > { lib . updated_at } </ TableCell >
98+ < TableCell > { formatDate ( lib . created_at ) } </ TableCell >
99+ < TableCell > { formatDate ( lib . updated_at ) } </ TableCell >
99100 </ TableRow >
100101 ) ) }
101102 </ TableBody >
Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ import {
2323 TableRow ,
2424} from '@/components/ui/table'
2525import { getListUsers } from '@/lib/api/user'
26+ import { formatDate } from '@/lib/utils'
2627import Link from 'next/link'
2728
2829export default async function Users ( {
@@ -92,7 +93,7 @@ export default async function Users({
9293 < TableCell > { u . id } </ TableCell >
9394 < TableCell > { u . name } </ TableCell >
9495 < TableCell > { u . email } </ TableCell >
95- < TableCell > { u . created_at } </ TableCell >
96+ < TableCell > { formatDate ( u . created_at ) } </ TableCell >
9697 </ TableRow >
9798 ) ) }
9899 </ TableBody >
Original file line number Diff line number Diff line change @@ -170,10 +170,15 @@ export const FormNewBorrow: React.FC<{ token: string }> = ({ token }) => {
170170 const [ staffs , setStaffs ] = useState < Staff [ ] > ( [ ] )
171171
172172 useEffect ( ( ) => {
173- getListStaffs ( {
174- limit : 20 ,
175- name : staffQ ,
176- } ) . then ( ( res ) => {
173+ getListStaffs (
174+ {
175+ limit : 20 ,
176+ name : staffQ ,
177+ } ,
178+ {
179+ headers,
180+ }
181+ ) . then ( ( res ) => {
177182 if ( 'error' in res ) {
178183 toast ( {
179184 title : 'Error' ,
Original file line number Diff line number Diff line change @@ -7,7 +7,8 @@ const STAFF_URL = `${BASE_URL}/staffs`
77type GetListStaffsQuery = QueryParams < Staff >
88type GetListStaffsResponse = Promise < ResList < Staff > >
99export const getListStaffs = async (
10- query : GetListStaffsQuery
10+ query : GetListStaffsQuery ,
11+ init ?: RequestInit
1112) : GetListStaffsResponse => {
1213 const url = new URL ( STAFF_URL )
1314 Object . entries ( query ) . forEach ( ( [ key , value ] ) => {
@@ -16,7 +17,7 @@ export const getListStaffs = async (
1617 }
1718 } )
1819
19- const response = await fetch ( url . toString ( ) )
20+ const response = await fetch ( url . toString ( ) , init )
2021 return response . json ( )
2122}
2223
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ export const config: MiddlewareConfig = {
1313 matcher : [
1414 '/subscriptions/:path*' ,
1515 '/borrows/:path*' ,
16+ '/staffs/:path*' ,
1617 '/libraries/([0-9a-fA-F-]{36})/edit' ,
1718 ] ,
1819}
You can’t perform that action at this time.
0 commit comments