generated from bcgov/quickstart-openshift
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add go to seedlot button in seedlot dashboard
- Loading branch information
Xiao Peng
authored and
Xiao Peng
committed
Sep 25, 2024
1 parent
545c686
commit 726f233
Showing
4 changed files
with
98 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import React, { useState } from 'react'; | ||
import { useNavigate } from 'react-router-dom'; | ||
|
||
import { | ||
Button, TextInput, Column | ||
} from '@carbon/react'; | ||
import { ArrowRight } from '@carbon/icons-react'; | ||
import ROUTES from '../../routes/constants'; | ||
|
||
import { addParamToPath } from '../../utils/PathUtils'; | ||
import focusById from '../../utils/FocusUtils'; | ||
|
||
const SeedlotNavigator = () => { | ||
const navigate = useNavigate(); | ||
|
||
const [seedlotNumber, setSeedlotNumber] = useState<string>(''); | ||
const [seedlotInputErr, setSeedlotInputErr] = useState<boolean>(false); | ||
|
||
return ( | ||
<> | ||
<Column className="no-padding-col" sm={4} md={6} lg={14} xlg={14}> | ||
<TextInput | ||
id="go-to-seedlot-input" | ||
type="number" | ||
labelText="" | ||
placeholder="Enter seedlot number" | ||
value={seedlotNumber} | ||
invalid={seedlotInputErr} | ||
invalidText="Please, enter a seedlot number" | ||
onChange={(e: React.ChangeEvent<HTMLInputElement>) => { | ||
setSeedlotInputErr(false); | ||
setSeedlotNumber(e.target.value); | ||
}} | ||
onWheel={(e: React.ChangeEvent<HTMLInputElement>) => e.target.blur()} | ||
/> | ||
</Column> | ||
<Column sm={4} md={2} lg={2} xlg={2}> | ||
<Button | ||
kind="primary" | ||
size="md" | ||
renderIcon={ArrowRight} | ||
onClick={() => { | ||
if (seedlotNumber) { | ||
navigate(addParamToPath(ROUTES.SEEDLOT_DETAILS, seedlotNumber)); | ||
} else { | ||
setSeedlotInputErr(true); | ||
focusById('go-to-seedlot-input'); | ||
} | ||
}} | ||
> | ||
Go to seedlot | ||
</Button> | ||
</Column> | ||
</> | ||
); | ||
}; | ||
|
||
export default SeedlotNavigator; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters