diff --git a/app/Http/Controllers/Api/SettingsController.php b/app/Http/Controllers/Api/SettingsController.php index 090c7bac..9faa5593 100644 --- a/app/Http/Controllers/Api/SettingsController.php +++ b/app/Http/Controllers/Api/SettingsController.php @@ -17,6 +17,7 @@ public function index(Request $request): JsonResponse ->json([ 'language' => $apiKey->user->language, 'theme' => $apiKey->user->theme, + 'weekly_report' => $apiKey->user->weekly_report, ]); } @@ -25,6 +26,7 @@ public function store(Request $request): JsonResponse $request->validate([ 'language' => 'nullable|string|in:en,nl,dk,de,fr,pt,ru', 'theme' => 'nullable|string|in:light,dark', + 'weekly_report' => 'nullable|boolean', ]); /** @var ApiKey $apiKey */ @@ -38,10 +40,15 @@ public function store(Request $request): JsonResponse $apiKey->user()->update(['theme' => $request->get('theme')]); } + if ($request->has('weekly_report')) { + $apiKey->user()->update(['weekly_report' => $request->get('weekly_report')]); + } + return response() ->json([ 'language' => $apiKey->user->language, 'theme' => $apiKey->user->theme, + 'weekly_report' => $apiKey->user->weekly_report, ]); } } diff --git a/resources/assets/js/prototype/screens/Settings/Preferences.vue b/resources/assets/js/prototype/screens/Settings/Preferences.vue index 3447b122..386ae36b 100644 --- a/resources/assets/js/prototype/screens/Settings/Preferences.vue +++ b/resources/assets/js/prototype/screens/Settings/Preferences.vue @@ -6,6 +6,7 @@ import Navigation from '../../components/Navigation.vue'; const language = ref('en'); const theme = ref('light'); +const weeklyReport = ref(false); const retrieve = () => { axios @@ -13,12 +14,19 @@ const retrieve = () => { .then(response => { language.value = response.data.language; theme.value = response.data.theme; + weeklyReport.value = response.data.weekly_report; }); }; +const toggleWeeklyReport = () => { + weeklyReport.value = !weeklyReport.value; + + update(); +}; + const update = () => { axios - .post('/api/settings', { language: language.value, theme: theme.value }, { headers: { 'api-key': localStorage.getItem('api_key') } }) + .post('/api/settings', { language: language.value, theme: theme.value, weekly_report: weeklyReport.value }, { headers: { 'api-key': localStorage.getItem('api_key') } }) .then(response => { // Done @@ -60,6 +68,12 @@ onMounted(() => retrieve()); +
+
Weekly report
+ +