How to use the react-intl.useIntl function in react-intl

To help you get started, we’ve selected a few react-intl examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github streetmix / streetmix / assets / scripts / palette / UndoRedo.jsx View on Github external
const UndoRedo = (props) => {
  const intl = useIntl()

  // Don’t allow undo/redo unless you own the street
  // TODO: We need a better function name than `getRemixOnFirstEdit`
  function isUndoAvailable () {
    return (props.undoPosition > 0) && !getRemixOnFirstEdit()
  }

  function isRedoAvailable () {
    return (props.undoPosition >= 0 && props.undoPosition < props.undoStack.length - 1) && !getRemixOnFirstEdit()
  }

  return (
    <>
github mirumee / saleor-dashboard / src / orders / components / OrderFulfillmentDialog / OrderFulfillmentDialog.tsx View on Github external
const OrderFulfillmentDialog: React.FC = props => {
  const { confirmButtonState, open, lines, onClose, onSubmit } = props;

  const classes = useStyles(props);
  const intl = useIntl();

  return (
    <dialog open="{open}">
      <form>
              lines.map(
                product =&gt; product.quantity - product.quantityFulfilled
              ),
            []
          ),
          trackingNumber: ""
        }}
        onSubmit={onSubmit}
      &gt;</form></dialog>
github opencollective / opencollective-frontend / components / host-dashboard / AppRejectionReasonModal.js View on Github external
const AppRejectionReasonModal = ({ show, onClose, collectiveId, hostCollectiveSlug }) =&gt; {
  const [rejectionReason, setRejectionReason] = useState('');
  const [rejectCollective, { loading, error }] = useMutation(rejectCollectiveQuery);
  const intl = useIntl();

  return (
    
      
        
      
      
        {error &amp;&amp; (
          
            {error.message}
          
        )}
github mirumee / saleor-dashboard / src / components / SearchBar / SearchBar.tsx View on Github external
const SearchBar: React.FC = props =&gt; {
  const {
    allTabLabel,
    currentTab,
    initialSearch,
    onSearchChange,
    searchPlaceholder,
    tabs,
    onAll,
    onTabChange,
    onTabDelete,
    onTabSave
  } = props;
  const intl = useIntl();

  const isCustom = currentTab === tabs.length + 1;

  return (
    &lt;&gt;
      
        
        {tabs.map((tab, tabIndex) =&gt; (
           onTabChange(tabIndex + 1)}
            label={tab}
            key={tabIndex}
          /&gt;
        ))}
        {isCustom &amp;&amp; (
github mirumee / saleor-dashboard / src / pages / components / PageInfo / PageInfo.tsx View on Github external
const PageInfo: React.FC = props =&gt; {
  const { data, disabled, errors, page, onChange } = props;
  const classes = useStyles(props);

  const intl = useIntl();

  return (
github dvaJi / ReaderFront / src / admin / chapters / CreateOrEdit / EditChapter.js View on Github external
function ChapterDetail({ onSubmit }) {
  const params = useParams();
  const { formatMessage: f } = useIntl();
  const { loading, error, data } = useQuery(FETCH_CHAPTER, {
    variables: { chapterId: parseInt(params.chapterId, 0) }
  });

  if (loading)
    return <div>{f({ id: 'loading', defaultMessage: 'Loading...' })}</div>;
  if (error) return <p id="error_edit_chapter">Error :(</p>;
  return (
    <div>
      
      </div>
github mirumee / saleor-dashboard / src / webhooks / views / WebhooksDetails.tsx View on Github external
export const WebhooksDetails: React.FC = ({
  id,
  params
}) =&gt; {
  const navigate = useNavigator();
  const notify = useNotifier();
  const intl = useIntl();
  const {
    search: searchServiceAccount,
    result: searchServiceAccountOpt
  } = useServiceAccountSearch({
    variables: DEFAULT_INITIAL_SEARCH_DATA
  });

  const [openModal, closeModal] = createDialogActionHandlers&lt;
    WebhookUrlDialog,
    WebhookUrlQueryParams
  &gt;(navigate, params =&gt; webhookUrl(id, params), params);

  const onWebhookDelete = (data: WebhookDelete) =&gt; {
    if (data.webhookDelete.errors.length === 0) {
      notify({
        text: intl.formatMessage(commonMessages.savedChanges)
github dvaJi / ReaderFront / src / admin / works / CreatePersonModal.js View on Github external
function CreatePersonModal({ isOpen, toggleModal }) {
  const [personName, setPersonName] = useState('');
  const [personNameKanji, setPersonNameKanji] = useState('');
  const [description, setDescription] = useState('');
  const [twitter, setTwitter] = useState('');
  const [thumbnail] = useState(null);
  const { formatMessage: f } = useIntl();
  const toggle = () =&gt; toggleModal(!isOpen);
  const [createPerson] = useMutation(CREATE_PERSON);
  const onCompleted = () =&gt; {
    toggle();
    setPersonName('');
    setPersonNameKanji('');
    setDescription('');
    setTwitter('');
  };
  const isIncomplete = !personName;

  return (
    
      
        {f({ id: 'create_person', defaultMessage: 'Create Person' })}
github mirumee / saleor-dashboard / src / plugins / components / PluginAuthorization / PluginAuthorization.tsx View on Github external
const PluginAuthorization: React.FC = props =&gt; {
  const { fields, onClear, onEdit } = props;

  const classes = useStyles(props);
  const intl = useIntl();

  const secretFields = fields.filter(field =&gt;
    isSecretField(fields, field.name)
  );

  return (
    
      
      
        {secretFields.map((field, fieldIndex) =&gt; (
github mirumee / saleor-dashboard / src / hooks / makeMutation.ts View on Github external
function useMutation({
    onCompleted,
    onError
  }: UseMutationCbs): UseMutation {
    const notify = useNotifier();
    const intl = useIntl();
    const [mutateFn, result] = useBaseMutation(mutation, {
      onCompleted,
      onError: (err: ApolloError) =&gt; {
        if (
          maybe(
            () =&gt;
              err.graphQLErrors[0].extensions.exception.code ===
              "ReadOnlyException"
          )
        ) {
          notify({
            text: intl.formatMessage(commonMessages.readOnly)
          });
        } else {
          notify({
            text: intl.formatMessage(commonMessages.somethingWentWrong)