muitas melhorias e novas funcionalidades

This commit is contained in:
Rodrigo Borba 2026-01-12 19:24:57 -03:00
parent 459a63528c
commit 06fb628248
6 changed files with 71 additions and 10 deletions

View File

@ -22,6 +22,9 @@ const submissionStatus = ref({
const appConfig = reactive({
title: 'Reserva Premium',
subtitle: 'Hotel 1001 Noites Prime',
phone_number: '',
primary_color: '#1E90FF',
secondary_color: '#1B3B5F',
});
const formData = reactive({
@ -69,6 +72,16 @@ const fetchMasterData = async () => {
brands.value = data.brands;
pricings.value = data.pricings;
extras.value = data.extras;
if (data.app_config) {
appConfig.title = data.app_config.title || appConfig.title;
appConfig.subtitle = data.app_config.subtitle || appConfig.subtitle;
appConfig.phone_number = data.app_config.phone_number || '';
appConfig.primary_color =
data.app_config.primary_color || appConfig.primary_color;
appConfig.secondary_color =
data.app_config.secondary_color || appConfig.secondary_color;
}
} catch (error) {
// console.error("Master Data Error:", error);
} finally {
@ -457,7 +470,7 @@ const viewTitle = computed(() => {
<!-- eslint-disable vue/no-bare-strings-in-template, vue/no-static-inline-styles -->
<div
class="min-h-screen py-6 px-4 sm:px-6 lg:px-8 flex flex-col items-center justify-center bg-fixed"
style="background: linear-gradient(135deg, #0a1a2f 0%, #1b3b5f 100%)"
:style="`background: linear-gradient(135deg, ${appConfig.secondary_color} 0%, ${appConfig.primary_color} 100%)`"
>
<div
class="w-full max-w-3xl bg-white rounded-[2rem] shadow-2xl overflow-hidden border border-white/10 relative"
@ -483,6 +496,13 @@ const viewTitle = computed(() => {
>
{{ appConfig.subtitle }}
</p>
<p
v-if="appConfig.phone_number"
class="text-sm font-bold text-emerald-600 mt-2"
>
<i class="i-lucide-phone mr-1" />
Suporte: {{ appConfig.phone_number }}
</p>
</div>
</div>

View File

@ -11,8 +11,8 @@ const route = useRoute();
const accountId = route.params.accountId;
const formData = ref({
page_title: '',
page_subtitle: '',
title: '',
subtitle: '',
primary_color: '#00af9e',
phone_number: '',
});
@ -24,8 +24,8 @@ const fetchConfig = async () => {
`/api/v1/accounts/${accountId}/captain/configuration`
);
formData.value = {
page_title: data.page_title || '',
page_subtitle: data.page_subtitle || '',
title: data.title || '',
subtitle: data.subtitle || '',
primary_color: data.primary_color || '#00af9e',
phone_number: data.phone_number || '',
};
@ -41,7 +41,7 @@ const saveConfig = async () => {
try {
await window.axios.put(
`/api/v1/accounts/${accountId}/captain/configuration`,
formData.value
{ configuration: formData.value }
);
useAlert('Configurações salvas!');
} catch (error) {
@ -78,7 +78,7 @@ onMounted(fetchConfig);
Título da Página
</label>
<input
v-model="formData.page_title"
v-model="formData.title"
type="text"
class="w-full px-3 py-2 border rounded-md dark:bg-slate-900 border-slate-200 dark:border-slate-700"
placeholder="Ex: Reservas Hotel Prime"
@ -92,7 +92,7 @@ onMounted(fetchConfig);
Subtítulo
</label>
<input
v-model="formData.page_subtitle"
v-model="formData.subtitle"
type="text"
class="w-full px-3 py-2 border rounded-md dark:bg-slate-900 border-slate-200 dark:border-slate-700"
placeholder="Ex: As melhores suítes da região"

View File

@ -0,0 +1,5 @@
class AddPhoneNumberToCaptainConfigurations < ActiveRecord::Migration[7.1]
def change
add_column :captain_configurations, :phone_number, :string
end
end

View File

@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema[7.1].define(version: 2026_01_14_101013) do
ActiveRecord::Schema[7.1].define(version: 2026_01_14_101014) do
# These extensions should be enabled to support this database
enable_extension "pg_stat_statements"
enable_extension "pg_trgm"
@ -357,6 +357,7 @@ ActiveRecord::Schema[7.1].define(version: 2026_01_14_101013) do
t.boolean "active", default: true
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "phone_number"
t.index ["account_id"], name: "index_captain_configurations_on_account_id"
end

View File

@ -25,7 +25,7 @@ module Api
end
def config_params
params.require(:configuration).permit(:title, :subtitle, :primary_color, :secondary_color, :active, :logo_url)
params.require(:configuration).permit(:title, :subtitle, :primary_color, :secondary_color, :active, :logo_url, :phone_number)
end
end
end

View File

@ -0,0 +1,35 @@
# Fix Public Page Configuration
## Objective
Ensure that "General Settings" in the Dashboard (Page Title, Subtitle, Phone, Primary Color) are correctly reflected in the Public Booking Page (`CaptainBooking`).
## Context
The user reported that changing settings in the dashboard had no effect on the public page. The public page was using hardcoded values.
## Steps Taken
1. **Backend**:
- Identified that `phone_number` column was missing in `captain_configurations` table.
- Created migration `AddPhoneNumberToCaptainConfigurations`.
- Updated `Api::V1::Accounts::Captain::ConfigurationsController` to permit `phone_number` param.
- Verified `Public::Api::V1::Captain::MasterDataController` returns the `captain_configuration` data.
2. **Frontend (`App.vue`)**:
- Updated `fetchMasterData` to consume `app_config` from the API response.
- Made `appConfig` reactive to the fetched data (`title`, `subtitle`, `phone_number`, `primary_color`, `secondary_color`).
- Added dynamic background gradient using `primary_color` and `secondary_color`.
- Added "Suporte: [Phone]" display in the header/subtitle area if a phone number is set.
## Files Changed
- `db/migrate/20260114101014_add_phone_number_to_captain_configurations.rb` (New)
- `enterprise/app/controllers/api/v1/accounts/captain/configurations_controller.rb`
- `app/javascript/captain_booking/App.vue`
## Validation
- Dashboard UI (`configurations/Index.vue`) already supported sending `phone_number`.
- `App.vue` now dynamically updates its UI based on the API response.