Skip to content

Commit 329bb0b

Browse files
authored
Merge pull request #4 from steelhawks/dev
Redo Form // Fix Min/Max Check for Counter
2 parents 77d9a09 + 81bc08d commit 329bb0b

File tree

6 files changed

+43
-41
lines changed

6 files changed

+43
-41
lines changed

components/inputs/CounterBox.jsx

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,18 +54,20 @@ const CounterBox = props => {
5454
return;
5555

5656
const newValue = parseInt(inputValue);
57-
if (!isNaN(newValue)) {
58-
if (newValue > (props.min || MIN_LOCAL) && newValue < (props.max || MAX_LOCAL)) {
59-
setValue(newValue);
57+
58+
if (isNaN(newValue)) {
59+
Alert.alert('Please enter a number');
60+
return;
61+
}
62+
63+
if (newValue >= (props.min || MIN_LOCAL) && newValue <= (props.max || MAX_LOCAL)) {
64+
setValue(newValue);
65+
} else {
66+
if (newValue <= (props.min || MIN_LOCAL)) {
67+
Alert.alert('Value cannot be below the minimum');
6068
} else {
61-
if (newValue < (props.min || MIN_LOCAL)) {
62-
Alert.alert('Value cannot be below the minimum');
63-
} else {
64-
Alert.alert('Value cannot exceed the maximum');
65-
}
69+
Alert.alert('Value cannot exceed the maximum');
6670
}
67-
} else {
68-
Alert.alert('Please enter a number');
6971
}
7072
};
7173

contexts/dict.jsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ export const useDictStore = create(set => ({
99
matchType: '', // qualification, practice, or elimination
1010
driveStation: null,
1111
alliance: '', // red or blue
12-
// preloaded: null, // true or false
13-
// robotLeft: null, // true or false
12+
preloaded: null, // true or false
13+
robotLeft: null, // true or false
1414
// autonSpeakerNotesScored: 0,
1515
// autonAmpNotesScored: 0,
1616
// autonMissed: 0,
@@ -24,14 +24,14 @@ export const useDictStore = create(set => ({
2424
// telopNotesReceivedFromHumanPlayer: 0,
2525
// telopNotesReceivedFromGround: 0,
2626
// ferryNotes: 0,
27-
// endGame: null, // PARKED, ONSTAGE, SPOTLIGHT, Default: EMPTY
2827
// trap: 0,
2928
// fouls: 0,
3029
// techFouls: 0,
3130
// yellowCards: 0,
3231
// redCards: 0,
3332
// telopIssues: [], // NOT_MOVING, LOST_CONNECTION, FMS_ISSUES, DISABLED, Default: EMPTY
34-
// didTeamPlayDefense: null, // YES, NO, Default: null
33+
didTeamPlayDefense: null, // YES, NO,
34+
endGame: null, // SHALLOW, DEEP, PARK, NONE
3535
timeOfCreation: '',
3636
},
3737
setDict: (key, value) =>

screens/Scouting/Auton2.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,11 @@ const Auton2 = ({backConfirm}) => {
6565
}
6666
/>,
6767
<Query
68-
title="Algae Shot"
68+
title="Net Algae Scored"
6969
item={
7070
<CounterBox
7171
onChange={value =>
72-
setDict('autonAlgaeShot', value)
72+
setDict('autonNetAlgaeScored', value)
7373
}
7474
/>
7575
}

screens/Scouting/Teleop.jsx

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,51 +11,41 @@ const Teleop = () => {
1111

1212
const reef_scoring_queries = [
1313
<Query
14-
title="L4 Reef Scored"
14+
title="Coral Scored L4"
1515
item={
1616
<CounterBox
1717
onChange={value =>
18-
setDict('teleopL4ReefScored', value)
18+
setDict('teleopCoralL4', value)
1919
}
2020
/>
2121
}
2222
/>,
2323
<Query
24-
title="L3 Reef Scored"
24+
title="Coral Scored L3"
2525
item={
2626
<CounterBox
2727
onChange={value =>
28-
setDict('teleopL3ReefScored', value)
28+
setDict('teleopCoralL3', value)
2929
}
3030
/>
3131
}
3232
/>,
3333
<Query
34-
title="L3 Reef Scored"
34+
title="Coral Scored L2"
3535
item={
3636
<CounterBox
3737
onChange={value =>
38-
setDict('teleopL3ReefScored', value)
38+
setDict('teleopCoralL2', value)
3939
}
4040
/>
4141
}
4242
/>,
4343
<Query
44-
title="L2 Reef Scored"
44+
title="Coral Scored L1"
4545
item={
4646
<CounterBox
4747
onChange={value =>
48-
setDict('teleopL2ReefScored', value)
49-
}
50-
/>
51-
}
52-
/>,
53-
<Query
54-
title="L1 Reef Scored"
55-
item={
56-
<CounterBox
57-
onChange={value =>
58-
setDict('teleopL1ReefScored', value)
48+
setDict('teleopCoralL1', value)
5949
}
6050
/>
6151
}
@@ -68,16 +58,16 @@ const Teleop = () => {
6858
item={
6959
<CounterBox
7060
onChange={value =>
71-
setDict('teleopNetShotsScored', value)
61+
setDict('teleopNetAlgaeScored', value)
7262
}
7363
/>
7464
}
7565
/>,
7666
<Query
77-
title="Processor Algae Scored"
67+
title="Algae Processed"
7868
item={
7969
<CounterBox
80-
onChange={value => setDict('teleopProcessorAlgaeScored', value)}
70+
onChange={value => setDict('teleopAlgaeProcessed', value)}
8171
/>
8272
}
8373
/>,

screens/Scouting/TeleopReceived.jsx

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ const TeleopReceived = () => {
2727
/>
2828
}
2929
/>,
30-
<Query
31-
title="Algae from Reef"
30+
<Query
31+
title="Coral from Ground"
3232
item={
3333
<CounterBox
3434
onChange={value =>
35-
setDict('teleopAlgaeFromReef', value)
35+
setDict('teleopCoralFromGround', value)
3636
}
3737
/>
3838
}
@@ -41,6 +41,16 @@ const TeleopReceived = () => {
4141
title="Algae from Ground"
4242
item={<CounterBox onChange={value => setDict('teleopAlgaeFromGround', value)} />}
4343
/>,
44+
<Query
45+
title="Algae from Reef"
46+
item={
47+
<CounterBox
48+
onChange={value =>
49+
setDict('teleopAlgaeFromReef', value)
50+
}
51+
/>
52+
}
53+
/>,
4454
];
4555

4656
const tele_missed_queries = [

screens/ScoutingPage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ const ScoutingPage: React.FC<ScoutingPageProps> = ({
5959
// define the required fields here
6060
// MAKE SURE THAT THEY ARE NULL IN THE DICT AS IT ONLY CHECKS
6161
// IF THE VALUE IS NULL!!!!!
62-
const requiredQueries = ['preloaded', 'robotLeft', 'didTeamPlayDefense'];
62+
const requiredQueries = ['preloaded', 'robotLeft', 'didTeamPlayDefense', 'endGame'];
6363

6464
// validation function to check if all required queries are completed
6565
const validateQueries = () => {

0 commit comments

Comments
 (0)