Commit b9c354e1 by Natthaphat

จัดการบริษัท แก้ภาษา

parent 956ae068
......@@ -82,7 +82,7 @@
</div>
</td>
<td>
<span class="badge bg-{{ item.status == 1 ? 'primary' : 'danger'}} text-white">
<span class="badge bg-{{ item.status == 1 ? 'primary' : 'warning'}} text-white">
{{item.getStatus()}}
</span>
</td>
......@@ -187,13 +187,23 @@
<img [src]="selectModel.getPicture()" alt="" id="profile-img">
<span class="badge rounded-full bg-primary avatar-badge">
<input (click)="triggerFileInput()" ng2FileSelect [uploader]="uploaderProfile" type="file"
name="photo" class="absolute w-full h-full opacity-[0]" id="profile-change" [disabled]="action === 'edit'">
name="photo" class="absolute w-full h-full opacity-[0]" id="profile-change"
[disabled]="action === 'edit'">
<i class="fe fe-camera text-[.625rem]"></i>
</span>
</span>
</div>
</div>
<div class="xl:col-span-12 col-span-12" *ngIf="action == 'edit'">
<label for="companyId" class="form-label">{{'รหัสบริษัท' | translate}}</label>
<input type="text" class="form-control !bg-input-readonly" id="companyId" placeholder=""
[(ngModel)]="selectModel.companyId" [disabled]="action === 'edit'">
<!-- <div class="text-danger" *ngIf="!selectModel.companyId && action === 'add'">
{{'Please fill in information' | translate}}
</div> -->
</div>
<div class="xl:col-span-12 col-span-12">
<label for="thName" class="form-label">{{'ชื่อบริษัท ไทย' | translate}}</label>
<input type="text" class="form-control" id="thName" placeholder="" [(ngModel)]="selectModel.thName">
......@@ -209,34 +219,43 @@
</div>
</div>
<div class="xl:col-span-12 col-span-12" *ngIf="action == 'edit'">
<label for="companyId" class="form-label">{{'รหัสบริษัท' | translate}}</label>
<input type="text" class="form-control !bg-input-readonly" id="companyId" placeholder="" [(ngModel)]="selectModel.companyId"
[disabled]="action === 'edit'" >
<!-- <div class="text-danger" *ngIf="!selectModel.companyId && action === 'add'">
{{'Please fill in information' | translate}}
</div> -->
</div>
<div class="xl:col-span-12 col-span-12">
<label for="email" class="form-label">{{'Email' | translate}}</label>
<input type="email" class="form-control" id="emailAddress" placeholder="Email Addresss" [(ngModel)]="selectModel.email" (input)="filterEngInput($event)">
<input type="email" class="form-control" id="emailAddress" placeholder="Email Addresss"
[(ngModel)]="selectModel.email" (input)="filterEngInput($event)">
<div class="text-danger" *ngIf="!selectModel.email">
{{ 'Please fill in information' | translate }}
</div>
<div class="text-danger" *ngIf="selectModel.email && (!selectModel.email.includes('@'))">
{{ 'Invalid email format @' | translate }}
</div>
<div class="text-danger" *ngIf="selectModel.email && selectModel.email.includes('@') && !selectModel.email.split('@')[1]?.includes('.')">
<div class="text-danger"
*ngIf="selectModel.email && selectModel.email.includes('@') && !selectModel.email.split('@')[1]?.includes('.')">
{{ 'Invalid email format .' | translate }}
</div>
</div>
<!-- <div class="xl:col-span-12 col-span-12">
<!-- <div class="xl:col-span-6 col-span-12" *ngIf="action !== 'edit'">
<label for="password" class="form-label">{{'Password' | translate}}</label>
<input type="password" class="form-control" id="emailAddress" placeholder="Choose Password" [(ngModel)]="selectModel.password">
<input type="password" class="form-control" id="password" placeholder="" [(ngModel)]="password">
<div class="text-danger" *ngIf="!password">
{{ 'Please fill in information' | translate }}
</div>
</div>
<div class="xl:col-span-6 col-span-12" *ngIf="action !== 'edit'">
<label for="deal-title" class="form-label">{{'Confirm Password' | translate}}</label>
<input type="password" class="form-control" id="deal-title" placeholder="" [(ngModel)]="confirmPassword">
<div class="text-danger" *ngIf="!confirmPassword">
{{'Please fill in information' | translate}}
</div>
<div class="text-danger" *ngIf="confirmPassword && (confirmPassword != password)">
{{'Password Not Match' | translate}}
</div>
</div> -->
<!-- <div class="xl:col-span-12 col-span-12">
<label for="companyDetail" class="form-label">{{'ข้อมูลบริษัท' | translate}}</label>
<textarea class="form-control" id="companyDetail" placeholder="" [(ngModel)]="selectModel.companyDetail">
......@@ -285,10 +304,27 @@
data-hs-overlay="#modal-detail">
{{'Cancel' | translate}}
</button>
<button type="button" (click)="save()" class="ti-btn bg-primary text-white !font-medium"
[class.ti-btn-disabled]="!selectModel.thName||!selectModel.engName"
[disabled]="!selectModel.thName||!selectModel.engName">
{{'Save' | translate}}</button>
<button *ngIf="action === 'add'" type="button" (click)="save()"
class="ti-btn bg-primary text-white !font-medium" [class.ti-btn-disabled]="!selectModel.thName||
!selectModel.engName ||
(!selectModel.email || isEmailDuplicate || !selectModel.email.includes('@') || !selectModel.email.includes('.'))"
[disabled]="!selectModel.thName||
!selectModel.engName ||
(!selectModel.email || isEmailDuplicate || !selectModel.email.includes('@') || !selectModel.email.includes('.'))">
<!-- !password || !confirmPassword || (confirmPassword !== password)" -->
{{'Save' | translate}}</button>
<button *ngIf="action === 'edit'" type="button" (click)="save()"
class="ti-btn bg-primary text-white !font-medium"
[class.ti-btn-disabled]="!selectModel.thName||
!selectModel.engName ||
(!selectModel.email || isEmailDuplicate || !selectModel.email.includes('@') || !selectModel.email.includes('.'))"
[disabled]="!selectModel.thName||
!selectModel.engName ||
(!selectModel.email || isEmailDuplicate || !selectModel.email.includes('@') || !selectModel.email.includes('.'))">
{{'Save' | translate}}</button>
</div>
</div>
</div>
......
......@@ -330,7 +330,7 @@
</div>
</div>
<div class="xl:col-span-6 col-span-12">
<div class="xl:col-span-6 col-span-12" *ngIf="action !== 'edit'">
<label for="deal-title" class="form-label">{{'Confirm Password' | translate}}</label>
<input type="password" class="form-control" id="deal-title" placeholder="" [(ngModel)]="confirmPassword">
<div class="text-danger" *ngIf="!confirmPassword">
......
......@@ -2,12 +2,14 @@ import { TranslateService } from "@ngx-translate/core"
import { BaseModel } from "./base.model"
import { RoleModel } from "./role.model"
import { ProfileModel } from "./profile.model"
import { CompanyModelS } from "./companys.mode"
export interface AuthModel {
username: string
password: string
role: RoleModel
profile: ProfileModel
company: CompanyModelS
}
export class AuthModel extends BaseModel implements AuthModel {
......@@ -15,6 +17,7 @@ export class AuthModel extends BaseModel implements AuthModel {
password: string
role: RoleModel
profile: ProfileModel
company: CompanyModelS
constructor(data?: Partial<AuthModel>, translateService?: TranslateService) {
super(data, translateService)
......@@ -22,6 +25,7 @@ export class AuthModel extends BaseModel implements AuthModel {
this.password = data?.password!
this.role = data?.role ? new RoleModel(data.role, translateService) : data?.role!
this.profile = data?.profile ? new ProfileModel(data.profile, translateService) : data?.profile!
this.company = data?.company ? new CompanyModelS(data.company, translateService) : data?.company!
}
}
......
......@@ -149,9 +149,9 @@ export class CompanyModelS extends BaseModel implements CompanyModelS {
getStatus(): string {
if (this.status == 1) {
return this.translateService.instant('PUBLIC');
return this.translateService.instant('Public');
} else {
return this.translateService.instant('PENDING');
return this.translateService.instant('Pending');
}
}
......
......@@ -5,7 +5,8 @@ import { Injectable } from '@angular/core';
import { forkJoin, map, Observable, switchMap } from 'rxjs';
import { environment } from "../../../environments/environment";
import { CompanyModelS } from '../models/companys.mode';
import { PageResponseModel } from '../models/base.model'; // ตรวจสอบว่ามี BaseModel ใน base.model.ts
import { PageResponseModel, ResponseModel } from '../models/base.model'; // ตรวจสอบว่ามี BaseModel ใน base.model.ts
import { AuthModel } from '../models/auth.model';
@Injectable({
providedIn: 'root'
......@@ -13,6 +14,7 @@ import { PageResponseModel } from '../models/base.model'; // ตรวจสอ
export class CompanyServiceS {
api = "/admin/manage-company";
urlApi = environment.baseUrl + "/admin/manage-company";
apiAuthUrl = "/auth"
constructor(private http: HttpClient) { }
......@@ -21,7 +23,7 @@ export class CompanyServiceS {
}
getList(): Observable<CompanyModelS[]> {
return this.http.get<CompanyModelS[]>(this.urlApi + "/lists");
return this.http.get<CompanyModelS[]>(this.urlApi + "/lists?status=1");
}
getListByPageSize(body: { page: number; size: number }): Observable<PageResponseModel<CompanyModelS>> {
......@@ -60,6 +62,14 @@ export class CompanyServiceS {
);
}
register(body: AuthModel) {
return this.http.post<ResponseModel>(this.apiAuthUrl + "/register", body);
}
put(body: CompanyModelS) {
return this.http.put<ResponseModel>(this.urlApi, new CompanyModelS(body));
}
saveOrUpdateCompany(body: CompanyModelS): Observable<any> {
return this.http.post(this.urlApi, body); // ใช้ POST สำหรับทั้งคู่
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment