Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 6507bdcd35 | |||
| e2c8a1edbc | |||
| 02b25ffc84 | |||
| 3e0d2743fb | |||
| fc3ee6724e | |||
| a72cf866fa |
@@ -2,6 +2,12 @@
|
|||||||
|
|
||||||
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.30](https://wibugit.wibudev.com/wibu/hipmi/compare/v1.5.29...v1.5.30) (2025-12-19)
|
||||||
|
|
||||||
|
## [1.5.29](https://wibugit.wibudev.com/wibu/hipmi/compare/v1.5.28...v1.5.29) (2025-12-17)
|
||||||
|
|
||||||
|
## [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.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,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "hipmi",
|
"name": "hipmi",
|
||||||
"version": "1.5.27",
|
"version": "1.5.30",
|
||||||
"private": true,
|
"private": true,
|
||||||
"prisma": {
|
"prisma": {
|
||||||
"seed": "bun prisma/seed.ts"
|
"seed": "bun prisma/seed.ts"
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
-- AlterTable
|
||||||
|
ALTER TABLE "Donasi_Invoice" ALTER COLUMN "masterBankId" DROP DEFAULT;
|
||||||
@@ -587,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 {
|
||||||
|
|||||||
@@ -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 }
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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,
|
||||||
|
|||||||
44
src/app/api/mobile/auth/device-tokens/[id]/route.ts
Normal file
44
src/app/api/mobile/auth/device-tokens/[id]/route.ts
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
import { NextRequest, NextResponse } from "next/server";
|
||||||
|
import { prisma } from "@/lib";
|
||||||
|
|
||||||
|
export { DELETE };
|
||||||
|
|
||||||
|
async function DELETE(
|
||||||
|
request: NextRequest,
|
||||||
|
{ params }: { params: { id: string } }
|
||||||
|
) {
|
||||||
|
const { id } = params;
|
||||||
|
try {
|
||||||
|
const findFirst = await prisma.tokenUserDevice.findFirst({
|
||||||
|
where: {
|
||||||
|
userId: id,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!findFirst) {
|
||||||
|
return NextResponse.json({
|
||||||
|
success: false,
|
||||||
|
message: "User tidak ditemukan !",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const deleted = await prisma.tokenUserDevice.delete({
|
||||||
|
where: {
|
||||||
|
id: findFirst.id,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log("DEL", deleted);
|
||||||
|
|
||||||
|
return NextResponse.json({
|
||||||
|
success: true,
|
||||||
|
message: "Berhasil menghapus device token user",
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.log("ERROR", error);
|
||||||
|
return NextResponse.json(
|
||||||
|
{ error: (error as Error).message, message: "Terjadi error pada API" },
|
||||||
|
{ status: 500 }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,13 +1,14 @@
|
|||||||
import { NextRequest, NextResponse } from "next/server";
|
import { NextRequest, NextResponse } from "next/server";
|
||||||
import { prisma } from "@/lib";
|
import { prisma } from "@/lib";
|
||||||
|
|
||||||
export async function POST(request: NextRequest) {
|
export { POST, GET };
|
||||||
|
|
||||||
|
async function POST(request: NextRequest) {
|
||||||
const { data } = await request.json();
|
const { data } = await request.json();
|
||||||
try {
|
try {
|
||||||
console.log("Data >>", JSON.stringify(data, null, 2));
|
console.log("Data >>", JSON.stringify(data, null, 2));
|
||||||
|
|
||||||
const { userId, platform, deviceId, model, appVersion, fcmToken } =
|
const { userId, platform, deviceId, model, appVersion, fcmToken } = data;
|
||||||
data;
|
|
||||||
|
|
||||||
if (!fcmToken) {
|
if (!fcmToken) {
|
||||||
return NextResponse.json({ error: "Missing Token" }, { status: 400 });
|
return NextResponse.json({ error: "Missing Token" }, { status: 400 });
|
||||||
@@ -62,3 +63,22 @@ export async function POST(request: NextRequest) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function GET(request: NextRequest) {
|
||||||
|
try {
|
||||||
|
const data = await prisma.tokenUserDevice.findMany({
|
||||||
|
where: {
|
||||||
|
isActive: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
return NextResponse.json({ success: true, data });
|
||||||
|
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
return NextResponse.json(
|
||||||
|
{ error: (error as Error).message },
|
||||||
|
{ status: 500 }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { NextRequest, NextResponse } from "next/server";
|
|||||||
export async function POST(request: NextRequest) {
|
export async function POST(request: NextRequest) {
|
||||||
try {
|
try {
|
||||||
const { data } = await request.json();
|
const { data } = await request.json();
|
||||||
const { fcmToken, title, body: notificationBody } = data;
|
const { fcmToken, title, body: notificationBody, userLoginId } = data;
|
||||||
|
|
||||||
console.log("Data Notifikasi >>", data);
|
console.log("Data Notifikasi >>", data);
|
||||||
|
|
||||||
@@ -16,24 +16,37 @@ export async function POST(request: NextRequest) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const message = {
|
const deviceToken = await prisma.tokenUserDevice.findMany({
|
||||||
token: fcmToken,
|
where: {
|
||||||
notification: {
|
isActive: true,
|
||||||
title,
|
NOT: {
|
||||||
body: notificationBody || "",
|
userId: userLoginId,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
data: {
|
});
|
||||||
sentAt: new Date().toISOString(), // ✅ Simpan metadata di data
|
|
||||||
// contoh: senderId, type, etc.
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
console.log("[MSG]", message);
|
for (let i of deviceToken) {
|
||||||
|
const message = {
|
||||||
|
token: i.token,
|
||||||
|
notification: {
|
||||||
|
title,
|
||||||
|
body: notificationBody || "",
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
sentAt: new Date().toISOString(), // ✅ Simpan metadata di data
|
||||||
|
// contoh: senderId, type, etc.
|
||||||
|
},
|
||||||
|
};
|
||||||
|
console.log("[MSG]", message);
|
||||||
|
|
||||||
const response = await adminMessaging.send(message);
|
const response = await adminMessaging.send(message);
|
||||||
console.log("✅ FCM sent:", response);
|
console.log("✅ FCM sent:", response);
|
||||||
|
}
|
||||||
|
|
||||||
return NextResponse.json({ success: true, messageId: response });
|
return NextResponse.json({
|
||||||
|
success: true,
|
||||||
|
message: "Notification sent successfully",
|
||||||
|
});
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
console.error("❌ FCM error:", error);
|
console.error("❌ FCM error:", error);
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
|
|||||||
@@ -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);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user