File tree Expand file tree Collapse file tree 5 files changed +55
-2
lines changed
Expand file tree Collapse file tree 5 files changed +55
-2
lines changed Original file line number Diff line number Diff line change @@ -76,6 +76,8 @@ const FormSchema = z.object({
7676 fine_per_day : z . coerce . number ( {
7777 required_error : 'Fine per day is required.' ,
7878 } ) ,
79+ price : z . coerce . number ( ) ,
80+ usage_limit : z . coerce . number ( ) ,
7981} )
8082
8183export default function ComboboxForm ( ) {
@@ -89,12 +91,13 @@ export default function ComboboxForm() {
8991 duration : 1 ,
9092 active_loan_limit : 1 ,
9193 fine_per_day : 0 ,
94+ price : 0 ,
95+ usage_limit : 0 ,
9296 } ,
9397 } )
9498
9599 function onSubmit ( data : z . infer < typeof FormSchema > ) {
96100 createMembership ( data )
97- . then ( console . log )
98101 . then ( ( ) => {
99102 toast ( {
100103 title : 'Membership Created' ,
@@ -316,6 +319,46 @@ export default function ComboboxForm() {
316319 ) }
317320 />
318321
322+ < FormField
323+ control = { form . control }
324+ name = "usage_limit"
325+ render = { ( { field } ) => (
326+ < FormItem className = "flex flex-col" >
327+ < FormLabel > Usage Limit</ FormLabel >
328+ < Input
329+ placeholder = "Times"
330+ type = "number"
331+ { ...field }
332+ onChange = { field . onChange }
333+ />
334+ < FormDescription >
335+ How many times can a membership be used?
336+ </ FormDescription >
337+ < FormMessage />
338+ </ FormItem >
339+ ) }
340+ />
341+
342+ < FormField
343+ control = { form . control }
344+ name = "price"
345+ render = { ( { field } ) => (
346+ < FormItem className = "flex flex-col" >
347+ < FormLabel > Price</ FormLabel >
348+ < Input
349+ placeholder = "Pts"
350+ type = "number"
351+ { ...field }
352+ onChange = { field . onChange }
353+ />
354+ < FormDescription >
355+ How much does the membership cost?
356+ </ FormDescription >
357+ < FormMessage />
358+ </ FormItem >
359+ ) }
360+ />
361+
319362 < Button type = "reset" variant = "ghost" onClick = { onReset } >
320363 Reset
321364 </ Button >
Original file line number Diff line number Diff line change @@ -94,7 +94,9 @@ export default async function Memberships({
9494 < TableHead > Duration</ TableHead >
9595 < TableHead > Borrow Limit</ TableHead >
9696 < TableHead > Borrow Period</ TableHead >
97+ < TableHead > Active Limit</ TableHead >
9798 < TableHead > Fine per Day</ TableHead >
99+ < TableHead > Price</ TableHead >
98100 </ TableRow >
99101 </ TableHeader >
100102 < TableBody >
@@ -103,9 +105,11 @@ export default async function Memberships({
103105 < TableCell > { m . name } </ TableCell >
104106 < TableCell > { m . library . name } </ TableCell >
105107 < TableCell > { m . duration } D</ TableCell >
106- < TableCell > { m . active_loan_limit } </ TableCell >
108+ < TableCell > { m . usage_limit ?? '-' } </ TableCell >
107109 < TableCell > { m . loan_period } D</ TableCell >
110+ < TableCell > { m . active_loan_limit } </ TableCell >
108111 < TableCell > { m . fine_per_day ?? '-' } Pts</ TableCell >
112+ < TableCell > { m . price ?? '-' } </ TableCell >
109113 </ TableRow >
110114 ) ) }
111115 </ TableBody >
Original file line number Diff line number Diff line change @@ -107,8 +107,10 @@ export default async function Subscriptions({
107107 < TableHead > Expires At</ TableHead >
108108 < TableHead > Active Since</ TableHead >
109109 < TableHead > Borrow Limit</ TableHead >
110+ < TableHead > Usage Limit</ TableHead >
110111 < TableHead > Borrow Period</ TableHead >
111112 < TableHead > Fine per Day</ TableHead >
113+ < TableHead > Amount</ TableHead >
112114 </ TableRow >
113115 </ TableHeader >
114116 < TableBody >
@@ -124,8 +126,10 @@ export default async function Subscriptions({
124126 < time dateTime = { s . created_at } > { formatDate ( s . created_at ) } </ time >
125127 </ TableCell >
126128 < TableCell > { s . active_loan_limit } </ TableCell >
129+ < TableCell > { s . usage_limit ?? '-' } </ TableCell >
127130 < TableCell > { s . loan_period } D</ TableCell >
128131 < TableCell > { s . fine_per_day ?? '-' } Pts</ TableCell >
132+ < TableCell > { s . amount ?? '-' } Pts</ TableCell >
129133 </ TableRow >
130134 ) ) }
131135 </ TableBody >
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ export type Membership = WithCommon<{
66 library_id : string
77 duration : number
88 active_loan_limit : number
9+ usage_limit : number
910 loan_period : number
1011 library : Pick < Library , 'id' | 'name' >
1112 fine_per_day : number
Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ export type Subscription = WithCommon<{
99 amount : number
1010 loan_period : number
1111 active_loan_limit : number
12+ usage_limit : number
1213 user : Pick < User , 'id' | 'name' >
1314 membership : Pick < Membership , 'id' | 'name' | 'library_id' | 'library' >
1415 fine_per_day : number
You can’t perform that action at this time.
0 commit comments