mirror of
https://github.com/UiO-Gaming/name-100-uio-gamers.git
synced 2026-11-05 13:56:53 +01:00
Only offer goals that are reachable with the current number of paying members
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
c6c22f9268
commit
7be5762297
2 files changed
+7
-6
No files matched your search
@@ -4,6 +4,8 @@ import { useLanguage } from "@/LanguageContext";
|
||||
import { translations } from "@/translations";
|
||||
import React from "react";
|
||||
|
||||
const DEFAULT_OPTIONS = [25, 50, 100];
|
||||
|
||||
interface GoalSelectorProps {
|
||||
goalAmount: number;
|
||||
setGoalAmount: (amount: number) => void;
|
||||
@@ -15,12 +17,8 @@ const GoalSelector: React.FC<GoalSelectorProps> = ({ goalAmount, setGoalAmount,
|
||||
const { language } = useLanguage();
|
||||
const t = translations[language];
|
||||
|
||||
const options = [25, 50, 100];
|
||||
if (totalMembers > 0 && !options.includes(totalMembers)) {
|
||||
// Add totalMembers to options and sort
|
||||
options.push(totalMembers);
|
||||
options.sort((a, b) => a - b);
|
||||
}
|
||||
const options =
|
||||
totalMembers > 0 ? [...DEFAULT_OPTIONS.filter((option) => option < totalMembers), totalMembers] : DEFAULT_OPTIONS;
|
||||
|
||||
return (
|
||||
<div className="flex items-center gap-2">
|
||||
|
||||
@@ -42,6 +42,9 @@ export default function HomeClient({ session }: { session: Session }) {
|
||||
if (res.ok) {
|
||||
const data = await res.json();
|
||||
setTotalMembers(data.count);
|
||||
if (data.count > 0) {
|
||||
setGoalAmount((goal) => Math.min(goal, data.count));
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Failed to fetch total members", error);
|
||||
|
||||
Reference in new issue
Block a user