-
Notifications
You must be signed in to change notification settings - Fork 2
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
Redirect to campaign detail upon entry creation #537
Conversation
Code Climate has analyzed commit 90b737e and detected 0 issues on this pull request. The test coverage on the diff in this pull request is 100.0% (90% is the threshold). This pull request will bring the total coverage in the repository to 91.6%. View more on Code Climate. |
Looks like I have a code smell for having too many redirects in the store function. Each redirect is chosen based on the type of entry being created (invalid gm entry, regular or dm entry with campaign, regular or dm w/o campaign...). The two options are to either ignore it or sacrifice one of the redirects. Thoughts? @m-triassi |
@JasonGadoury there's a third option, instead of returning, assign the route name string to a variable that changes based on the conditions, and then pass that variable to the if ($x == "Condition A") {
$redirect = 'campaign.show';
$extraData = [...];
} elseif ($x == "Condition B") {
$redirect = 'character.index';
$extraData = null;
}
return redirect()->route($redirect, $extraData); |
Kudos, SonarCloud Quality Gate passed! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This works, some things to consider for refactor, but I'll handle that at a later date.
if (isset($campaign)) { | ||
$redirectRoute = 'campaign.show'; | ||
$parameter = $campaign; | ||
} elseif (!isset($campaign)) { | ||
if ($entryData['type'] === Entry::TYPE_DM) { | ||
$redirectRoute = 'dm-entry.index'; | ||
$parameter = null; | ||
} else { | ||
$redirectRoute = 'character.show'; | ||
$parameter = $entry->character_id; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typically i'd avoid nesting control flow logic more than 1 layer deep if possible. Since we don't really have the luxary of time, ill just say this is a refactor target and move on
Description
Closes #500
Once a campaign entry or dm entry is successfully created, the user is now redirected to the campaign detail page instead of the character detail or dm entry index pages respectively.
To test:
(if they are not dm for any campaign, create a campaign and assign them dm)