File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ import { formatDate } from "@/lib/utils";
88interface Props {
99 title : string ;
1010 price : number ;
11- description : string ;
11+ description ? : string ;
1212 category ?: string ;
1313 condition ?: string ;
1414 priceLabel ?: string ;
@@ -19,6 +19,7 @@ interface Props {
1919}
2020
2121const MAX_DESCRIPTION_LENGTH = 250 ;
22+ const NO_DESCRIPTION = "No description" ;
2223
2324export const ListingInfo = ( {
2425 title,
@@ -33,11 +34,13 @@ export const ListingInfo = ({
3334 end_date,
3435} : Props ) => {
3536 const [ isExpanded , setIsExpanded ] = useState ( false ) ;
36- const shouldTruncate = description . length > MAX_DESCRIPTION_LENGTH ;
37+ const hasDescription = description && description . trim ( ) . length > 0 ;
38+ const descriptionText = hasDescription ? description : NO_DESCRIPTION ;
39+ const shouldTruncate = hasDescription && descriptionText . length > MAX_DESCRIPTION_LENGTH ;
3740 const displayDescription =
3841 ! shouldTruncate || isExpanded
39- ? description
40- : `${ description . slice ( 0 , MAX_DESCRIPTION_LENGTH ) } ...` ;
42+ ? descriptionText
43+ : `${ descriptionText . slice ( 0 , MAX_DESCRIPTION_LENGTH ) } ...` ;
4144
4245 return (
4346 < div className = "space-y-3" >
Original file line number Diff line number Diff line change @@ -135,7 +135,7 @@ export const BaseListingForm = <T extends BaseCreatePayload>({
135135 >
136136 < Textarea
137137 { ...field }
138- placeholder = { `Enter ${ displayLabel } Description ` }
138+ placeholder = { `Enter description (optional) ` }
139139 className = "min-h-[120px] resize-y"
140140 aria-invalid = { ! ! errors . description }
141141 disabled = { disabled }
Original file line number Diff line number Diff line change @@ -145,7 +145,7 @@ export type ListingFiltersMap = {
145145// ------------------------------------------------------------
146146export type BaseCreatePayload = {
147147 title : string ;
148- description : string ;
148+ description ? : string ;
149149 price : string ;
150150} ;
151151
Original file line number Diff line number Diff line change @@ -101,8 +101,8 @@ export const createItemSchema = z.object({
101101 description : z
102102 . string ( )
103103 . trim ( )
104- . min ( 1 , "Description is required " )
105- . max ( 5000 , "Description must be less than 5000 characters" ) ,
104+ . max ( 5000 , "Description must be less than 5000 characters " )
105+ . optional ( ) ,
106106 price : priceSchema ,
107107 tags : z . array ( z . string ( ) . trim ( ) ) ,
108108 condition : z . enum ( itemConditionValues , "Condition is required" ) ,
@@ -121,8 +121,8 @@ export const createSubletSchema = z
121121 description : z
122122 . string ( )
123123 . trim ( )
124- . min ( 1 , "Description is required " )
125- . max ( 5000 , "Description must be less than 5000 characters" ) ,
124+ . max ( 5000 , "Description must be less than 5000 characters " )
125+ . optional ( ) ,
126126 price : priceSchema ,
127127 tags : z . array ( z . string ( ) . trim ( ) ) ,
128128 street_address : z . string ( ) . trim ( ) . min ( 1 , "Street address is required" ) ,
You can’t perform that action at this time.
0 commit comments