From f86ad69132669a850bc66a50cc0fcedd58d5d891 Mon Sep 17 00:00:00 2001 From: edmondlang Date: Fri, 11 Aug 2023 15:12:34 +0800 Subject: [PATCH] update customer profile --- .../UpdateCompanyProfileLogic.php | 2 +- .../CompanyProfileObject.php | 10 +-- .../Services/UpdatesCompanyProfile.php | 2 +- .../elements/CompanyDetailsComponent.vue | 34 +++++---- .../EditCustomerCompanyTypeFormComponent.vue | 71 +++++++++++++++++++ ...EditCustomerContactNumberFormComponent.vue | 70 ++++++++++++++++++ .../EditCustomerProfileInfoFormComponent.vue | 30 +++----- 7 files changed, 178 insertions(+), 41 deletions(-) create mode 100644 resources/assets/vue/components/companies/forms/EditCustomerCompanyTypeFormComponent.vue create mode 100644 resources/assets/vue/components/companies/forms/EditCustomerContactNumberFormComponent.vue diff --git a/app/Classes/Modules/Companies/ControllersLogic/UpdateCompanyProfileLogic.php b/app/Classes/Modules/Companies/ControllersLogic/UpdateCompanyProfileLogic.php index f9a1c91e..e25fdbf6 100644 --- a/app/Classes/Modules/Companies/ControllersLogic/UpdateCompanyProfileLogic.php +++ b/app/Classes/Modules/Companies/ControllersLogic/UpdateCompanyProfileLogic.php @@ -52,7 +52,7 @@ class UpdateCompanyProfileLogic extends AbstractControllerLogic */ public function logic(Request $request) : JsonResponse { - $object = new CompanyProfileObject($request->input('email'), $request->input('phone'), $request->input('business_type')); + $object = new CompanyProfileObject($request->input('email'), $request->input('phone'), $request->input('type')); $company = $this->fetchesCompany->execute(['id' => $request->route('id')]); diff --git a/app/Classes/Modules/Companies/DataTransferObjects/CompanyProfileObject.php b/app/Classes/Modules/Companies/DataTransferObjects/CompanyProfileObject.php index b82e33a0..0f3e8a54 100644 --- a/app/Classes/Modules/Companies/DataTransferObjects/CompanyProfileObject.php +++ b/app/Classes/Modules/Companies/DataTransferObjects/CompanyProfileObject.php @@ -14,7 +14,7 @@ class CompanyProfileObject implements DataTransferObject private $phone; /** @var int|null */ - private $businessType; + private $companyType; /** * CompanyObject constructor. @@ -22,11 +22,11 @@ class CompanyProfileObject implements DataTransferObject * @param string $phone * @param int|null $businessType */ - public function __construct(?string $email, string $phone, ?int $businessType = BusinessType::IMPORTER) + public function __construct(?string $email, string $phone, int $companyType) { $this->email = $email; $this->phone = $phone; - $this->businessType = $businessType; + $this->companyType = $companyType; } /** @@ -48,8 +48,8 @@ class CompanyProfileObject implements DataTransferObject /** * @return int */ - public function getBusinessType(): int + public function getCompanyType(): int { - return $this->businessType; + return $this->companyType; } } diff --git a/app/Classes/Modules/Companies/Services/UpdatesCompanyProfile.php b/app/Classes/Modules/Companies/Services/UpdatesCompanyProfile.php index fd5e9f5a..85da8836 100644 --- a/app/Classes/Modules/Companies/Services/UpdatesCompanyProfile.php +++ b/app/Classes/Modules/Companies/Services/UpdatesCompanyProfile.php @@ -17,7 +17,7 @@ class UpdatesCompanyProfile extends AbstractUpdateRecord */ public function execute(Company $model, CompanyProfileObject $object) { - $model->business_type = $object->getBusinessType(); + $model->type = $object->getCompanyType(); $contact = $model->contacts()->first(); if ($contact) { diff --git a/resources/assets/vue/components/companies/elements/CompanyDetailsComponent.vue b/resources/assets/vue/components/companies/elements/CompanyDetailsComponent.vue index ebb188e2..8bc0b7a8 100644 --- a/resources/assets/vue/components/companies/elements/CompanyDetailsComponent.vue +++ b/resources/assets/vue/components/companies/elements/CompanyDetailsComponent.vue @@ -10,8 +10,13 @@
- - + +
@@ -23,7 +28,12 @@
- +
@@ -42,7 +52,7 @@
-
+
Edit Profile Info
@@ -73,7 +83,12 @@ - + + + + + +
@@ -204,14 +219,7 @@ } }, getCompanyTypeDesc(company_type_id) { - switch (company_type_id) { - case 0: - return 'Personal Business'; - case 1: - return 'Company Business'; - default: - return null; - } + return (company_type_id == 1) ? 'Company Business' : 'Personal Business'; }, }, mixins: [componentHandler] diff --git a/resources/assets/vue/components/companies/forms/EditCustomerCompanyTypeFormComponent.vue b/resources/assets/vue/components/companies/forms/EditCustomerCompanyTypeFormComponent.vue new file mode 100644 index 00000000..c15091b5 --- /dev/null +++ b/resources/assets/vue/components/companies/forms/EditCustomerCompanyTypeFormComponent.vue @@ -0,0 +1,71 @@ + + \ No newline at end of file diff --git a/resources/assets/vue/components/companies/forms/EditCustomerContactNumberFormComponent.vue b/resources/assets/vue/components/companies/forms/EditCustomerContactNumberFormComponent.vue new file mode 100644 index 00000000..0145e057 --- /dev/null +++ b/resources/assets/vue/components/companies/forms/EditCustomerContactNumberFormComponent.vue @@ -0,0 +1,70 @@ + + \ No newline at end of file diff --git a/resources/assets/vue/components/companies/forms/EditCustomerProfileInfoFormComponent.vue b/resources/assets/vue/components/companies/forms/EditCustomerProfileInfoFormComponent.vue index 09cdaa9a..949ab2a4 100644 --- a/resources/assets/vue/components/companies/forms/EditCustomerProfileInfoFormComponent.vue +++ b/resources/assets/vue/components/companies/forms/EditCustomerProfileInfoFormComponent.vue @@ -1,5 +1,5 @@