Skip to content

Commit

Permalink
fix: fix call reasons (#6686)
Browse files Browse the repository at this point in the history
  • Loading branch information
asbiin authored Jun 16, 2023
1 parent 00548f8 commit ba06e85
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 8 deletions.
6 changes: 0 additions & 6 deletions app/Domains/Settings/CreateAccount/Jobs/SetupAccount.php
Original file line number Diff line number Diff line change
Expand Up @@ -924,12 +924,6 @@ private function addCallReasonTypes(): void
'call_reason_type_id' => $type->id,
'label_translation_key' => trans_key('To hear their story'),
]);
(new CreateCallReason())->execute([
'account_id' => $this->author->account_id,
'author_id' => $this->author->id,
'call_reason_type_id' => $type->id,
'label_translation_key' => trans_key(''),
]);

// business
$type = (new CreateCallReasonType())->execute([
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function execute(array $data): CallReason
$callReason = CallReason::create([
'call_reason_type_id' => $type->id,
'label' => $data['label'] ?? null,
'label_translation_key' => $data['label'] ?? null,
'label_translation_key' => $data['label_translation_key'] ?? null,
]);

return $callReason;
Expand Down
46 changes: 46 additions & 0 deletions database/migrations/2023_06_16_103430_fix_call_reasons.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

use App\Models\CallReasonType;
use Illuminate\Database\Migrations\Migration;

return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
CallReasonType::all()->each(function (CallReasonType $type) {
$reasons = $type->callReasons()->get();
if ($type->label_translation_key === 'Personal') {
$reasons[0]->updateQuietly([
'label_translation_key' => 'For advice',
]);
$reasons[1]->updateQuietly([
'label_translation_key' => 'Just to say hello',
]);
$reasons[2]->updateQuietly([
'label_translation_key' => 'To see if they need anything',
]);
$reasons[3]->updateQuietly([
'label_translation_key' => 'Out of respect and appreciation',
]);
$reasons[4]->updateQuietly([
'label_translation_key' => 'To hear their story',
]);
try {
$reasons[5]->delete();
} catch (\Exception $e) {
// ignore
}
} elseif ($type->label_translation_key === 'Business') {
$reasons[0]->updateQuietly([
'label_translation_key' => 'Discuss recent purchases',
]);
$reasons[1]->updateQuietly([
'label_translation_key' => 'Discuss partnership',
]);
}
});
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,6 @@
v-for="reason in callReasonType.reasons"
:key="reason.id"
class="border-b border-gray-200 hover:bg-slate-50 dark:border-gray-700 dark:bg-slate-900 hover:dark:bg-slate-800">
{{ reason }}
<!-- detail of the relationship type -->
<div v-if="renameReasonModalId !== reason.id" class="flex items-center justify-between px-5 py-2 ps-6">
<span>{{ reason.label }}</span>
Expand Down

0 comments on commit ba06e85

Please sign in to comment.