feat: (eventos) vincula dropdown com api
This commit is contained in:
parent
f7e79f3673
commit
ee4f530bb1
2 changed files with 34 additions and 33 deletions
|
|
@ -26,7 +26,7 @@ import { useData } from "../contexts/DataContext";
|
|||
import { UserRole } from "../types";
|
||||
import { InstitutionForm } from "./InstitutionForm";
|
||||
import { MapboxMap } from "./MapboxMap";
|
||||
import { getEventTypes } from "../services/apiService";
|
||||
import { getEventTypes, EventTypeResponse } from "../services/apiService";
|
||||
|
||||
interface EventFormProps {
|
||||
onCancel: () => void;
|
||||
|
|
@ -56,7 +56,7 @@ export const EventForm: React.FC<EventFormProps> = ({
|
|||
const [showToast, setShowToast] = useState(false);
|
||||
const [showInstitutionForm, setShowInstitutionForm] = useState(false);
|
||||
const [availableCourses, setAvailableCourses] = useState<any[]>([]);
|
||||
const [eventTypes, setEventTypes] = useState<string[]>([]);
|
||||
const [eventTypes, setEventTypes] = useState<EventTypeResponse[]>([]);
|
||||
const [isBackendDown, setIsBackendDown] = useState(false);
|
||||
const [isLoadingEventTypes, setIsLoadingEventTypes] = useState(true);
|
||||
|
||||
|
|
@ -342,13 +342,11 @@ export const EventForm: React.FC<EventFormProps> = ({
|
|||
{["details", "location", "briefing", "files"].map((tab, idx) => (
|
||||
<div
|
||||
key={tab}
|
||||
className={`flex flex-col items-center ${
|
||||
activeTab === tab ? "opacity-100" : "opacity-40"
|
||||
className={`flex flex-col items-center ${activeTab === tab ? "opacity-100" : "opacity-40"
|
||||
}`}
|
||||
>
|
||||
<span
|
||||
className={`w-7 h-7 sm:w-8 sm:h-8 rounded-full flex items-center justify-center text-xs font-bold mb-1 ${
|
||||
activeTab === tab
|
||||
className={`w-7 h-7 sm:w-8 sm:h-8 rounded-full flex items-center justify-center text-xs font-bold mb-1 ${activeTab === tab
|
||||
? "bg-[#492E61] text-white"
|
||||
: "bg-gray-200 text-gray-600"
|
||||
}`}
|
||||
|
|
@ -377,8 +375,7 @@ export const EventForm: React.FC<EventFormProps> = ({
|
|||
<button
|
||||
key={item.id}
|
||||
onClick={() => setActiveTab(item.id as any)}
|
||||
className={`flex-1 px-4 py-3 text-xs sm:text-sm font-medium transition-colors border-b-2 whitespace-nowrap ${
|
||||
activeTab === item.id
|
||||
className={`flex-1 px-4 py-3 text-xs sm:text-sm font-medium transition-colors border-b-2 whitespace-nowrap ${activeTab === item.id
|
||||
? "text-brand-gold border-brand-gold bg-brand-gold/5"
|
||||
: "text-gray-500 border-transparent hover:bg-gray-50"
|
||||
}`}
|
||||
|
|
@ -411,8 +408,7 @@ export const EventForm: React.FC<EventFormProps> = ({
|
|||
<button
|
||||
key={item.id}
|
||||
onClick={() => setActiveTab(item.id as any)}
|
||||
className={`w-full text-left px-4 py-3 rounded-sm text-sm font-medium transition-colors ${
|
||||
activeTab === item.id
|
||||
className={`w-full text-left px-4 py-3 rounded-sm text-sm font-medium transition-colors ${activeTab === item.id
|
||||
? "bg-white shadow-sm text-brand-gold border-l-4 border-brand-gold"
|
||||
: "text-gray-500 hover:bg-gray-100"
|
||||
}`}
|
||||
|
|
@ -478,8 +474,8 @@ export const EventForm: React.FC<EventFormProps> = ({
|
|||
>
|
||||
<option value="">Selecione o tipo de evento</option>
|
||||
{eventTypes.map((type) => (
|
||||
<option key={type} value={type}>
|
||||
{type}
|
||||
<option key={type.id} value={type.nome}>
|
||||
{type.nome}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
|
|
@ -888,8 +884,7 @@ export const EventForm: React.FC<EventFormProps> = ({
|
|||
/>
|
||||
<button
|
||||
onClick={() => removeContact(idx)}
|
||||
className={`mt-1 p-2 text-gray-400 hover:text-red-500 ${
|
||||
idx === 0 ? "mt-7" : ""
|
||||
className={`mt-1 p-2 text-gray-400 hover:text-red-500 ${idx === 0 ? "mt-7" : ""
|
||||
}`}
|
||||
>
|
||||
<X size={16} />
|
||||
|
|
|
|||
|
|
@ -46,11 +46,17 @@ export async function getProfessionalRoles(): Promise<ApiResponse<string[]>> {
|
|||
return fetchFromBackend<string[]>('/professional-roles');
|
||||
}
|
||||
|
||||
export interface EventTypeResponse {
|
||||
id: string;
|
||||
nome: string;
|
||||
precos: any[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Busca os tipos de eventos disponíveis
|
||||
*/
|
||||
export async function getEventTypes(): Promise<ApiResponse<string[]>> {
|
||||
return fetchFromBackend<string[]>('/event-types');
|
||||
export async function getEventTypes(): Promise<ApiResponse<EventTypeResponse[]>> {
|
||||
return fetchFromBackend<EventTypeResponse[]>('/api/tipos-eventos');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in a new issue