@@ -18,7 +18,7 @@ import { parsePriceString } from "@/lib/utils";
1818import { createSubletSchema } from "@/lib/validations" ;
1919import type { CreateSubletPayload } from "@/lib/types" ;
2020import type { CreateSubletFormData } from "@/lib/validations" ;
21- import { AddressAutocomplete } from "../address/ address-autocomplete " ;
21+ import { AddressAutocomplete } from "@/components/listings/ address/AddressAutocomplete " ;
2222
2323const DISPLAY_LABEL = "Listing" ;
2424const EXAMPLE_TITLE = "e.g., Spacious 2BR near campus" ;
@@ -42,7 +42,8 @@ export function SubletForm() {
4242 description : "" ,
4343 tags : [ ] ,
4444 street_address : "" ,
45- validated_address : null ,
45+ latitude : 0 ,
46+ longitude : 0 ,
4647 beds : 0 ,
4748 baths : 0 ,
4849 start_date : "" ,
@@ -96,39 +97,48 @@ export function SubletForm() {
9697 control = { control }
9798 render = { ( { field : streetField } ) => (
9899 < Controller
99- name = "validated_address "
100+ name = "latitude "
100101 control = { control }
101- render = { ( { field : validatedField } ) => (
102- < FormField
103- label = { "Street Address" }
104- error = { errors . street_address ?. message }
105- touched = { touchedFields . street_address }
106- labelSupplement = {
107- < span className = { "group relative inline-flex" } >
108- < Info
109- className = { "text-muted-foreground h-4 w-4 shrink-0 cursor-help" }
110- aria-label = "address privacy info"
102+ render = { ( { field : latField } ) => (
103+ < Controller
104+ name = "longitude"
105+ control = { control }
106+ render = { ( { field : lonField } ) => (
107+ < FormField
108+ label = { "Street Address" }
109+ error = { errors . street_address ?. message }
110+ touched = { touchedFields . street_address }
111+ labelSupplement = {
112+ < span className = { "group relative inline-flex" } >
113+ < Info
114+ className = { "text-muted-foreground h-4 w-4 shrink-0 cursor-help" }
115+ aria-label = "address privacy info"
116+ />
117+ < span
118+ className = {
119+ "bg-popover text-popover-foreground pointer-events-none absolute top-full left-0 z-10 mt-1.5 w-56 rounded-md border px-3 py-2 text-xs opacity-0 shadow-md transition-opacity duration-150 group-hover:opacity-100"
120+ }
121+ >
122+ Your address will not be visible to the public. Only an approximate
123+ location will be shown on the map.
124+ </ span >
125+ </ span >
126+ }
127+ >
128+ < AddressAutocomplete
129+ value = { streetField . value }
130+ onChange = { streetField . onChange }
131+ onValidatedAddressChange = { ( addr ) => {
132+ latField . onChange ( addr ? parseFloat ( addr . lat ) : 0 ) ;
133+ lonField . onChange ( addr ? parseFloat ( addr . lon ) : 0 ) ;
134+ } }
135+ disabled = { isFormDisabled }
136+ error = { ! ! errors . street_address }
137+ placeholder = { "123 Main St 19104" }
111138 />
112- < span
113- className = {
114- "bg-popover text-popover-foreground pointer-events-none absolute top-full left-0 z-10 mt-1.5 w-56 rounded-md border px-3 py-2 text-xs opacity-0 shadow-md transition-opacity duration-150 group-hover:opacity-100"
115- }
116- >
117- Your address will not be visible to the public. Only an approximate location
118- will be shown on the map.
119- </ span >
120- </ span >
121- }
122- >
123- < AddressAutocomplete
124- value = { streetField . value }
125- onChange = { streetField . onChange }
126- onValidatedAddressChange = { validatedField . onChange }
127- disabled = { isFormDisabled }
128- error = { ! ! errors . street_address }
129- placeholder = { "123 Main St, Philadelphia, PA 19104" }
130- />
131- </ FormField >
139+ </ FormField >
140+ ) }
141+ />
132142 ) }
133143 />
134144 ) }
0 commit comments