|
| 1 | +import BugConfigFormPanelGroup from "@core/BugConfigFormPanelGroup"; |
| 2 | +import BugConfigFormTextField from "@core/BugConfigFormTextField"; |
| 3 | +import BugConfigWrapper from "@core/BugConfigWrapper"; |
| 4 | +import BugLoading from "@core/BugLoading"; |
| 5 | +import { useConfigFormHandler } from "@hooks/ConfigFormHandler"; |
| 6 | +import { Grid } from "@mui/material"; |
| 7 | +import { useSelector } from "react-redux"; |
| 8 | + |
| 9 | +export default function ConfigPanel() { |
| 10 | + const panelConfig = useSelector((state) => state.panelConfig); |
| 11 | + |
| 12 | + if (panelConfig.status === "loading") { |
| 13 | + return <BugLoading />; |
| 14 | + } |
| 15 | + |
| 16 | + if (panelConfig.status !== "success") { |
| 17 | + return null; |
| 18 | + } |
| 19 | + |
| 20 | + const { register, handleSubmit, control, errors, validateServer, messages } = useConfigFormHandler({ |
| 21 | + panelId: panelConfig.data.id, |
| 22 | + }); |
| 23 | + |
| 24 | + return ( |
| 25 | + <> |
| 26 | + <BugConfigWrapper config={panelConfig.data} handleSubmit={handleSubmit}> |
| 27 | + <Grid size={{ xs: 12 }}> |
| 28 | + <BugConfigFormTextField |
| 29 | + name="title" |
| 30 | + control={control} |
| 31 | + rules={{ required: true }} |
| 32 | + fullWidth |
| 33 | + error={errors.title} |
| 34 | + defaultValue={panelConfig.data.title} |
| 35 | + label="Panel Title" |
| 36 | + /> |
| 37 | + </Grid> |
| 38 | + <Grid size={{ xs: 12 }}> |
| 39 | + <BugConfigFormTextField |
| 40 | + name="description" |
| 41 | + control={control} |
| 42 | + fullWidth |
| 43 | + error={errors.description} |
| 44 | + defaultValue={panelConfig.data.description} |
| 45 | + label="Description" |
| 46 | + /> |
| 47 | + </Grid> |
| 48 | + <Grid size={{ xs: 12 }}> |
| 49 | + <BugConfigFormPanelGroup name="group" control={control} defaultValue={panelConfig.data.group} /> |
| 50 | + </Grid> |
| 51 | + <Grid size={{ xs: 12 }}> |
| 52 | + <BugConfigFormTextField |
| 53 | + name="url" |
| 54 | + control={control} |
| 55 | + fullWidth |
| 56 | + error={errors.url} |
| 57 | + defaultValue={panelConfig.data.url} |
| 58 | + label="URL" |
| 59 | + /> |
| 60 | + </Grid> |
| 61 | + </BugConfigWrapper> |
| 62 | + </> |
| 63 | + ); |
| 64 | +} |
0 commit comments