Skip to content

Commit 1ea66a1

Browse files
Create DeleteUserButton component and show it in settings
1 parent d174593 commit 1ea66a1

File tree

6 files changed

+87
-0
lines changed

6 files changed

+87
-0
lines changed

app/Http/Controllers/SettingsController.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,13 @@ public function getAccount()
9494
return view('settings.account');
9595
}
9696

97+
public function postAccountDelete()
98+
{
99+
// TODO DELETE
100+
101+
return redirect()->route('login');
102+
}
103+
97104
public function getSpaces()
98105
{
99106
return view('settings.spaces.index', [

resources/assets/js/app.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { Chrome } from 'vue-color';
66
import ButtonDropdown from './components/ButtonDropdown.vue';
77
import DatePicker from './components/DatePicker.vue';
88
import BarChart from './components/BarChart.vue';
9+
import DeleteUserButton from './components/DeleteUserButton.vue';
910
import Dropdown from './components/Dropdown.vue';
1011
import TransactionWizard from './components/TransactionWizard.vue';
1112
import ValidationError from './components/ValidationError.vue';
@@ -21,6 +22,7 @@ Vue.component('button-dropdown', ButtonDropdown);
2122
Vue.component('datepicker', DatePicker); // TODO DEPRECATE
2223
Vue.component('date-picker', DatePicker);
2324
Vue.component('barchart', BarChart);
25+
Vue.component('delete-user-button', DeleteUserButton);
2426
Vue.component('dropdown', Dropdown);
2527
Vue.component('transaction-wizard', TransactionWizard);
2628
Vue.component('validation-error', ValidationError);
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<template>
2+
<div>
3+
<button
4+
class="button link button--link-danger"
5+
@click.prevent="showWarning">Delete</button>
6+
<div
7+
v-if="warningShown"
8+
style="position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0, 0, 0, 0.50); box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);"
9+
@click.self="hideWarning">
10+
<div style="margin: 50px auto; max-width: 500px; padding: 20px; background: #FFF; border-radius: 5px;">
11+
<div>Are you sure you want to delete your user? This is irreversible.</div>
12+
<div class="row mt-2">
13+
<form method="POST" action="/settings/account/delete">
14+
<input
15+
type="hidden"
16+
name="_token"
17+
:value="csrfToken" />
18+
<button class="button button--danger mr-2">Yes, I am sure</button>
19+
</form>
20+
<button
21+
class="button button--light"
22+
@click="hideWarning">No</button>
23+
</div>
24+
</div>
25+
</div>
26+
</div>
27+
</template>
28+
29+
<script>
30+
export default {
31+
props: [
32+
'csrfToken'
33+
],
34+
35+
data() {
36+
return {
37+
warningShown: false
38+
};
39+
},
40+
41+
methods: {
42+
showWarning() {
43+
this.warningShown = true;
44+
},
45+
46+
hideWarning() {
47+
this.warningShown = false;
48+
},
49+
50+
doIt() {
51+
// axios.
52+
}
53+
}
54+
};
55+
</script>

resources/assets/sass/components/input.scss

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,26 @@ button.button {
140140
background: none;
141141
}
142142

143+
&.button--link-danger {
144+
padding: 0;
145+
font-size: 16px;
146+
color: $colors-red;
147+
background: none;
148+
}
149+
143150
&.button--wide {
144151
padding: 12.5px 20px;
145152
width: 100%;
146153
}
154+
155+
&.button--light {
156+
background: #EEE;
157+
color: #000;
158+
}
159+
160+
&.button--danger {
161+
background: $colors-red;
162+
}
147163
}
148164

149165
.button, .button-dropdown {

resources/views/settings/account.blade.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,9 @@
2727
</div>
2828
</div>
2929
@endsection
30+
31+
@section('settings_body_formless')
32+
<delete-user-button
33+
class="mt-2"
34+
csrf-token="{{ csrf_token() }}"></delete-user-button>
35+
@endsection

routes/web.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@
120120
Route::post('/settings', [SettingsController::class, 'postIndex']);
121121
Route::get('/settings/profile', [SettingsController::class, 'getProfile'])->name('profile');
122122
Route::get('/settings/account', [SettingsController::class, 'getAccount'])->name('account');
123+
Route::post('/settings/account/delete', [SettingsController::class, 'postAccountDelete'])->name('account.delete');
123124
Route::get('/settings/preferences', [SettingsController::class, 'getPreferences'])->name('preferences');
124125
Route::get('/settings/billing', [SettingsController::class, 'getBilling'])->name('billing')->middleware('stripe');
125126
Route::post('/settings/billing/upgrade', [SettingsController::class, 'postUpgrade'])->name('billing.upgrade')->middleware('stripe');

0 commit comments

Comments
 (0)