bugfixing
This commit is contained in:
parent
f9dfb8321a
commit
3ae53d4fd7
@ -6,7 +6,7 @@ export const POST: RequestHandler = async ({ request, locals }) => {
|
|||||||
let output;
|
let output;
|
||||||
|
|
||||||
// For non-Pro users, ensure they can only have 1 watchlist.
|
// 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.
|
// Get the current watchlists for the user.
|
||||||
const existingWatchlists = await pb.collection("watchlist").getFullList({
|
const existingWatchlists = await pb.collection("watchlist").getFullList({
|
||||||
filter: `user="${user.id}"`
|
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 the user already has a watchlist, return an error response.
|
||||||
if (existingWatchlists.length >= 1) {
|
if (existingWatchlists.length >= 1) {
|
||||||
return new Response(
|
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 }
|
{ status: 403 }
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -11,9 +11,8 @@ export const POST = (async ({ request, locals }) => {
|
|||||||
let output;
|
let output;
|
||||||
|
|
||||||
|
|
||||||
// Determine the ticker limit: 50 for Pro users, 5 for non-Pro users.
|
const isSubscribed = user?.tier === "Pro" || user?.tier === "Plus";
|
||||||
const isProUser = user?.tier === "Pro" || user?.tier === "Plus";
|
const tickerLimit = user?.tier === "Pro" ? 300 : user?.tier === 'Plus' ? 100 : 5;
|
||||||
const tickerLimit = isProUser ? 100 : 5;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const watchList = await pb.collection("watchlist").getOne(watchListId);
|
const watchList = await pb.collection("watchlist").getOne(watchListId);
|
||||||
@ -40,7 +39,7 @@ export const POST = (async ({ request, locals }) => {
|
|||||||
if (tickerInput.length > tickerLimit) {
|
if (tickerInput.length > tickerLimit) {
|
||||||
return new Response(
|
return new Response(
|
||||||
JSON.stringify({
|
JSON.stringify({
|
||||||
error: isProUser
|
error: isSubscribed
|
||||||
? `You can only have up to ${tickerLimit} stocks in your watchlist.`
|
? `You can only have up to ${tickerLimit} stocks in your watchlist.`
|
||||||
: `Upgrade to Pro to add unlimited stocks!`,
|
: `Upgrade to Pro to add unlimited stocks!`,
|
||||||
}),
|
}),
|
||||||
@ -67,7 +66,7 @@ export const POST = (async ({ request, locals }) => {
|
|||||||
if (newTickerList.length > tickerLimit) {
|
if (newTickerList.length > tickerLimit) {
|
||||||
return new Response(
|
return new Response(
|
||||||
JSON.stringify({
|
JSON.stringify({
|
||||||
error: isProUser
|
error: isSubscribed
|
||||||
? `You can only have up to ${tickerLimit} stocks in your watchlist.`
|
? `You can only have up to ${tickerLimit} stocks in your watchlist.`
|
||||||
: `Upgrade to Pro to add unlimited stocks`,
|
: `Upgrade to Pro to add unlimited stocks`,
|
||||||
}),
|
}),
|
||||||
@ -83,7 +82,7 @@ export const POST = (async ({ request, locals }) => {
|
|||||||
if (tickersArray.length > tickerLimit) {
|
if (tickersArray.length > tickerLimit) {
|
||||||
return new Response(
|
return new Response(
|
||||||
JSON.stringify({
|
JSON.stringify({
|
||||||
error: isProUser
|
error: isSubscribed
|
||||||
? `You can only have up to ${tickerLimit} stocks in your watchlist.`
|
? `You can only have up to ${tickerLimit} stocks in your watchlist.`
|
||||||
: `Upgrade to Pro to add unlimited stocks!`,
|
: `Upgrade to Pro to add unlimited stocks!`,
|
||||||
}),
|
}),
|
||||||
|
|||||||
@ -203,7 +203,7 @@
|
|||||||
stroke-width="2"
|
stroke-width="2"
|
||||||
d="M5 13l4 4L19 7"
|
d="M5 13l4 4L19 7"
|
||||||
></path></svg
|
></path></svg
|
||||||
><span class="">1 Watchlist</span>
|
><span class="">1 Watchlist (up to 5 stocks)</span>
|
||||||
</li>
|
</li>
|
||||||
<li class="flex items-start">
|
<li class="flex items-start">
|
||||||
<svg
|
<svg
|
||||||
@ -760,7 +760,7 @@
|
|||||||
stroke-width="2"
|
stroke-width="2"
|
||||||
d="M5 13l4 4L19 7"
|
d="M5 13l4 4L19 7"
|
||||||
></path></svg
|
></path></svg
|
||||||
><span class="">Unlimited Watchlist</span>
|
><span class="">Unlimited Watchlist (up to 100 stocks)</span>
|
||||||
</li>
|
</li>
|
||||||
<li class="flex items-start">
|
<li class="flex items-start">
|
||||||
<svg
|
<svg
|
||||||
@ -1080,6 +1080,22 @@
|
|||||||
><span class="">Everything in Plus and ...</span>
|
><span class="">Everything in Plus and ...</span>
|
||||||
</li>
|
</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">
|
<li class="flex items-start">
|
||||||
<svg
|
<svg
|
||||||
class="w-5 h-5 mr-2 flex-shrink-0 mt-0.5"
|
class="w-5 h-5 mr-2 flex-shrink-0 mt-0.5"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user