import React, {useEffect, useState} from 'react'; const { __ } = wp.i18n; export function SearchDropdown( props ) { const [searchResultsFieldStatus, setSearchResultsFieldStatus] = useState( 'closed' ); const [textareaValue, setTextareaValue] = useState( '' ); const [dropdownMarkup, setDropdownMarkup] = useState( '' ); const [reset, setReset] = useState( false ); let searchResultsItems = []; /** * Sets the dropdown content when there's a change on any of props.searchResults, props.showDefaultMessage, props.showNoResultsMessage */ useEffect(() => { if ( props.searchResults ) { searchResultsItems = props.searchResults; } else { searchResultsItems = []; } if ( ! props.showDefaultMessage && ! props.showNoResultsMessage ) { setDropdownMarkup( printItems() ); } else { setDropdownMarkup( dropdownContent() ); } }, [props.searchResults, props.showDefaultMessage, props.showNoResultsMessage], reset); /** * Initially sets the dropdown content to the default message. */ useEffect( () => { setDropdownMarkup( getDefaultMessage() ); }, [] ); /** * On dropdown container focus, the textarea gets focused so user can start typing immediately. * @param el */ const handleSearchDropdownFocus = ( el ) => { if ( 'closed' === searchResultsFieldStatus ) { const textarea = el.currentTarget.querySelector( 'textarea' ); if ( 'undefined' !== typeof textarea && textarea !== null ) { textarea.tabIndex = '-1'; textarea.focus(); } } } const handleSearchDropdownClick = ( el ) => { } /** * On keydown sets the value of textarea. * @param el */ const handleSearchDropdownKeyDown = ( el ) => { setTextareaValue( el.currentTarget.value ) setSearchResultsFieldStatus( 'open' ); } /** * Expands results area upon textarea focus. * @param el */ const handleTextareaFocus = ( el ) => { setSearchResultsFieldStatus( 'open' ); } const handleSearchDropdownBlur = ( el ) => { const blurTimer = setInterval(function() { const resultsWrapperId = `sui-select-dropdown-wrap-${props.id}`, textareaId = `search-dropdown-textbox-${props.id}`, rendererWrapId = `blc-search-dropdown__renderer_wrap-${props.id}`; if ( resultsWrapperId !== document.activeElement.id && textareaId !== document.activeElement.id && rendererWrapId !== document.activeElement.id ) { setSearchResultsFieldStatus( 'closed' ); setTextareaValue( '' ); } clearInterval( blurTimer ); }, 160); } const handleResultsContainerClick = ( el ) => { el.currentTarget.tabIndex = '-1'; el.currentTarget.focus(); } const clearDropdown = () => { setSearchResultsFieldStatus( 'closed' ); setTextareaValue( '' ); //props.searchResults = []; setDropdownMarkup( ''); //props.showDefaultMessage = true; //props.showNoResultsMessage = false; setDropdownMarkup( getDefaultMessage() ); setReset( true ) } const printItems = () => { if ( typeof searchResultsItems !== 'undefined' && searchResultsItems.length > 0 ) { return ( searchResultsItems.map( (listItem) => ( ( typeof listItem !== 'undefined' && listItem.hasOwnProperty( 'key' ) ) &&
  • { listItem.onClick(); clearDropdown(); } } > {listItem.display}
  • ) ) ) } } const getDefaultMessage = () => { return
  • {props.defaultMessage}
  • ; } const dropdownContent = () => { if ( props.showDefaultMessage && props.defaultMessage ) { return getDefaultMessage(); } else if ( props.showNoResultsMessage && props.noResultsMessage ) { return
  • {props.noResultsMessage}
  • ; } return printItems(); } return(
    { handleSearchDropdownFocus(e) }} onClick={(e)=> { handleSearchDropdownClick(e) }} onKeyDown={(e)=> { handleSearchDropdownKeyDown(e) }} onBlur={(e)=> { handleSearchDropdownBlur(e) }} >
    { handleResultsContainerClick(e) }} >
      {dropdownMarkup}
    ) }
    {"id":508,"date":"2024-04-08T08:00:00","date_gmt":"2024-04-08T11:00:00","guid":{"rendered":"https:\/\/automax.net.br\/?p=508"},"modified":"2024-03-25T11:19:13","modified_gmt":"2024-03-25T14:19:13","slug":"o-melhor-sistema-para-gestao-de-oficinas-inovacao-e-eficiencia-ao-seu-alcance","status":"publish","type":"post","link":"https:\/\/automax.net.br\/o-melhor-sistema-para-gestao-de-oficinas-inovacao-e-eficiencia-ao-seu-alcance\/","title":{"rendered":"O Melhor Sistema para Gest\u00e3o de Oficinas: Inova\u00e7\u00e3o e Efici\u00eancia ao Seu Alcance"},"content":{"rendered":"\n

    O gerenciamento eficiente de uma oficina mec\u00e2nica \u00e9 um desafio que demanda um sistema de gest\u00e3o robusto e adapt\u00e1vel.<\/p>\n\n\n\n

    No cora\u00e7\u00e3o desta opera\u00e7\u00e3o est\u00e1 a necessidade de um “Sistema de Gest\u00e3o de Oficinas” e um eficaz “RP (Registro de Performance) de Oficina”, que juntos, s\u00e3o cruciais para otimizar o desempenho e garantir a satisfa\u00e7\u00e3o do cliente.<\/p>\n\n\n\n

    A Import\u00e2ncia de um Sistema de Gest\u00e3o de Oficinas Eficaz:<\/strong><\/p>\n\n\n\n

    Um sistema de gest\u00e3o de oficinas \u00e9 mais do que apenas um software; \u00e9 uma ferramenta integrada que abrange todos os aspectos operacionais, desde o agendamento de servi\u00e7os at\u00e9 a gest\u00e3o de invent\u00e1rio e an\u00e1lises financeiras.<\/p>\n\n\n\n

    Esses sistemas proporcionam automa\u00e7\u00e3o, reduzem erros humanos e aumentam a efici\u00eancia.<\/p>\n\n\n\n

    Caracter\u00edsticas de um Sistema de Gest\u00e3o Ideal:<\/strong><\/p>\n\n\n\n