File tree Expand file tree Collapse file tree 2 files changed +243
-136
lines changed
packages/ra-ui-materialui/src/input Expand file tree Collapse file tree 2 files changed +243
-136
lines changed Original file line number Diff line number Diff line change @@ -516,44 +516,41 @@ const PostCreate = () => {
516516}
517517
518518const CreateTag = () => {
519- const { filter , onCancel , onCreate } = useCreateSuggestionContext ();
520- const [value , setValue ] = React .useState (filter || ' ' );
521- const [create ] = useCreate ();
522-
523- const handleSubmit = event => {
524- event .preventDefault ();
525- create (
526- ' tags' ,
527- {
528- data: {
529- title: value,
530- },
531- },
532- {
533- onSuccess : (data ) => {
534- setValue (' ' );
535- onCreate (data);
536- },
537- }
538- );
539- };
540-
519+ const { onCancel , onCreate } = useCreateSuggestionContext ();
520+
521+ const onTagCreate = (tag ) => {
522+ onCreate (tag);
523+ }
541524 return (
542525 < Dialog open onClose= {onCancel}>
543- < form onSubmit= {handleSubmit}>
544- < DialogContent>
545- < TextField
546- label= " New tag"
547- value= {value}
548- onChange= {event => setValue (event .target .value )}
549- autoFocus
550- / >
551- < / DialogContent>
552- < DialogActions>
553- < Button type= " submit" > Save< / Button>
554- < Button onClick= {onCancel}> Cancel< / Button>
555- < / DialogActions>
556- < / form>
526+ < DialogTitle sx= {{ m: 0 , p: 2 }}> Create Tag< / DialogTitle>
527+ < IconButton
528+ aria- label= " close"
529+ onClick= {onCancel}
530+ sx= {theme => ({
531+ position: ' absolute' ,
532+ right: 8 ,
533+ top: 8 ,
534+ color: theme .palette .grey [500 ],
535+ })}
536+ >
537+ < CloseIcon / >
538+ < / IconButton>
539+ < DialogContent sx= {{ p: 0 }}>
540+ < CreateBase
541+ redirect= {false }
542+ resource= " tags"
543+ mutationOptions= {{
544+ onSuccess : tag => {
545+ onTagCreate (tag);
546+ },
547+ }}
548+ >
549+ < SimpleForm>
550+ < TextInput source= " name" helperText= {false } autoFocus/ >
551+ < / SimpleForm>
552+ < / CreateBase>
553+ < / DialogContent>
557554 < / Dialog>
558555 );
559556};
You can’t perform that action at this time.
0 commit comments