Skip to content

Commit

Permalink
Modals Update
Browse files Browse the repository at this point in the history
  • Loading branch information
pedrogomes18 committed May 13, 2024
1 parent cc993ed commit b256d3a
Show file tree
Hide file tree
Showing 10 changed files with 54 additions and 54 deletions.
12 changes: 0 additions & 12 deletions src/components/ButtonAdded/index.tsx

This file was deleted.

24 changes: 0 additions & 24 deletions src/components/ButtonAdded/styles.ts

This file was deleted.

3 changes: 1 addition & 2 deletions src/components/FormsLogin/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,8 @@ const FormsLogin: React.FC = () => {
loading || isEnviarDisabled ? undefined : handleEnviarPress
}
disabled={loading || isEnviarDisabled}
style={{ opacity: buttonOpacity }} // Define a opacidade do botão
style={{ opacity: buttonOpacity }}
>
{/* Desabilita o botão quando o carregamento estiver ocorrendo ou algum dos campos estiver vazio */}
{loading ? (
<ActivityIndicator color="#fff" />
) : (
Expand Down
15 changes: 13 additions & 2 deletions src/components/HeaderMenu/index.tsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,27 @@
import * as S from './styles';
import React, { useState } from 'react';
import { useNavigation } from '@react-navigation/native';
import { ActivityIndicator } from 'react-native';
import Modal from 'react-native-modal';
import useAuth from '@hooks/useAuth';

const HeaderMenu: React.FC = () => {
const navigation = useNavigation();
const { user, logout } = useAuth();
const [isModalVisible, setIsModalVisible] = useState(false);
const [loading, setLoading] = useState(false);

const toggleModal = () => {
setIsModalVisible(!isModalVisible);
};

const handleClick = () => {
setLoading(!loading);
setTimeout(() => {
navigation.navigate('Login' as never);
logout();
}, 1000);
setLoading(!loading);
};

return (
Expand All @@ -32,8 +36,15 @@ const HeaderMenu: React.FC = () => {
<S.ImageWarning source={require('@assets/img/warnnign.png')} />
<S.TextModal>Deseja Sair?</S.TextModal>
</S.WrapperConteudo>
<S.BtnYes onPress={handleClick}>
<S.TitleBtnYes>Sim</S.TitleBtnYes>
<S.BtnYes
onPress={!loading ? handleClick : undefined}
disabled={loading}
>
{loading ? (
<ActivityIndicator color="#fff" />
) : (
<S.TitleBtnYes>Sim</S.TitleBtnYes>
)}
</S.BtnYes>
<S.BtnBack onPress={toggleModal}>
<S.TitleBtnBack>Não</S.TitleBtnBack>
Expand Down
4 changes: 2 additions & 2 deletions src/components/HeaderMenu/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export const TitleBtnYes = styled(Text)`
`;

export const BtnBack = styled(TouchableOpacity)`
border: 2px solid ${theme.colors.secundary.main};
border: 2px solid #e5484d;
border-radius: 8px;
padding: 16px;
display: flex;
Expand All @@ -96,7 +96,7 @@ export const BtnBack = styled(TouchableOpacity)`
`;

export const TitleBtnBack = styled(Text)`
color: ${theme.colors.secundary.main};
color: #e5484d;
font-family: PoppinsBold;
font-size: 14px;
text-transform: uppercase;
Expand Down
20 changes: 17 additions & 3 deletions src/screens/EvaluateMentoring/CompleteMentorship/index.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import React, { useState } from 'react';
import { StatusBar } from 'expo-status-bar';
import { theme } from '@styles/default.theme';
import * as S from './styles';
import { useRoute, RouteProp, useNavigation } from '@react-navigation/native';
import ModuleGradeServices from '@services/ModuleGradeService';
import DivGradient from '@components/DivGradient';
import HeaderPages from '@components/HeaderPages';
import ISeller from '@interfaces/Seller';
import { useToast } from 'react-native-toast-notifications';
import { ActivityIndicator } from 'react-native';
import DateTimePicker, {
DateTimePickerEvent,
} from '@react-native-community/datetimepicker';
Expand Down Expand Up @@ -34,6 +36,7 @@ const CompleteMentorship: React.FC = () => {
const toast = useToast();
const { data, setData } = useDataContext();
const navigation = useNavigation();
const [loading, setLoading] = useState(false);

const handleModuleChange = (value: string) => {
setSelectedValue(value);
Expand All @@ -54,12 +57,14 @@ const CompleteMentorship: React.FC = () => {

const handleComplete = async () => {
try {
setLoading(true);
await Promise.all(ModulesEvaluate.map(updateModuleGrade));

setData({
...data,
seller: Seller,
});
setLoading(false);
console.log('Módulos avaliados com sucesso');
showToast('Módulos avaliados com sucesso', 'success');
} catch (error) {
Expand Down Expand Up @@ -133,6 +138,7 @@ const CompleteMentorship: React.FC = () => {
setComment={setComment}
/>
<ButtonsSection
loading={loading}
handleComplete={handleComplete}
handleCompleteWithoutActionPlan={handleCompleteWithoutActionPlan}
/>
Expand Down Expand Up @@ -221,14 +227,22 @@ const InputsSection: React.FC<{
const ButtonsSection: React.FC<{
handleComplete: () => void;
handleCompleteWithoutActionPlan: () => void;
}> = ({ handleComplete, handleCompleteWithoutActionPlan }) => (
loading: boolean;
}> = ({ handleComplete, handleCompleteWithoutActionPlan, loading }) => (
<>
<S.BtnConcluirPlano onPress={handleCompleteWithoutActionPlan}>
<S.TextBtnPlano>CONCLUIR PLANO DE AÇÃO</S.TextBtnPlano>
</S.BtnConcluirPlano>

<S.BtnConcluirSemPlano onPress={handleComplete}>
<S.TextBtnSemPlano>FINALIZAR SEM PLANO</S.TextBtnSemPlano>
<S.BtnConcluirSemPlano
onPress={!loading ? handleComplete : undefined}
disabled={loading}
>
{loading ? (
<ActivityIndicator color={theme.colors.secundary.main} />
) : (
<S.TextBtnSemPlano>FINALIZAR SEM PLANO</S.TextBtnSemPlano>
)}
</S.BtnConcluirSemPlano>
</>
);
Expand Down
1 change: 0 additions & 1 deletion src/screens/EvaluateMentoring/ModuloAsk/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ const ModuloAsk: React.FC<Props> = ({ route }) => {
const editedModules = moduleValues.filter(
(moduleValue) => moduleValue !== undefined
);
console.log(editedModules);
navigation.navigate('CompleteMentoring', {
Seller: seller,
ModulesEvaluate: editedModules,
Expand Down
2 changes: 0 additions & 2 deletions src/screens/Home/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import Header from '@components/HeaderMenu';
import ContainerActions from '@components/ContainerActions';
import MatrizSlider from '@components/MatrizSlider';
import Container from '@components/ContainerCards';
import ButtonAdded from '@components/ButtonAdded';
import useAuth from '@hooks/useAuth';
import SupervisorServices from '@services/SupervisorServices';
import SellerServices from '@services/SellerServices';
Expand Down Expand Up @@ -77,7 +76,6 @@ const Home = () => {
media={media}
/>
</S.Wrapper>
<ButtonAdded />
</>
);
};
Expand Down
23 changes: 19 additions & 4 deletions src/screens/SalesInspector/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,19 @@ import SellerServices from '@services/SellerServices';
import ISeller from '@interfaces/Seller';
import ISupervisor from '@interfaces/Supervisor';

import { View } from 'react-native';
import { View, ActivityIndicator } from 'react-native';
import Modal from 'react-native-modal';
import SupervisorServices from '@services/SupervisorServices';
import { useDataContext } from '../../context/DataContext';

const SalesInspector = ({ route }) => {
const navigation = useNavigation();
const { idEmployee, cargo, companyId } = route.params;
const { user } = useAuth();
const { data, setData } = useDataContext();
const [seller, setSeller] = useState<ISeller | null>(null);
const [supervisors, setSupervisors] = useState<ISupervisor | null>(null);

const [loading, setLoading] = useState(false);
const [isModalVisible, setIsModalVisible] = useState(false);

useEffect(() => {
Expand Down Expand Up @@ -52,11 +54,17 @@ const SalesInspector = ({ route }) => {

const handleDelete = async () => {
try {
setLoading(true);
if (cargo === 'Supervisor' && supervisors) {
await SupervisorServices.delete(supervisors.id);
} else if (cargo === 'Vendedor' && seller) {
await SellerServices.delete(seller.id);
}
setData({
...data,
seller: seller,
});
setLoading(false);
navigation.goBack();
} catch (error) {
console.error('Erro ao excluir vendedor:', error);
Expand Down Expand Up @@ -101,8 +109,15 @@ const SalesInspector = ({ route }) => {
Tem certeza que deseja excluir esse vendedor?
</S.TextModal>
</S.WrapperConteudo>
<S.BtnYes onPress={handleDelete}>
<S.TitleBtnYes>Sim</S.TitleBtnYes>
<S.BtnYes
onPress={!loading ? handleDelete : undefined}
disabled={loading}
>
{loading ? (
<ActivityIndicator color="#fff" />
) : (
<S.TitleBtnYes>Sim</S.TitleBtnYes>
)}
</S.BtnYes>
<S.BtnBack onPress={toggleModal}>
<S.TitleBtnBack>Voltar</S.TitleBtnBack>
Expand Down
4 changes: 2 additions & 2 deletions src/screens/SalesInspector/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export const TitleBtnYes = styled(Text)`
`;

export const BtnBack = styled(TouchableOpacity)`
border: 2px solid ${theme.colors.secundary.main};
border: 2px solid #e5484d;
border-radius: 8px;
padding: 16px;
display: flex;
Expand All @@ -137,7 +137,7 @@ export const BtnBack = styled(TouchableOpacity)`
`;

export const TitleBtnBack = styled(Text)`
color: ${theme.colors.secundary.main};
color: #e5484d;
font-family: PoppinsBold;
font-size: 14px;
text-transform: uppercase;
Expand Down

0 comments on commit b256d3a

Please sign in to comment.