bugfixing

This commit is contained in:
MuslemRahimi 2025-04-16 09:38:24 +02:00
parent f9dfb8321a
commit 3ae53d4fd7
3 changed files with 25 additions and 10 deletions

View File

@ -6,7 +6,7 @@ export const POST: RequestHandler = async ({ request, locals }) => {
let output;
// For non-Pro users, ensure they can only have 1 watchlist.
if (user?.tier !== 'Pro') {
if (!['Pro','Plus']?.includes(user?.tier)) {
// Get the current watchlists for the user.
const existingWatchlists = await pb.collection("watchlist").getFullList({
filter: `user="${user.id}"`
@ -15,7 +15,7 @@ export const POST: RequestHandler = async ({ request, locals }) => {
// If the user already has a watchlist, return an error response.
if (existingWatchlists.length >= 1) {
return new Response(
JSON.stringify({ error: "Non-Pro users can only have 1 watchlist" }),
JSON.stringify({ error: "Upgrade your account to unlock unlimited watchlists." }),
{ status: 403 }
);
}

View File

@ -11,9 +11,8 @@ export const POST = (async ({ request, locals }) => {
let output;
// Determine the ticker limit: 50 for Pro users, 5 for non-Pro users.
const isProUser = user?.tier === "Pro" || user?.tier === "Plus";
const tickerLimit = isProUser ? 100 : 5;
const isSubscribed = user?.tier === "Pro" || user?.tier === "Plus";
const tickerLimit = user?.tier === "Pro" ? 300 : user?.tier === 'Plus' ? 100 : 5;
try {
const watchList = await pb.collection("watchlist").getOne(watchListId);
@ -40,7 +39,7 @@ export const POST = (async ({ request, locals }) => {
if (tickerInput.length > tickerLimit) {
return new Response(
JSON.stringify({
error: isProUser
error: isSubscribed
? `You can only have up to ${tickerLimit} stocks in your watchlist.`
: `Upgrade to Pro to add unlimited stocks!`,
}),
@ -67,7 +66,7 @@ export const POST = (async ({ request, locals }) => {
if (newTickerList.length > tickerLimit) {
return new Response(
JSON.stringify({
error: isProUser
error: isSubscribed
? `You can only have up to ${tickerLimit} stocks in your watchlist.`
: `Upgrade to Pro to add unlimited stocks`,
}),
@ -83,7 +82,7 @@ export const POST = (async ({ request, locals }) => {
if (tickersArray.length > tickerLimit) {
return new Response(
JSON.stringify({
error: isProUser
error: isSubscribed
? `You can only have up to ${tickerLimit} stocks in your watchlist.`
: `Upgrade to Pro to add unlimited stocks!`,
}),

View File

@ -203,7 +203,7 @@
stroke-width="2"
d="M5 13l4 4L19 7"
></path></svg
><span class="">1 Watchlist</span>
><span class="">1 Watchlist (up to 5 stocks)</span>
</li>
<li class="flex items-start">
<svg
@ -760,7 +760,7 @@
stroke-width="2"
d="M5 13l4 4L19 7"
></path></svg
><span class="">Unlimited Watchlist</span>
><span class="">Unlimited Watchlist (up to 100 stocks)</span>
</li>
<li class="flex items-start">
<svg
@ -1080,6 +1080,22 @@
><span class="">Everything in Plus and ...</span>
</li>
<li class="flex items-start">
<svg
class="w-5 h-5 mr-2 flex-shrink-0 mt-0.5"
fill="none"
stroke="currentColor"
viewBox="0 0 24 24"
xmlns="http://www.w3.org/2000/svg"
><path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M5 13l4 4L19 7"
></path></svg
><span class="">Watchlist with up to 300 stocks</span>
</li>
<li class="flex items-start">
<svg
class="w-5 h-5 mr-2 flex-shrink-0 mt-0.5"