diff --git a/app/components/modal-location.hbs b/app/components/modal-location.hbs new file mode 100644 index 00000000..73d5176b --- /dev/null +++ b/app/components/modal-location.hbs @@ -0,0 +1,112 @@ +{{#if this.isOpen}} + +{{else}} + + update location + +{{/if}} \ No newline at end of file diff --git a/app/components/modal-location.js b/app/components/modal-location.js new file mode 100644 index 00000000..02f0ce4a --- /dev/null +++ b/app/components/modal-location.js @@ -0,0 +1,116 @@ +/* eslint-disable prettier/prettier */ +import Component from '@glimmer/component'; +import { action } from '@ember/object'; +import { tracked } from '@glimmer/tracking'; + + +import ENV from 'website-my/config/environment'; + +const BASE_URL = ENV.GEOCODING_API_URL; + + +export default class ModalLocationComponent extends Component{ + + @tracked isOpen = false; + + @tracked location = ''; + + @tracked updateLocation = null; + + @tracked sendNotification = null; + + @tracked isCheckAll = false; + + @tracked isLoading = false; + + @tracked placesArray = []; + + @action setSelection(event) { + this.updateLocation = event.target.value; + + console.log(this.updateLocation, 'update location option'); + } + + @action setSelectedNotification(event) { + this.sendNotification = event.target.value; + + console.log(this.sendNotification, 'notification sent to'); + } + + + @action handleSelectedPlace(places) { + + console.log('clicked' , places); + + + this.location = places; + } + + @action async updateValue(event) { + this.location = event.target.value; + + this.isLoading = true; + + try { + const response = await fetch( + `${BASE_URL}/${this.location}.json?limit=4&proximity=ip&types=place%2Cpostcode%2Caddress&access_token=pk.eyJ1IjoidmluYXlhay0wOSIsImEiOiJjbDdoM24waG0wYW9tM3dwYjN3aWJpNGh4In0.pcwljIKYp_NL-GmtDztvPg`, + { + method: 'GET', + headers: { + 'Content-Type': 'application/json', + }, + } + ); + + if (response.ok) { + this.isLoading = false; + console.log(response, 'result url'); + + const result = await response.json(); + + this.placesArray = result?.features; + + console.log(this.placesArray, '____result'); + } + } catch (error) { + this.isLoading = false; + console.log(error.message, '__error'); + } finally { + this.isLoading = false; + } + } + + @action toggleModal() { + this.isOpen = !this.isOpen; + } + + formDataKeyName = 'modal'; + + @tracked isSubmitDisabled = false; + + @action async handleSubmit(e) { + e.preventDefault(); + + this.isOpen = false; + + const cleanReqObject = { + location: this.location, + + updateLocation: this.updateLocation, + + sendNotification: this.sendNotification, + }; + + this.isSubmitClicked = true; + + this.location = ''; + + console.log(cleanReqObject, 'feilds value'); + } + + + + + + +} \ No newline at end of file diff --git a/app/components/navbar.hbs b/app/components/navbar.hbs index 30498328..286fa6ad 100644 --- a/app/components/navbar.hbs +++ b/app/components/navbar.hbs @@ -1,24 +1,24 @@ -