Skip to content

Commit 653f678

Browse files
authored
Merge pull request #148 from CapstoneProjectCMC/feature/sap-service-and-payment
add user to block
2 parents a40e917 + cdde31f commit 653f678

24 files changed

+742
-47
lines changed

src/app/core/interceptors/handle/error-handler.service.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,13 @@ export class ErrorHandlerService {
4141
'Bạn đã mua sản phẩm này rồi!',
4242
'warning'
4343
);
44+
} else if (errorCode === 4059101) {
45+
sendNotification(
46+
this.store,
47+
'Hết tiền!',
48+
'Bạn cần nạp tiền vào tài khoản của mình trước nhé!',
49+
'error'
50+
);
4451
} else {
4552
sendNotification(
4653
this.store,

src/app/core/models/organization.model.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,16 @@ export type ParamGetAllBlockOfOrg = {
8686
activeOnlyMembers?: boolean;
8787
includeUnassigned?: boolean;
8888
};
89+
90+
//add user
91+
export type InfoUserNeedToAdd = {
92+
userId: string;
93+
role: string;
94+
active: string;
95+
};
96+
97+
export type AddUsersOrgRequest = {
98+
members: InfoUserNeedToAdd[];
99+
defaultRole: string;
100+
active: boolean;
101+
};

src/app/core/services/api-service/organization.service.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { ApiMethod } from '../config-service/api.methods';
33
import { ApiResponse, IPaginationResponse } from '../../models/api-response';
44
import { API_CONFIG } from '../config-service/api.enpoints';
55
import {
6+
AddUsersOrgRequest,
67
BlockResponse,
78
CreateOrgRequest,
89
EditOrgRequest,
@@ -102,4 +103,11 @@ export class OrganizationService {
102103
API_CONFIG.ENDPOINTS.GET.GET_BLOCK_DETAILS(blockId, data)
103104
);
104105
}
106+
107+
bulkAddToBlock(blockId: string, data: AddUsersOrgRequest) {
108+
return this.api.post<ApiResponse<null>>(
109+
API_CONFIG.ENDPOINTS.POST.BULK_ADD_TO_BLOCK(blockId),
110+
data
111+
);
112+
}
105113
}

src/app/core/services/config-service/api.enpoints.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,9 @@ export const API_CONFIG = {
267267
PURCHASE: '/payment/purchase',
268268
CREATE_ORGANIZATION: '/org/organization',
269269
CREATE_BLOCK_IN_ORG: (orgId: string) => `/org/${orgId}/block`,
270+
BULK_ADD_TO_ORG: (orgId: string) => `/org/${orgId}/members:bulk`,
271+
BULK_ADD_TO_BLOCK: (blockId: string) =>
272+
`/org/block/${blockId}/members:bulk`,
270273
},
271274
PUT: {
272275
EDIT_FILE: (id: string) => `/file/api/FileDocument/edit/${id}`,

src/app/features/excercise/exercise-pages/exercise-code-details/exercise-code-details.component.html

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,7 @@ <h1 class="title">{{ exercise.title }}</h1>
8181
</div>
8282
<div class="time-info" title="Giá bài tập">
8383
<i class="fa-solid fa-money-bill-1-wave"></i>
84-
<span>
85-
{{ exercise.cost }}
86-
</span>
84+
<span> {{ exercise.cost | formatView }} VNĐ </span>
8785
</div>
8886
</div>
8987
</div>

src/app/features/excercise/exercise-pages/exercise-code-details/exercise-code-details.component.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import { isAvailabelTime } from '../../../../shared/utils/availableTime';
3131
import { PaymentService } from '../../../../core/services/api-service/payment.service';
3232
import { v4 as uuidv4 } from 'uuid';
3333
import { IPurChaseTransactionRequest } from '../../../../core/models/service-and-payment';
34+
import { FormatViewPipe } from '../../../../shared/pipes/format-view.pipe';
3435

3536
@Component({
3637
selector: 'app-exercise-code-details',
@@ -39,6 +40,7 @@ import { IPurChaseTransactionRequest } from '../../../../core/models/service-and
3940
FormsModule,
4041
UpdateCodeDetailsComponent,
4142
UpdateExerciseComponent,
43+
FormatViewPipe,
4244
],
4345
templateUrl: './exercise-code-details.component.html',
4446
styleUrls: ['./exercise-code-details.component.scss'],
@@ -230,6 +232,7 @@ export class ExerciseCodeDetailsComponent {
230232
this.authorName = res.result.user.displayName;
231233
this.authorRoles = Array.from(res.result.user.roles).join(', ');
232234
this.avatarUrl = res.result.user.avatarUrl ?? avatarUrlDefault;
235+
this.isBought = res.result.purchased;
233236
}
234237
this.isActionActive = activeForMyContent(
235238
res.result.user?.username ?? '',

src/app/features/excercise/exercise-pages/exercise-details/exercise-details.component.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ export class ExerciseDetailsComponent implements OnInit {
224224
if (res.result.user) {
225225
this.authorName = res.result.user.displayName;
226226
this.avatarUrl = res.result.user.avatarUrl;
227+
this.isBought = res.result.purchased;
227228
this.availabelDate = res.result.startTime
228229
? new Date(res.result.startTime)
229230
: null;

src/app/features/excercise/exercise-pages/list-exercise/list-exercise.component.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ export class ListExerciseComponent implements OnInit {
8989
{ value: '1', label: 'Trung bình' },
9090
{ value: '2', label: 'Khó' },
9191
];
92-
const role = decodeJWT(localStorage.getItem('token') ?? '')?.payload.scope;
9392
}
9493

9594
private mapExerciseResToCardDataUI(data: ExerciseItem[]): CardExcercise[] {

src/app/features/organization/organization-component/details-organization/details-organization.component.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@
108108

109109
.org-name {
110110
margin: 0;
111-
font-size: 28px;
111+
font-size: 24px;
112112
font-weight: 700;
113113
color: var(--title-text);
114114
line-height: 1.2;

src/app/features/organization/organization-component/details-organization/details-organization.component.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ export class DetailsOrganizationComponent implements OnInit {
5353
});
5454
}
5555

56-
getStatusLabel(status: number): string {
56+
getStatusLabel(status: number | string): string {
5757
switch (status) {
58-
case 0:
58+
case 'Active':
5959
return 'Hoạt động';
6060
case 1:
6161
return 'Tạm ngưng';
@@ -66,9 +66,9 @@ export class DetailsOrganizationComponent implements OnInit {
6666
}
6767
}
6868

69-
getStatusClass(status: number): string {
69+
getStatusClass(status: number | string): string {
7070
switch (status) {
71-
case 0:
71+
case 'Active':
7272
return 'status-active';
7373
case 1:
7474
return 'status-inactive';

0 commit comments

Comments
 (0)