refactor: add conditional value

This commit is contained in:
Mauricio Siu
2024-12-21 15:10:00 -06:00
parent a953e59327
commit b85163d935

View File

@@ -136,10 +136,12 @@ export const ManageTraefikPorts = ({ children, serverId }: Props) => {
onChange={(e) => { onChange={(e) => {
const newPorts = [...additionalPorts]; const newPorts = [...additionalPorts];
// @ts-ignore if (newPorts[index]) {
newPorts?.[index].targetPort = Number.parseInt( newPorts[index].targetPort = Number.parseInt(
e.target.value, e.target.value,
); );
}
setAdditionalPorts(newPorts); setAdditionalPorts(newPorts);
}} }}
className="w-full rounded border p-2" className="w-full rounded border p-2"
@@ -155,10 +157,11 @@ export const ManageTraefikPorts = ({ children, serverId }: Props) => {
value={port.publishedPort} value={port.publishedPort}
onChange={(e) => { onChange={(e) => {
const newPorts = [...additionalPorts]; const newPorts = [...additionalPorts];
// @ts-ignore if (newPorts[index]) {
newPorts?.[index].publishedPort = Number.parseInt( newPorts[index].publishedPort = Number.parseInt(
e.target.value, e.target.value,
); );
}
setAdditionalPorts(newPorts); setAdditionalPorts(newPorts);
}} }}
className="w-full rounded border p-2" className="w-full rounded border p-2"
@@ -172,8 +175,10 @@ export const ManageTraefikPorts = ({ children, serverId }: Props) => {
value={port.publishMode} value={port.publishMode}
onValueChange={(value: "ingress" | "host") => { onValueChange={(value: "ingress" | "host") => {
const newPorts = [...additionalPorts]; const newPorts = [...additionalPorts];
// @ts-ignore
newPorts?.[index].publishMode = value; if (newPorts[index]) {
newPorts[index].publishMode = value;
}
setAdditionalPorts(newPorts); setAdditionalPorts(newPorts);
}} }}
> >