From 19e67924cdb75b45f2fc4e6526575459cae4e4f0 Mon Sep 17 00:00:00 2001 From: Pedro Gomes Date: Sun, 27 Oct 2024 10:22:10 -0300 Subject: [PATCH] :bug: fix: Supervisor Added And Collaborators, And Manager Service --- .../SupervisorAdded/index.tsx | 43 ++++++++++++------- .../SupervisorAdded/styles.ts | 21 ++++++++- src/screens/EvaluateVisit/index.tsx | 8 +++- src/screens/EvaluateVisit/styles.ts | 7 ++- src/services/SupervisorServices.ts | 31 ++++++++++--- 5 files changed, 84 insertions(+), 26 deletions(-) diff --git a/src/screens/AddCollaborators/SupervisorAdded/index.tsx b/src/screens/AddCollaborators/SupervisorAdded/index.tsx index 5d97ba3..a7e7159 100644 --- a/src/screens/AddCollaborators/SupervisorAdded/index.tsx +++ b/src/screens/AddCollaborators/SupervisorAdded/index.tsx @@ -29,6 +29,7 @@ const SupervisorAdded: React.FC = () => { const { data, setData } = useDataContext(); const [loading, setLoading] = useState(false); const { user } = useAuth(); + const [showPassword, setShowPassword] = useState(false); const [name, setName] = useState(''); const [email, setEmail] = useState(''); const [password, setPassword] = useState(''); @@ -36,7 +37,6 @@ const SupervisorAdded: React.FC = () => { const [selectedManager, setSelectedManager] = useState(null); const [isButtonEnabled, setIsButtonEnabled] = useState(false); const toast = useToast(); - const [selectedValue, setSelectedValue] = useState(''); const [isModalVisible, setIsModalVisible] = useState(false); const options = [ @@ -70,14 +70,10 @@ const SupervisorAdded: React.FC = () => { setIsModalVisible(!isModalVisible); }; - const handleSelectChange = (value: string) => { - setSelectedValue(value); - }; - const handleCreate = async () => { try { setLoading(true); - const managerId = selectedManager?.id || undefined; + const managerId = selectedManager?.id || ''; const companyId = user.companyId; const supervisor: Supervisor = await SupervisorServices.create({ @@ -111,6 +107,7 @@ const SupervisorAdded: React.FC = () => { duration: 3000, animationType: 'zoom-in', }); + console.log('Erro ao criar supervisor:', error); } finally { setLoading(false); setIsModalVisible(false); @@ -118,7 +115,11 @@ const SupervisorAdded: React.FC = () => { } }; - const isCreateDisabled = !name || !selectedValue || !selectedManager; + const toggleShowPassword = () => { + setShowPassword(!showPassword); + }; + + const isCreateDisabled = !name || !selectedManager; return ( { Senha - setPassword(text)} - /> + + setPassword(text)} + /> + + + + Responsável @@ -177,7 +190,7 @@ const SupervisorAdded: React.FC = () => { source={require('@assets/img/Triangle_Warning.png')} /> - Tem certeza que deseja adicionar esse vendedor? + Tem certeza que deseja adicionar esse Supervisor? diff --git a/src/screens/AddCollaborators/SupervisorAdded/styles.ts b/src/screens/AddCollaborators/SupervisorAdded/styles.ts index e3b68ba..b6b9e35 100644 --- a/src/screens/AddCollaborators/SupervisorAdded/styles.ts +++ b/src/screens/AddCollaborators/SupervisorAdded/styles.ts @@ -11,7 +11,7 @@ import { theme } from '@styles/default.theme'; export const Wrapper = styled(View)` width: 100%; - height: 80%; + height: 630px; align-items: center; overflow: hidden; background-color: ${theme.colors.primary.main}; @@ -38,10 +38,29 @@ export const NameField = styled(Text)` letter-spacing: 0.5px; `; +export const DivViewTextInput = styled(View)` + display: flex; + flex-direction: row; + align-items: center; +`; + +export const BtnIconPass = styled(TouchableOpacity)` + width: 16px; + height: 16px; + position: absolute; + right: 10px; +`; + +export const Icon = styled(Image)` + width: 16px; + height: 16px; +`; + export const InputField = styled(TextInput)` ::placeholder { color: #687076; } + width: 100%; border-width: 1px; border-color: #d7dbdf; background-color: #f1f3f5; diff --git a/src/screens/EvaluateVisit/index.tsx b/src/screens/EvaluateVisit/index.tsx index f6b04b7..5a1250c 100644 --- a/src/screens/EvaluateVisit/index.tsx +++ b/src/screens/EvaluateVisit/index.tsx @@ -324,8 +324,12 @@ const EvaluateVisit = () => { {indexScreen === categories.length && categories.length !== 0 && ( <> - - Ver Resumo do dia de visita + + {loading ? ( + + ) : ( + Ver Resumo do dia de visita + )} Iniciar nova visita diff --git a/src/screens/EvaluateVisit/styles.ts b/src/screens/EvaluateVisit/styles.ts index 0c0f84e..47d31c3 100644 --- a/src/screens/EvaluateVisit/styles.ts +++ b/src/screens/EvaluateVisit/styles.ts @@ -124,7 +124,12 @@ export const ButtonFirst = styled(TouchableOpacity)` margin-top: 80%; `; -export const ButtonIniciar = styled(TouchableOpacity)` +export const ButtonIniciar = styled(TouchableOpacity)<{ disabled: boolean }>` + pointer-events: ${({ disabled }) => (disabled ? 'none' : 'auto')}; + background-color: ${({ disabled }) => (disabled ? '#B0B0B0' : '#3e63dd')}; + + opacity: ${({ disabled }) => (disabled ? 0.5 : 1)}; + padding: 8px 24px; background-color: #3e63dd; width: 90%; diff --git a/src/services/SupervisorServices.ts b/src/services/SupervisorServices.ts index 60640c6..51ad97d 100644 --- a/src/services/SupervisorServices.ts +++ b/src/services/SupervisorServices.ts @@ -1,14 +1,31 @@ import api from './api'; import ISupervisor from '@interfaces/Supervisor'; +interface ICreateSupervisorResponse { + email: string; + image: string; + password: string; + name: string; + companyId: string; + managerId: string; +} export default class SupervisorServices { - static async create( - newSupervisor: Partial - ): Promise { - const supervisorResponse = await api.post( - '/supervisor/create', - newSupervisor - ); + static async create({ + email, + companyId, + image, + managerId, + name, + password, + }: ICreateSupervisorResponse): Promise { + const supervisorResponse = await api.post('/supervisor/create', { + email, + companyId, + image, + managerId, + name, + password, + }); return supervisorResponse.data; } static async getSupervisorById(