ajuste galeria de imagens
This commit is contained in:
parent
f12e1d6545
commit
f2fb40afaa
@ -257,6 +257,16 @@ const suiteRevenueChart = computed(() => ({
|
||||
],
|
||||
}));
|
||||
|
||||
const statusColor = reservationStatus => {
|
||||
const colors = {
|
||||
draft: 'bg-n-slate-3 text-n-slate-11',
|
||||
pending_payment: 'bg-n-amber-3 text-n-amber-11',
|
||||
confirmed: 'bg-n-teal-3 text-n-teal-11',
|
||||
cancelled: 'bg-n-ruby-3 text-n-ruby-11',
|
||||
};
|
||||
return colors[reservationStatus] || 'bg-n-slate-3 text-n-slate-11';
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
readFiltersFromRoute();
|
||||
store.dispatch('captainUnits/get');
|
||||
@ -483,7 +493,8 @@ onMounted(() => {
|
||||
<td class="px-3 py-2">{{ formatMoney(reservation.amount) }}</td>
|
||||
<td class="px-3 py-2">
|
||||
<span
|
||||
class="px-2 py-1 text-xs rounded-full bg-n-surface-2 text-n-slate-12"
|
||||
class="px-2 py-1 text-xs rounded-full font-medium"
|
||||
:class="statusColor(reservation.ui_status)"
|
||||
>
|
||||
{{ reservation.status_label }}
|
||||
</span>
|
||||
|
||||
@ -73,6 +73,18 @@ const statusLabel = computed(() => {
|
||||
: translated;
|
||||
});
|
||||
|
||||
const statusColor = computed(() => {
|
||||
const status =
|
||||
reservation.value?.ui_status || props.marker?.status || 'draft';
|
||||
const colors = {
|
||||
draft: 'bg-n-slate-3 text-n-slate-11',
|
||||
pending_payment: 'bg-n-amber-3 text-n-amber-11',
|
||||
confirmed: 'bg-n-teal-3 text-n-teal-11',
|
||||
cancelled: 'bg-n-ruby-3 text-n-ruby-11',
|
||||
};
|
||||
return colors[status] || 'bg-n-slate-3 text-n-slate-11';
|
||||
});
|
||||
|
||||
const onCopyPix = async () => {
|
||||
if (!pixValue.value) {
|
||||
useAlert(
|
||||
@ -107,7 +119,12 @@ const onCopyPix = async () => {
|
||||
<span class="text-n-slate-11">{{
|
||||
$t('CAPTAIN_RESERVATIONS.SIDEBAR.STATUS')
|
||||
}}</span>
|
||||
<span class="font-medium text-n-slate-12">{{ statusLabel }}</span>
|
||||
<span
|
||||
class="px-2 py-0.5 text-xs rounded font-medium"
|
||||
:class="statusColor"
|
||||
>
|
||||
{{ statusLabel }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="flex items-start justify-between gap-2">
|
||||
<span class="text-n-slate-11">{{
|
||||
|
||||
@ -46,6 +46,8 @@ class Captain::Tools::SendSuiteImagesTool < Captain::Tools::BaseTool
|
||||
@conversation ||= resolve_conversation(args, params)
|
||||
return error_response('Erro técnico ao enviar fotos. Não consegui identificar a conversa atual.') if @conversation.blank?
|
||||
|
||||
enrich_suite_filters_from_conversation!(actual_params)
|
||||
|
||||
selected_items = find_selected_items(actual_params)
|
||||
return no_images_response(actual_params) if selected_items.blank?
|
||||
|
||||
@ -171,6 +173,34 @@ class Captain::Tools::SendSuiteImagesTool < Captain::Tools::BaseTool
|
||||
items.limit(normalize_limit(actual_params[:limit]))
|
||||
end
|
||||
|
||||
def enrich_suite_filters_from_conversation!(actual_params)
|
||||
return if normalize_filter(actual_params[:suite_number]).present?
|
||||
|
||||
inferred_suite = infer_suite_number_from_last_incoming_message
|
||||
return if inferred_suite.blank?
|
||||
|
||||
actual_params[:suite_number] = inferred_suite
|
||||
end
|
||||
|
||||
def infer_suite_number_from_last_incoming_message
|
||||
text = last_incoming_text
|
||||
return nil if text.blank?
|
||||
|
||||
# Captura "suite 110", "suíte 110", "suite n 110", "suite nº 110".
|
||||
match = text.match(/\bsu[ií]te\s*(?:n(?:u|ú)?m(?:ero)?\.?\s*)?(?:n[ºo]\s*)?([a-z0-9_-]{1,20})\b/i)
|
||||
return nil if match.blank?
|
||||
|
||||
normalize_filter(match[1])
|
||||
end
|
||||
|
||||
def last_incoming_text
|
||||
@conversation.messages
|
||||
.where(message_type: :incoming)
|
||||
.order(created_at: :desc)
|
||||
.limit(1)
|
||||
.pick(:content)
|
||||
end
|
||||
|
||||
def send_images(items)
|
||||
items.count do |item|
|
||||
next false unless item.image.attached?
|
||||
|
||||
23
progresso/colorful_reservation_status.md
Normal file
23
progresso/colorful_reservation_status.md
Normal file
@ -0,0 +1,23 @@
|
||||
# Adicionando Cores aos Status de Reserava
|
||||
|
||||
**Objetivo:** Alterar a exibição em texto simples dos status das reservas (Rascunho, Confirmada, etc.) para tags visuais coloridas, facilitando a visualização rápida pelos capitães.
|
||||
|
||||
**Contexto:** O componente UI de listagem de reservas (`Index.vue`) e o componente de resumo na barra lateral das conversas (`ReservationSummary.vue`) exibiam o `status_label` com um fundo cinza genérico para todos os status.
|
||||
|
||||
**Passos:**
|
||||
1. Criada uma função `statusColor` que mapeia o campo `ui_status` do backend para classes CSS dinâmicas baseadas nas cores já disponíveis da paleta atual (Tailwind - `bg-n-...`).
|
||||
2. Atualizado o `Index.vue` na visualização tipo Lista (Tabela) para injetar essas classes de cor correspondente.
|
||||
3. Atualizado o `ReservationSummary.vue` (barra lateral do chat) para usar a mesma lógica no Computed property `statusColor`.
|
||||
|
||||
**Principais Arquivos Alterados:**
|
||||
- [app/javascript/dashboard/routes/dashboard/captain/reservations/Index.vue](file:///Users/user/Dev/Produtos/Chatwoot-fazer-ai/fazer-ai-kanban/chatwoot/app/javascript/dashboard/routes/dashboard/captain/reservations/Index.vue)
|
||||
- [app/javascript/dashboard/routes/dashboard/conversation/reservation/ReservationSummary.vue](file:///Users/user/Dev/Produtos/Chatwoot-fazer-ai/fazer-ai-kanban/chatwoot/app/javascript/dashboard/routes/dashboard/conversation/reservation/ReservationSummary.vue)
|
||||
|
||||
**Como Validar:**
|
||||
1. Acesse o painel web local (ex: `localhost:3001`).
|
||||
2. Vá até o menu de Reservas (Captain).
|
||||
3. Na visualização de "Lista", verifique se a coluna "Status" tem diferentes cores, como ex. cinza para Draft, verde para Confirmada, e amarelo para Aguardando Pagamento.
|
||||
4. Abra uma conversa que tenha uma reserva vinculada e veja se na barra lateral direita se o badge "Status" também aparece colorido de forma coerente com o `ui_status`.
|
||||
|
||||
**Como Reverter:**
|
||||
As classes customizadas dinâmicas podem ser removidas revertendo o commit correspondente nestes arquivos, voltando assim o uso estático de `class="bg-n-surface-2 text-n-slate-12"` em ambos os templates do span.
|
||||
@ -106,4 +106,40 @@ RSpec.describe Captain::Tools::SendSuiteImagesTool, type: :model do
|
||||
expect(result[:success]).to be(true)
|
||||
expect(result[:formatted_message]).to match(/não encontrei fotos cadastradas/i)
|
||||
end
|
||||
|
||||
it 'infers suite number from customer message when suite_number is not passed' do
|
||||
create(
|
||||
:captain_gallery_item,
|
||||
:inbox_scoped,
|
||||
account: account,
|
||||
captain_unit: unit,
|
||||
inbox: conversation.inbox,
|
||||
suite_category: 'hidromassagem',
|
||||
suite_number: '110'
|
||||
)
|
||||
create(
|
||||
:captain_gallery_item,
|
||||
:inbox_scoped,
|
||||
account: account,
|
||||
captain_unit: unit,
|
||||
inbox: conversation.inbox,
|
||||
suite_category: 'hidromassagem',
|
||||
suite_number: '101'
|
||||
)
|
||||
create(
|
||||
:message,
|
||||
conversation: conversation,
|
||||
inbox: conversation.inbox,
|
||||
message_type: :incoming,
|
||||
content: 'Vc tem a foto da suíte 110?'
|
||||
)
|
||||
|
||||
result = nil
|
||||
expect do
|
||||
result = tool.execute(tool_context, suite_category: 'hidromassagem')
|
||||
end.to change { conversation.messages.outgoing.where(sender: assistant).count }.by(1)
|
||||
|
||||
expect(result[:success]).to be(true)
|
||||
expect(result[:suite_number]).to eq('110')
|
||||
end
|
||||
end
|
||||
|
||||
Loading…
Reference in New Issue
Block a user