Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(procu): add rounds in matching #3021

Merged
merged 1 commit into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default function MandatePersonCardButtonGroup(
fullWidth={props.fullWidth}
disabled={props.isProcessing}
>
Sélectionner
Sélectionner {props.extraText}
</Button>
)
case MandatePersonCardType.MATCH_MANDANT:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,6 @@ export default function MandatePersonCard(props: MandatePersonCardProps) {
<Divider sx={{ mt: MuiSpacing.normal }} />
</Grid>

{!props.hideActions && props.type !== MandatePersonCardType.FIND && (
<Grid item xs={12} textAlign="right">
{/* @ts-expect-error wkejfhkej */}
<MandatePersonCardButtonGroup fullWidth {...props} />
</Grid>
)}

{linkedPeople?.map(x => (
<>
<Grid key={x.uuid} item xs={12}>
Expand All @@ -110,8 +103,8 @@ export default function MandatePersonCard(props: MandatePersonCardProps) {
</Typography>
</Grid>

{props.type === MandatePersonCardType.FIND ? (
<Grid key={x.uuid} item xs={12}>
{props.type === MandatePersonCardType.FIND || props.roundId === x.round.uuid ? (
<Grid key={x.uuid} item xs={12} pb={2}>
{x.proxy.length < 1 && (
<>
<MandatePersonCardButtonGroup
Expand Down Expand Up @@ -153,7 +146,12 @@ export default function MandatePersonCard(props: MandatePersonCardProps) {
lastName={el.last_name}
src={props.avatarUrl}
id={props.id}
onPersonView={() => props.onPersonView?.(el.uuid, x.round.uuid)}
onPersonView={() =>
props.onPersonView?.(
MandatePersonCardType.MATCH_MANDANT === props.type ? props.uuid! : el.uuid,
x.round.uuid
)
}
/>
{/*@ts-expect-error fefwf */}
{el.matched_at && (
Expand All @@ -172,6 +170,9 @@ export default function MandatePersonCard(props: MandatePersonCardProps) {
</GroupContainer>
</Grid>
)}
<Grid item xs={12}>
<Divider sx={{ mt: MuiSpacing.normal }} />
</Grid>
</>
))}
</Grid>
Expand Down
91 changes: 55 additions & 36 deletions src/components/Procurations/Pages/MandateMatchPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,13 @@ export default function MandateMatchPage() {
</Grid>
)}

<Proxy expended={expended[el.id]} setExpended={setExpendedMemo} el={el} onSelect={onSelect(el)} />
<Proxy
expended={expended[el.id]}
setExpended={setExpendedMemo}
el={el}
onSelect={onSelect(el)}
roundId={params.round}
/>
</Fragment>
))}

Expand Down Expand Up @@ -157,21 +163,27 @@ const getSectionName = (type: MatchingLevelEnum) => {
}
}

const MandateInfo = memo((data: ProcurationDetailsModel) => (
<MandatePersonCard
firstName={data.first_names}
lastName={data.last_name}
id={data.id}
location={data.vote_zone.name}
tags={data.tags ?? []}
votePlace={data.vote_place_name}
type={MandatePersonCardType.MATCH_MANDANT}
extraInfos={buildExtraData(data)}
expended
hideStateActions
inFrenchSoil={data.from_france}
/>
))
const MandateInfo = memo((data: ProcurationDetailsModel) => {
const navigate = useNavigate()
return (
<MandatePersonCard
firstName={data.first_names}
lastName={data.last_name}
id={data.id}
uuid={data.uuid}
location={data.vote_zone.name}
tags={data.tags ?? []}
votePlace={data.vote_place_name}
type={MandatePersonCardType.MATCH_MANDANT}
extraInfos={buildExtraData(data)}
linkedPeople={data.request_slots ?? data.proxy_slots ?? undefined}
expended
onPersonView={(id, round) => navigate(`${paths.procurations}/request/${id}/${round}/edit`)}
hideStateActions
inFrenchSoil={data.from_france}
/>
)
})
MandateInfo.displayName = 'MandateInfo'

const Proxy = memo(
Expand All @@ -180,30 +192,37 @@ const Proxy = memo(
setExpended,
expended,
onSelect,
roundId,
}: {
el: AvailableProxyModel
setExpended: (id: string) => void
onSelect: () => void
expended: boolean
}) => (
<MandatePersonCard
key={el.uuid}
firstName={el.first_names}
lastName={el?.last_name}
id={el.id}
location={el.vote_zone.name}
tags={el.tags ?? []}
votePlace={el.vote_place_name}
type={MandatePersonCardType.MATCH_PROXY}
extraInfos={buildExtraData(el)}
onExpend={setExpended}
onNarrow={setExpended}
expended={expended}
maxProxyCount={el.slots}
onSelect={onSelect}
linkedPeople={el.request_slots ?? undefined}
uuid={el.uuid}
/>
)
roundId: string | undefined
}) => {
const navigate = useNavigate()
return (
<MandatePersonCard
key={el.uuid}
firstName={el.first_names}
lastName={el?.last_name}
id={el.id}
location={el.vote_zone.name}
tags={el.tags ?? []}
roundId={roundId}
votePlace={el.vote_place_name}
type={MandatePersonCardType.MATCH_PROXY}
extraInfos={buildExtraData(el)}
onExpend={setExpended}
onNarrow={setExpended}
expended={expended}
maxProxyCount={el.slots}
onSelect={onSelect}
onPersonView={(id, round) => navigate(`${paths.procurations}/request/${id}/${round}/edit`)}
linkedPeople={el.request_slots ?? el.proxy_slots ?? undefined}
uuid={el.uuid}
/>
)
}
)
Proxy.displayName = 'Proxy'
Loading