From b6adaa576a3c93bc58fd9ff09f17f14d39442d2a Mon Sep 17 00:00:00 2001 From: ShootingStar91 Date: Fri, 30 Aug 2024 14:48:06 +0300 Subject: [PATCH] Fix time bound new mode crashing due to lack of bounds --- .../components/TimeUnit/Tabs/TimeUnitTab.tsx | 37 ++++++++++++------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/frontend/src/components/TimeUnit/Tabs/TimeUnitTab.tsx b/frontend/src/components/TimeUnit/Tabs/TimeUnitTab.tsx index dbcb8c99..5dd9436a 100644 --- a/frontend/src/components/TimeUnit/Tabs/TimeUnitTab.tsx +++ b/frontend/src/components/TimeUnit/Tabs/TimeUnitTab.tsx @@ -37,19 +37,24 @@ export const TimeUnitTab = () => { />, ], ] - const low_bound = [ - ['Id', data.low_bound.bid], - ['Name', data.low_bound.b_name], - ['Age', data.low_bound.age], - ['Comment', data.low_bound.b_comment], - ] - const up_bound = [ - ['Id', data.up_bound.bid], - ['Name', data.up_bound.b_name], - ['Age', data.up_bound.age], - ['Comment', data.up_bound.b_comment], - ] + const low_bound = mode.new + ? [] + : [ + ['Id', data.low_bound?.bid], + ['Name', data.low_bound?.b_name], + ['Age', data.low_bound?.age], + ['Comment', data.low_bound?.b_comment], + ] + + const up_bound = mode.new + ? [] + : [ + ['Id', data.up_bound?.bid], + ['Name', data.up_bound?.b_name], + ['Age', data.up_bound?.age], + ['Comment', data.up_bound?.b_comment], + ] const time_bound_edit = [ [ @@ -75,8 +80,12 @@ export const TimeUnitTab = () => { return ( <> - - + {!mode.new && ( + <> + + + + )} {!mode.read && } )