Skip to content

Commit

Permalink
feat(fe-piattaforma): fe updates 08312022
Browse files Browse the repository at this point in the history
  • Loading branch information
nicogheart1 committed Aug 31, 2022
2 parents ae51289 + eee57f8 commit e899247
Show file tree
Hide file tree
Showing 14 changed files with 97 additions and 40 deletions.
Binary file modified .DS_Store
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ const AccordionAddress: React.FC<AccordionAddressI> = ({
/>

<OpenDaysSelect
openDays={addressInfo.fasceOrarieAperturaIndirizzoSede}
openDays={addressInfo.fasceOrarieAperturaIndirizzoSede || {}}
index={index}
onAddOpenDay={openDayAddHandler}
onRemoveOpenDay={openDayRemoveHandler}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ const AddressInfoForm: React.FC<AddressInfoFormI> = ({
}
/>
<OpenDaysSelect
openDays={addressInfo.fasceOrarieAperturaIndirizzoSede}
openDays={addressInfo.fasceOrarieAperturaIndirizzoSede || {}}
onAddOpenDay={openDayAddHandler}
onRemoveOpenDay={openDayRemoveHandler}
onTimeChange={timeChangeHandler}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import { useAppSelector } from '../../../../../redux/hooks';
import {
selectAuthorities,
selectHeadquarters,
setHeadquarterDetails,
setHeadquartersList,
} from '../../../../../redux/features/administrativeArea/administrativeAreaSlice';
import { useDispatch } from 'react-redux';
Expand Down Expand Up @@ -95,7 +94,8 @@ const ManageHeadquarter: React.FC<ManageHeadquarterI> = ({

// flag for conditionally render multiple address selection
const [movingHeadquarter, setMovingHeadquarter] = useState<boolean>(false);
const { projectId, authorityId, headquarterId } = useParams();
const { projectId, authorityId, headquarterId, identeDiRiferimento } =
useParams();
const authorityInfo =
useAppSelector(selectAuthorities).detail?.dettagliInfoEnte;
const headquartersList = useAppSelector(selectHeadquarters).list;
Expand Down Expand Up @@ -205,8 +205,6 @@ const ManageHeadquarter: React.FC<ManageHeadquarterI> = ({
};

const handleSearchReset = () => {
dispatch(setHeadquartersList(null));
dispatch(setHeadquarterDetails(null));
setAddressList([
{
indirizzoSede: {
Expand All @@ -222,6 +220,17 @@ const ManageHeadquarter: React.FC<ManageHeadquarterI> = ({
},
]);
setMovingHeadquarter(false);
if (headquarterId && projectId && (authorityId || identeDiRiferimento)) {
dispatch(
GetHeadquarterDetails(
headquarterId,
authorityId || identeDiRiferimento || '',
projectId
)
);
} else if (headquarterId) {
dispatch(GetHeadquarterLightDetails(headquarterId));
}
};

let content = (
Expand Down Expand Up @@ -282,7 +291,7 @@ const ManageHeadquarter: React.FC<ManageHeadquarterI> = ({
<GenericModal
id={id}
primaryCTA={{
disabled: !isFormValid,
disabled: !isFormValid || !validateAddressList(addressList),
label: 'Conferma',
onClick: handleSaveAssignHeadquarter,
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

&__title {
min-width: rem(200px);
//max-width: rem(250px);
max-width: rem(250px);
display: block;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ const CardStatusAction: React.FC<CardStatusActionI> = (props) => {
)}
>
<div
className='card-status-action__title w-100 pr-4 text-truncate'
style={{
minWidth: device.mediaIsDesktop ? '300px' : '200px',
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,14 @@ const CardStatusActionHeadquarters: React.FC<CardStatusActionI> = (props) => {
device.mediaIsPhone && 'flex-wrap'
)}
>
<div className={clsx(device.mediaIsPhone && 'title')}>
<div
className={clsx(
device.mediaIsPhone && 'title',
'card-status-action__title',
'pr-4',
'text-truncate'
)}
>
<span className='neutral-1-color-a8 card-status-action__title'>
<strong>{title}</strong>
{subtitle && <span className='neutral-1-color-a8'>{subtitle}</span>}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ const CardStatusActionPartnerAuthority: React.FC<CardStatusActionI> = (
: 'flex-column align-items-start'
)}
>
<div className='card-status-action__title w-100'>
<div className='card-status-action__title w-100 pr-4 text-truncate'>
<span className='neutral-1-color-a8'>
<strong>{title}</strong>
{subtitle && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const CardStatusActionProject: React.FC<CardStatusActionI> = (props) => {
: 'flex-column align-items-start'
)}
>
<div className='card-status-action__title w-100'>
<div className='card-status-action__title w-100 pr-4 text-truncate'>
<span className='neutral-1-color-a8'>
<strong>{title}</strong>
{subtitle && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ const CardStatusActionSurveys: React.FC<CardStatusActionI> = (props) => {
: 'flex-column align-items-start'
)}
>
<div className='card-status-action__title w-100'>
<div className='card-status-action__title w-100 pr-4 text-truncate'>
<span className='neutral-1-color-a8'>
<strong>{title}</strong>
{subtitle && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import { withFormHandlerProps } from '../../../../../hoc/withFormHandler';
import {
//resetAuthorityDetails,
selectAuthorities,
selectEnteGestoreProgetto,
selectEnteGestoreProgramma,
setAuthoritiesList,
setAuthorityDetails,
} from '../../../../../redux/features/administrativeArea/administrativeAreaSlice';
Expand Down Expand Up @@ -73,9 +75,12 @@ const ManageManagerAuthority: React.FC<ManageManagerAuthorityI> = ({
const dispatch = useDispatch();
const { entityId, projectId } = useParams();
const authoritiesList = useAppSelector(selectAuthorities).list;
const enteGestoreProgettoId = useAppSelector(selectEnteGestoreProgetto);
const enteGestoreProgrammaId = useAppSelector(selectEnteGestoreProgramma);

useEffect(() => {
dispatch(setAuthoritiesList(null));
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

useEffect(() => {
Expand All @@ -90,6 +95,7 @@ const ManageManagerAuthority: React.FC<ManageManagerAuthorityI> = ({
clearForm();
if (creation) dispatch(setAuthorityDetails(null));
setNoResult(false);
dispatch(closeModal());
//dispatch(resetAuthorityDetails());
};

Expand All @@ -106,18 +112,38 @@ const ManageManagerAuthority: React.FC<ManageManagerAuthorityI> = ({
if (newFormValues.id) {
if (projectId) {
// Project
await dispatch(
UpdateManagerAuthority({ ...newFormValues }, projectId, 'progetto')
const res = await dispatch(
UpdateManagerAuthority(
{ ...newFormValues },
enteGestoreProgettoId,
projectId,
'progetto'
)
);
await dispatch(GetProjectDetail(projectId));
dispatch(GetAuthorityManagerDetail(projectId, 'progetto'));
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
if (res) {
await dispatch(GetProjectDetail(projectId));
dispatch(GetAuthorityManagerDetail(projectId, 'progetto'));
resetModal();
}
} else if (entityId) {
// Program
await dispatch(
UpdateManagerAuthority({ ...newFormValues }, entityId, 'programma')
const res = await dispatch(
UpdateManagerAuthority(
{ ...newFormValues },
enteGestoreProgrammaId,
entityId,
'programma'
)
);
await dispatch(GetProgramDetail(entityId));
dispatch(GetAuthorityManagerDetail(entityId, 'programma'));
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
if (res) {
await dispatch(GetProgramDetail(entityId));
dispatch(GetAuthorityManagerDetail(entityId, 'programma'));
resetModal();
}
}
}
// Creation
Expand All @@ -129,17 +155,17 @@ const ManageManagerAuthority: React.FC<ManageManagerAuthorityI> = ({
);
await dispatch(GetProjectDetail(projectId));
dispatch(GetAuthorityManagerDetail(projectId, 'progetto'));
resetModal();
} else if (entityId) {
// Program
await dispatch(
CreateManagerAuthority({ ...newFormValues }, entityId, 'programma')
);
await dispatch(GetProgramDetail(entityId));
dispatch(GetAuthorityManagerDetail(entityId, 'programma'));
resetModal();
}
}
resetModal();
dispatch(closeModal());
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -437,8 +437,12 @@ export const selectEntityPagination = (state: RootState) =>
state.administrativeArea.pagination;
export const selectPrograms = (state: RootState) =>
state.administrativeArea.programs;
export const selectEnteGestoreProgramma = (state: RootState) =>
state.administrativeArea.programs?.detail?.idEnteGestoreProgramma;
export const selectProjects = (state: RootState) =>
state.administrativeArea.projects;
export const selectEnteGestoreProgetto = (state: RootState) =>
state.administrativeArea.projects?.detail?.idEnteGestoreProgetto;
export const selectSurveys = (state: RootState) =>
state.administrativeArea.surveys;
export const selectUsers = (state: RootState) => state.administrativeArea.users;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,32 +285,41 @@ const UpdateAuthorityAction = {
};

export const UpdateManagerAuthority =
(authorityDetail: any, entityId: string, entity: 'programma' | 'progetto') =>
(authorityDetail: any, enteGestoreId: string | number, entityId: string, entity: 'programma' | 'progetto') =>
async (dispatch: Dispatch) => {
try {
dispatch(showLoader());
dispatch({ ...UpdateAuthorityAction });

if (authorityDetail) {
let res = await API.put(
`/ente/${authorityDetail.id}/${
dispatch({ ...UpdateAuthorityAction, ...authorityDetail, entityId, entity });
if (authorityDetail?.id) {
let res;
if (enteGestoreId) {
res = await API.put(`/ente/${enteGestoreId}/${
entity === 'programma' ? 'gestoreProgramma' : 'gestoreProgetto'
}/${entityId}`,
{
...authorityDetail,
}
);
}/${entityId}`, authorityDetail);

res = await API.put(
`/${entity}/${entityId}/assegna/${
entity === 'programma' ? 'entegestore' : 'enteGestore'
}/${authorityDetail.id}`
);
return res;
} else {
res = await API.put(
`/ente/${authorityDetail.id}/${
entity === 'programma' ? 'gestoreProgramma' : 'gestoreProgetto'
}/${entityId}`,
{
...authorityDetail,
}
);

res = await API.put(
`/${entity}/${entityId}/assegna/${
entity === 'programma' ? 'entegestore' : 'enteGestore'
}/${authorityDetail.id}`
);

return res;
return res;
}
}
} catch (error) {
console.log(error);
return false;
} finally {
dispatch(hideLoader());
}
Expand Down
2 changes: 1 addition & 1 deletion fe-piattaforma/src/styles/common/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ $z-index-docked: 1;
$z-index-base: 10;
$z-index-modal: $z-index-base + 900;
$z-index-curtain: $z-index-modal - 10;
$z-index-notification: $z-index-curtain - 10;
$z-index-notification: $z-index-base + 9999;
$z-index-banner: $z-index-notification - 10;
$z-index-sticky: $z-index-banner - 10;
$z-index-dropdown: $z-index-sticky - 10;
Expand Down

0 comments on commit e899247

Please sign in to comment.