-
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.
- Loading branch information
Showing
3 changed files
with
70 additions
and
42 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
55 changes: 55 additions & 0 deletions
55
src/pages/campaigns/components/campaignForm/fields/TargetSize.tsx
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,55 @@ | ||
import { Title, Checkbox } from "@appquality/appquality-design-system"; | ||
import InputField from "./InputField"; | ||
import { useState } from "react"; | ||
import { NewCampaignValues } from "../FormProvider"; | ||
import { useFormikContext } from "formik"; | ||
|
||
const TargetSize = () => { | ||
const { | ||
setFieldValue, | ||
values: { targetCap }, | ||
} = useFormikContext<NewCampaignValues>(); | ||
const [hasCap, setHasCap] = useState(!!targetCap); | ||
return ( | ||
<> | ||
<div> | ||
<Title size="s" className="aq-mb-2"> | ||
Set the target | ||
</Title> | ||
<div> | ||
<InputField | ||
type="number" | ||
name="targetSize" | ||
label="Number of participants" | ||
style={{ maxWidth: "225px" }} | ||
/> | ||
</div> | ||
</div> | ||
<div> | ||
<Title size="s" className="q-mb-2"> | ||
Set the maximum candidates capacity | ||
</Title> | ||
|
||
<Checkbox | ||
name="checkboxCap" | ||
id="checkboxCap" | ||
label="Limit the number of candidates" | ||
checked={hasCap} | ||
onChange={(e) => { | ||
setHasCap(e.target.checked); | ||
if (!e.target.checked) setFieldValue("targetCap", ""); | ||
}} | ||
/> | ||
<InputField | ||
disabled={!hasCap} | ||
type="number" | ||
name="targetCap" | ||
label="" | ||
style={{ maxWidth: "225px" }} | ||
/> | ||
</div> | ||
</> | ||
); | ||
}; | ||
|
||
export default TargetSize; |
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