diff --git a/frontend/src/components/configCommon.tsx b/frontend/src/components/configCommon.tsx
index 7b96f84..ac8498f 100644
--- a/frontend/src/components/configCommon.tsx
+++ b/frontend/src/components/configCommon.tsx
@@ -3,21 +3,24 @@ import { Regions } from "./configRegions";
import type { CommonConfig } from "@/types/config";
interface CommonFieldsProps {
- commonConfig: CommonConfig;
- globalCommonConfig?: CommonConfig; // Unset if common config IS global config
- updateCommonConfig: (config: CommonConfig) => void;
+ config: CommonConfig;
+ globalConfig?: CommonConfig; // Unset if common config IS global config
+ updateConfig: (config: CommonConfig) => void;
}
export function CommonFields({
- commonConfig: config,
- globalCommonConfig: globalConfig,
- updateCommonConfig: updateConfig,
+ config,
+ globalConfig,
+ updateConfig,
}: CommonFieldsProps) {
+ // If fields are for global config, globalConfig will not be set
+ const isGlobal = !globalConfig;
+
return (
{
updateConfig({ ...config, regions: value });
@@ -31,9 +34,9 @@ export function CommonFields({
type="fraction"
value={config.eventSimilarity}
showReset={true}
- resetValue={-1}
+ resetValue={!isGlobal ? -1 : undefined} // Reset value for global is undefined
defaultValuePlaceholder="0.9"
- showGlobalReset={!!globalConfig}
+ showGlobalReset={!isGlobal}
globalValuePlaceholder={
globalConfig?.eventSimilarity?.toString() || "0.9"
}
@@ -48,9 +51,9 @@ export function CommonFields({
type="integer"
value={config.numTickets}
showReset={true}
- resetValue={-1}
+ resetValue={!isGlobal ? -1 : undefined} // Reset value for global is undefined
defaultValuePlaceholder="Any"
- showGlobalReset={!!globalConfig}
+ showGlobalReset={!isGlobal}
globalValuePlaceholder={globalConfig?.numTickets?.toString() || "Any"}
updateValue={(value) => {
updateConfig({ ...config, numTickets: value });
@@ -63,9 +66,9 @@ export function CommonFields({
type="price"
value={config.maxTicketPrice}
showReset={true}
- resetValue={-1}
+ resetValue={!isGlobal ? -1 : undefined} // Reset value for global is undefined
defaultValuePlaceholder="No Max"
- showGlobalReset={!!globalConfig}
+ showGlobalReset={!isGlobal}
globalValuePlaceholder={
globalConfig?.maxTicketPrice?.toString() || "No Max"
}
@@ -80,9 +83,9 @@ export function CommonFields({
type="percentage"
value={config.discount}
showReset={true}
- resetValue={-1}
+ resetValue={!isGlobal ? -1 : undefined} // Reset value for global is undefined
defaultValuePlaceholder="No Min"
- showGlobalReset={!!globalConfig}
+ showGlobalReset={!isGlobal}
globalValuePlaceholder={
globalConfig?.discount?.toString() || "No Min"
}
diff --git a/frontend/src/components/configGlobal.tsx b/frontend/src/components/configGlobal.tsx
index b7d1f72..878dbad 100644
--- a/frontend/src/components/configGlobal.tsx
+++ b/frontend/src/components/configGlobal.tsx
@@ -36,8 +36,8 @@ export function GlobalSettings() {
}
>
{
+ config={draft}
+ updateConfig={(commonConfig) => {
setDraft(commonConfig);
}}
/>
diff --git a/frontend/src/components/configTicket.tsx b/frontend/src/components/configTicket.tsx
index 2c3dd7c..d0c43a8 100644
--- a/frontend/src/components/configTicket.tsx
+++ b/frontend/src/components/configTicket.tsx
@@ -18,7 +18,7 @@ import {
import { Button } from "@/components/ui/button";
import type { CommonConfig, TicketConfig } from "@/types/config";
import { isEqual } from "lodash";
-import { Trash, } from "lucide-react";
+import { Trash } from "lucide-react";
import { useEffect, useState } from "react";
interface TicketProps {
@@ -95,7 +95,6 @@ export function Ticket({
{
+ config={draft}
+ globalConfig={globalConfig}
+ updateConfig={(commonConfig) => {
setDraft((prev) => ({ ...prev, ...commonConfig }));
}}
/>