Commit 19e7072d authored by Rafael's avatar Rafael

Merge branch 'master' into material-v5

# Conflicts:
#	cli/web/cliente/src/views/ProposalData/pages/CustomerData/References/References.tsx
#	cli/web/cliente/src/views/ProposalData/pages/CustomerData/Vehicles/Vehicles.tsx
parents 69a2359e d9214454
......@@ -68,7 +68,12 @@ export class AddInvolvedPersonIdentification implements ApiAdapter<InvolvedPerso
nome: domain.name,
cpfcnpj: extractNumbers(domain.cpfcnpj),
sexo: domain.gender,
tipo: domain.type === INVOLVED_PERSON_NAMES['2'] ? INVOLVED_PERSON_TYPES['CUSTOMER'] : '',
tipo:
domain.type === INVOLVED_PERSON_NAMES['2']
? INVOLVED_PERSON_TYPES['CUSTOMER']
: domain.type === INVOLVED_PERSON_TYPES['CUSTOMER']
? domain.type
: '',
contaBanestes: domain.account ? this.mapBanestesAccountToApi(domain.account) : undefined,
dadosTipo: domain.dataType ? this.mapDateTypeToApi(domain.dataType) : undefined,
})
......
......@@ -11,6 +11,7 @@ import {
Vehicle,
Workplace
} from '@agiliza/api/domain'
import { INVOLVED_PERSON_NAMES, INVOLVED_PERSON_TYPES } from '@agiliza/constants/involvedPeople'
import {
EnderecoApiModel,
ProjetoPessoaEnvolvidaConjugeApiModel,
......@@ -61,7 +62,7 @@ export class CDIdentificationAdapter implements DomainAdapter<ProjetoPessoaEnvol
name: pessoa.nome,
cpfcnpj: pessoa.cpfcnpj,
gender: pessoa.sexo,
type: pessoa.tipo,
type: pessoa.tipo === INVOLVED_PERSON_NAMES[INVOLVED_PERSON_TYPES.CUSTOMER] ? INVOLVED_PERSON_TYPES.CUSTOMER : '',
account: pessoa.contaBanestes ? this.mapContaBanestesToDomain(pessoa.contaBanestes) : undefined,
dataType: pessoa.dadosTipo ? this.mapDadosTipoToDomain(pessoa.dadosTipo) : undefined,
})
......
......@@ -17,7 +17,7 @@ import {
UpdateCDVehicle
} from '@agiliza/api/domain'
import { DadosCliente } from '@agiliza/api/mappers/domain/proposalData'
import { INVOLVED_PERSON_NAMES, INVOLVED_PERSON_TYPES } from '@agiliza/constants/involvedPeople'
import { INVOLVED_PERSON_TYPES } from '@agiliza/constants/involvedPeople'
import { ClienteApi, Configuration } from '@microcredito/client'
import { ErrorMappers, ProposalDataApiMappers, ProposalDataMappers } from '../../mappers'
......@@ -106,8 +106,7 @@ export class PDCustomerDataRepositoryImpl implements PDCustomerDataDataRepositor
try {
const pessoasEnvolvidas = await this.api.obterPessoasEnvolvidas({ projetoId: input.projectId })
const involvedPeople = pessoasEnvolvidas.map(this.cdIdentificationMapper.mapApiModelToDomain)
console.log(involvedPeople)
const identification = involvedPeople.find((pE) => pE.type === INVOLVED_PERSON_NAMES[INVOLVED_PERSON_TYPES['CUSTOMER']])
const identification = involvedPeople.find((pE) => pE.type === INVOLVED_PERSON_TYPES['CUSTOMER'])
return identification
} catch (e) {
const result = await this.errorAdapter.mapApiModelToDomain(e)
......@@ -141,6 +140,7 @@ export class PDCustomerDataRepositoryImpl implements PDCustomerDataDataRepositor
public updateIdentification = async (input: UpdateCDIdentification['Input']): Promise<UpdateCDIdentification['Output']> => {
try {
console.log(this.cdUpdateIdentificationApiMapper.mapDomainToApiModel(input))
const response = await this.api.atualizarIdentificacaoPessoaEnvolvida(this.cdUpdateIdentificationApiMapper.mapDomainToApiModel(input))
return this.cdIdentificationMapper.mapApiModelToDomain(response)
} catch (e) {
......
......@@ -50,6 +50,17 @@ const updateVehiclesReferences = (state: Store, pds: Vehicle[] = [], rfs: Refere
state.references.byId = references
state.references.allIds = keys(references)
}
const updateReferences = (state: Store, rfs: Reference[]) => {
const { references } = normalizeCustomerData([], rfs)
state.references.byId = references
state.references.allIds = keys(references)
}
const updateVehicles = (state: Store, vhs: Vehicle[]) => {
const { vehicles } = normalizeCustomerData(vhs, [])
state.vehicles.byId = vehicles
state.vehicles.allIds = keys(vehicles)
}
export default createSlice({
name: `${PROPOSAL_DATA_PREFIX}/customerData`,
......@@ -69,27 +80,27 @@ export default createSlice({
},
[customerDataTypes.getVehicles.fulfilled]: (state, action: PayloadAction<GetCDVehicles['Output']>) => {
const { payload } = action
updateVehiclesReferences(state, payload)
updateVehicles(state, payload)
},
[customerDataTypes.updateReference.fulfilled]: (state, action: PayloadAction<UpdateCDVehicle['Output']>) => {
[customerDataTypes.updateVehicle.fulfilled]: (state, action: PayloadAction<UpdateCDVehicle['Output']>) => {
const { payload } = action
updateVehiclesReferences(state, payload)
updateVehicles(state, payload)
},
[customerDataTypes.addReference.fulfilled]: (state, action: PayloadAction<AddCDVehicle['Output']>) => {
[customerDataTypes.addVehicle.fulfilled]: (state, action: PayloadAction<AddCDVehicle['Output']>) => {
const { payload } = action
updateVehiclesReferences(state, payload)
updateVehicles(state, payload)
},
[customerDataTypes.getReferences.fulfilled]: (state, action: PayloadAction<GetCDReferences['Output']>) => {
const { payload } = action
updateVehiclesReferences(state, [], payload)
updateReferences(state, payload)
},
[customerDataTypes.updateReference.fulfilled]: (state, action: PayloadAction<UpdateCDReference['Output']>) => {
const { payload } = action
updateVehiclesReferences(state, [], payload)
updateReferences(state, payload)
},
[customerDataTypes.addReference.fulfilled]: (state, action: PayloadAction<AddCDReference['Output']>) => {
const { payload } = action
updateVehiclesReferences(state, [], payload)
updateReferences(state, payload)
},
},
})
......@@ -38,7 +38,6 @@ export default createSlice({
state.personId = action.payload.id
},
[customerDataTypes.getIdentification.fulfilled]: (state, action: PayloadAction<Identification>) => {
console.log(action.payload)
state.personId = action.payload?.id
},
},
......
......@@ -2,3 +2,5 @@ import { State } from './slice'
export const isFetching = (state: State) => state.fetching
export const isGettingCustomerData = (state: State) => state.gettingCustomerData
export const isGettingReferences = (state: State) => state.gettingReferences
export const isGettingVehicles = (state: State) => state.gettingVehicles
......@@ -7,6 +7,7 @@ import {
GetCDReferences,
GetCDVehicles,
GetCustomerData,
InvolvedPerson,
UpdateCDAddress,
UpdateCDHome,
UpdateCDIdentification,
......@@ -33,11 +34,15 @@ const prefix = 'useCases/customerData'
export interface State {
fetching: boolean
gettingCustomerData: boolean
gettingReferences: boolean
gettingVehicles: boolean
}
export const initialState: State = {
fetching: false,
gettingCustomerData: false,
gettingReferences: false,
gettingVehicles: false,
}
export const actions = {
......@@ -181,16 +186,19 @@ export const actions = {
return thunkApi.rejectWithValue(e)
}
}),
getCustomerData: createAsyncThunk(`${prefix}/getCustomerData`, async (input: WithSuccess<GetCustomerData['Input']>, thunkApi) => {
getCustomerData: createAsyncThunk(
`${prefix}/getCustomerData`,
async (input: WithSuccess<GetCustomerData['Input'], Omit<InvolvedPerson, 'id'>>, thunkApi) => {
const useCase = PDCustomerDataRepositoryImplFactory.create(appPlatform)
try {
const response = await useCase.getCustomerData(input)
input.onSuccess && input.onSuccess()
input.onSuccess && input.onSuccess(response)
return response
} catch (e) {
return thunkApi.rejectWithValue(e)
}
}),
}
),
getIdentification: createAsyncThunk(`${prefix}/getIdentification`, async (input: WithSuccess<GetCDIdentification['Input'], string>, thunkApi) => {
const useCase = PDCustomerDataRepositoryImplFactory.create(appPlatform)
try {
......@@ -211,6 +219,8 @@ const login = createSlice({
extraReducers: {
...values(types).reduce((reducers, type) => ({ ...reducers, ...createAsyncReducers(type) }), {}),
...createAsyncReducers(types.getCustomerData, 'gettingCustomerData'),
...createAsyncReducers(types.getReferences, 'gettingReferences'),
...createAsyncReducers(types.getVehicles, 'gettingVehicles'),
},
})
......
......@@ -7,19 +7,7 @@ export interface CDIdentificationState extends ExtendedState {
hasAccount: boolean
}
export const initialState: CDIdentificationState =
process.env.NODE_ENV === 'development'
? {
id: '',
name: 'TEST',
cpfcnpj: '80.162.745/0001-96',
gender: '1',
type: INVOLVED_PERSON_TYPES['CUSTOMER'],
hasAccount: false,
account: { agencyNumber: '', number: '', cardPicture: '' },
dataType: { doesWithdrawal: false, framework: '1' },
}
: {
export const initialState: CDIdentificationState = {
id: '',
name: '',
cpfcnpj: '',
......@@ -28,4 +16,4 @@ export const initialState: CDIdentificationState =
hasAccount: false,
account: { agencyNumber: '', number: '', cardPicture: '' },
dataType: { doesWithdrawal: false, framework: '' },
}
}
......@@ -11,7 +11,7 @@ export interface ConnectedProps {
}
type StateProps = Pick<ConnectedProps, 'fetching' | 'context'>
// type DispatchProps = Pick<ConnectedProps, 'updateIndentification'>
// type DispatchProps = Pick<ConnectedProps, 'getReferences'>
const mapStateToProps = (state: StoreState): StateProps => ({
fetching: ucProposalDataContext.selectors.isFetching(state.ui.login),
......@@ -21,6 +21,7 @@ const mapStateToProps = (state: StoreState): StateProps => ({
// const mapDispatchToProps = (dispatch: Dispatch): DispatchProps =>
// bindActionCreators(
// {
// getReferences: ucProposalData.actions.getReferences,
// },
// dispatch
// )
......
......@@ -3,7 +3,15 @@ import React, { useEffect, useState } from 'react'
import { Reference } from '@agiliza/api/domain/proposalData/involvedPeople/reference'
import { ActionType } from '@agiliza/utils/hooks/state'
import { Add as AddIcon, EmojiEmotions as EmojiEmotionsIcon } from '@mui/icons-material'
import { Avatar, List, ListItem, ListItemAvatar, ListItemText } from '@mui/material'
import {
Avatar,
Box,
CircularProgress,
List,
ListItem,
ListItemAvatar,
ListItemText
} from '@mui/material'
import { useTheme } from '@mui/material/styles'
import { connected, ConnectedProps } from './connect'
......@@ -29,7 +37,7 @@ const References = (props: Props) => {
const [open, setOpen] = useState(false)
useEffect(() => {
if (!references.length) props.getReferences({ personId, projectId })
props.getReferences({ projectId, personId })
}, [])
const handleClickListItem = (reference: Reference) => () => {
......@@ -48,8 +56,8 @@ const References = (props: Props) => {
const handleSave = (reference: Reference, add: boolean) => () => {
const onSuccess = () => {
setOpen(false)
setSelectedReference(reference)
// setOpen(false)
// setSelectedReference(reference)
}
if (add)
props.addReference({
......@@ -68,10 +76,12 @@ const References = (props: Props) => {
})
}
if (fetching) return <CircularProgress sx={styles.circularProgress} />
return (
<>
<div style={styles.contentContainer}>
<div style={styles.content}>
<Box sx={styles.contentContainer}>
<Box sx={styles.content}>
<List sx={styles.list}>
{references.map((reference, i) => (
<ListItem key={i} button onClick={handleClickListItem(reference)}>
......@@ -84,8 +94,8 @@ const References = (props: Props) => {
</ListItem>
))}
</List>
</div>
</div>
</Box>
</Box>
<Avatar sx={styles.avatarBtnContainer} onClick={handleClickAdd}>
<AddIcon />
</Avatar>
......
......@@ -20,7 +20,7 @@ type StateProps = Pick<ConnectedProps, 'fetching' | 'context' | 'references'>
type DispatchProps = Pick<ConnectedProps, 'getReferences' | 'addReference' | 'updateReference'>
const mapStateToProps = (state: StoreState): StateProps => ({
fetching: ucProposalData.selectors.isFetching(state.useCases.proposalData.customerData),
fetching: ucProposalData.selectors.isGettingReferences(state.useCases.proposalData.customerData),
context: entProposalDataContext.selectors.getContext(state.entities.proposalData.context),
references: entCustomerData.selectors.getReferences(state.entities.proposalData.customerData),
})
......
import React, { useState } from 'react'
import React, { useEffect, useState } from 'react'
import { Vehicle } from '@agiliza/api/domain'
import { ActionType } from '@agiliza/utils/hooks/state'
import { Add as AddIcon, DriveEta as DriveEtaIcon } from '@mui/icons-material'
import { Avatar, List, ListItem, ListItemAvatar, ListItemText } from '@mui/material'
import {
Avatar,
Box,
CircularProgress,
List,
ListItem,
ListItemAvatar,
ListItemText
} from '@mui/material'
import { useTheme } from '@mui/material/styles'
import { connected, ConnectedProps } from './conect'
......@@ -27,6 +35,9 @@ const Vehicles = (props: Props) => {
const [selectedVehicle, setSelectedVehicle] = useState<Vehicle | undefined>()
const [open, setOpen] = useState(false)
useEffect(() => {
props.getVehicles({ personId, projectId })
}, [])
const handleClickListItem = (vehicle: Vehicle) => () => {
setOpen(true)
......@@ -65,10 +76,12 @@ const Vehicles = (props: Props) => {
})
}
if (fetching) return <CircularProgress sx={styles.circularProgress} />
return (
<>
<div style={styles.contentContainer}>
<div style={styles.content}>
<Box style={styles.contentContainer}>
<Box style={styles.content}>
<List sx={styles.list}>
{vehicles.map((vehicle, i) => (
<ListItem key={i} button onClick={handleClickListItem(vehicle)}>
......@@ -81,8 +94,8 @@ const Vehicles = (props: Props) => {
</ListItem>
))}
</List>
</div>
</div>
</Box>
</Box>
<Avatar sx={styles.avatarBtnContainer} onClick={handleClickAdd}>
<AddIcon />
</Avatar>
......
......@@ -20,7 +20,7 @@ type StateProps = Pick<ConnectedProps, 'fetching' | 'context' | 'vehicles'>
type DispatchProps = Pick<ConnectedProps, 'getVehicles' | 'addVehicle' | 'updateVehicle'>
const mapStateToProps = (state: StoreState): StateProps => ({
fetching: ucProposalData.selectors.isFetching(state.useCases.proposalData.customerData),
fetching: ucProposalData.selectors.isGettingVehicles(state.useCases.proposalData.customerData),
context: entProposalDataContext.selectors.getContext(state.entities.proposalData.context),
vehicles: entCustomerData.selectors.getVehicles(state.entities.proposalData.customerData),
})
......
......@@ -90,7 +90,12 @@ const ProposalData = (props: Props) => {
props.getCDIdentification({
projectId: proposalId,
onSuccess: (pID) => {
if (pID) props.getCustomerData({ projectId: proposalId, personId: pID })
if (pID)
props.getCustomerData({
projectId: proposalId,
personId: pID,
onSuccess: (cD) => {},
})
},
})
}, [])
......@@ -139,20 +144,18 @@ const ProposalData = (props: Props) => {
else return idn
}, {})
)
}, [customerData])
useEffect(() => {
const { identification, address, stockSalesCosts } = businessData
if (identification)
const { identification: bdIdentification, address: bdAddress, stockSalesCosts } = businessData
if (bdIdentification)
bdIdentificationState.actions.update(
entries(identification).reduce((idn, [k, v]) => {
entries(bdIdentification).reduce((idn, [k, v]) => {
if (v !== undefined) return { ...idn, [k]: v }
else return idn
}, {})
)
if (address)
if (bdAddress)
bdAddressState.actions.update(
entries(address).reduce((idn, [k, v]) => {
entries(bdAddress).reduce((idn, [k, v]) => {
if (v !== undefined) return { ...idn, [k]: v }
else return idn
}, {})
......@@ -164,7 +167,7 @@ const ProposalData = (props: Props) => {
else return idn
}, {})
)
}, [businessData])
}, [customerData, businessData])
const customerDataItems = useMemo(
() => [
......@@ -173,7 +176,11 @@ const ProposalData = (props: Props) => {
icon: <AccountBoxIcon />,
component: <Identification state={cdIdentification.state} actions={cdIdentification.actions} />,
},
{ label: 'Dados Pessoais', icon: <ListIcon />, component: <PersonalData state={cdPersonalData.state} actions={cdPersonalData.actions} /> },
{
label: 'Dados Pessoais',
icon: <ListIcon />,
component: <PersonalData state={cdPersonalData.state} actions={cdPersonalData.actions} />,
},
{ label: 'Endereço', icon: <ContactMailIcon />, component: <Address state={cdAddress.state} actions={cdAddress.actions} /> },
{ label: 'Fonte de renda', icon: <LocalAtmIcon />, component: <SourceIncome state={cdSourceIncome.state} actions={cdSourceIncome.actions} /> },
{ label: 'Cônjuge - Ident.', icon: <ForumIcon />, component: <SpouseData state={cdSpouseData.state} actions={cdSpouseData.actions} /> },
......@@ -194,7 +201,7 @@ const ProposalData = (props: Props) => {
component: <Vehicles state={cdVehicleState.state} actions={cdVehicleState.actions} projectId={proposalId} personId={personId} />,
},
],
[cdIdentification, cdPersonalData, cdAddress, cdSpouseData, cdReference, cdHomeState, cdVehicleState]
[cdIdentification, cdPersonalData, cdAddress, cdSourceIncome, cdSpouseData, cdReference, cdHomeState, cdVehicleState]
)
const businessDataItems = useMemo(
......@@ -333,7 +340,7 @@ const ProposalData = (props: Props) => {
</Typography>
<Typography sx={styles.pageSubtitle}>{proposalDataItems[activeStep].label}</Typography>
<div style={styles.stepContentContainer}>
{fetching ? <CircularProgress style={styles.circularProgress} /> : proposalDataItems[activeStep].component}
{fetching ? <CircularProgress sx={styles.circularProgress} /> : proposalDataItems[activeStep].component}
</div>
<div style={styles.stepperContainer}>
{/* <Stepper activeStep={activeStep} alternativeLabel style={styles.stepper}> */}
......
......@@ -36,6 +36,7 @@ export interface ConnectedProps {
getCDIdentification: typeof ucProposalDataCD.actions.getIdentification
getCustomerData: typeof ucProposalDataCD.actions.getCustomerData
getBusinessData: typeof ucProposalDataBD.actions.getBusinessData
getReferences: typeof ucProposalDataCD.actions.getReferences
}
type StateProps = Pick<ConnectedProps, 'fetching' | 'proposalId' | 'personId' | 'businessData' | 'customerData'>
......@@ -58,6 +59,7 @@ type DispatchProps = Pick<
| 'getCDIdentification'
| 'getCustomerData'
| 'getBusinessData'
| 'getReferences'
>
const isFetching = createSelector(
......@@ -99,6 +101,7 @@ const mapDispatchToProps = (dispatch: Dispatch): DispatchProps =>
getBusinessData: ucProposalDataBD.actions.getBusinessData,
getCustomerData: ucProposalDataCD.actions.getCustomerData,
getCDIdentification: ucProposalDataCD.actions.getIdentification,
getReferences: ucProposalDataCD.actions.getReferences,
},
dispatch
)
......
......@@ -95,7 +95,7 @@ const CreditLinesList = (props: Props) => {
</InputAdornment>
)
const validEndAdornment = React.cloneElement(params.InputProps.endAdornment as React.ReactElement, {
style: { marginRight: '1rem' },
style: { marginRight: '0.5rem' },
})
const refreshEndAdorment = (
<InputAdornment position="end" style={{ flex: '1', display: 'flex', justifyContent: 'flex-end' }}>
......
......@@ -9,9 +9,10 @@ export default (theme: Theme) =>
...sharedStyles(theme),
contentContainer: { display: 'flex', justifyContent: 'center', width: '100%', overflowY: 'auto' },
content: { display: 'flex', flexDirection: 'column', alignItems: 'center', width: '50%' },
creditLinesAutocomplete: { width: '100%' },
creditLinesAutocomplete: { width: '100%', '& .MuiOutlinedInput-root': { paddingRight: `${theme.spacing(2)} !important` } },
description: { margin: theme.spacing(2), width: '100%' },
sliderField: { textAlign: 'center', width: '100%', marginBottom: theme.spacing(3) },
btnContainer: { width: '100%', textAlign: 'right', marginBottom: theme.spacing(2) },
destinationsSelect: { marginBottom: theme.spacing(2) },
autocompleteInput: {},
})
......@@ -12,7 +12,7 @@ const styles = (theme: Theme) => {
padding: theme?.spacing(2),
display: 'flex',
flexDirection: 'column',
overflowY: 'hidden',
overflowY: 'auto',
},
title: {
flexGrow: 1,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment