This repository has been archived by the owner on Feb 8, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 129
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
342 additions
and
3 deletions.
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
app/Http/Controllers/Company/Adminland/AdminCancelAccountController.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers\Company\Adminland; | ||
|
||
use Inertia\Inertia; | ||
use Inertia\Response; | ||
use Illuminate\Http\Request; | ||
use App\Helpers\InstanceHelper; | ||
use Illuminate\Http\JsonResponse; | ||
use App\Helpers\NotificationHelper; | ||
use App\Http\Controllers\Controller; | ||
use App\Services\Company\Adminland\Company\DestroyCompany; | ||
|
||
class AdminCancelAccountController extends Controller | ||
{ | ||
/** | ||
* Show the Cancel account page. | ||
* | ||
* @return Response | ||
*/ | ||
public function index(): Response | ||
{ | ||
return Inertia::render('Adminland/General/Cancel/Index', [ | ||
'notifications' => NotificationHelper::getNotifications(InstanceHelper::getLoggedEmployee()), | ||
]); | ||
} | ||
|
||
/** | ||
* Destroy the company. | ||
* | ||
* @param Request $request | ||
* @param int $companyId | ||
* @return JsonResponse | ||
*/ | ||
public function destroy(Request $request, int $companyId): JsonResponse | ||
{ | ||
$loggedEmployee = InstanceHelper::getLoggedEmployee(); | ||
$loggedCompany = InstanceHelper::getLoggedCompany(); | ||
|
||
$data = [ | ||
'company_id' => $loggedCompany->id, | ||
'author_id' => $loggedEmployee->id, | ||
]; | ||
|
||
(new DestroyCompany)->execute($data); | ||
|
||
return response()->json([ | ||
'data' => true, | ||
], 200); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?php | ||
|
||
namespace App\Services\Company\Adminland\Company; | ||
|
||
use App\Services\BaseService; | ||
use App\Models\Company\Company; | ||
|
||
class DestroyCompany extends BaseService | ||
{ | ||
protected Company $company; | ||
|
||
protected array $data; | ||
|
||
/** | ||
* Get the validation rules that apply to the service. | ||
* | ||
* @return array | ||
*/ | ||
public function rules(): array | ||
{ | ||
return [ | ||
'company_id' => 'required|integer|exists:companies,id', | ||
'author_id' => 'required|integer|exists:employees,id', | ||
]; | ||
} | ||
|
||
/** | ||
* Destroy the company. | ||
* | ||
* @param array $data | ||
*/ | ||
public function execute(array $data): void | ||
{ | ||
$this->data = $data; | ||
$this->validate(); | ||
|
||
$this->data = $data; | ||
$this->destroy(); | ||
} | ||
|
||
private function validate(): void | ||
{ | ||
$this->validateRules($this->data); | ||
|
||
$this->author($this->data['author_id']) | ||
->inCompany($this->data['company_id']) | ||
->asAtLeastAdministrator() | ||
->canExecuteService(); | ||
|
||
$this->company = Company::find($this->data['company_id']); | ||
} | ||
|
||
private function destroy(): void | ||
{ | ||
$this->company->delete(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
<style lang="scss" scoped> | ||
.check { | ||
color: #fb8444; | ||
top: 4px; | ||
width: 20px; | ||
} | ||
</style> | ||
|
||
<template> | ||
<layout title="Home" :notifications="notifications"> | ||
<div class="ph2 ph0-ns"> | ||
<!-- BREADCRUMB --> | ||
<div class="mt4-l mt1 mw6 br3 bg-white box center breadcrumb relative z-0 f6 pb2"> | ||
<ul class="list ph0 tc-l tl"> | ||
<li class="di"> | ||
<inertia-link :href="'/' + $page.props.auth.company.id + '/dashboard'">{{ $t('app.breadcrumb_dashboard') }}</inertia-link> | ||
</li> | ||
<li class="di"> | ||
<inertia-link :href="'/' + $page.props.auth.company.id + '/account'">{{ $t('app.breadcrumb_account_home') }}</inertia-link> | ||
</li> | ||
<li class="di"> | ||
{{ $t('app.breadcrumb_account_manage_cancel_account') }} | ||
</li> | ||
</ul> | ||
</div> | ||
|
||
<!-- BODY --> | ||
<div class="mw7 center br3 mb5 bg-white box restricted relative z-1"> | ||
<div class="mt5"> | ||
<h2 class="tc normal mb4 pt3 relative"> | ||
{{ $t('account.cancel_account_title') }} | ||
|
||
<help :url="$page.props.help_links.account_cancellation" :top="'1px'" /> | ||
</h2> | ||
|
||
<div class="ph5 pv3 bb bb-gray"> | ||
<p class="mb5">{{ $t('account.cancel_account_thanks') }}</p> | ||
|
||
<p class="fw6">{{ $t('account.cancel_account_please_note') }}</p> | ||
<ul class="list ma0 pa0"> | ||
<li class="relative mb2-l lh-copy"> | ||
<svg class="check relative" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor"> | ||
<path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z" clip-rule="evenodd" /> | ||
</svg> | ||
{{ $t('account.cancel_account_company_account_closed') }} | ||
</li> | ||
<li class="relative mb2-l lh-copy"> | ||
<svg class="check relative" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor"> | ||
<path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z" clip-rule="evenodd" /> | ||
</svg> | ||
{{ $t('account.cancel_account_company_employee_deleted') }} | ||
</li> | ||
<li class="relative mb2-l lh-copy"> | ||
<svg class="check relative" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor"> | ||
<path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z" clip-rule="evenodd" /> | ||
</svg> | ||
{{ $t('account.cancel_account_company_data_deleted') }} | ||
</li> | ||
<li class="relative mb2-l lh-copy"> | ||
<svg class="check relative" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor"> | ||
<path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z" clip-rule="evenodd" /> | ||
</svg> | ||
{{ $t('account.cancel_account_company_subscription') }} | ||
</li> | ||
</ul> | ||
|
||
<p class="lh-copy">{{ $t('account.cancel_account_data_lost_forever') }}</p> | ||
</div> | ||
|
||
<form class="cf pa3" @submit.prevent="destroy"> | ||
<div class="flex-ns justify-between"> | ||
<div> | ||
<inertia-link :href="'/' + $page.props.auth.company.id + '/account'" class="btn dib tc w-auto-ns w-100 pv2 ph3 mb0-ns mb2"> | ||
{{ $t('app.cancel') }} | ||
</inertia-link> | ||
</div> | ||
<loading-button :classes="'btn destroy w-auto-ns w-100 pv2 ph3'" :state="loadingState" :text="$t('account.cancel_cta')" /> | ||
</div> | ||
</form> | ||
</div> | ||
</div> | ||
</div> | ||
</layout> | ||
</template> | ||
|
||
<script> | ||
import Layout from '@/Shared/Layout'; | ||
import LoadingButton from '@/Shared/LoadingButton'; | ||
import Help from '@/Shared/Help'; | ||
export default { | ||
components: { | ||
Layout, | ||
LoadingButton, | ||
Help, | ||
}, | ||
props: { | ||
notifications: { | ||
type: Array, | ||
default: null, | ||
}, | ||
}, | ||
data() { | ||
return { | ||
loadingState: '', | ||
}; | ||
}, | ||
methods: { | ||
destroy() { | ||
this.loadingState = 'loading'; | ||
axios.delete(`/${this.$page.props.auth.company.id}/account/cancel`) | ||
.then(response => { | ||
this.$inertia.visit('/home'); | ||
}) | ||
.catch(error => { | ||
this.loadingState = null; | ||
}); | ||
}, | ||
} | ||
}; | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.