Compare commits

..

21 Commits

Author SHA1 Message Date
de1d668ff2 Merge pull request 'staging' (#34) from staging into main
Reviewed-on: http://wibugit.wibudev.com/wibu/hipmi/pulls/34
2025-12-17 15:30:56 +08:00
f1c8432fdc Merge pull request 'Fix DB table donasi' (#33) from login-api/17-dec-25 into staging
Reviewed-on: http://wibugit.wibudev.com/wibu/hipmi/pulls/33
2025-12-17 14:44:53 +08:00
3e0d2743fb Fix DB table donasi:
- Relasi ke master bank dengan nilai default NULL

### No issue
2025-12-17 14:43:09 +08:00
fc3ee6724e chore(release): 1.5.28 2025-12-17 14:42:19 +08:00
602d759919 Merge pull request 'Update Versi 1.5.27' (#32) from staging into main
Reviewed-on: http://wibugit.wibudev.com/wibu/hipmi/pulls/32
2025-12-17 12:22:27 +08:00
1cd4c3713e Merge pull request 'login-api/17-dec-25' (#31) from login-api/17-dec-25 into staging
Reviewed-on: http://wibugit.wibudev.com/wibu/hipmi/pulls/31
2025-12-17 11:43:32 +08:00
a72cf866fa Fix API Login dan filter 0 di input nomor
### No Issue
2025-12-17 11:40:01 +08:00
c50e0ceaf7 chore(release): 1.5.27 2025-12-17 11:07:15 +08:00
4307b383e3 Merge pull request 'Penerapan notifikasi mobil ke database' (#30) from mobile-notification/16-dec-25 into staging
Reviewed-on: http://wibugit.wibudev.com/wibu/hipmi/pulls/30
2025-12-16 17:57:21 +08:00
563d95b928 Penerapan notifikasi mobil ke database
Fix:
- modified:   prisma/schema.prisma

Add:
prisma/migrations/20251216041242_add_token_user_device_indexes/
src/app/api/mobile/auth/device-tokens/

### No Issue
2025-12-16 17:50:03 +08:00
0786d23336 Merge pull request 'API notif dan penambahan package firebase-admin' (#29) from mobile-notification/15-dec-25 into staging
Reviewed-on: http://wibugit.wibudev.com/wibu/hipmi/pulls/29
2025-12-15 17:52:03 +08:00
cb3511f973 Merge pull request 'Fix QC ( Ayu )' (#28) from qc-mobile/10-dec-25 into staging
Reviewed-on: http://wibugit.wibudev.com/wibu/hipmi/pulls/28
2025-12-10 17:38:42 +08:00
b4921c4e82 Merge pull request 'Fix API untuk QC: Ayu' (#27) from qc-mobile/9-dec-25 into staging
Reviewed-on: http://wibugit.wibudev.com/wibu/hipmi/pulls/27
2025-12-09 17:40:20 +08:00
a9325054eb Merge pull request 'Fix Apple Reject' (#26) from qc-mobile/8-dec-25 into staging
Reviewed-on: http://wibugit.wibudev.com/wibu/hipmi/pulls/26
2025-12-08 15:33:58 +08:00
819812149f Merge pull request 'Fix QC Admin ( Inno )' (#25) from qc-mobile/5-dec-25 into staging
Reviewed-on: http://wibugit.wibudev.com/wibu/hipmi/pulls/25
2025-12-05 17:15:53 +08:00
75ba2b29ae Merge pull request 'Fix QC Inno:' (#24) from mobile-reject/4-dec-25 into staging
Reviewed-on: http://wibugit.wibudev.com/wibu/hipmi/pulls/24
2025-12-04 17:45:04 +08:00
54a4d15bdd Merge pull request 'Fix WA Server' (#23) from mobile-reject/3-dec-25 into staging
Reviewed-on: http://wibugit.wibudev.com/wibu/hipmi/pulls/23
2025-12-03 16:28:09 +08:00
1321f33da9 Merge pull request 'Fix Apple Rejected' (#22) from mobile-reject/3-dec-25 into staging
Reviewed-on: http://wibugit.wibudev.com/wibu/hipmi/pulls/22
2025-12-03 15:02:40 +08:00
fad0c33b9a Merge pull request 'Alur autentikasi dirubah' (#21) from mobile-reject/2-dec-25 into staging
Reviewed-on: http://wibugit.wibudev.com/wibu/hipmi/pulls/21
2025-12-02 14:41:44 +08:00
565bab4998 Merge pull request 'QC Mobile: Pak jun dan Inno' (#20) from qc/1-dec-25 into staging
Reviewed-on: http://wibugit.wibudev.com/wibu/hipmi/pulls/20
2025-12-01 17:44:48 +08:00
7530a38c4d Merge pull request 'Fix version' (#19) from apple-reject/28-nov-25 into staging
Reviewed-on: http://wibugit.wibudev.com/wibu/hipmi/pulls/19
2025-11-28 11:47:44 +08:00
9 changed files with 188 additions and 29 deletions

View File

@@ -2,6 +2,10 @@
All notable changes to this project will be documented in this file. See [commit-and-tag-version](https://github.com/absolute-version/commit-and-tag-version) for commit guidelines. All notable changes to this project will be documented in this file. See [commit-and-tag-version](https://github.com/absolute-version/commit-and-tag-version) for commit guidelines.
## [1.5.28](https://wibugit.wibudev.com/wibu/hipmi/compare/v1.5.27...v1.5.28) (2025-12-17)
## [1.5.27](https://wibugit.wibudev.com/wibu/hipmi/compare/v1.5.26...v1.5.27) (2025-12-17)
## [1.5.26](https://wibugit.wibudev.com/wibu/hipmi/compare/v1.5.25...v1.5.26) (2025-12-10) ## [1.5.26](https://wibugit.wibudev.com/wibu/hipmi/compare/v1.5.25...v1.5.26) (2025-12-10)
## [1.5.25](https://wibugit.wibudev.com/wibu/hipmi/compare/v1.5.24...v1.5.25) (2025-12-09) ## [1.5.25](https://wibugit.wibudev.com/wibu/hipmi/compare/v1.5.24...v1.5.25) (2025-12-09)

View File

@@ -1,6 +1,6 @@
{ {
"name": "hipmi", "name": "hipmi",
"version": "1.5.26", "version": "1.5.28",
"private": true, "private": true,
"prisma": { "prisma": {
"seed": "bun prisma/seed.ts" "seed": "bun prisma/seed.ts"

View File

@@ -0,0 +1,28 @@
-- AlterTable
ALTER TABLE "Notifikasi" ADD COLUMN "deepLink" TEXT,
ADD COLUMN "readAt" TIMESTAMP(3);
-- CreateTable
CREATE TABLE "TokenUserDevice" (
"id" TEXT NOT NULL,
"isActive" BOOLEAN NOT NULL DEFAULT true,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,
"platform" TEXT,
"deviceId" TEXT,
"model" TEXT,
"appVersion" TEXT,
"token" TEXT NOT NULL,
"userId" TEXT,
CONSTRAINT "TokenUserDevice_pkey" PRIMARY KEY ("id")
);
-- CreateIndex
CREATE INDEX "TokenUserDevice_userId_idx" ON "TokenUserDevice"("userId");
-- CreateIndex
CREATE INDEX "TokenUserDevice_token_idx" ON "TokenUserDevice"("token");
-- AddForeignKey
ALTER TABLE "TokenUserDevice" ADD CONSTRAINT "TokenUserDevice_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;

View File

@@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "Donasi_Invoice" ALTER COLUMN "masterBankId" DROP DEFAULT;

View File

@@ -58,6 +58,7 @@ model User {
acceptedTermsAt DateTime? acceptedTermsAt DateTime?
acceptedForumTermsAt DateTime? acceptedForumTermsAt DateTime?
tokenUserDevices TokenUserDevice[]
} }
model MasterUserRole { model MasterUserRole {
@@ -586,7 +587,7 @@ model Donasi_Invoice {
imageId String? imageId String?
MasterBank MasterBank? @relation(fields: [masterBankId], references: [id]) MasterBank MasterBank? @relation(fields: [masterBankId], references: [id])
masterBankId String? @default("null") masterBankId String?
} }
model Donasi_Kabar { model Donasi_Kabar {
@@ -973,16 +974,19 @@ model NomorAdmin {
} }
model Notifikasi { model Notifikasi {
id String @id @default(cuid()) id String @id @default(cuid())
isActive Boolean @default(true) isActive Boolean @default(true)
createdAt DateTime @default(now()) createdAt DateTime @default(now())
updatedAt DateTime @updatedAt updatedAt DateTime @updatedAt
isRead Boolean @default(false)
appId String appId String
kategoriApp String kategoriApp String
pesan String pesan String
title String? title String?
status String? status String?
isRead Boolean @default(false)
readAt DateTime? // kapan user membaca notifikasi ini
deepLink String? // misal: "announcement/123", "user/profile/cmha6wb9w0001cfndwl9fcse6"
Role MasterUserRole? @relation(fields: [userRoleId], references: [id]) Role MasterUserRole? @relation(fields: [userRoleId], references: [id])
userRoleId String userRoleId String
@@ -1099,3 +1103,22 @@ model BlockedUser {
@@unique([blockerId, blockedId]) @@unique([blockerId, blockedId])
} }
model TokenUserDevice {
id String @id @default(uuid())
isActive Boolean @default(true)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
platform String? // "ios" | "android"
deviceId String? // UUID unik dari device (misal: dari expo-device)
model String? // "iPhone15,4", "Pixel 7", dll
appVersion String? // "1.5.15" — sangat berguna saat debug
token String @db.Text
user User? @relation(fields: [userId], references: [id])
userId String?
@@index([userId])
@@index([token]) // untuk pencarian cepat & deduplikasi
}

View File

@@ -33,18 +33,24 @@ export async function POST(req: Request) {
// const encodedMsg = encodeURIComponent(msg); // const encodedMsg = encodeURIComponent(msg);
const res = await fetch( const res = await fetch(
`https://wa.wibudev.com/code?nom=${nomor}&text=${msg}`, `https://cld-dkr-prod-wajs-server.wibudev.com/api/wa/code?nom=${nomor}&text=${msg}`,
{ cache: "no-cache" } {
cache: "no-cache",
headers: {
Authorization: `Bearer ${process.env.WA_SERVER_TOKEN}`,
},
}
); );
const sendWa = await res.json(); if (res.status !== 200)
if (sendWa.status !== "success")
return NextResponse.json( return NextResponse.json(
{ success: false, message: "Nomor Whatsapp Tidak Aktif" }, { success: false, message: "Nomor Whatsapp Tidak Aktif" },
{ status: 400 } { status: 400 }
); );
const sendWa = await res.text();
console.log("WA Response:", sendWa);
return NextResponse.json( return NextResponse.json(
{ {
success: true, success: true,
@@ -63,5 +69,5 @@ export async function POST(req: Request) {
}, },
{ status: 500 } { status: 500 }
); );
} }
} }

View File

@@ -18,22 +18,25 @@ export async function POST(req: Request) {
const msg = `HIPMI%20-%20Kode%20ini%20bersifat%20RAHASIA%20dan%20JANGAN%20DI%20BAGIKAN%20KEPADA%20SIAPAPUN%2C%20termasuk%20anggota%20ataupun%20pengurus%20HIPMI%20lainnya.%5Cn%5Cn%3E%3E%20Kode%20OTP%20anda%3A%20${codeOtp}.`; const msg = `HIPMI%20-%20Kode%20ini%20bersifat%20RAHASIA%20dan%20JANGAN%20DI%20BAGIKAN%20KEPADA%20SIAPAPUN%2C%20termasuk%20anggota%20ataupun%20pengurus%20HIPMI%20lainnya.%5Cn%5Cn%3E%3E%20Kode%20OTP%20anda%3A%20${codeOtp}.`;
const res = await fetch( const res = await fetch(
`https://wa.wibudev.com/code?nom=${nomor}&text=${msg}`, `https://cld-dkr-prod-wajs-server.wibudev.com/api/wa/code?nom=${nomor}&text=${msg}`,
{ cache: "no-cache" } {
cache: "no-cache",
headers: {
Authorization: `Bearer ${process.env.WA_SERVER_TOKEN}`,
},
}
); );
const sendWa = await res.json(); if (res.status !== 200)
if (sendWa.status !== "success")
return NextResponse.json( return NextResponse.json(
{ { success: false, message: "Nomor Whatsapp Tidak Aktif" },
success: false,
message: "Nomor Whatsapp Tidak Aktif",
},
{ status: 400 } { status: 400 }
); );
const sendWa = await res.text();
console.log("WA Response:", sendWa);
const createOtpId = await prisma.kodeOtp.create({ const createOtpId = await prisma.kodeOtp.create({
data: { data: {
nomor: nomor, nomor: nomor,

View File

@@ -0,0 +1,64 @@
import { NextRequest, NextResponse } from "next/server";
import { prisma } from "@/lib";
export async function POST(request: NextRequest) {
const { data } = await request.json();
try {
console.log("Data >>", JSON.stringify(data, null, 2));
const { userId, platform, deviceId, model, appVersion, fcmToken } =
data;
if (!fcmToken) {
return NextResponse.json({ error: "Missing Token" }, { status: 400 });
}
const existing = await prisma.tokenUserDevice.findFirst({
where: {
token: fcmToken,
userId: userId,
},
select: {
id: true,
},
});
let deviceToken;
if (existing) {
deviceToken = await prisma.tokenUserDevice.update({
where: {
id: existing?.id,
},
data: {
platform,
deviceId,
model,
appVersion,
isActive: true,
updatedAt: new Date(),
},
});
} else {
// Buat baru jika belum ada
deviceToken = await prisma.tokenUserDevice.create({
data: {
token: fcmToken,
userId: userId,
platform,
deviceId,
model,
appVersion,
isActive: true,
},
});
}
return NextResponse.json({ success: true, data: deviceToken });
} catch (error) {
return NextResponse.json(
{ error: (error as Error).message },
{ status: 500 }
);
}
}

View File

@@ -21,17 +21,24 @@ import { apiFetchLogin } from "../_lib/api_fetch_auth";
export default function Login({ version }: { version: string }) { export default function Login({ version }: { version: string }) {
const router = useRouter(); const router = useRouter();
const [phone, setPhone] = useState("");
const [loading, setLoading] = useState(false); const [loading, setLoading] = useState(false);
const [isError, setError] = useState(false); const [isError, setError] = useState(false);
const [phone, setPhone] = useState("");
const [countryCode, setCountryCode] = useState<string>("62"); // default ke Indonesia
async function onLogin() { async function onLogin() {
const nomor = phone.substring(1); console.log("phone >>", phone);
const nomor = phone;
if (nomor.length <= 4) return setError(true); if (nomor.length <= 4) return setError(true);
const fixPhone = `${countryCode}${nomor}`;
console.log("fixPhone >>", fixPhone);
try { try {
setLoading(true); setLoading(true);
const respone = await apiFetchLogin({ nomor: nomor }); const respone = await apiFetchLogin({ nomor: fixPhone });
if (respone && respone.success) { if (respone && respone.success) {
localStorage.setItem("hipmi_auth_code_id", respone.kodeId); localStorage.setItem("hipmi_auth_code_id", respone.kodeId);
@@ -72,16 +79,38 @@ export default function Login({ version }: { version: string }) {
<Center> <Center>
<Text c={MainColor.white}>Nomor telepon</Text> <Text c={MainColor.white}>Nomor telepon</Text>
</Center> </Center>
<PhoneInput <PhoneInput
countrySelectorStyleProps={{ countrySelectorStyleProps={{
buttonStyle: { buttonStyle: {
backgroundColor: MainColor.login, backgroundColor: MainColor.login,
}, },
}} }}
inputStyle={{ width: "100%", backgroundColor: MainColor.login }}
defaultCountry="id" defaultCountry="id"
onChange={(val) => { inputStyle={{ width: "100%", backgroundColor: MainColor.login }}
setPhone(val); onChange={(fullPhone, meta) => {
const dialCode = meta.country.dialCode; // string, misal: "62"
let localNumber = fullPhone;
// Hapus kode negara dari awal string
if (fullPhone.startsWith(`+${dialCode}`)) {
localNumber = fullPhone.slice(`+${dialCode}`.length);
}
// Bersihkan semua non-digit
localNumber = localNumber.replace(/\D/g, "");
// ✅ Filter khusus: untuk Indonesia (+62), hapus leading zero
if (dialCode === "62" && localNumber.startsWith("0")) {
localNumber = localNumber.replace(/^0+/, ""); // hapus semua 0 di awal
}
// Simpan hasil akhir
setCountryCode(dialCode);
setPhone(localNumber);
// console.log("Country Code:", dialCode);
// console.log("Clean Local Number:", localNumber);
}} }}
/> />