mirror of
https://github.com/cheveguerra/whaticket-community.git
synced 2026-04-20 04:39:20 +00:00
fix: queue color picker not working
This commit is contained in:
@@ -1,8 +1,9 @@
|
|||||||
|
import { Dialog } from "@material-ui/core";
|
||||||
import React, { useState } from "react";
|
import React, { useState } from "react";
|
||||||
|
|
||||||
import { GithubPicker } from "react-color";
|
import { GithubPicker } from "react-color";
|
||||||
|
|
||||||
const ColorPicker = ({ onChange, currentColor }) => {
|
const ColorPicker = ({ onChange, currentColor, handleClose, open }) => {
|
||||||
const [color, setColor] = useState(currentColor);
|
const [color, setColor] = useState(currentColor);
|
||||||
|
|
||||||
const handleChange = color => {
|
const handleChange = color => {
|
||||||
@@ -10,7 +11,11 @@ const ColorPicker = ({ onChange, currentColor }) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<Dialog
|
||||||
|
onClose={handleClose}
|
||||||
|
aria-labelledby="simple-dialog-title"
|
||||||
|
open={open}
|
||||||
|
>
|
||||||
<GithubPicker
|
<GithubPicker
|
||||||
width={"100%"}
|
width={"100%"}
|
||||||
triangle="hide"
|
triangle="hide"
|
||||||
@@ -18,7 +23,7 @@ const ColorPicker = ({ onChange, currentColor }) => {
|
|||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
onChangeComplete={color => onChange(color.hex)}
|
onChangeComplete={color => onChange(color.hex)}
|
||||||
/>
|
/>
|
||||||
</div>
|
</Dialog>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,8 @@ import { i18n } from "../../translate/i18n";
|
|||||||
import api from "../../services/api";
|
import api from "../../services/api";
|
||||||
import toastError from "../../errors/toastError";
|
import toastError from "../../errors/toastError";
|
||||||
import ColorPicker from "../ColorPicker";
|
import ColorPicker from "../ColorPicker";
|
||||||
import { InputAdornment } from "@material-ui/core";
|
import { IconButton, InputAdornment } from "@material-ui/core";
|
||||||
|
import { Colorize } from "@material-ui/icons";
|
||||||
|
|
||||||
const useStyles = makeStyles(theme => ({
|
const useStyles = makeStyles(theme => ({
|
||||||
root: {
|
root: {
|
||||||
@@ -71,6 +72,7 @@ const QueueModal = ({ open, onClose, queueId }) => {
|
|||||||
greetingMessage: "",
|
greetingMessage: "",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const [colorPickerModalOpen, setColorPickerModalOpen] = useState(false);
|
||||||
const [queue, setQueue] = useState(initialState);
|
const [queue, setQueue] = useState(initialState);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -116,13 +118,7 @@ const QueueModal = ({ open, onClose, queueId }) => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={classes.root}>
|
<div className={classes.root}>
|
||||||
<Dialog
|
<Dialog open={open} onClose={handleClose} scroll="paper">
|
||||||
open={open}
|
|
||||||
onClose={handleClose}
|
|
||||||
maxWidth="sm"
|
|
||||||
fullWidth
|
|
||||||
scroll="paper"
|
|
||||||
>
|
|
||||||
<DialogTitle>
|
<DialogTitle>
|
||||||
{queueId
|
{queueId
|
||||||
? `${i18n.t("queueModal.title.edit")}`
|
? `${i18n.t("queueModal.title.edit")}`
|
||||||
@@ -156,6 +152,9 @@ const QueueModal = ({ open, onClose, queueId }) => {
|
|||||||
<Field
|
<Field
|
||||||
as={TextField}
|
as={TextField}
|
||||||
label={i18n.t("queueModal.form.color")}
|
label={i18n.t("queueModal.form.color")}
|
||||||
|
name="color"
|
||||||
|
id="color"
|
||||||
|
// disabled
|
||||||
InputProps={{
|
InputProps={{
|
||||||
startAdornment: (
|
startAdornment: (
|
||||||
<InputAdornment position="start">
|
<InputAdornment position="start">
|
||||||
@@ -165,20 +164,26 @@ const QueueModal = ({ open, onClose, queueId }) => {
|
|||||||
></div>
|
></div>
|
||||||
</InputAdornment>
|
</InputAdornment>
|
||||||
),
|
),
|
||||||
|
endAdornment: (
|
||||||
|
<IconButton
|
||||||
|
size="small"
|
||||||
|
color="default"
|
||||||
|
onClick={() => setColorPickerModalOpen(true)}
|
||||||
|
>
|
||||||
|
<Colorize />
|
||||||
|
</IconButton>
|
||||||
|
),
|
||||||
}}
|
}}
|
||||||
name="color"
|
|
||||||
error={touched.color && Boolean(errors.color)}
|
|
||||||
helperText={touched.color && errors.color}
|
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
margin="dense"
|
margin="dense"
|
||||||
/>
|
/>
|
||||||
<ColorPicker
|
<ColorPicker
|
||||||
label={"Pick Color"}
|
open={colorPickerModalOpen}
|
||||||
currentColor={queue.color}
|
handleClose={() => setColorPickerModalOpen(false)}
|
||||||
onChange={color => {
|
onChange={color => {
|
||||||
values.color = color;
|
values.color = color;
|
||||||
setQueue(prevState => {
|
setQueue(() => {
|
||||||
return { ...prevState, color };
|
return { ...values, color };
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -37,7 +37,6 @@ const useStyles = makeStyles(theme => ({
|
|||||||
},
|
},
|
||||||
customTableCell: {
|
customTableCell: {
|
||||||
display: "flex",
|
display: "flex",
|
||||||
|
|
||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
justifyContent: "center",
|
justifyContent: "center",
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user