Skip to content

Commit

Permalink
Toast and ModulesGrades Salvos
Browse files Browse the repository at this point in the history
  • Loading branch information
pedrogomes18 committed Mar 23, 2024
1 parent 58b5f23 commit 3dc0a08
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 32 deletions.
4 changes: 3 additions & 1 deletion src/components/InputRage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@ interface askProps {
textAsk: string;
moduleId: string;
onChangeValue: (moduleId: string, newValue: number) => void;
initialValue?: number; // Propriedade para receber o valor inicial
}

const InputRange: React.FC<askProps> = ({
textAsk,
moduleId,
onChangeValue,
initialValue = 1, // Atribui o valor 1 caso initialValue não seja fornecido
}) => {
const [value, setValue] = useState(1);
const [value, setValue] = useState(initialValue); // Usa initialValue como valor inicial

return (
<S.Container>
Expand Down
9 changes: 9 additions & 0 deletions src/screens/EvaluateMentoring/CompleteMentorship/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ 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';

interface RouteParams {
ModulesEvaluate: Array<{
Expand All @@ -28,6 +29,8 @@ const CompleteMentoship: React.FC = () => {
const [selectedYear, setSelectedYear] = useState('');
const [comment, setComment] = useState('');

const toast = useToast();

const days = Array.from(Array(30), (_, i) => (i + 1).toString());
const months = [
'Janeiro',
Expand Down Expand Up @@ -87,6 +90,12 @@ const CompleteMentoship: React.FC = () => {
})
);
console.log('Módulos avaliados com sucesso');
toast.show('Módulos avaliados com sucesso', {
type: 'success',
placement: 'bottom',
duration: 3500,
animationType: 'zoom-in',
});
} catch (error) {
console.error('Erro ao completar o mentorado:', error);
}
Expand Down
75 changes: 44 additions & 31 deletions src/screens/EvaluateMentoring/ModuloAsk/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import HeaderPages from '@components/HeaderPages';
import IModule from '@interfaces/Module';
import ISeller from '@interfaces/Seller';
import ModulesServices from '@services/ModuleServices';
import ModuleGradeServices from '@services/ModuleGradeService';
import IModuleGrade from '@interfaces/ModuleGrade';

interface RouteParams {
module: IModule;
Expand All @@ -24,6 +26,7 @@ interface Props {
const ModuloAsk: React.FC<Props> = ({ route }) => {
const { seller } = route.params;
const [modules, setModules] = useState<IModule[]>([]);
const [modulesGrades, setModulesGrades] = useState<IModuleGrade[]>();
const [loading, setLoading] = useState(true);
const [moduleValues, setModuleValues] = useState<
Array<{ idModule: string; conhecimento: number; implementacao: number }>
Expand All @@ -34,6 +37,9 @@ const ModuloAsk: React.FC<Props> = ({ route }) => {
const fetchData = async () => {
try {
const modulesData = await ModulesServices.getAllModules();
const modulesGradeData =
await ModuleGradeServices.getModuleGradesByIdSeller(seller.id);
setModulesGrades(modulesGradeData);
setModules(modulesData);
} catch (error) {
console.log(error);
Expand Down Expand Up @@ -90,38 +96,45 @@ const ModuloAsk: React.FC<Props> = ({ route }) => {
<S.NomeMentora>{seller.name}</S.NomeMentora>
</S.DivFilds>
</S.HeaderMentorado>
{modules.map((module, index) => (
<S.AskDiv key={module.id}>
<S.TitleModule>
Módulo {index + 1}: {module.name}
</S.TitleModule>
<InputRange
moduleId={module.id}
textAsk="Conhecimento"
onChangeValue={(moduleId, value) =>
handleUpdateModuleValues(
moduleId,
index,
value,
moduleValues[index]?.implementacao || 0
)
}
/>
<InputRange
moduleId={module.id}
textAsk="Implementação"
onChangeValue={(moduleId, value) =>
handleUpdateModuleValues(
moduleId,
index,
moduleValues[index]?.conhecimento || 0,
value
)
}
/>
</S.AskDiv>
))}
{modules.map((module, index) => {
const moduleGrade = modulesGrades.find(
(grade) => grade.moduleId === module.id
);

return (
<S.AskDiv key={module.id}>
<S.TitleModule>
Módulo {index + 1}: {module.name}
</S.TitleModule>
<InputRange
moduleId={module.id}
textAsk="Conhecimento"
initialValue={moduleGrade?.knowledgeScore || 1}
onChangeValue={(moduleId, value) =>
handleUpdateModuleValues(
moduleId,
index,
value,
moduleValues[index]?.implementacao || 0
)
}
/>
<InputRange
moduleId={module.id}
textAsk="Implementação"
initialValue={moduleGrade?.implementationScore || 1}
onChangeValue={(moduleId, value) =>
handleUpdateModuleValues(
moduleId,
index,
moduleValues[index]?.conhecimento || 0,
value
)
}
/>
</S.AskDiv>
);
})}
<S.ButtonConcluir onPress={handleSetComplete}>
<S.TextBtn>Concluir Avaliação</S.TextBtn>
</S.ButtonConcluir>
Expand Down

0 comments on commit 3dc0a08

Please sign in to comment.