Skip to content

Commit

Permalink
✔ Fix Update Profile ~
Browse files Browse the repository at this point in the history
  • Loading branch information
bifeldy committed Jun 30, 2023
1 parent 4d58752 commit 9a4cb25
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 17 deletions.
1 change: 0 additions & 1 deletion dist/fansubid/browser/794.2d3bf421d3fbb2bf.js

This file was deleted.

1 change: 1 addition & 0 deletions dist/fansubid/browser/794.5dd08991545ae6be.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/fansubid/browser/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
<noscript>🎉 Harap Menyalakan JavaScript Untuk Dapat Mengakses Website Ini ✨</noscript>
</div>
<app-root></app-root>
<script src="runtime.16435f2c8019c783.js" type="module"></script><script src="polyfills.325a71d3e423341a.js" type="module"></script><script src="scripts.03e7a8120a25f41a.js" defer></script><script src="main.8b4d0cb386160527.js" type="module"></script>
<script src="runtime.b049e9967779cb93.js" type="module"></script><script src="polyfills.325a71d3e423341a.js" type="module"></script><script src="scripts.03e7a8120a25f41a.js" defer></script><script src="main.8b4d0cb386160527.js" type="module"></script>


</body></html>
12 changes: 6 additions & 6 deletions dist/fansubid/browser/ngsw.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"configVersion": 1,
"timestamp": 1688086232546,
"timestamp": 1688089652678,
"index": "/index.html",
"assetGroups": [
{
Expand Down Expand Up @@ -30,7 +30,7 @@
"/635.f50d22077aeb7d2e.js",
"/750.0c44f58b7f21cc1e.js",
"/772.eebac240ffd089ed.js",
"/794.2d3bf421d3fbb2bf.js",
"/794.5dd08991545ae6be.js",
"/839.f854a9f9523c5acc.js",
"/847.c271b193fec80db3.js",
"/915.6b0fb83fcaa7dc11.js",
Expand All @@ -43,7 +43,7 @@
"/main.8b4d0cb386160527.js",
"/manifest.webmanifest",
"/polyfills.325a71d3e423341a.js",
"/runtime.16435f2c8019c783.js",
"/runtime.b049e9967779cb93.js",
"/scripts.03e7a8120a25f41a.js",
"/styles.b697e74e91f54c20.css"
],
Expand Down Expand Up @@ -103,7 +103,7 @@
"/635.f50d22077aeb7d2e.js": "3980b188a72809c30bacbd0ddd7b70064134cd70",
"/750.0c44f58b7f21cc1e.js": "93bf8b9d38c41efb0a7ee30d7052565d80d966e8",
"/772.eebac240ffd089ed.js": "af356d0dffacda5b8d767f7bac30d11f7bd07f11",
"/794.2d3bf421d3fbb2bf.js": "51175329ef693352fa00fa08c3c7a9a9a621b305",
"/794.5dd08991545ae6be.js": "0f87fe093889a0e4c69baf528948492f52cbce19",
"/839.f854a9f9523c5acc.js": "39f995b5eb8108ae18b098aedfee2609e14bf8f2",
"/847.c271b193fec80db3.js": "a96a8a04c132159e7984373ea09a0d9e504ab26d",
"/915.6b0fb83fcaa7dc11.js": "0178f1bdbedb7e451eb99338557350fa08bb7eed",
Expand All @@ -112,11 +112,11 @@
"/960.5e014ce2e6e49bcf.js": "f853b2cc2ee3b2b356b3aee241491de4c14cba22",
"/common.ac0ed540e3ab82a3.js": "27ad6f976af96ecfe2f83db7a8e582f55ed6d0e9",
"/favicon.ico": "071facb8fab2e4b3493dcfbb0b02d7bd21bca97e",
"/index.html": "fa045b8563bb8d22114989b675af1b16cbb13f8d",
"/index.html": "3da0f5b144dac9afe29de3a65ea770ffb2b67f28",
"/main.8b4d0cb386160527.js": "6afc7cbf026a9a9bb2588b61fc237024333b8752",
"/manifest.webmanifest": "eafb5426cdc9fd714787e5453af315b9972875a3",
"/polyfills.325a71d3e423341a.js": "18f8a8b77e7d11be1385d438c6d218cc68c0edb3",
"/runtime.16435f2c8019c783.js": "6c1d48e5d8896f702b3eb558ef32080bf08950bd",
"/runtime.b049e9967779cb93.js": "0c2a638cf8da74d6492d48d1e0e7d3e06e854acf",
"/scripts.03e7a8120a25f41a.js": "2f52334f58ca527e57efab741f2fac760e6dd84d",
"/styles.b697e74e91f54c20.css": "972988388aafead5cb07e9a94f2b9c42e53cf768"
},
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/fansubid/server/main.js

