refactor: simplify party handling in ManagePage component
Updated the ManagePage component to streamline the handling of party-related props. Introduced a local variable for party to reduce redundancy and improve code readability. Adjusted references throughout the component to utilize the new variable, ensuring consistent behavior and clearer logic.
This commit is contained in:
1 parent
724d5a68ae
commit
fb30b6e92b
1 file changed
+11
-10
+11
-10
@@ -375,6 +375,7 @@ export function ManagePage(props: {
|
|||||||
note?: string;
|
note?: string;
|
||||||
}) {
|
}) {
|
||||||
const signup = props.signup;
|
const signup = props.signup;
|
||||||
|
const party = props.party;
|
||||||
const cancelled = signup.status !== 'confirmed';
|
const cancelled = signup.status !== 'confirmed';
|
||||||
return (
|
return (
|
||||||
<article class="manage">
|
<article class="manage">
|
||||||
@@ -434,22 +435,22 @@ export function ManagePage(props: {
|
|||||||
</div>
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
</dl>
|
</dl>
|
||||||
{props.party || props.switches ? (
|
{party || props.switches ? (
|
||||||
<div class="manage-follow">
|
<div class="manage-follow">
|
||||||
{props.party ? (
|
{party ? (
|
||||||
<form class="move-form manage-action" method="post" action={props.party.action}>
|
<form class="move-form manage-action" method="post" action={party.action}>
|
||||||
<input type="hidden" name="party_token" value={props.party.token} />
|
<input type="hidden" name="party_token" value={party.token} />
|
||||||
<div class="manage-action-row">
|
<div class="manage-action-row">
|
||||||
<label for="manage-partySize">
|
<label for="manage-partySize">
|
||||||
How many people?
|
How many people?
|
||||||
<select
|
<select
|
||||||
id="manage-partySize"
|
id="manage-partySize"
|
||||||
name="party_size"
|
name="party_size"
|
||||||
aria-invalid={props.party.error ? 'true' : undefined}
|
aria-invalid={party.error ? 'true' : undefined}
|
||||||
aria-describedby={props.party.error ? 'manage-partySize-hint manage-partySize-error' : 'manage-partySize-hint'}
|
aria-describedby={party.error ? 'manage-partySize-hint manage-partySize-error' : 'manage-partySize-hint'}
|
||||||
>
|
>
|
||||||
{partyChoices(props.party.remaining).map((count) => (
|
{partyChoices(party.remaining).map((count) => (
|
||||||
<option key={count} value={String(count)} selected={props.party.value === String(count) ? true : undefined}>
|
<option key={count} value={String(count)} selected={party.value === String(count) ? true : undefined}>
|
||||||
{partyChoiceLabel(count)}
|
{partyChoiceLabel(count)}
|
||||||
</option>
|
</option>
|
||||||
))}
|
))}
|
||||||
@@ -460,9 +461,9 @@ export function ManagePage(props: {
|
|||||||
<p class="hint" id="manage-partySize-hint">
|
<p class="hint" id="manage-partySize-hint">
|
||||||
Including you. This holds that many spots, and the name stays the same.
|
Including you. This holds that many spots, and the name stays the same.
|
||||||
</p>
|
</p>
|
||||||
{props.party.error ? (
|
{party.error ? (
|
||||||
<p class="field-error" id="manage-partySize-error">
|
<p class="field-error" id="manage-partySize-error">
|
||||||
{props.party.error}
|
{party.error}
|
||||||
</p>
|
</p>
|
||||||
) : null}
|
) : null}
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
Reference in new issue
Block a user