diff --git a/app/controllers/api/v1/accounts/landing_hosts_controller.rb b/app/controllers/api/v1/accounts/landing_hosts_controller.rb index 5c7343cec..4539c3b40 100644 --- a/app/controllers/api/v1/accounts/landing_hosts_controller.rb +++ b/app/controllers/api/v1/accounts/landing_hosts_controller.rb @@ -1,6 +1,6 @@ class Api::V1::Accounts::LandingHostsController < Api::V1::Accounts::BaseController before_action :fetch_inbox, only: [:index, :create] - before_action :fetch_landing_host, only: [:destroy] + before_action :fetch_landing_host, only: [:update, :destroy] def index @landing_hosts = LandingHost.where(inbox_id: @inbox.id) @@ -17,6 +17,14 @@ class Api::V1::Accounts::LandingHostsController < Api::V1::Accounts::BaseControl end end + def update + if @landing_host.update(landing_host_params) + render json: @landing_host + else + render json: { error: @landing_host.errors.full_messages }, status: :unprocessable_entity + end + end + def destroy @landing_host.destroy! head :no_content @@ -31,7 +39,7 @@ class Api::V1::Accounts::LandingHostsController < Api::V1::Accounts::BaseControl end def fetch_landing_host - # Garantimos que a pessoa só possa apagar LandingHosts de Inboxes que pertencem a ela + # Garantimos que a pessoa só possa acessar/apagar LandingHosts de Inboxes que pertencem a ela valid_inbox_ids = Current.account.inboxes.pluck(:id) @landing_host = LandingHost.where(inbox_id: valid_inbox_ids).find(params[:id]) rescue ActiveRecord::RecordNotFound @@ -39,6 +47,11 @@ class Api::V1::Accounts::LandingHostsController < Api::V1::Accounts::BaseControl end def landing_host_params - params.require(:landing_host).permit(:hostname, :unit_code, :active, :auto_label) + params.require(:landing_host).permit( + :hostname, :unit_code, :active, :auto_label, + :page_title, :page_subtitle, :button_text, :logo_url, + :suite_image_url, :theme_color, :whatsapp_number, + :initial_message, :default_source, :default_campanha + ) end end diff --git a/app/controllers/public/landing_pages_controller.rb b/app/controllers/public/landing_pages_controller.rb index 32e21a338..cbae6bc03 100644 --- a/app/controllers/public/landing_pages_controller.rb +++ b/app/controllers/public/landing_pages_controller.rb @@ -1,5 +1,23 @@ class Public::LandingPagesController < PublicController layout false - def show; end + def show + host = request.host.to_s.sub(/^www\./, '') + @landing_host = LandingHost.find_by(hostname: host, active: true) + + # Fallback local para testes + return unless Rails.env.development? && @landing_host.nil? + + @landing_host = LandingHost.first || LandingHost.new( + page_title: 'Atendimento Express', + page_subtitle: 'Clique e fale direto com a recepcao agora', + whatsapp_number: '556136131003', + initial_message: 'Ola! Tenho interesse.', + theme_color: '#27c15b', + logo_url: 'https://iachat.hoteis1001noites.com.br/assets/images/dashboard/captain/logo.svg', + unit_code: 'express', + default_source: 'direto', + default_campanha: 'site' + ) + end end diff --git a/app/javascript/dashboard/api/landingHosts.js b/app/javascript/dashboard/api/landingHosts.js index 3895b78e1..86a5fa6f7 100644 --- a/app/javascript/dashboard/api/landingHosts.js +++ b/app/javascript/dashboard/api/landingHosts.js @@ -13,6 +13,12 @@ export default { { landing_host: data } ); }, + updateHost(accountId, inboxId, id, data) { + return axios.patch( + `/api/v1/accounts/${accountId}/inboxes/${inboxId}/landing_hosts/${id}`, + { landing_host: data } + ); + }, deleteHost(accountId, inboxId, id) { return axios.delete( `/api/v1/accounts/${accountId}/inboxes/${inboxId}/landing_hosts/${id}` diff --git a/app/javascript/dashboard/i18n/locale/pt_BR/captain.json b/app/javascript/dashboard/i18n/locale/pt_BR/captain.json index f0a51be2c..b454f61cb 100644 --- a/app/javascript/dashboard/i18n/locale/pt_BR/captain.json +++ b/app/javascript/dashboard/i18n/locale/pt_BR/captain.json @@ -234,7 +234,8 @@ "Ações" ], "ADD_NEW_ITEM": "Adicione fotos na galeria", - "NO_ITEMS_MESSAGE": "Ainda não há fotos cadastradas para envio automático aos clientes." + "NO_ITEMS_MESSAGE": "Ainda não há fotos cadastradas para envio automático aos clientes.", + "VIEW_URL": "URL da Imagem" }, "DELETE": { "CONFIRM": { @@ -274,14 +275,14 @@ "SPECIFIC_HELP": "Essas fotos serão usadas somente na caixa de entrada {inbox}." }, "SUITE_CATEGORY": { - "LABEL": "Categoria da suíte", + "LABEL": "Categoria", "PLACEHOLDER": "Ex: Hidromassagem", "ERROR": "A categoria é obrigatória" }, "SUITE_NUMBER": { - "LABEL": "Número/identificador da suíte", + "LABEL": "Nome/identificador", "PLACEHOLDER": "Ex: 101", - "ERROR": "O identificador da suíte é obrigatório" + "ERROR": "O identificador é obrigatório" }, "DESCRIPTION": { "LABEL": "Descrição da foto", @@ -337,7 +338,7 @@ "SELECT_INBOX_HINT": "Clique em uma caixa de entrada acima para ver e configurar os templates.", "EMPTY": { "TITLE": "Nenhum template configurado", - "DESC": "Crie templates de mensagem automática para esta caixa de entrada." + "DESC": "Configure as permissões das informações que o sistema utiliza. Por ex.: Quais imagens enviar durante as aproximações." } } }, diff --git a/app/javascript/dashboard/routes/dashboard/settings/captain/gallery/Index.vue b/app/javascript/dashboard/routes/dashboard/settings/captain/gallery/Index.vue index eb68c4295..6eb92ec35 100644 --- a/app/javascript/dashboard/routes/dashboard/settings/captain/gallery/Index.vue +++ b/app/javascript/dashboard/routes/dashboard/settings/captain/gallery/Index.vue @@ -98,11 +98,6 @@ const confirmDelete = async () => { > {{ t('CAPTAIN_SETTINGS.GALLERY.LIST.TABLE_HEADER[2]') }} -
+ {{ item.suite_category }} +
++ {{ item.suite_number }} +
+{{ @@ -131,13 +134,19 @@ const confirmDelete = async () => {
{{ item.description }}
+