Refactor for admin links

This commit is contained in:
David Bomba 2023-06-07 14:50:02 +10:00
parent 6e847888fc
commit cf5b2f6bfd
10 changed files with 26 additions and 38 deletions

View File

@ -56,7 +56,7 @@ class CreditEmailedNotification implements ShouldQueue
unset($methods[$key]);
$nmo = new NinjaMailerObject;
$nmo->mailable = new NinjaMailer((new EntitySentObject($event->invitation, 'credit', $event->template))->build());
$nmo->mailable = new NinjaMailer((new EntitySentObject($event->invitation, 'credit', $event->template, $company_user->portalType()))->build());
$nmo->company = $credit->company;
$nmo->settings = $credit->company->settings;
$nmo->to_user = $user;

View File

@ -49,7 +49,7 @@ class InvoiceFailedEmailNotification
unset($methods[$key]);
$nmo = new NinjaMailerObject;
$nmo->mailable = new NinjaMailer((new EntityFailedSendObject($event->invitation->withoutRelations(), 'invoice', $event->template, $event->message))->build());
$nmo->mailable = new NinjaMailer((new EntityFailedSendObject($event->invitation->withoutRelations(), 'invoice', $event->template, $event->message, $company_user->portalType()))->build());
$nmo->company = $invoice->company->withoutRelations();
$nmo->settings = $invoice->company->settings;
$nmo->to_user = $user;

View File

@ -70,7 +70,7 @@ class InvitationViewedListener implements ShouldQueue
$nmo = new NinjaMailerObject;
$nmo->mailable = new NinjaMailer((new EntityViewedObject($invitation, $entity_name))->build());
$nmo->mailable = new NinjaMailer((new EntityViewedObject($invitation, $entity_name, $company_user->portalType()))->build());
$nmo->company = $invitation->company;
$nmo->settings = $invitation->company->settings;

View File

@ -59,7 +59,7 @@ class PurchaseOrderAcceptedListener implements ShouldQueue
unset($methods[$key]);
$nmo = new NinjaMailerObject;
$nmo->mailable = new NinjaMailer((new PurchaseOrderAcceptedObject($purchase_order, $event->company))->build());
$nmo->mailable = new NinjaMailer((new PurchaseOrderAcceptedObject($purchase_order, $event->company, $company_user->portalType()))->build());
$nmo->company = $event->company;
$nmo->settings = $event->company->settings;

View File

@ -39,7 +39,9 @@ class EntityFailedSendObject
private $message;
public function __construct($invitation, $entity_type, $template, $message)
protected $use_react_url;
public function __construct($invitation, $entity_type, $template, $message, $use_react_url)
{
$this->invitation = $invitation;
$this->entity_type = $entity_type;
@ -48,6 +50,7 @@ class EntityFailedSendObject
$this->company = $invitation->company;
$this->template = $template;
$this->message = $message;
$this->use_react_url = $use_react_url;
}
public function build()
@ -149,7 +152,7 @@ class EntityFailedSendObject
'contact' => $this->contact->present()->name(),
]
),
'url' => $this->invitation->getAdminLink(),
'url' => $this->invitation->getAdminLink($this->use_react_url),
'button' => ctrans("texts.view_{$this->entity_type}"),
'signature' => $signature,
'logo' => $this->company->present()->logo(),

View File

