add restuarant to contact entity
This commit is contained in:
@@ -12,7 +12,8 @@ type FindContactsOpts = {
|
||||
orderBy?: string;
|
||||
order?: 'asc' | 'desc';
|
||||
status?: ContactStatusEnum;
|
||||
scope?: ContactScope
|
||||
scope?: ContactScope;
|
||||
restaurantId?: string;
|
||||
};
|
||||
|
||||
@Injectable()
|
||||
@@ -26,7 +27,7 @@ export class ContactRepository extends EntityRepository<Contact> {
|
||||
* Supports: search (subject/content/phone), status, ordering.
|
||||
*/
|
||||
async findAllPaginated(opts: FindContactsOpts = {}): Promise<PaginatedResult<Contact>> {
|
||||
const { page = 1, limit = 10, search, scope, orderBy = 'createdAt', order = 'desc', status } = opts;
|
||||
const { page = 1, limit = 10, search, scope, orderBy = 'createdAt', order = 'desc', status, restaurantId } = opts;
|
||||
|
||||
const offset = (page - 1) * limit;
|
||||
|
||||
@@ -38,6 +39,9 @@ export class ContactRepository extends EntityRepository<Contact> {
|
||||
if (scope) {
|
||||
where.scope = scope;
|
||||
}
|
||||
if (restaurantId) {
|
||||
where.restaurant = restaurantId;
|
||||
}
|
||||
|
||||
if (search) {
|
||||
const pattern = `%${search}%`;
|
||||
|
||||
Reference in New Issue
Block a user