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