@ -36,7 +36,9 @@ class EntitySentObject
private $template_body;
public function __construct($invitation, $entity_type, $template)
protected $use_react_url;
public function __construct($invitation, $entity_type, $template, use_react_url)
{
$this->invitation = $invitation;
$this->entity_type = $entity_type;
@ -44,6 +46,7 @@ class EntitySentObject
$this->contact = $invitation->contact;
$this->company = $invitation->company;
$this->template = $template;
$this->use_react_url = $use_react_url;
}
public function build()
@ -78,7 +81,7 @@ class EntitySentObject
'purchase_order' => $this->entity->number,
]
),
'url' => $this->invitation->getAdminLink(),
'url' => $this->invitation->getAdminLink($this->use_react_url),
'button' => ctrans("texts.view_{$this->entity_type}"),
'signature' => $this->company->settings->email_signature,
'logo' => $this->company->present()->logo(),
@ -185,7 +188,7 @@ class EntitySentObject
return [
'title' => $this->getSubject(),
'message' => $this->getMessage(),
'url' => $this->invitation->getAdminLink(),
'url' => $this->invitation->getAdminLink($this->use_react_url),
'button' => ctrans("texts.view_{$this->entity_type}"),
'signature' => $settings->email_signature,
'logo' => $this->company->present()->logo(),

View File

@ -30,13 +30,16 @@ class EntityViewedObject
public $settings;
public function __construct($invitation, $entity_type)
protected $use_react_url;
public function __construct($invitation, $entity_type, $use_react_url)
{
$this->invitation = $invitation;
$this->entity_type = $entity_type;
$this->entity = $invitation->{$entity_type};
$this->contact = $invitation->contact;
$this->company = $invitation->company;
$this->use_react_url = $use_react_url;
}
public function build()
@ -104,7 +107,7 @@ class EntityViewedObject
'invoice' => $this->entity->number,
]
),
'url' => $this->invitation->getAdminLink(),
'url' => $this->invitation->getAdminLink($this->use_react_url),
'button' => ctrans("texts.view_{$this->entity_type}"),
'signature' => $settings->email_signature,
'logo' => $this->company->present()->logo(),

View File

@ -21,16 +21,9 @@ use stdClass;
class PurchaseOrderAcceptedObject
{
public $purchase_order;
public $company;
public $settings;
public function __construct(PurchaseOrder $purchase_order, Company $company)
public function __construct(public PurchaseOrder $purchase_order, public Company $company, protected bool $use_react_url)
{
$this->purchase_order = $purchase_order;
$this->company = $company;
}
public function build()
@ -90,7 +83,7 @@ class PurchaseOrderAcceptedObject
'purchase_order' => $this->purchase_order->number,
]
),
'url' => $this->purchase_order->invitations->first()->getAdminLink(),
'url' => $this->purchase_order->invitations->first()->getAdminLink($this->use_react_url),
'button' => ctrans('texts.view_purchase_order'),
'signature' => $settings->email_signature,
'logo' => $this->company->present()->logo(),

View File

@ -21,16 +21,9 @@ use stdClass;
class QuoteApprovedObject
{
public $quote;
public $company;
public $settings;
public function __construct(Quote $quote, Company $company)
public function __construct(public Quote $quote, public Company $company, public bool $use_react_url)
{
$this->quote = $quote;
$this->company = $company;
}
public function build()
@ -90,7 +83,7 @@ class QuoteApprovedObject
'invoice' => $this->quote->number,
]
),
'url' => $this->quote->invitations->first()->getAdminLink(),
'url' => $this->quote->invitations->first()->getAdminLink($this->use_react_url),
'button' => ctrans('texts.view_quote'),
'signature' => $settings->email_signature,
'logo' => $this->company->present()->logo(),

View File

@ -21,16 +21,9 @@ use stdClass;
class QuoteExpiredObject
{
public $quote;
public $company;
public $settings;
public function __construct(Quote $quote, Company $company)
public function __construct(public Quote $quote, public Company $company, public bool $use_react_url)
{
$this->quote = $quote;
$this->company = $company;
}
public function build()
@ -90,7 +83,7 @@ class QuoteExpiredObject
'invoice' => $this->quote->number,
]
),
'url' => $this->quote->invitations->first()->getAdminLink(),
'url' => $this->quote->invitations->first()->getAdminLink($this->use_react_url),
'button' => ctrans('texts.view_quote'),
'signature' => $settings->email_signature,
'logo' => $this->company->present()->logo(),