Skip to content

Commit

Permalink
fix: field order (#71)
Browse files Browse the repository at this point in the history
  • Loading branch information
h4l-yup authored Oct 30, 2023
1 parent 7d57fd8 commit ee6b6d9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 23 deletions.
4 changes: 2 additions & 2 deletions apps/api/src/domains/channel/field/field.mysql.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ export class FieldMySQLService {
this.checkReservedFieldKey(fields);

const fieldsToCreate: CreateFieldDto[] = [
...fields,
{
name: 'ID',
key: 'id',
Expand Down Expand Up @@ -134,6 +133,7 @@ export class FieldMySQLService {
status: FieldStatusEnum.ACTIVE,
description: '',
},
...fields,
];

const fieldEntities = [];
Expand All @@ -158,7 +158,7 @@ export class FieldMySQLService {
return await this.repository.find({
where: { channel: { id: channelId } },
relations: { options: true },
order: { createdAt: 'DESC' },
order: { createdAt: 'ASC' },
});
}

Expand Down
25 changes: 4 additions & 21 deletions apps/api/src/domains/feedback/feedback.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,27 +162,10 @@ export class FeedbackService {
});
const worksheet = workbook.addWorksheet('Sheet 1');

const headerOrderForType = ['DEFAULT', 'API', 'ADMIN'];
const headers = fields
.sort((a, b) => {
const typeA = headerOrderForType.indexOf(a.type);
const typeB = headerOrderForType.indexOf(b.type);

if (typeA !== typeB) return typeA - typeB;

if (a.type === 'DEFAULT' && b.type === 'DEFAULT') {
const nameOrder = ['ID', 'Created', 'Updated', 'Issue'];
const nameA = nameOrder.indexOf(a.name);
const nameB = nameOrder.indexOf(b.name);
return nameA - nameB;
}

return 0;
})
.map((field) => ({
header: field.name,
key: field.name,
}));
const headers = fields.map((field) => ({
header: field.name,
key: field.name,
}));
worksheet.columns = headers;

const pageSize = 1000;
Expand Down

0 comments on commit ee6b6d9

Please sign in to comment.