diff --git a/src/lib/helpers/sizeConvertion.ts b/src/lib/helpers/sizeConvertion.ts
index 00709e4de8..5d1f7c73bc 100644
--- a/src/lib/helpers/sizeConvertion.ts
+++ b/src/lib/helpers/sizeConvertion.ts
@@ -14,6 +14,7 @@ export function calculateSize(bytes: number, decimals = 1, base: 1000 | 1024 = 1
}
export function sizeToBytes(value: number, unit: Size, base = 1000) {
+ if (typeof value !== 'number') return 0;
const index = sizes.indexOf(unit);
return value * Math.pow(base, index);
}
diff --git a/src/lib/helpers/unit.ts b/src/lib/helpers/unit.ts
index 9d14b32df8..bc24429bdf 100644
--- a/src/lib/helpers/unit.ts
+++ b/src/lib/helpers/unit.ts
@@ -70,7 +70,7 @@ export function createTimeUnitPair(initialValue = 0) {
{ name: 'Minutes', value: 60 },
{ name: 'Seconds', value: 1 }
];
- return { ...createValueUnitPair(initialValue, units), units };
+ return { ...createValueUnitPair(initialValue || 0, units), units };
}
export function createByteUnitPair(initialValue = 0, base: 1000 | 1024 = 1000) {
diff --git a/src/routes/(console)/project-[project]/auth/security/updateMockNumbers.svelte b/src/routes/(console)/project-[project]/auth/security/updateMockNumbers.svelte
index f73df991f0..9db581f0b3 100644
--- a/src/routes/(console)/project-[project]/auth/security/updateMockNumbers.svelte
+++ b/src/routes/(console)/project-[project]/auth/security/updateMockNumbers.svelte
@@ -22,7 +22,6 @@
let numbers: Models.MockNumber[] = $project?.authMockNumbers ?? [];
let initialNumbers = [];
- let projectId: string = $project.$id;
$: initialNumbers = $project?.authMockNumbers?.map((num) => ({ ...num })) ?? [];
$: isSubmitDisabled = JSON.stringify(numbers) === JSON.stringify(initialNumbers);
@@ -39,7 +38,7 @@
async function updateMockNumbers() {
try {
- await sdk.forConsole.projects.updateMockNumbers(projectId, numbers);
+ await sdk.forConsole.projects.updateMockNumbers($project.$id, numbers);
await invalidate(Dependencies.PROJECT);
addNotification({
type: 'success',
diff --git a/src/routes/(console)/project-[project]/auth/security/updatePasswordDictionary.svelte b/src/routes/(console)/project-[project]/auth/security/updatePasswordDictionary.svelte
index 2cc776a020..67b9ad5a69 100644
--- a/src/routes/(console)/project-[project]/auth/security/updatePasswordDictionary.svelte
+++ b/src/routes/(console)/project-[project]/auth/security/updatePasswordDictionary.svelte
@@ -8,13 +8,12 @@
import { sdk } from '$lib/stores/sdk';
import { project } from '../../store';
- const projectId = $project.$id;
- let passwordDictionary = $project.authPasswordDictionary ?? false;
+ let passwordDictionary = $project?.authPasswordDictionary ?? false;
async function updatePasswordDictionary() {
try {
await sdk.forConsole.projects.updateAuthPasswordDictionary(
- projectId,
+ $project.$id,
passwordDictionary
);
await invalidate(Dependencies.PROJECT);
@@ -56,7 +55,7 @@
-
diff --git a/src/routes/(console)/project-[project]/auth/security/updatePasswordHistory.svelte b/src/routes/(console)/project-[project]/auth/security/updatePasswordHistory.svelte
index 40bfec487b..a308e99624 100644
--- a/src/routes/(console)/project-[project]/auth/security/updatePasswordHistory.svelte
+++ b/src/routes/(console)/project-[project]/auth/security/updatePasswordHistory.svelte
@@ -9,15 +9,14 @@
import { sdk } from '$lib/stores/sdk';
import { project } from '../../store';
- const projectId = $project.$id;
- let passwordHistory = $project.authPasswordHistory < 1 ? 5 : $project.authPasswordHistory;
- let passwordHistoryEnabled = ($project.authPasswordHistory ?? 0) != 0;
+ let passwordHistory = $project?.authPasswordHistory < 1 ? 5 : $project?.authPasswordHistory;
+ let passwordHistoryEnabled = ($project?.authPasswordHistory ?? 0) !== 0;
let initialPasswordHistoryEnabled = passwordHistoryEnabled;
async function updatePasswordHistoryLimit() {
try {
await sdk.forConsole.projects.updateAuthPasswordHistory(
- projectId,
+ $project.$id,
passwordHistoryEnabled ? passwordHistory : 0
);
await invalidate(Dependencies.PROJECT);
@@ -67,8 +66,8 @@
diff --git a/src/routes/(console)/project-[project]/auth/security/updatePersonalDataCheck.svelte b/src/routes/(console)/project-[project]/auth/security/updatePersonalDataCheck.svelte
index 2a758875fe..2bee05aed8 100644
--- a/src/routes/(console)/project-[project]/auth/security/updatePersonalDataCheck.svelte
+++ b/src/routes/(console)/project-[project]/auth/security/updatePersonalDataCheck.svelte
@@ -9,7 +9,7 @@
import { sdk } from '$lib/stores/sdk';
import { project } from '../../store';
- let authPersonalDataCheck = $project.authPersonalDataCheck ?? false;
+ let authPersonalDataCheck = $project?.authPersonalDataCheck ?? false;
async function updatePersonalDataCheck() {
try {
@@ -50,7 +50,7 @@
-
diff --git a/src/routes/(console)/project-[project]/auth/security/updateSessionAlerts.svelte b/src/routes/(console)/project-[project]/auth/security/updateSessionAlerts.svelte
index 7ad63290c4..c6f176ffa7 100644
--- a/src/routes/(console)/project-[project]/auth/security/updateSessionAlerts.svelte
+++ b/src/routes/(console)/project-[project]/auth/security/updateSessionAlerts.svelte
@@ -9,7 +9,7 @@
import { sdk } from '$lib/stores/sdk';
import { project } from '../../store';
- let authSessionAlerts = $project.authSessionAlerts ?? false;
+ let authSessionAlerts = $project?.authSessionAlerts ?? false;
async function updateSessionAlerts() {
try {
@@ -46,7 +46,7 @@
-
diff --git a/src/routes/(console)/project-[project]/auth/security/updateSessionLength.svelte b/src/routes/(console)/project-[project]/auth/security/updateSessionLength.svelte
index 848f2bbf83..cbac619cbd 100644
--- a/src/routes/(console)/project-[project]/auth/security/updateSessionLength.svelte
+++ b/src/routes/(console)/project-[project]/auth/security/updateSessionLength.svelte
@@ -9,13 +9,12 @@
import { sdk } from '$lib/stores/sdk';
import { project } from '../../store';
- const projectId = $project.$id;
- const { value, unit, baseValue, units } = createTimeUnitPair($project.authDuration);
+ const { value, unit, baseValue, units } = createTimeUnitPair($project?.authDuration);
const options = units.map((v) => ({ label: v.name, value: v.name }));
async function updateSessionLength() {
try {
- await sdk.forConsole.projects.updateAuthDuration(projectId, $baseValue);
+ await sdk.forConsole.projects.updateAuthDuration($project.$id, $baseValue);
await invalidate(Dependencies.PROJECT);
addNotification({
diff --git a/src/routes/(console)/project-[project]/auth/security/updateSessionsLimit.svelte b/src/routes/(console)/project-[project]/auth/security/updateSessionsLimit.svelte
index 5fe3d16f90..2172756bac 100644
--- a/src/routes/(console)/project-[project]/auth/security/updateSessionsLimit.svelte
+++ b/src/routes/(console)/project-[project]/auth/security/updateSessionsLimit.svelte
@@ -8,13 +8,11 @@
import { sdk } from '$lib/stores/sdk';
import { project } from '../../store';
- const projectId = $project.$id;
-
- let maxSessions = $project.authSessionsLimit;
+ let maxSessions = $project?.authSessionsLimit;
async function updateSessionsLimit() {
try {
- await sdk.forConsole.projects.updateAuthSessionsLimit(projectId, maxSessions);
+ await sdk.forConsole.projects.updateAuthSessionsLimit($project.$id, maxSessions);
await invalidate(Dependencies.PROJECT);
addNotification({
@@ -43,7 +41,7 @@
- Update
+ Update
diff --git a/src/routes/(console)/project-[project]/auth/security/updateUsersLimit.svelte b/src/routes/(console)/project-[project]/auth/security/updateUsersLimit.svelte
index e2ec755499..6f67ceae0d 100644
--- a/src/routes/(console)/project-[project]/auth/security/updateUsersLimit.svelte
+++ b/src/routes/(console)/project-[project]/auth/security/updateUsersLimit.svelte
@@ -10,15 +10,13 @@
import { sdk } from '$lib/stores/sdk';
import { project } from '../../store';
- const projectId = $project.$id;
-
- let isLimited = $project.authLimit !== 0;
- let newLimit = isLimited ? $project.authLimit : 100;
+ let isLimited = $project?.authLimit !== 0;
+ let newLimit = isLimited ? $project?.authLimit : 100;
$: btnDisabled = (function isBtnDisabled() {
if (
- (!isLimited && $project.authLimit === 0) ||
- (isLimited && $project.authLimit === newLimit)
+ (!isLimited && $project?.authLimit === 0) ||
+ (isLimited && $project?.authLimit === newLimit)
) {
return true;
}
@@ -28,7 +26,7 @@
async function updateLimit() {
try {
- await sdk.forConsole.projects.updateAuthLimit(projectId, isLimited ? newLimit : 0);
+ await sdk.forConsole.projects.updateAuthLimit($project?.$id, isLimited ? newLimit : 0);
await invalidate(Dependencies.PROJECT);
addNotification({
type: 'success',
diff --git a/src/routes/(console)/project-[project]/auth/templates/+page.svelte b/src/routes/(console)/project-[project]/auth/templates/+page.svelte
index 59ccc5fa70..369080543f 100644
--- a/src/routes/(console)/project-[project]/auth/templates/+page.svelte
+++ b/src/routes/(console)/project-[project]/auth/templates/+page.svelte
@@ -33,11 +33,9 @@
diff --git a/src/routes/(console)/project-[project]/functions/function-[function]/+page.svelte b/src/routes/(console)/project-[project]/functions/function-[function]/+page.svelte
index fb6103a3ca..fbd5bca71c 100644
--- a/src/routes/(console)/project-[project]/functions/function-[function]/+page.svelte
+++ b/src/routes/(console)/project-[project]/functions/function-[function]/+page.svelte
@@ -16,7 +16,6 @@
import Create from './create.svelte';
import { GRACE_PERIOD_OVERRIDE, isCloud } from '$lib/system';
import { readOnly } from '$lib/stores/billing';
- import { project } from '../../store';
import { writable } from 'svelte/store';
import type { Column } from '$lib/helpers/types';
import Table from './table.svelte';
@@ -199,7 +198,7 @@
{/if}
Execute
diff --git a/src/routes/(console)/project-[project]/messaging/topics/table.svelte b/src/routes/(console)/project-[project]/messaging/topics/table.svelte
index 120df58495..971430a887 100644
--- a/src/routes/(console)/project-[project]/messaging/topics/table.svelte
+++ b/src/routes/(console)/project-[project]/messaging/topics/table.svelte
@@ -16,12 +16,12 @@
} from '$lib/elements/table';
import { addNotification } from '$lib/stores/notifications';
import type { PageData } from './$types';
- import { project } from '$routes/(console)/project-[project]/store';
import { invalidate } from '$app/navigation';
import { Dependencies } from '$lib/constants';
import { sdk } from '$lib/stores/sdk';
import { toLocaleDateTime } from '$lib/helpers/date';
import type { Column } from '$lib/helpers/types';
+ import { page } from '$app/stores';
import { canWriteTopics } from '$lib/stores/roles';
export let columns: Column[];
@@ -75,7 +75,7 @@
{#each data.topics.topics as topic (topic.$id)}
+ href={`${base}/project-${$page.params.project}/messaging/topics/topic-${topic.$id}`}>
{#if $canWriteTopics}
{/if}