Notes![what is notes.io? What is notes.io?](/theme/images/whatisnotesio.png)
![]() ![]() Notes - notes.io |
*
* ReasonCodeTaskCategoryDialog
* @author biswabijayee.m
*
*/
import React, { memo, useEffect, useState } from 'react';
import { Button, Grid, Typography, TextField } from '@material-ui/core';
import CustomDialog from '@highradius/g4_ui_components/lib/components/molecules/CustomDialog';
import { makeStyles } from '@material-ui/core/styles';
import SelectBox from '@highradius/g4_ui_components/lib/components/atoms/SelectBox';
import PropTypes from 'prop-types';
import { defaultStyle } from './styles';
const useStyles = makeStyles(defaultStyle);
function ReasonCodeTaskCategoryDialog({
show,
data,
close,
mode,
onSubmit,
getfkCategoryId,
fkcategoryId,
}) {
const classes = useStyles();
const [taskAddDialog, settaskAddDialog] = React.useState(show);
const [dialogData, setDialogData] = useState({
category: '',
description: '',
fkCategoryId: '',
});
useEffect(() => {
if (show) {
openTaskAddDialog();
getfkCategoryId();
}
}, [show]);
const handleChange = (e: { target: { name?: any; value?: any } }) => {
const { name } = e.target;
const { value } = e.target;
setDialogData({ ...dialogData, [name]: value });
};
const closeTaskAddDialog = () => {
settaskAddDialog(false);
close();
};
const openTaskAddDialog = () => {
settaskAddDialog(true);
setDialogData(data);
};
const handleTaskAddDialog = () => {
if (mode === 'add') {
onSubmit(dialogData);
} else {
onSubmit({
category: dialogData.category,
description: dialogData.description,
pkClientTaskCategoryId: data.pkClientTaskCategoryId,
fkCategoryId: dialogData.fkCategoryId,
});
}
closeTaskAddDialog();
};
const handleSelectBox = (selectedId: string) => {
setDialogData({ ...dialogData, fkCategoryId: selectedId });
};
const getOptions = (buckets: any[]) => {
const arrayBuckets: Array<{ id: any; name: any }> = [];
if (buckets && buckets.length > 0) {
buckets.map((bucket) => {
const b = {
id: bucket.pkCategoryId,
name: bucket.name,
};
arrayBuckets.push(b);
return null;
});
}
return arrayBuckets;
};
const getContent = () => (
<Grid container xs={12} direction="column">
<Grid container item xs={12} className={classes.itemStyle}>
<Grid item xs={12}>
<Typography variant="body1">Task Category Name</Typography>
<TextField
fullWidth
variant="outlined"
name="category"
value={dialogData?.category}
onChange={handleChange}
/>
</Grid>
</Grid>
<Grid container item xs={12} className={classes.itemStyle}>
<Grid item xs={12}>
<Typography variant="body1">Description</Typography>
</Grid>
<Grid item xs={12}>
<TextField
fullWidth
variant="outlined"
name="description"
rows={5}
multiline
value={dialogData?.description}
onChange={handleChange}
/>
</Grid>
<Grid item xs={12} className={classes.itemStyle}>
<Typography variant="body1">Task Category Bucket</Typography>
<SelectBox
defaultValue={dialogData?.fkCategoryId}
disableClearable
handleChange={(_e, selectedId) => {
handleSelectBox(selectedId);
}}
className={classes.selectbox}
options={getOptions(fkcategoryId)}
/>
</Grid>
</Grid>
</Grid>
);
return (
<>
<CustomDialog
useDialog={{
dialogState: { open: taskAddDialog },
closeDialog: closeTaskAddDialog,
}}
id="task-category-dialog"
onCloseClick={closeTaskAddDialog}
header={mode === 'add' ? 'Add Task Category' : 'Edit Task category'}
topDivider
contentHead={getContent()}
actions={[
<Button variant="text" onClick={closeTaskAddDialog}>
Cancel
</Button>,
<Button
variant="contained"
onClick={() => {
handleTaskAddDialog();
}}
>
{mode === 'add' ? 'Add' : 'Save'}
</Button>,
]}
/>
</>
);
}
ReasonCodeTaskCategoryDialog.propTypes = {
show: PropTypes.bool,
data: PropTypes.object,
close: PropTypes.func,
mode: PropTypes.string,
onSubmit: PropTypes.func,
getfkCategoryId: PropTypes.func,
fkcategoryId: PropTypes.array,
};
export default memo(ReasonCodeTaskCategoryDialog);
![]() |
Notes is a web-based application for online taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000+ notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 14 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team