From ea465a8739263b83e558ac20ee2857f821fc158c Mon Sep 17 00:00:00 2001 From: Fairuz Date: Mon, 31 May 2021 11:45:41 +0800 Subject: [PATCH] Set default, delete, update & view identity documents --- .../ControllersLogic/UpdateAddressLogic.php | 14 +++++++---- .../Addresses/Services/UpdatesAddress.php | 14 +++++------ .../address/elements/AddressComponent.vue | 2 +- .../address/forms/AddressFormComponent.vue | 9 ++++++- .../elements/CompanyDetailsComponent.vue | 24 +++++++++---------- .../CustomerProfileSectionComponent.vue | 20 ++++++++++------ 6 files changed, 50 insertions(+), 33 deletions(-) diff --git a/app/Classes/Modules/Addresses/ControllersLogic/UpdateAddressLogic.php b/app/Classes/Modules/Addresses/ControllersLogic/UpdateAddressLogic.php index aa76a032..805bc7ac 100644 --- a/app/Classes/Modules/Addresses/ControllersLogic/UpdateAddressLogic.php +++ b/app/Classes/Modules/Addresses/ControllersLogic/UpdateAddressLogic.php @@ -6,6 +6,7 @@ namespace App\Classes\Modules\Addresses\ControllersLogic; use App\Classes\General\Abstracts\AbstractControllerLogic; use App\Classes\Modules\Addresses\Services\UpdatesAddress; use App\Classes\Modules\Addresses\Services\FetchesAddress; +use App\Classes\Modules\Addresses\Services\FetchesDistrict; use App\Classes\Modules\Addresses\Standards\Rules\CanUpdateAddress; use App\Classes\Modules\Addresses\DataTransferObjects\AddressObject; use App\Http\Resources\AddressResource; @@ -35,17 +36,22 @@ class UpdateAddressLogic extends AbstractControllerLogic /** @var FetchesAddress */ private $fetchesAddress; + /** @var FetchesDistrict */ + private $fetchesDistrict; + /** * UpdateAddressLogic constructor. * @param CanUpdateAddress $canUpdateAddress * @param UpdatesAddress $updatesAddress * @param FetchesAddress $fetchesAddress + * @param FetchesDistrict $fetchesDistrict */ - public function __construct(CanUpdateAddress $canUpdateAddress, UpdatesAddress $updatesAddress, FetchesAddress $fetchesAddress) + public function __construct(CanUpdateAddress $canUpdateAddress, UpdatesAddress $updatesAddress, FetchesAddress $fetchesAddress, FetchesDistrict $fetchesDistrict) { $this->canUpdateAddress = $canUpdateAddress; $this->updatesAddress = $updatesAddress; $this->fetchesAddress = $fetchesAddress; + $this->fetchesDistrict = $fetchesDistrict; } @@ -58,9 +64,9 @@ class UpdateAddressLogic extends AbstractControllerLogic { try { - //$district = $this->fetchesDistrict->execute(['id' => $request->input('district_id')]); - //$object = new AddressObject($request->input('street_one'), $request->input('street_two'), $district->country_id, $district->state_id, $district->id, $request->input('post_code')); - $object = new AddressObject($request->input('company_id'), $request->input('street_one'), $request->input('street_two'), $request->input('city'), $request->input('state'), $request->input('post_code'), $request->input('country'), $request->input('default'), $request->input('billing')); + $district = $this->fetchesDistrict->execute(['id' => $request->input('district_id')]); + $object = new AddressObject($request->input('street_one'), $request->input('street_two'), $district->country_id, $district->state_id, $district->id, $request->input('post_code')); + //$object = new AddressObject($request->input('company_id'), $request->input('street_one'), $request->input('street_two'), $request->input('city'), $request->input('state'), $request->input('post_code'), $request->input('country'), $request->input('default'), $request->input('billing')); $this->canUpdateAddress->passes($object); diff --git a/app/Classes/Modules/Addresses/Services/UpdatesAddress.php b/app/Classes/Modules/Addresses/Services/UpdatesAddress.php index 76ba4d15..907edc73 100644 --- a/app/Classes/Modules/Addresses/Services/UpdatesAddress.php +++ b/app/Classes/Modules/Addresses/Services/UpdatesAddress.php @@ -17,15 +17,15 @@ class UpdatesAddress extends AbstractUpdateRecord */ public function execute(Address $model, AddressObject $object) { - $model->company_id = $object->getCompanyId(); + //$model->company_id = $object->getCompanyId(); $model->street_one = $object->getStreetOne(); $model->street_two = $object->getStreetTwo(); - $model->city = $object->getCity(); - $model->state = $object->getState(); - $model->post_code = $object->getPostCode(); - $model->country = $object->getCountry(); - $model->default = $object->getDefault(); - $model->billing = $object->getBilling(); + $model->district_id = $object->getDistrictId(); + $model->state_id = $object->getStateId(); + $model->postcode = $object->getPostCode(); + $model->country_id = $object->getCountryId(); + //$model->default = $object->getDefault(); + //$model->billing = $object->getBilling(); return $this->handler($model); diff --git a/resources/assets/vue/components/address/elements/AddressComponent.vue b/resources/assets/vue/components/address/elements/AddressComponent.vue index b4e9e8ec..df0062e6 100644 --- a/resources/assets/vue/components/address/elements/AddressComponent.vue +++ b/resources/assets/vue/components/address/elements/AddressComponent.vue @@ -88,7 +88,7 @@ this.submit(route('api.address.default',this.address.id), 'put', this.section, true, true); }, updateAddress(id){ - this.$root.$emit('updateAddressForm', this.address); + this.$root.$emit('updateAddressForm', this.address, true); }, deleteAddress(id){ this.$root.$emit('deleteAddressConfirm', id); diff --git a/resources/assets/vue/components/address/forms/AddressFormComponent.vue b/resources/assets/vue/components/address/forms/AddressFormComponent.vue index 00dd0b2f..a201f4e5 100644 --- a/resources/assets/vue/components/address/forms/AddressFormComponent.vue +++ b/resources/assets/vue/components/address/forms/AddressFormComponent.vue @@ -40,6 +40,7 @@
+
@@ -56,6 +57,7 @@ required: true }, type: { + //Npte: type 1 = create, type 2 = update set default, type 3 = update address type: Number, default: 1 }, @@ -70,6 +72,7 @@ this.parameters.company_id = this.id; }, 'addressData': function() { + this.resetForm(); this.parameters = { company_id: this.id, street_one: this.addressData.street_one, @@ -107,9 +110,13 @@ this.submit((this.route('api.address.create')), 'post', 'bookingDetailSection', true, true) } }, + closeForm(){ + this.$root.$emit('updateAddressForm', {}, false); + }, successHandler(response){ if(this.type==3){ - console.log('updated??'); + this.closeForm(); + this.$store.dispatch('reloadList', {'name': "addresslist"}); }else { this.type !== 2 ? this.$emit('updateDefaultAddress', response.payload.data) : this.$emit('createdAddress', response.payload.data); this.resetForm(); diff --git a/resources/assets/vue/components/companies/elements/CompanyDetailsComponent.vue b/resources/assets/vue/components/companies/elements/CompanyDetailsComponent.vue index 05d3c522..8576dd0f 100644 --- a/resources/assets/vue/components/companies/elements/CompanyDetailsComponent.vue +++ b/resources/assets/vue/components/companies/elements/CompanyDetailsComponent.vue @@ -17,17 +17,13 @@ -
- - +
+ +
-
+
+
-
-
-
{{ this.company_details.identification.document_type === 'IDENTITY_CARD' ? 'IC' : 'SSM Registration' }} Document
-
-
@@ -41,6 +37,10 @@
+
+ + +
@@ -70,12 +70,10 @@ } }, watch: { - company: function(newVal, oldVal) { - console.log(newVal); - }, company_details: function(newVal, oldVal) { + this.company_details=newVal; console.log(newVal); - +console.log('hellp'); if(newVal !== null) { let approved = 0, completed = 0, rejected = 0, expired = 0, pending = 0; diff --git a/resources/assets/vue/components/companies/sections/CustomerProfileSectionComponent.vue b/resources/assets/vue/components/companies/sections/CustomerProfileSectionComponent.vue index f3876772..a7652179 100644 --- a/resources/assets/vue/components/companies/sections/CustomerProfileSectionComponent.vue +++ b/resources/assets/vue/components/companies/sections/CustomerProfileSectionComponent.vue @@ -78,7 +78,7 @@
-
+
- +
@@ -215,6 +215,7 @@ return { section: 'customerProfileSection', company: null, + company_details: {}, bookingFilters: { reference: '', type: 0, @@ -247,11 +248,13 @@ this.address_id=id; $("#deleteAddressModal").closest('.modal').modal('show'); }); - this.$root.$on('updateAddressForm', (address) => { - console.log(">>>> "+address); - console.log(">>>> "+address.street_one); - this.address=address; - this.displayAddressForm = true; + this.$root.$on('updateAddressForm', (address, show) => { + if(show) { + this.address = address; + this.displayAddressForm = true; + }else{ + this.displayAddressForm = false; + } }); }, watch: { @@ -265,6 +268,9 @@ this.$store.dispatch('updateListQueue', {'name': this.section}); }, methods: { + refreshCompanyDetails(){ + this.company_details = this.company ; + }, fetchCompany(){ this.submit(route('api.company.show', this.id), 'get', this.section, false, false) },