Skip to content

Commit

Permalink
✨ feat: Module Create
Browse files Browse the repository at this point in the history
  • Loading branch information
pedrogomes18 committed Aug 10, 2024
1 parent 6f93e97 commit 6b63676
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 11 deletions.
6 changes: 4 additions & 2 deletions src/interfaces/Plain.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Seller from './Seller';
import Supervisor from './Supervisor';

export default interface Plains {
id: string;
Expand All @@ -8,7 +9,8 @@ export default interface Plains {
sellerId: string;
done: boolean;
supervisorId: string;
visitId: string;
moduleId: string;
visitId: string | null;
moduleId: string | null;
seller: Seller;
supervisivor: Supervisor;
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React, { useState } from 'react';
import * as S from './styles';
import Select from '@components/Select';

import DateTimePicker, {
DateTimePickerEvent,
} from '@react-native-community/datetimepicker';
Expand All @@ -10,7 +9,6 @@ import { useToast } from 'react-native-toast-notifications';
import ISeller from '@interfaces/Seller';
import IModules from '@interfaces/Module';
import IVisits from '@interfaces/Visit/Visit';

import PlainService from '@services/PlainService';

interface PlainActionProps {
Expand Down Expand Up @@ -50,20 +48,29 @@ const PlainMentory: React.FC<PlainActionProps> = ({

const handleCompletePlainAction = async () => {
try {
// Formate a data no formato "dia/mês/ano"
const formattedDate = date.toLocaleDateString('pt-BR', {
day: '2-digit',
month: '2-digit',
year: 'numeric',
});

const newPlain = await PlainService.createPlain({
title: titleAction,
comments: comment,
prize: date.toLocaleDateString(),
prize: formattedDate, // Envia a data formatada
sellerId: seller.id,
supervisorId: seller.supervisorId,
moduleId: seller.stage === 'Mentoria' ? selectedValue : selectedValue,
});

console.log(newPlain);
addNewPlain(newPlain);
setState();
showToast('Plano de ação efetivado com sucesso', 'success');
} catch (error) {
setState();
showToast('Modulo Já disponhem de um plano de ação', 'warning');
showToast('Módulo já dispõe de um plano de ação', 'warning');
}
};

Expand Down Expand Up @@ -109,7 +116,7 @@ const PlainMentory: React.FC<PlainActionProps> = ({
/>

<S.BtnCriarAction onPress={handleCompletePlainAction}>
<S.TextBtn>criar plano de ação</S.TextBtn>
<S.TextBtn>Criar plano de ação</S.TextBtn>
</S.BtnCriarAction>
<S.Outline onPress={returnPage}>
<S.TextBtnNova>Voltar</S.TextBtnNova>
Expand Down Expand Up @@ -140,7 +147,7 @@ const ActionSpecificFields: React.FC<ActionSpecificFieldsProps> = ({
<>
{stage === 'Visita' && (
<>
<S.TextForms>Vísita de Avaliação</S.TextForms>
<S.TextForms>Visita de Avaliação</S.TextForms>
<Select
placeholder="Selecione"
options={visits?.map(({ id, storeVisited }) => ({
Expand Down Expand Up @@ -196,7 +203,13 @@ export const DateTimePickerComponent: React.FC<
<S.TextForms>Data</S.TextForms>
<S.BtnData onPress={showDatePickerModal}>
<S.TextBtnData>
{date ? date.toLocaleDateString() : 'Selecione a Data'}
{date
? date.toLocaleDateString('pt-BR', {
day: '2-digit',
month: '2-digit',
year: 'numeric',
})
: 'Selecione a Data'}
</S.TextBtnData>
</S.BtnData>
{showDatePicker && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ export const Wrapper = styled(ScrollView)`
`;

export const WrapperView = styled(View)`
width: 90%;
width: 100%;
max-height: 100%;
flex: 1;
padding: 12px;
padding: 8px;
gap: 8px;
margin: 0 auto;
`;
Expand Down

0 comments on commit 6b63676

Please sign in to comment.