|
1 | 1 | import * as React from 'react';
|
2 |
| -import {useEffect, useRef, useState} from 'react'; |
| 2 | +import {useContext, useEffect, useRef, useState} from 'react'; |
3 | 3 | import theme from "./theme";
|
4 |
| -import {Checkbox, Chip, FormControl, FormControlLabel, InputLabel, Link, Select, useMediaQuery} from "@mui/material"; |
| 4 | +import { |
| 5 | + Checkbox, |
| 6 | + Chip, |
| 7 | + FormControl, |
| 8 | + FormControlLabel, |
| 9 | + InputLabel, |
| 10 | + Link, |
| 11 | + Select, |
| 12 | + Tooltip, |
| 13 | + useMediaQuery |
| 14 | +} from "@mui/material"; |
5 | 15 | import TextField from "@mui/material/TextField";
|
6 | 16 | import priority1 from "../img/priority-1.svg";
|
7 | 17 | import priority2 from "../img/priority-2.svg";
|
@@ -29,9 +39,11 @@ import session from "../app/Session";
|
29 | 39 | import routes from "./routes";
|
30 | 40 | import accountApi from "../app/AccountApi";
|
31 | 41 | import {UnauthorizedError} from "../app/errors";
|
| 42 | +import {AccountContext} from "./App"; |
32 | 43 |
|
33 | 44 | const PublishDialog = (props) => {
|
34 | 45 | const { t } = useTranslation();
|
| 46 | + const { account } = useContext(AccountContext); |
35 | 47 | const [baseUrl, setBaseUrl] = useState("");
|
36 | 48 | const [topic, setTopic] = useState("");
|
37 | 49 | const [message, setMessage] = useState("");
|
@@ -416,20 +428,29 @@ const PublishDialog = (props) => {
|
416 | 428 | setCall("");
|
417 | 429 | setShowCall(false);
|
418 | 430 | }}>
|
419 |
| - <TextField |
420 |
| - margin="dense" |
421 |
| - label={t("publish_dialog_call_label")} |
422 |
| - placeholder={t("publish_dialog_call_placeholder")} |
423 |
| - value={call} |
424 |
| - onChange={ev => setCall(ev.target.value)} |
425 |
| - disabled={disabled} |
426 |
| - type="tel" |
427 |
| - variant="standard" |
| 431 | + <FormControl |
428 | 432 | fullWidth
|
429 |
| - inputProps={{ |
430 |
| - "aria-label": t("publish_dialog_call_label") |
431 |
| - }} |
432 |
| - /> |
| 433 | + variant="standard" |
| 434 | + margin="dense" |
| 435 | + > |
| 436 | + <InputLabel/> |
| 437 | + <Select |
| 438 | + label={t("publish_dialog_call_label")} |
| 439 | + margin="dense" |
| 440 | + value={call} |
| 441 | + onChange={(ev) => setCall(ev.target.value)} |
| 442 | + disabled={disabled} |
| 443 | + inputProps={{ |
| 444 | + "aria-label": t("publish_dialog_call_label") |
| 445 | + }} |
| 446 | + > |
| 447 | + {account?.phone_numbers?.map((phoneNumber, i) => |
| 448 | + <MenuItem key={`phoneNumberMenuItem${i}`} value={phoneNumber} aria-label={phoneNumber}> |
| 449 | + {t("publish_dialog_call_item", { number: phoneNumber })} |
| 450 | + </MenuItem> |
| 451 | + )} |
| 452 | + </Select> |
| 453 | + </FormControl> |
433 | 454 | </ClosableRow>
|
434 | 455 | }
|
435 | 456 | {showAttachUrl &&
|
@@ -536,11 +557,12 @@ const PublishDialog = (props) => {
|
536 | 557 | <div>
|
537 | 558 | {!showClickUrl && <Chip clickable disabled={disabled} label={t("publish_dialog_chip_click_label")} aria-label={t("publish_dialog_chip_click_label")} onClick={() => setShowClickUrl(true)} sx={{marginRight: 1, marginBottom: 1}}/>}
|
538 | 559 | {!showEmail && <Chip clickable disabled={disabled} label={t("publish_dialog_chip_email_label")} aria-label={t("publish_dialog_chip_email_label")} onClick={() => setShowEmail(true)} sx={{marginRight: 1, marginBottom: 1}}/>}
|
539 |
| - {!showCall && <Chip clickable disabled={disabled} label={t("publish_dialog_chip_call_label")} aria-label={t("publish_dialog_chip_call_label")} onClick={() => setShowCall(true)} sx={{marginRight: 1, marginBottom: 1}}/>} |
| 560 | + {account?.phone_numbers?.length > 0 && !showCall && <Chip clickable disabled={disabled} label={t("publish_dialog_chip_call_label")} aria-label={t("publish_dialog_chip_call_label")} onClick={() => { setShowCall(true); setCall(account.phone_numbers[0]); }} sx={{marginRight: 1, marginBottom: 1}}/>} |
540 | 561 | {!showAttachUrl && !showAttachFile && <Chip clickable disabled={disabled} label={t("publish_dialog_chip_attach_url_label")} aria-label={t("publish_dialog_chip_attach_url_label")} onClick={() => setShowAttachUrl(true)} sx={{marginRight: 1, marginBottom: 1}}/>}
|
541 | 562 | {!showAttachFile && !showAttachUrl && <Chip clickable disabled={disabled} label={t("publish_dialog_chip_attach_file_label")} aria-label={t("publish_dialog_chip_attach_file_label")} onClick={() => handleAttachFileClick()} sx={{marginRight: 1, marginBottom: 1}}/>}
|
542 | 563 | {!showDelay && <Chip clickable disabled={disabled} label={t("publish_dialog_chip_delay_label")} aria-label={t("publish_dialog_chip_delay_label")} onClick={() => setShowDelay(true)} sx={{marginRight: 1, marginBottom: 1}}/>}
|
543 | 564 | {!showTopicUrl && <Chip clickable disabled={disabled} label={t("publish_dialog_chip_topic_label")} aria-label={t("publish_dialog_chip_topic_label")} onClick={() => setShowTopicUrl(true)} sx={{marginRight: 1, marginBottom: 1}}/>}
|
| 565 | + {account && !account?.phone_numbers && <Tooltip title={t("publish_dialog_chip_call_no_verified_numbers_tooltip")}><span><Chip clickable disabled label={t("publish_dialog_chip_call_label")} aria-label={t("publish_dialog_chip_call_label")} sx={{marginRight: 1, marginBottom: 1}}/></span></Tooltip>} |
544 | 566 | </div>
|
545 | 567 | <Typography variant="body1" sx={{marginTop: 1, marginBottom: 1}}>
|
546 | 568 | <Trans
|
|
0 commit comments