Skip to content

Commit

Permalink
subcommunities: fix request redirect url
Browse files Browse the repository at this point in the history
  • Loading branch information
alejandromumo authored and slint committed Jun 28, 2024
1 parent 87283cd commit 8ea7d05
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class CommunityCreateForm extends Component {
setSubmitting(true);
const client = new CommunityApi();
const { hasCommunity } = this.state;
const { communityId } = this.props;
const { community } = this.props;
let payload = {};
let slug = "";
if (hasCommunity) {
Expand All @@ -124,7 +124,7 @@ class CommunityCreateForm extends Component {
};
}
this.cancellableCreate = withCancel(
client.createSubcommunity(communityId, payload)
client.createSubcommunity(community.id, payload)
);

try {
Expand All @@ -133,7 +133,7 @@ class CommunityCreateForm extends Component {
const requestID = response.data.id;
// TODO this should redirect to the request page as returned by the API.
// TODO It is computed for now because the link contains references to two different entities (request and community), and that's not supported yet by the backend.
window.location.href = `/communities/${slug}/requests/${requestID}`;
window.location.href = `/communities/${community.slug}/requests/${requestID}`;
} catch (error) {
if (error === "UNMOUNTED") return;

Expand All @@ -150,7 +150,7 @@ class CommunityCreateForm extends Component {
};

render() {
const { formConfig, canCreateRestricted, communityId } = this.props;
const { formConfig, canCreateRestricted, community } = this.props;
const { hasCommunity, communities, error } = this.state;

return (
Expand All @@ -159,7 +159,7 @@ class CommunityCreateForm extends Component {
formConfig={formConfig}
canCreateRestricted={canCreateRestricted}
error={error}
communityId={communityId}
community={community}
IdentifierField={IdentifierField}
>
<Formik
Expand Down Expand Up @@ -313,21 +313,21 @@ class CommunityCreateForm extends Component {
CommunityCreateForm.propTypes = {
formConfig: PropTypes.object.isRequired,
canCreateRestricted: PropTypes.bool.isRequired,
communityId: PropTypes.string.isRequired,
community: PropTypes.object.isRequired,
};

const domContainer = document.getElementById("app");
const formConfig = JSON.parse(domContainer.dataset.formConfig);
const canCreateRestricted = JSON.parse(domContainer.dataset.canCreateRestricted);
const communityId = domContainer.dataset.communityId;
const community = JSON.parse(domContainer.dataset.community);

const overriddenComponents = overrideStore.getAll();
ReactDOM.render(
<OverridableContext.Provider value={overriddenComponents}>
<CommunityCreateForm
formConfig={formConfig}
canCreateRestricted={canCreateRestricted}
communityId={communityId}
community={community}
/>
</OverridableContext.Provider>,
domContainer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
{{ super() }}
<div
id="app"
data-community-id='{{ community_ui.id }}'
data-community ='{{ community_ui | tojson }}'
data-form-config='{{ form_config | tojson }}'
data-custom-fields='{{ custom_fields | tojson }}'
data-can-create-restricted='{{ can_create_restricted | tojson }}'
Expand Down

0 comments on commit 8ea7d05

Please sign in to comment.