added CancelSubmit common element
This commit is contained in:
parent
374ba20f0c
commit
c31712464b
5 changed files with 55 additions and 42 deletions
|
|
@ -58,8 +58,6 @@ export default function ChatInput(props: Props) {
|
||||||
const { openSnack } = useSnackbar();
|
const { openSnack } = useSnackbar();
|
||||||
const [shift, setShift] = useState(false);
|
const [shift, setShift] = useState(false);
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
//const [attachmentDialogOpen, setAttachmentDialogOpen] = useState(false);
|
|
||||||
//const [uploadingFile, setUploadingFile] = useState(false);
|
|
||||||
const [uploadedFiles, setUploadedFiles] = useState<Map<string, string>>(new Map());
|
const [uploadedFiles, setUploadedFiles] = useState<Map<string, string>>(new Map());
|
||||||
|
|
||||||
const clearEntry = () => {
|
const clearEntry = () => {
|
||||||
|
|
@ -145,7 +143,7 @@ export default function ChatInput(props: Props) {
|
||||||
<Box
|
<Box
|
||||||
style={{
|
style={{
|
||||||
position: "absolute",
|
position: "absolute",
|
||||||
right: "10px",
|
right: theme.spacing(1),
|
||||||
top: "50%",
|
top: "50%",
|
||||||
transform: "translateY(-50%)",
|
transform: "translateY(-50%)",
|
||||||
}}
|
}}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
import {
|
import {
|
||||||
Avatar,
|
Avatar,
|
||||||
Box,
|
Box,
|
||||||
Button,
|
|
||||||
Dialog,
|
Dialog,
|
||||||
DialogActions,
|
DialogActions,
|
||||||
DialogContent,
|
DialogContent,
|
||||||
|
|
@ -22,6 +21,7 @@ import React, { useState } from "react";
|
||||||
import { pond } from "protobuf-ts/pond";
|
import { pond } from "protobuf-ts/pond";
|
||||||
import { red } from "@mui/material/colors";
|
import { red } from "@mui/material/colors";
|
||||||
import { makeStyles } from "@mui/styles";
|
import { makeStyles } from "@mui/styles";
|
||||||
|
import CancelSubmit from "common/CancelSubmit";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
index: number;
|
index: number;
|
||||||
|
|
@ -134,12 +134,11 @@ export default function ChatMessage(props: Props) {
|
||||||
<DialogContent>Are you sure you wish to delete this message</DialogContent>
|
<DialogContent>Are you sure you wish to delete this message</DialogContent>
|
||||||
|
|
||||||
<DialogActions>
|
<DialogActions>
|
||||||
<Button onClick={closeDialog} color="primary">
|
<CancelSubmit
|
||||||
Cancel
|
onCancel={closeDialog}
|
||||||
</Button>
|
onSubmit={deleteMessage}
|
||||||
<Button onClick={deleteMessage} color="primary">
|
submitText="Delete"
|
||||||
Delete
|
/>
|
||||||
</Button>
|
|
||||||
</DialogActions>
|
</DialogActions>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
41
src/common/CancelSubmit.tsx
Normal file
41
src/common/CancelSubmit.tsx
Normal file
|
|
@ -0,0 +1,41 @@
|
||||||
|
import { Button, Theme, Typography } from "@mui/material";
|
||||||
|
import { makeStyles } from "@mui/styles";
|
||||||
|
|
||||||
|
const useStyles = makeStyles((theme: Theme) => {
|
||||||
|
return ({
|
||||||
|
submitButton: {
|
||||||
|
marginRight: theme.spacing(1)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
submitDisabled?: boolean;
|
||||||
|
onSubmit?: () => void;
|
||||||
|
onCancel?: () => void;
|
||||||
|
submitText?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function CancelSubmit(props: Props) {
|
||||||
|
const { submitDisabled, onSubmit, onCancel, submitText } = props;
|
||||||
|
const classes = useStyles();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Button onClick={onCancel} color="primary" aria-label="Cancel">
|
||||||
|
<Typography variant="subtitle2" color="textPrimary">
|
||||||
|
Cancel
|
||||||
|
</Typography>
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
disabled={submitDisabled}
|
||||||
|
onClick={onSubmit}
|
||||||
|
className={classes.submitButton}
|
||||||
|
>
|
||||||
|
<Typography variant="subtitle2" color={ submitDisabled ? "disabled" : "primary"}>
|
||||||
|
{submitText ? submitText : "Submit"}
|
||||||
|
</Typography>
|
||||||
|
</Button>
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
@ -24,7 +24,6 @@ import { blue } from "@mui/material/colors";
|
||||||
import { makeStyles } from "@mui/styles";
|
import { makeStyles } from "@mui/styles";
|
||||||
import { useGlobalState, useUserAPI } from "providers";
|
import { useGlobalState, useUserAPI } from "providers";
|
||||||
import { Star, StarBorder } from "@mui/icons-material";
|
import { Star, StarBorder } from "@mui/icons-material";
|
||||||
import { cloneDeep } from "lodash";
|
|
||||||
|
|
||||||
const useStyles = makeStyles(() => ({
|
const useStyles = makeStyles(() => ({
|
||||||
shareIcon: {
|
shareIcon: {
|
||||||
|
|
@ -90,7 +89,6 @@ export default function TeamActions(props: Props) {
|
||||||
setOpenState({ ...openState, share: true });
|
setOpenState({ ...openState, share: true });
|
||||||
setAnchorEl(null);
|
setAnchorEl(null);
|
||||||
}}
|
}}
|
||||||
// button
|
|
||||||
>
|
>
|
||||||
<ListItemIcon>
|
<ListItemIcon>
|
||||||
<ShareObjectIcon className={classes.shareIcon} />
|
<ShareObjectIcon className={classes.shareIcon} />
|
||||||
|
|
@ -105,7 +103,6 @@ export default function TeamActions(props: Props) {
|
||||||
setOpenState({ ...openState, users: true });
|
setOpenState({ ...openState, users: true });
|
||||||
setAnchorEl(null);
|
setAnchorEl(null);
|
||||||
}}
|
}}
|
||||||
// button
|
|
||||||
>
|
>
|
||||||
<ListItemIcon>
|
<ListItemIcon>
|
||||||
<ObjectUsersIcon />
|
<ObjectUsersIcon />
|
||||||
|
|
@ -119,7 +116,6 @@ export default function TeamActions(props: Props) {
|
||||||
setOpenState({ ...openState, removeSelf: true });
|
setOpenState({ ...openState, removeSelf: true });
|
||||||
setAnchorEl(null);
|
setAnchorEl(null);
|
||||||
}}
|
}}
|
||||||
// button
|
|
||||||
>
|
>
|
||||||
<ListItemIcon>
|
<ListItemIcon>
|
||||||
<RemoveSelfIcon className={classes.red} />
|
<RemoveSelfIcon className={classes.red} />
|
||||||
|
|
@ -164,7 +160,6 @@ export default function TeamActions(props: Props) {
|
||||||
label={label}
|
label={label}
|
||||||
isDialogOpen={openState.removeSelf}
|
isDialogOpen={openState.removeSelf}
|
||||||
closeDialogCallback={(removeSelf: boolean) => {
|
closeDialogCallback={(removeSelf: boolean) => {
|
||||||
// console.log(removeSelf)
|
|
||||||
if (removeSelf) refreshCallback()
|
if (removeSelf) refreshCallback()
|
||||||
setOpenState({ ...openState, removeSelf: false })
|
setOpenState({ ...openState, removeSelf: false })
|
||||||
}}
|
}}
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ import React, { useEffect, useState } from "react";
|
||||||
import DeleteButton from "common/DeleteButton";
|
import DeleteButton from "common/DeleteButton";
|
||||||
import { userRoleFromPermissions } from "pbHelpers/User";
|
import { userRoleFromPermissions } from "pbHelpers/User";
|
||||||
import { IconPicker } from "common/IconPicker";
|
import { IconPicker } from "common/IconPicker";
|
||||||
|
import CancelSubmit from "common/CancelSubmit";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
teamDialogOpen: boolean;
|
teamDialogOpen: boolean;
|
||||||
|
|
@ -57,20 +58,6 @@ export default function TeamSettings(props: Props) {
|
||||||
}
|
}
|
||||||
}, [team]);
|
}, [team]);
|
||||||
|
|
||||||
// const ColorButton = withStyles((theme: Theme) => ({
|
|
||||||
// root: {
|
|
||||||
// color: theme.palette.getContrastText(theme.palette.primary.main),
|
|
||||||
// backgroundColor: theme.palette.primary.main,
|
|
||||||
// "&:hover": {
|
|
||||||
// backgroundColor: theme.palette.primary.light
|
|
||||||
// },
|
|
||||||
// "&:disabled": {
|
|
||||||
// backgroundColor: "rgba(0,0,0,0)",
|
|
||||||
// color: theme.palette.getContrastText(theme.palette.primary.main)
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }))(Button);
|
|
||||||
|
|
||||||
const removeTeam = () => {
|
const removeTeam = () => {
|
||||||
if (team?.key())
|
if (team?.key())
|
||||||
teamAPI
|
teamAPI
|
||||||
|
|
@ -246,19 +233,12 @@ export default function TeamSettings(props: Props) {
|
||||||
Delete
|
Delete
|
||||||
</DeleteButton>
|
</DeleteButton>
|
||||||
)}
|
)}
|
||||||
<Button onClick={close} color="primary" aria-label="Cancel">
|
<CancelSubmit
|
||||||
<Typography variant="subtitle2" color="textPrimary">
|
onSubmit={teamKey ? updateTeam : addTeam}
|
||||||
Cancel
|
onCancel={close}
|
||||||
</Typography>
|
submitDisabled={disable}
|
||||||
</Button>
|
submitText={teamKey ? "Update" : "Submit"}
|
||||||
<Button
|
/>
|
||||||
disabled={disable}
|
|
||||||
onClick={teamKey ? updateTeam : addTeam}
|
|
||||||
style={{ marginRight: theme.spacing(2) }}>
|
|
||||||
<Typography variant="subtitle2" color="primary">
|
|
||||||
{teamKey ? "Update" : "Submit"}
|
|
||||||
</Typography>
|
|
||||||
</Button>
|
|
||||||
</DialogActions>
|
</DialogActions>
|
||||||
</ResponsiveDialog>
|
</ResponsiveDialog>
|
||||||
{deleteConfirmation()}
|
{deleteConfirmation()}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue