Skip to content

Commit

Permalink
Download single application
Browse files Browse the repository at this point in the history
  • Loading branch information
Lucieo committed Mar 6, 2024
1 parent 8214416 commit 6decfae
Show file tree
Hide file tree
Showing 27 changed files with 2,146 additions and 1,190 deletions.
44 changes: 27 additions & 17 deletions back/api/application/controllers/application.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
'use strict';
'use strict'

/**
* Read the documentation (https://strapi.io/documentation/developer-docs/latest/development/backend-customization.html#core-controllers)
Expand All @@ -7,18 +7,29 @@

module.exports = {
async myApplications(ctx) {
const populateCommon = ['disponibility.espace', 'disponibility.espace.users_permissions_user', 'creation_file' ]
const { id, type } = ctx.state.user;
const {query: initialQuery}=ctx.request;
const query = type === "place" ? {...initialQuery, 'disponibility.espace.users_permissions_user.id':id} : {...initialQuery, company: id };
const populate = type==="place"? [...populateCommon,'company', ]:[...populateCommon,'place']
const populateCommon = [
'disponibility.espace',
'disponibility.espace.users_permissions_user',
'creation_file',
'campaign',
]
const { id, type } = ctx.state.user
const { query: initialQuery } = ctx.request
const query =
type === 'place'
? {
...initialQuery,
'disponibility.espace.users_permissions_user.id': id,
}
: { ...initialQuery, company: id }
const populate =
type === 'place'
? [...populateCommon, 'company']
: [...populateCommon, 'place']

return strapi
.query("application")
.find(
query,
populate
)
.query('application')
.find(query, populate)
.then((res) => {
return Promise.all(
res.map(async (application) => {
Expand All @@ -29,10 +40,9 @@ module.exports = {
type,
applicationId: application.id,
}),
};
})
);
});
}
}),
)
})
},

};
}
Loading

0 comments on commit 6decfae

Please sign in to comment.