MCPcopy Create free account
hub / github.com/Botloader/botloader / EditOptionBooleanField

Function EditOptionBooleanField

frontend/src/components/GuildScriptPage.tsx:590–625  ·  view source on GitHub ↗
({ option }: { option: SettingsOption })

Source from the content-addressed store, hash-verified

588
589
590function EditOptionBooleanField({ option }: { option: SettingsOption }) {
591 const { value: rawValue, setValue, error } = useSettingsField(option.name)
592 const value = booleanValue(rawValue?.value, option)
593
594 if (option.kind.kind !== "boolean") {
595 throw new Error("not a number field")
596 }
597
598 return <Box mt={3}>
599 <Box>
600 <FormControlLabel
601 sx={{ marginRight: 0 }}
602 label={option.label}
603 control={<Checkbox checked={value}
604 onChange={(evt) => {
605 setValue(evt.target.checked)
606 }}
607 />}
608 />
609
610 {(Boolean(rawValue) && (option.defaultValue || !option.required)) &&
611 <IconButton
612 color='warning'
613 onClick={() => {
614 setValue(null)
615 }}
616 >
617 <ReplayIcon />
618 </IconButton>}
619 </Box>
620
621 <FormHelperText error={Boolean(error)}>
622 <FieldHelpText description={option.description} error={error} />
623 </FormHelperText>
624 </Box>
625}
626
627
628function EditOptionTextField({ option }: { option: SettingsOption }) {

Callers

nothing calls this directly

Calls 3

useSettingsFieldFunction · 0.85
booleanValueFunction · 0.85
setValueFunction · 0.85

Tested by

no test coverage detected