Large diffs are not rendered by default.

23 changes: 19 additions & 4 deletions src/api/controllers/user.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,12 @@ export class UserController {
@FilterApiKeyAccess()
async updateByUsername(@Req() req: Request, @Res({ passthrough: true }) res: Response): Promise<any> {
try {
if ('description' in req.body || 'new_password' in req.body || 'image_photo' in req.body || 'image_cover' in req.body || 'private' in req.body) {
if (
'old_password' in req.body && (
'nama' in req.body || 'description' in req.body || 'new_password' in req.body ||
'image_photo' in req.body || 'image_cover' in req.body || 'private' in req.body
)
) {
const user: UserModel = res.locals['user'];
const old_password = this.cs.hashPassword(req.body.old_password);
const selectedUser = await this.userRepo.findOneOrFail({
Expand All @@ -186,6 +191,14 @@ export class UserController {
if ('private' in req.body) {
selectedUser.private = req.body.private;
}
const selectedKtp = await this.ktpRepo.findOneOrFail({
where: [
{ id: Equal(selectedUser.kartu_tanda_penduduk_.id) }
]
});
if ('nama' in req.body) {
selectedKtp.nama = req.body.nama;
}
const selectedProfile = await this.profileRepo.findOneOrFail({
where: [
{ id: selectedUser.profile_.id }
Expand All @@ -197,6 +210,8 @@ export class UserController {
if ('description' in req.body) {
selectedProfile.description = req.body.description;
}
const resKtpSave = await this.ktpRepo.save(selectedKtp);
selectedUser.kartu_tanda_penduduk_ = resKtpSave;
const resProfileSave = await this.profileRepo.save(selectedProfile);
selectedUser.profile_ = resProfileSave;
let resUserSave = await this.userRepo.save(selectedUser);
Expand Down Expand Up @@ -260,11 +275,11 @@ export class UserController {
} catch (error) {
if (error instanceof HttpException) throw error;
throw new HttpException({
info: `🙄 404 - User API :: Gagal Mencari User ${req.params['username']} 😪`,
info: `🙄 400 - User API :: Gagal Mencari User ${req.params['username']} 😪`,
result: {
message: 'User Tidak Ditemukan!'
message: 'Kredensial tidak tepat!'
}
}, HttpStatus.NOT_FOUND);
}, HttpStatus.BAD_REQUEST);
}
}

Expand Down
17 changes: 14 additions & 3 deletions src/app/_pages/user/user-edit/user-edit.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,22 @@
<!-- Content -->
<div class="col-md-8 col-xl-9 pt-3">
<div class="row py-3 px-0 profile-height-large">
<h1 class="m-0 mt-auto">
<b>{{ userData.kartu_tanda_penduduk_.nama }}</b>
</h1>
<!--
<h1 class="m-0 mt-auto">
<b>{{ userData.kartu_tanda_penduduk_.nama }}</b>
</h1>
-->
</div>
<div class="row py-3">
<mat-form-field appearance="outline" class="p-3 col-12" [color]="'accent'">
<mat-label>Nama Lengkap</mat-label>
<input matInput formControlName="nama" placeholder="Nama Lengkap" />
<mat-icon matSuffix>wysiwyg</mat-icon>
<mat-error>
<div *ngIf="fg.get('nama').hasError('required')">Nama Tidak Boleh Kosong</div>
<div *ngIf="fg.get('nama').hasError('pattern')">Nama Hanya Boleh Huruf Standar Papan Ketik</div>
</mat-error>
</mat-form-field>
<mat-form-field appearance="outline" class="px-3 pt-3 w-100" [color]="'accent'">
<mat-label>Cover Image</mat-label>
<ngx-mat-file-input class="w-100" placeholder="Basic Input" (change)="uploadCoverImage($event, coverImage)" #coverImage
Expand Down
1 change: 1 addition & 0 deletions src/app/_pages/user/user-edit/user-edit.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ export class UserEditComponent implements OnInit, OnDestroy {

initForm(data): void {
this.fg = this.fb.group({
nama: [data.kartu_tanda_penduduk_.nama, [Validators.required, Validators.pattern('^[a-zA-Z. ]+$')]],
description: [data.profile_.description, Validators.compose([Validators.pattern(CONSTANTS.regexEnglishKeyboardKeys)])],
old_password: [null, Validators.compose([Validators.required, Validators.minLength(8), Validators.pattern(CONSTANTS.regexEnglishKeyboardKeys)])],
new_password: [null, Validators.compose([Validators.minLength(8), Validators.pattern(CONSTANTS.regexEnglishKeyboardKeys)])],
Expand Down

0 comments on commit 9a4cb25

Please sign in to comment.