@material-ui/icons#CropFree JavaScript Examples
The following examples show how to use
@material-ui/icons#CropFree.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: index.js From whaticket with MIT License | 4 votes |
Connections = () => {
const classes = useStyles();
const { whatsApps, loading } = useContext(WhatsAppsContext);
const [whatsAppModalOpen, setWhatsAppModalOpen] = useState(false);
const [qrModalOpen, setQrModalOpen] = useState(false);
const [selectedWhatsApp, setSelectedWhatsApp] = useState(null);
const [confirmModalOpen, setConfirmModalOpen] = useState(false);
const confirmationModalInitialState = {
action: "",
title: "",
message: "",
whatsAppId: "",
open: false,
};
const [confirmModalInfo, setConfirmModalInfo] = useState(
confirmationModalInitialState
);
const handleStartWhatsAppSession = async whatsAppId => {
try {
await api.post(`/whatsappsession/${whatsAppId}`);
} catch (err) {
toastError(err);
}
};
const handleRequestNewQrCode = async whatsAppId => {
try {
await api.put(`/whatsappsession/${whatsAppId}`);
} catch (err) {
toastError(err);
}
};
const handleOpenWhatsAppModal = () => {
setSelectedWhatsApp(null);
setWhatsAppModalOpen(true);
};
const handleCloseWhatsAppModal = useCallback(() => {
setWhatsAppModalOpen(false);
setSelectedWhatsApp(null);
}, [setSelectedWhatsApp, setWhatsAppModalOpen]);
const handleOpenQrModal = whatsApp => {
setSelectedWhatsApp(whatsApp);
setQrModalOpen(true);
};
const handleCloseQrModal = useCallback(() => {
setSelectedWhatsApp(null);
setQrModalOpen(false);
}, [setQrModalOpen, setSelectedWhatsApp]);
const handleEditWhatsApp = whatsApp => {
setSelectedWhatsApp(whatsApp);
setWhatsAppModalOpen(true);
};
const handleOpenConfirmationModal = (action, whatsAppId) => {
if (action === "disconnect") {
setConfirmModalInfo({
action: action,
title: i18n.t("connections.confirmationModal.disconnectTitle"),
message: i18n.t("connections.confirmationModal.disconnectMessage"),
whatsAppId: whatsAppId,
});
}
if (action === "delete") {
setConfirmModalInfo({
action: action,
title: i18n.t("connections.confirmationModal.deleteTitle"),
message: i18n.t("connections.confirmationModal.deleteMessage"),
whatsAppId: whatsAppId,
});
}
setConfirmModalOpen(true);
};
const handleSubmitConfirmationModal = async () => {
if (confirmModalInfo.action === "disconnect") {
try {
await api.delete(`/whatsappsession/${confirmModalInfo.whatsAppId}`);
} catch (err) {
toastError(err);
}
}
if (confirmModalInfo.action === "delete") {
try {
await api.delete(`/whatsapp/${confirmModalInfo.whatsAppId}`);
toast.success(i18n.t("connections.toasts.deleted"));
} catch (err) {
toastError(err);
}
}
setConfirmModalInfo(confirmationModalInitialState);
};
const renderActionButtons = whatsApp => {
return (
<>
{whatsApp.status === "qrcode" && (
<Button
size="small"
variant="contained"
color="primary"
onClick={() => handleOpenQrModal(whatsApp)}
>
{i18n.t("connections.buttons.qrcode")}
</Button>
)}
{whatsApp.status === "DISCONNECTED" && (
<>
<Button
size="small"
variant="outlined"
color="primary"
onClick={() => handleStartWhatsAppSession(whatsApp.id)}
>
{i18n.t("connections.buttons.tryAgain")}
</Button>{" "}
<Button
size="small"
variant="outlined"
color="secondary"
onClick={() => handleRequestNewQrCode(whatsApp.id)}
>
{i18n.t("connections.buttons.newQr")}
</Button>
</>
)}
{(whatsApp.status === "CONNECTED" ||
whatsApp.status === "PAIRING" ||
whatsApp.status === "TIMEOUT") && (
<Button
size="small"
variant="outlined"
color="secondary"
onClick={() => {
handleOpenConfirmationModal("disconnect", whatsApp.id);
}}
>
{i18n.t("connections.buttons.disconnect")}
</Button>
)}
{whatsApp.status === "OPENING" && (
<Button size="small" variant="outlined" disabled color="default">
{i18n.t("connections.buttons.connecting")}
</Button>
)}
</>
);
};
const renderStatusToolTips = whatsApp => {
return (
<div className={classes.customTableCell}>
{whatsApp.status === "DISCONNECTED" && (
<CustomToolTip
title={i18n.t("connections.toolTips.disconnected.title")}
content={i18n.t("connections.toolTips.disconnected.content")}
>
<SignalCellularConnectedNoInternet0Bar color="secondary" />
</CustomToolTip>
)}
{whatsApp.status === "OPENING" && (
<CircularProgress size={24} className={classes.buttonProgress} />
)}
{whatsApp.status === "qrcode" && (
<CustomToolTip
title={i18n.t("connections.toolTips.qrcode.title")}
content={i18n.t("connections.toolTips.qrcode.content")}
>
<CropFree />
</CustomToolTip>
)}
{whatsApp.status === "CONNECTED" && (
<CustomToolTip title={i18n.t("connections.toolTips.connected.title")}>
<SignalCellular4Bar style={{ color: green[500] }} />
</CustomToolTip>
)}
{(whatsApp.status === "TIMEOUT" || whatsApp.status === "PAIRING") && (
<CustomToolTip
title={i18n.t("connections.toolTips.timeout.title")}
content={i18n.t("connections.toolTips.timeout.content")}
>
<SignalCellularConnectedNoInternet2Bar color="secondary" />
</CustomToolTip>
)}
</div>
);
};
return (
<MainContainer>
<ConfirmationModal
title={confirmModalInfo.title}
open={confirmModalOpen}
onClose={setConfirmModalOpen}
onConfirm={handleSubmitConfirmationModal}
>
{confirmModalInfo.message}
</ConfirmationModal>
<QrcodeModal
open={qrModalOpen}
onClose={handleCloseQrModal}
whatsAppId={!whatsAppModalOpen && selectedWhatsApp?.id}
/>
<WhatsAppModal
open={whatsAppModalOpen}
onClose={handleCloseWhatsAppModal}
whatsAppId={!qrModalOpen && selectedWhatsApp?.id}
/>
<MainHeader>
<Title>{i18n.t("connections.title")}</Title>
<MainHeaderButtonsWrapper>
<Button
variant="contained"
color="primary"
onClick={handleOpenWhatsAppModal}
>
{i18n.t("connections.buttons.add")}
</Button>
</MainHeaderButtonsWrapper>
</MainHeader>
<Paper className={classes.mainPaper} variant="outlined">
<Table size="small">
<TableHead>
<TableRow>
<TableCell align="center">
{i18n.t("connections.table.name")}
</TableCell>
<TableCell align="center">
{i18n.t("connections.table.status")}
</TableCell>
<TableCell align="center">
{i18n.t("connections.table.session")}
</TableCell>
<TableCell align="center">
{i18n.t("connections.table.lastUpdate")}
</TableCell>
<TableCell align="center">
{i18n.t("connections.table.default")}
</TableCell>
<TableCell align="center">
{i18n.t("connections.table.actions")}
</TableCell>
</TableRow>
</TableHead>
<TableBody>
{loading ? (
<TableRowSkeleton />
) : (
<>
{whatsApps?.length > 0 &&
whatsApps.map(whatsApp => (
<TableRow key={whatsApp.id}>
<TableCell align="center">{whatsApp.name}</TableCell>
<TableCell align="center">
{renderStatusToolTips(whatsApp)}
</TableCell>
<TableCell align="center">
{renderActionButtons(whatsApp)}
</TableCell>
<TableCell align="center">
{format(parseISO(whatsApp.updatedAt), "dd/MM/yy HH:mm")}
</TableCell>
<TableCell align="center">
{whatsApp.isDefault && (
<div className={classes.customTableCell}>
<CheckCircle style={{ color: green[500] }} />
</div>
)}
</TableCell>
<TableCell align="center">
<IconButton
size="small"
onClick={() => handleEditWhatsApp(whatsApp)}
>
<Edit />
</IconButton>
<IconButton
size="small"
onClick={e => {
handleOpenConfirmationModal("delete", whatsApp.id);
}}
>
<DeleteOutline />
</IconButton>
</TableCell>
</TableRow>
))}
</>
)}
</TableBody>
</Table>
</Paper>
</MainContainer>
);
}
Example #2
Source File: MyActivitiesLoggedin.js From pwa with MIT License | 4 votes |
function MyActivitiesLoggedin(props) {
let history = useHistory();
const date =
props.eventResult !== null
? new Intl.DateTimeFormat('fa', {
month: 'short',
day: '2-digit',
year: 'numeric',
hour: 'numeric',
minute: 'numeric',
}).format(new Date(props.createTime))
: null;
const firstDate =
props.firstCreateTime !== null
? new Intl.DateTimeFormat('fa', {
month: 'short',
day: '2-digit',
year: 'numeric',
hour: 'numeric',
minute: 'numeric',
}).format(new Date(props.firstCreateTime))
: null;
const mySelf =
props.eventResult !== null
? props.eventResult.people.filter((person) => {
return person.phone_number === props.eventResult.phone_number;
})
: null;
let healthMessageColor = 'rgba(0,0,0,0.75)';
if (mySelf !== null) {
if (mySelf[0].health_state == 1) {
healthMessageColor = '#00ffba';
} else if (mySelf[0].health_state == 2) {
healthMessageColor = '#f1e100';
} else if (mySelf[0].health_state == 3) {
healthMessageColor = '#ff005c';
}
}
return (
<>
<MyActivitiesHelp />
<AppBar position="static" className="activity-header">
<Toolbar>
<img src={logo} className="app-header-logo" />
<div>
<IconButton
color="inherit"
onClick={() => {
props.hideNavigation();
history.push('/qr-scanner');
}}
>
<CameraAlt />
</IconButton>
<IconButton
color="inherit"
onClick={() => {
props.hideNavigation();
history.push('/my-qrcode');
}}
>
<CropFree />
</IconButton>
<IconButton
color="inherit"
onClick={() => {
props.hideNavigation();
history.push('/bluetooth');
}}
>
<Bluetooth />
</IconButton>
</div>
</Toolbar>
</AppBar>
<div
className={`contentWrapper MyActivitiesWrapper`}
style={
props.eventResult === null
? { justifyContent: 'center' }
: { justifyContent: 'flex-start' }
}
>
{props.eventResult === null && (
<>
<PlaylistAdd
style={{ fontSize: 80, marginBottom: 22, marginTop: -50 }}
color="primary"
/>
<span className="message">
{PersianLan.myActivitiesTab.noActivityYet}
</span>
<span className="message">
{PersianLan.myActivitiesTab.touchButtonToSetActivity}
</span>
</>
)}
{props.eventResult !== null && (
<div>
<div className="lastUpdateContainer">
<span>زمان بروزرسانی وضعیت شما:</span>
<span>{date}</span>
</div>
<div className="healthMessageContainer">
{mySelf[0].health_state === 1 && (
<Favorite style={{ fontSize: 70, color: healthMessageColor }} />
)}
{mySelf[0].health_state === 2 && (
<Warning style={{ fontSize: 70, color: healthMessageColor }} />
)}
{mySelf[0].health_state === 3 && (
<Warning style={{ fontSize: 70, color: healthMessageColor }} />
)}
<div className="healthMessage">
<p style={{ color: healthMessageColor, fontSize: 14 }}>
{props.eventResult.people[0].health_message}
</p>
</div>
</div>
<div className="healthCount">
<span>{props.eventCounter} بار ثبت اطلاعات در سلامت روزانه</span>
{props.eventCounter > 1 && (
<span className="healthPerod">
از {firstDate} تا {date}
</span>
)}
</div>
</div>
)}
<Button
onClick={() => {
props.hideNavigation();
history.push('/add-myactivities');
}}
disableElevation
className={`btn addActivityBtn`}
color="primary"
variant="contained"
>
{PersianLan.myActivitiesTab.addNewActivity}
</Button>
</div>
</>
);
}