restriction text implementation for the frontend

This commit is contained in:
Čarodej
2022-06-14 10:31:55 +02:00
parent ebf1b16aa5
commit aaea435eb0
7 changed files with 18 additions and 16 deletions

View File

@@ -108,7 +108,7 @@ return [
'want_to_delete_card_description' => 'We will no longer settle your payments automatically and you will have to fund your account for the next payments.',
'credit_card_deleted' => 'Your credit card was deleted.',
'billed_annually' => 'Billed Annually',
'restricted_account_warning' => 'Your functionality is restricted. Please review your billing settings.',
'restricted_account_warning' => 'Your functionality is restricted.',
'subscription_type' => 'Subscription Type',
'subscription_type_note' => 'Please do not change in production environment.',
'select_subscription_type' => 'Select your subscription type',

View File

@@ -63,7 +63,7 @@
"/chunks/settings-password.js": "/chunks/settings-password.js?id=1cf499fe8326b3c4",
"/chunks/settings-storage.js": "/chunks/settings-storage.js?id=ecfee7f7e98204f8",
"/chunks/billing.js": "/chunks/billing.js?id=f016e8454a346fc6",
"/chunks/platform.js": "/chunks/platform.js?id=0716f5215cdb26a8",
"/chunks/platform.js": "/chunks/platform.js?id=ac9e1881456b1cb8",
"/chunks/files.js": "/chunks/files.js?id=77289ebbd049d5ac",
"/chunks/recent-uploads.js": "/chunks/recent-uploads.js?id=248310cdd67d62fb",
"/chunks/my-shared-items.js": "/chunks/my-shared-items.js?id=15fba3b663103c88",

View File

@@ -1,7 +1,7 @@
<template>
<div v-if="$store.getters.isLimitedUser" class="bg-red-500 py-1 text-center">
<div v-if="$store.getters.userLimitationReason" class="bg-gradient-to-r from-red-600 to-red-500 py-2.5 px-1 text-center leading-none">
<router-link :to="{ name: 'Billing' }" class="text-xs font-bold text-white">
{{ $t('restricted_account_warning') }}
{{ $t('restricted_account_warning') + ' ' + $store.getters.userLimitationReason }}
</router-link>
</div>
</template>

View File

@@ -201,10 +201,7 @@ const mutations = {
}
const getters = {
isLimitedUser: (state) =>
state.user &&
state.user.data.relationships.failedPayments &&
state.user.data.relationships.failedPayments.data.length === 3,
userLimitationReason: (state) => state.user && state.user.data.meta.restrictions.reason,
permission: (state) => state.permission,
user: (state) => state.user,
}

View File

@@ -110,7 +110,7 @@ export default {
DragUI,
},
computed: {
...mapGetters(['isVisibleSidebar', 'isLimitedUser', 'config', 'currentFolder']),
...mapGetters(['isVisibleSidebar', 'config', 'currentFolder']),
},
data() {
return {

View File

@@ -3,6 +3,7 @@ namespace App\Users\Models;
use ByteUnits\Metric;
use Illuminate\Support\Str;
use BadMethodCallException;
use Domain\Files\Models\File;
use Domain\Folders\Models\Folder;
use Laravel\Sanctum\HasApiTokens;
@@ -196,10 +197,14 @@ class User extends Authenticatable implements MustVerifyEmail
public function __call($method, $parameters)
{
if (str_starts_with($method, 'can') || str_starts_with($method, 'get')) {
return resolve(RestrictionsManager::class)
->driver()
->$method($this, ...$parameters);
try {
if (str_starts_with($method, 'can') || str_starts_with($method, 'get')) {
return resolve(RestrictionsManager::class)
->driver()
->$method($this, ...$parameters);
}
} catch (BadMethodCallException $e) {
return parent::__call($method, $parameters);
}
return parent::__call($method, $parameters);

View File

@@ -70,13 +70,13 @@ class MeteredBillingRestrictionsEngine implements RestrictionsEngine
{
if ($this->getDunningSequenceCount($user) === 3) {
return match ($user->dunning->type) {
'limit_usage_in_new_accounts' => 'Please make your first payment.',
'usage_bigger_than_balance' => 'Please increase your account balance.',
'limit_usage_in_new_accounts' => 'Please make your first payment to cover your usage.',
'usage_bigger_than_balance' => 'Please increase your account balance higher than your monthly usage.',
};
}
if (! $this->checkFailedPayments($user)) {
return 'Please update your credit card.';
return 'Please update your credit card to pay your usage.';
}
return null;