I'm trying to find Opportunity records with an address within X amount of miles from an entered location. I'm using the lightning-input-address and passing the value to an Apex class and am getting this error - "AuraEnabled methods do not support parameter type of System.Address ". Is there any workaround to this?
LWC snippet:
<lightning-input-address
class="location" value={location}
address-label="Address" street-label="Street"
city-label="City" country-label="Country"
province-label="State" postal-code-label="Zip/ Postal Code"
onchange={handleAddressChange} address-lookup-placeholder = "Search Address..."
show-address-lookup>
</lightning-input-address>
@wire(getAddy, {location: '$location', allData: '$allData', distance: '$distance'})
wiredAccounts({ error, data }) {...}
Apex
@AuraEnabled(cacheable=true)
public static List<Opportunity> getLocation(Address location, List<Opportunity> allData, Integer distance) {
// Address addr = location;
Double lat = location.latitude;
Double lon = location.longitude;
List<Opportunity> oppList = new List<Opportunity>([SELECT ID, Name FROM Opportunity WHERE DISTANCE(Hospital_Location__c, GEOLOCATION(:lat,:lon), 'mi') < :distance AND Id IN :allData]);
return oppList;
}