Merge pull request 'join' (#45) from join into staging

Reviewed-on: bip/sistem-desa-mandiri#45
This commit is contained in:
2025-09-22 16:15:25 +08:00
25 changed files with 5039 additions and 1 deletions

2514
darmasaba-api-ai.yml Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,253 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Privacy Policy — Bali Interaktif Perkasa</title>
<style>
:root {
--bg: #ffffff;
--fg: #111111;
--muted: #555555;
--accent: #0a7cff;
--card: #f7f7f8;
--border: #e5e7eb;
}
* { box-sizing: border-box; }
body {
margin: 0;
font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
color: var(--fg);
background: var(--bg);
line-height: 1.6;
}
header {
padding: 2.5rem 1rem 1rem;
background: linear-gradient(180deg, #eef4ff, #fff);
border-bottom: 1px solid var(--border);
}
.container {
max-width: 840px;
margin: 0 auto;
padding: 0 1rem 3rem;
}
h1 {
margin: 0 0 0.5rem;
font-size: clamp(1.6rem, 3vw, 2.2rem);
line-height: 1.2;
letter-spacing: -0.01em;
}
.updated {
color: var(--muted);
font-size: 0.95rem;
}
nav.toc {
background: var(--card);
border: 1px solid var(--border);
border-radius: 12px;
padding: 1rem 1.25rem;
margin: 1.25rem 0 2rem;
}
nav.toc h2 {
margin: 0 0 0.5rem;
font-size: 1.05rem;
}
nav.toc ol {
margin: 0.25rem 0 0.5rem 1.25rem;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
section { margin: 2rem 0; }
h2 {
font-size: 1.35rem;
margin: 0 0 0.5rem;
letter-spacing: -0.01em;
}
h3 { font-size: 1.05rem; margin: 1rem 0 0.25rem; }
.summary {
background: #fffef5;
border: 1px solid #f1e8c6;
border-radius: 12px;
padding: 1rem 1.25rem;
}
ul, ol { padding-left: 1.25rem; }
address { font-style: normal; white-space: pre-line; }
footer {
margin-top: 2.5rem;
padding-top: 1rem;
border-top: 1px solid var(--border);
color: var(--muted);
font-size: 0.95rem;
}
code { background: #f1f5f9; padding: 0.1rem 0.3rem; border-radius: 6px; }
.lead { font-size: 1.05rem; }
</style>
</head>
<body>
<header>
<div class="container">
<h1>Privacy Policy</h1>
<div class="updated">Last updated September 01, 2025</div>
</div>
</header>
<main class="container">
<p class="lead">
This Privacy Notice for <strong>Bali Interaktif Perkasa</strong> ("we," "us," or "our") describes how and why we might access, collect, store, use, and/or share ("process") your personal information when you use our services ("Services"), including when you:
</p>
<ul>
<li>Download and use our mobile application (<em>Darmasaba mobile</em>), or any other application of ours that links to this Privacy Notice.</li>
<li>Use Administration. This mobile application is specifically designed to help village officials manage data and monitor the progress of internal activities. It offers features such as data management by division, general activity monitoring, discussion forums, official announcements, and document folder management.</li>
<li>Engage with us in other related ways, including any sales, marketing, or events.</li>
</ul>
<p>Questions or concerns? Reading this Privacy Notice will help you understand your privacy rights and choices. We are responsible for making decisions about how your personal information is processed. If you do not agree with our policies and practices, please do not use our Services. If you still have any questions or concerns, please contact us at <a href="mailto:bip.baliinteraktifperkasa@gmail.com">bip.baliinteraktifperkasa@gmail.com</a>.</p>
<section class="summary">
<h2>Summary of Key Points</h2>
<p>This summary provides key points from our Privacy Notice, but you can find out more details about any of these topics by using the table of contents below.</p>
<ul>
<li><strong>What personal information do we process?</strong> We may process personal information depending on how you interact with us and the Services, the choices you make, and the products and features you use.</li>
<li><strong>Do we process any sensitive personal information?</strong> We do not process sensitive personal information.</li>
<li><strong>Do we collect any information from third parties?</strong> We do not collect any information from third parties.</li>
<li><strong>How do we process your information?</strong> To provide, improve, and administer our Services; communicate with you; for security and fraud prevention; and to comply with law. We may also process your information for other purposes with your consent.</li>
<li><strong>In what situations and with which parties do we share personal information?</strong> We may share information in specific situations and with specific third parties.</li>
<li><strong>How do we keep your information safe?</strong> We have organizational and technical measures to protect your personal information; however, no method is 100% secure.</li>
<li><strong>What are your rights?</strong> Depending on your location, you may have certain rights regarding your personal information.</li>
<li><strong>How do you exercise your rights?</strong> The easiest way is by emailing <a href="mailto:bip.baliinteraktifperkasa@gmail.com">bip.baliinteraktifperkasa@gmail.com</a>.</li>
</ul>
<p>Want to learn more about what we do with information we collect? Review the Privacy Notice in full below.</p>
</section>
<nav class="toc" aria-label="Table of contents">
<h2>Table of Contents</h2>
<ol>
<li><a href="#collect">1. WHAT INFORMATION DO WE COLLECT?</a></li>
<li><a href="#process">2. HOW DO WE PROCESS YOUR INFORMATION?</a></li>
<li><a href="#share">3. WHEN AND WITH WHOM DO WE SHARE YOUR PERSONAL INFORMATION?</a></li>
<li><a href="#retention">4. HOW LONG DO WE KEEP YOUR INFORMATION?</a></li>
<li><a href="#security">5. HOW DO WE KEEP YOUR INFORMATION SAFE?</a></li>
<li><a href="#minors">6. DO WE COLLECT INFORMATION FROM MINORS?</a></li>
<li><a href="#rights">7. WHAT ARE YOUR PRIVACY RIGHTS?</a></li>
<li><a href="#dnt">8. CONTROLS FOR DO-NOT-TRACK FEATURES</a></li>
<li><a href="#updates">9. DO WE MAKE UPDATES TO THIS NOTICE?</a></li>
<li><a href="#contact">10. HOW CAN YOU CONTACT US ABOUT THIS NOTICE?</a></li>
<li><a href="#review">11. HOW CAN YOU REVIEW, UPDATE, OR DELETE THE DATA WE COLLECT FROM YOU?</a></li>
</ol>
</nav>
<section id="collect">
<h2>1. WHAT INFORMATION DO WE COLLECT?</h2>
<h3>Personal information you disclose to us</h3>
<p><em>In Short:</em> We collect personal information that you provide to us.</p>
<p>We collect personal information that you voluntarily provide to us when you express an interest in obtaining information about us or our products and Services, when you participate in activities on the Services, or otherwise when you contact us.</p>
<h3>Personal Information Provided by You</h3>
<p>The personal information we collect depends on the context of your interactions with us and the Services, the choices you make, and the products and features you use. This may include:</p>
<ul>
<li>names</li>
<li>phone numbers</li>
<li>email addresses</li>
</ul>
<h3>Sensitive Information</h3>
<p>We do not process sensitive information.</p>
<h3>Application Data</h3>
<p>If you use our application(s), we may also collect the following information if you choose to provide us with access or permission:</p>
<ul>
<li><strong>Mobile Device Access.</strong> We may request access or permission to certain features from your mobile device, including your mobile device's camera, and other features. You may change access or permissions in your device's settings.</li>
<li><strong>Push Notifications.</strong> We may request to send you push notifications regarding your account or certain features of the application(s). You may opt out in your device's settings.</li>
</ul>
<p>This information is primarily needed to maintain the security and operation of our application(s), for troubleshooting, and for internal analytics and reporting purposes.</p>
<p>All personal information that you provide to us must be true, complete, and accurate, and you must notify us of any changes to such personal information.</p>
</section>
<section id="process">
<h2>2. HOW DO WE PROCESS YOUR INFORMATION?</h2>
<p><em>In Short:</em> We process your information to provide, improve, and administer our Services, communicate with you, for security and fraud prevention, and to comply with law. We may also process your information for other purposes with your consent.</p>
<p>We process your personal information for a variety of reasons, depending on how you interact with our Services, including:</p>
<ul>
<li><strong>To deliver and facilitate delivery of services to the user.</strong> We may process your information to provide you with the requested service.</li>
<li><strong>To enable user-to-user communications.</strong> We may process your information if you choose to use offerings that allow communication with another user.</li>
<li><strong>To evaluate and improve our Services, products, marketing, and your experience.</strong> We may process your information to identify usage trends, determine the effectiveness of our promotional campaigns, and to evaluate and improve our Services, products, marketing, and your experience.</li>
</ul>
</section>
<section id="share">
<h2>3. WHEN AND WITH WHOM DO WE SHARE YOUR PERSONAL INFORMATION?</h2>
<p><em>In Short:</em> We may share information in specific situations described in this section and/or with the following third parties.</p>
<p><strong>Vendors, Consultants, and Other Third-Party Service Providers.</strong> We may share your data with third-party vendors, service providers, contractors, or agents ("third parties") who perform services for us or on our behalf and require access to such information to do that work.</p>
<p>The third parties we may share personal information with include:</p>
<ul>
<li><strong>Functionality and Infrastructure Optimization:</strong> Firebase Realtime Database and Cloud Functions for Firebase</li>
<li><strong>Functionality &amp; Infrastructure Optimization:</strong> Expo / EAS Services</li>
</ul>
<p>We may also need to share your personal information in the following situations:</p>
<ul>
<li><strong>Business Transfers.</strong> We may share or transfer your information in connection with, or during negotiations of, any merger, sale of company assets, financing, or acquisition of all or a portion of our business to another company.</li>
<li><strong>Other Users.</strong> When you share personal information (for example, by posting comments or other content to the Services) or interact with public areas of the Services, such information may be viewed by all users and may be publicly available outside the Services in perpetuity. Other users may view descriptions of your activity, communicate with you, and view your profile.</li>
</ul>
</section>
<section id="retention">
<h2>4. HOW LONG DO WE KEEP YOUR INFORMATION?</h2>
<p><em>In Short:</em> We keep your information for as long as necessary to fulfill the purposes outlined in this Privacy Notice unless otherwise required by law.</p>
<p>We will only keep your personal information as long as necessary for the purposes set out in this Privacy Notice, unless a longer retention period is required or permitted by law (such as tax, accounting, or other legal requirements).</p>
<p>When we have no ongoing legitimate business need to process your personal information, we will delete or anonymize such information. If deletion is not possible (for example, if your personal information is stored in backup archives), we will securely store your personal information and isolate it from any further processing until deletion is possible.</p>
</section>
<section id="security">
<h2>5. HOW DO WE KEEP YOUR INFORMATION SAFE?</h2>
<p><em>In Short:</em> We aim to protect your personal information through a system of organizational and technical security measures.</p>
<p>We have implemented appropriate and reasonable technical and organizational security measures designed to protect the security of any personal information we process. However, despite our safeguards and efforts to secure your information, no electronic transmission over the Internet or information storage technology can be guaranteed to be 100% secure. Transmission of personal information to and from our Services is at your own risk. You should only access the Services within a secure environment.</p>
</section>
<section id="minors">
<h2>6. DO WE COLLECT INFORMATION FROM MINORS?</h2>
<p><em>In Short:</em> We do not knowingly collect data from or market to children under 18 years of age.</p>
<p>We do not knowingly collect, solicit data from, or market to children under 18 years of age, nor do we knowingly sell such personal information. By using the Services, you represent that you are at least 18 or that you are the parent or guardian of such a minor and consent to such minor dependents use of the Services. If we learn that personal information from users less than 18 years of age has been collected, we will deactivate the account and take reasonable measures to promptly delete such data from our records. If you become aware of any data we may have collected from children under age 18, please contact us at <a href="mailto:bip.baliinteraktifperkasa@gmail.com">bip.baliinteraktifperkasa@gmail.com</a>.</p>
</section>
<section id="rights">
<h2>7. WHAT ARE YOUR PRIVACY RIGHTS?</h2>
<p><em>In Short:</em> You may review, change, or terminate your account at any time, depending on your country, province, or state of residence.</p>
<p><strong>Withdrawing your consent:</strong> If we are relying on your consent to process your personal information (which may be express and/or implied consent depending on the applicable law), you have the right to withdraw your consent at any time. You can do so by contacting us using the details in the section "<a href="#contact">HOW CAN YOU CONTACT US ABOUT THIS NOTICE?</a>" below. This will not affect the lawfulness of the processing before its withdrawal, nor will it affect processing conducted in reliance on lawful processing grounds other than consent where permitted by law.</p>
<p>If you have questions or comments about your privacy rights, email us at <a href="mailto:bip.baliinteraktifperkasa@gmail.com">bip.baliinteraktifperkasa@gmail.com</a>.</p>
</section>
<section id="dnt">
<h2>8. CONTROLS FOR DO-NOT-TRACK FEATURES</h2>
<p>Most web browsers and some mobile operating systems and applications include a Do-Not-Track ("DNT") setting you can activate to signal your privacy preference not to have data about your online browsing activities monitored and collected. At this stage, no uniform technology standard for recognizing and implementing DNT signals has been finalized. As such, we do not currently respond to DNT browser signals or any other mechanism that automatically communicates your choice not to be tracked online. If a standard for online tracking is adopted that we must follow in the future, we will inform you about that practice in a revised version of this Privacy Notice.</p>
</section>
<section id="updates">
<h2>9. DO WE MAKE UPDATES TO THIS NOTICE?</h2>
<p><em>In Short:</em> Yes, we will update this notice as necessary to stay compliant with relevant laws.</p>
<p>We may update this Privacy Notice from time to time. The updated version will be indicated by an updated "Revised" date at the top of this Privacy Notice. If we make material changes, we may notify you by prominently posting a notice of such changes or by directly sending you a notification. We encourage you to review this Privacy Notice frequently to stay informed of how we are protecting your information.</p>
</section>
<section id="contact">
<h2>10. HOW CAN YOU CONTACT US ABOUT THIS NOTICE?</h2>
<address>
Bali Interaktif Perkasa
Park23 Creative Hub, Bali Interaktif Perkasa - Private Office
Jl. Kediri 3rd Floor, Number 01 - 02, Tuban
Badung, Bali 80361
Indonesia
</address>
<p>Email: <a href="mailto:bip.baliinteraktifperkasa@gmail.com">bip.baliinteraktifperkasa@gmail.com</a></p>
</section>
<section id="review">
<h2>11. HOW CAN YOU REVIEW, UPDATE, OR DELETE THE DATA WE COLLECT FROM YOU?</h2>
<p>You have the right to request access to the personal information we collect from you, details about how we have processed it, correct inaccuracies, or delete your personal information. You may also have the right to withdraw your consent to our processing of your personal information. These rights may be limited in some circumstances by applicable law.</p>
<p>To make a request, please contact us at <a href="mailto:bip.baliinteraktifperkasa@gmail.com">bip.baliinteraktifperkasa@gmail.com</a>.</p>
</section>
<footer>
<p>&copy; <span id="year"></span> Bali Interaktif Perkasa. All rights reserved.</p>
</footer>
</main>
<script>
document.getElementById('year').textContent = new Date().getFullYear();
</script>
</body>
</html>

View File

@@ -0,0 +1,95 @@
import { prisma } from "@/module/_global";
import _ from "lodash";
import { NextResponse } from "next/server";
// GET ONE PENGUMUMAN, UNTUK TAMPIL DETAIL PENGUMUMAN
export async function GET(request: Request, context: { params: { id: string } }) {
try {
const { id } = context.params;
const data = await prisma.announcement.count({
where: {
id: id,
},
});
if (data == 0) {
return NextResponse.json(
{
success: false,
message: "Gagal mendapatkan pengumuman, data tidak ditemukan",
},
{ status: 404 }
);
}
const announcement = await prisma.announcement.findUnique({
where: {
id: id,
},
select: {
id: true,
title: true,
desc: true,
},
});
if (!announcement) {
return NextResponse.json(
{
success: false,
message: "Gagal mendapatkan pengumuman, data tidak ditemukan",
},
{ status: 404 }
);
}
let dataFix = { ...announcement, member: {} };
const announcementMember = await prisma.announcementMember.findMany({
where: {
idAnnouncement: id,
},
select: {
idGroup: true,
idDivision: true,
Group: {
select: {
name: true,
},
},
Division: {
select: {
name: true,
},
},
},
});
const formatMember = announcementMember.map((v: any) => ({
..._.omit(v, ["Group", "Division"]),
idGroup: v.idGroup,
idDivision: v.idDivision,
group: v.Group.name,
division: v.Division.name
}))
dataFix.member = formatMember
return NextResponse.json(
{
success: true,
message: "Berhasil mendapatkan pengumuman",
data: dataFix,
},
{ status: 200 }
);
} catch (error) {
console.error(error);
return NextResponse.json({ success: false, message: "Gagal mendapatkan pengumuman, coba lagi nanti (error: 500)", reason: (error as Error).message, }, { status: 500 });
}
}

View File

@@ -0,0 +1,52 @@
import { prisma } from "@/module/_global";
import _ from "lodash";
import "moment/locale/id";
import { NextResponse } from "next/server";
export const dynamic = 'force-dynamic'
// GET ALL PENGUMUMAN
export async function GET(request: Request) {
try {
const { searchParams } = new URL(request.url);
const judul = searchParams.get('search');
const page = searchParams.get('page');
const get = searchParams.get('get');
const villageId = searchParams.get('desa');
const active = searchParams.get('active');
let getFix = 0;
if (get == null || get == undefined || get == "" || _.isNaN(Number(get))) {
getFix = 10;
} else {
getFix = Number(get);
}
const dataSkip = page == null || page == undefined ? 0 : Number(page) * getFix - getFix;
let kondisi: any = {
idVillage: String(villageId),
isActive: (active == "false" || active == undefined) ? false : true,
title: {
contains: (judul == undefined || judul == null) ? "" : judul,
mode: "insensitive"
}
}
const data = await prisma.announcement.findMany({
skip: dataSkip,
take: getFix,
where: kondisi,
orderBy: {
createdAt: 'desc'
}
});
return NextResponse.json({ success: true, message: "Berhasil mendapatkan pengumuman", data, }, { status: 200 });
} catch (error) {
console.error(error);
return NextResponse.json({ success: false, message: "Gagal mendapatkan pengumuman, coba lagi nanti (error: 500)", reason: (error as Error).message, }, { status: 500 });
}
}

View File

@@ -0,0 +1,21 @@
import { prisma } from "@/module/_global";
import { NextResponse } from "next/server";
// GET ONE BANNER
export async function GET(request: Request, context: { params: { id: string } }) {
try {
const { id } = context.params;
const data = await prisma.bannerImage.findUnique({
where: {
id: String(id)
}
})
return NextResponse.json({ success: true, message: "Berhasil mendapatkan banner", data }, { status: 200 });
} catch (error) {
console.error(error);
return NextResponse.json({ success: false, message: "Gagal mendapatkan banner, coba lagi nanti (error: 500)", reason: (error as Error).message, }, { status: 500 });
}
}

View File

@@ -0,0 +1,48 @@
import { prisma } from "@/module/_global";
import _ from "lodash";
import { NextResponse } from "next/server";
// GET ALL BANNER
export async function GET(request: Request) {
try {
const { searchParams } = new URL(request.url);
const judul = searchParams.get('search');
const page = searchParams.get('page');
const get = searchParams.get('get');
const villageId = searchParams.get('desa');
const active = searchParams.get('active');
let getFix = 0;
if (get == null || get == undefined || get == "" || _.isNaN(Number(get))) {
getFix = 10;
} else {
getFix = Number(get);
}
const dataSkip = page == null || page == undefined ? 0 : Number(page) * getFix - getFix;
let kondisi: any = {
idVillage: String(villageId),
isActive: (active == "false" || active == undefined) ? false : true,
title: {
contains: (judul == undefined || judul == null) ? "" : judul,
mode: "insensitive"
}
}
const data = await prisma.bannerImage.findMany({
skip: dataSkip,
take: getFix,
where: kondisi,
orderBy: {
createdAt: 'desc'
}
});
return NextResponse.json({ success: true, message: "Berhasil mendapatkan banner", data }, { status: 200 });
} catch (error) {
console.error(error);
return NextResponse.json({ success: false, message: "Gagal mendapatkan data banner, coba lagi nanti (error: 500)", reason: (error as Error).message, }, { status: 500 });
}
}

View File

@@ -0,0 +1,99 @@
import { prisma } from "@/module/_global";
import _ from "lodash";
import moment from "moment";
import { NextResponse } from "next/server";
// GET ONE CALENDER BY ID KALENDER REMINDER
export async function GET(request: Request, context: { params: { id: string } }) {
try {
const { id } = context.params
const cek = await prisma.divisionCalendarReminder.count({
where: {
id: id
}
})
if (cek == 0) {
return NextResponse.json(
{
success: false,
message: "Gagal mendapatkan acara, data tidak ditemukan",
},
{ status: 404 }
);
}
const data: any = await prisma.divisionCalendarReminder.findUnique({
where: {
id: id
},
select: {
id: true,
timeStart: true,
dateStart: true,
timeEnd: true,
createdAt: true,
DivisionCalendar: {
select: {
id: true,
title: true,
desc: true,
linkMeet: true,
repeatEventTyper: true,
repeatValue: true,
}
}
}
});
const { DivisionCalendar, ...dataCalender } = data
const timeStart = moment.utc(dataCalender?.timeStart).format("HH:mm")
const timeEnd = moment.utc(dataCalender?.timeEnd).format("HH:mm")
const idCalendar = data?.DivisionCalendar.id
const title = data?.DivisionCalendar?.title
const desc = data?.DivisionCalendar?.desc
const linkMeet = data?.DivisionCalendar?.linkMeet
const repeatEventTyper = data?.DivisionCalendar?.repeatEventTyper
const repeatValue = data?.DivisionCalendar?.repeatValue
const result = { ...dataCalender, timeStart, timeEnd, title, desc, linkMeet, repeatEventTyper, repeatValue }
const member = await prisma.divisionCalendarMember.findMany({
where: {
idCalendar
},
select: {
id: true,
idUser: true,
User: {
select: {
id: true,
name: true,
email: true,
img: true
}
}
}
})
const fixMember = member.map((v: any) => ({
..._.omit(v, ["User"]),
name: v.User.name,
email: v.User.email,
img: v.User.img
}))
const dataFix = {
...result,
member: fixMember,
}
return NextResponse.json({ success: true, message: "Berhasil mendapatkan kalender", data: dataFix }, { status: 200 });
} catch (error) {
return NextResponse.json({ success: false, message: "Gagal mendapatkan kalender, data tidak ditemukan (error: 500)", }, { status: 500 });
}
}

View File

@@ -0,0 +1,149 @@
import { prisma } from "@/module/_global";
import _ from "lodash";
import moment from "moment";
import "moment/locale/id";
import { NextResponse } from "next/server";
//GET ALL CALENDER
export async function GET(request: Request) {
try {
const { searchParams } = new URL(request.url);
const idDivision = searchParams.get("division");
const isDate = searchParams.get("date")
const villageId = searchParams.get("desa")
const active = searchParams.get("active")
const search = searchParams.get("search")
const page = searchParams.get("page")
const get = searchParams.get("get")
let getFix = 0;
if (get == null || get == undefined || get == "" || _.isNaN(Number(get))) {
getFix = 10;
} else {
getFix = Number(get);
}
const dataSkip = page == null || page == undefined ? 0 : Number(page) * getFix - getFix;
let kondisi: any = {}
if (idDivision != "" && idDivision != null && idDivision != undefined) {
if (isDate != null && isDate != undefined && isDate != "") {
kondisi = {
idDivision: String(idDivision),
dateStart: new Date(String(isDate)),
DivisionCalendar: {
title: {
contains: (search == undefined || search == null) ? "" : search,
mode: "insensitive"
},
isActive: (active == "false" || active == undefined) ? false : true,
Division: {
idVillage: String(villageId)
}
}
}
} else {
kondisi = {
idDivision: String(idDivision),
DivisionCalendar: {
title: {
contains: (search == undefined || search == null) ? "" : search,
mode: "insensitive"
},
isActive: (active == "false" || active == undefined) ? false : true,
Division: {
idVillage: String(villageId)
}
}
}
}
} else {
if (isDate != null && isDate != undefined && isDate != "") {
kondisi = {
dateStart: new Date(String(isDate)),
DivisionCalendar: {
title: {
contains: (search == undefined || search == null) ? "" : search,
mode: "insensitive"
},
isActive: (active == "false" || active == undefined) ? false : true,
Division: {
idVillage: String(villageId)
}
}
}
} else {
kondisi = {
DivisionCalendar: {
title: {
contains: (search == undefined || search == null) ? "" : search,
mode: "insensitive"
},
isActive: (active == "false" || active == undefined) ? false : true,
Division: {
idVillage: String(villageId)
}
}
}
}
}
const data = await prisma.divisionCalendarReminder.findMany({
where: kondisi,
skip: dataSkip,
take: getFix,
select: {
id: true,
dateStart: true,
timeStart: true,
timeEnd: true,
createdAt: true,
DivisionCalendar: {
select: {
isActive: true,
title: true,
desc: true,
User: {
select: {
name: true
}
}
}
}
},
orderBy: [
{
dateStart: 'asc'
},
{
timeStart: 'asc'
},
{
timeEnd: 'asc'
}
]
});
const allOmit = data.map((v: any) => ({
..._.omit(v, ["DivisionCalendar", "User"]),
title: v.DivisionCalendar.title,
desc: v.DivisionCalendar.desc,
createdBy: v.DivisionCalendar.User.name,
isActive: v.DivisionCalendar.isActive,
timeStart: moment.utc(v.timeStart).format('HH:mm'),
timeEnd: moment.utc(v.timeEnd).format('HH:mm')
}))
return NextResponse.json({ success: true, message: "Berhasil mendapatkan kalender", data: allOmit }, { status: 200 });
} catch (error) {
console.error(error)
return NextResponse.json({ success: false, message: "Gagal mendapatkan kalender, data tidak ditemukan (error: 500)" }, { status: 404 });
}
}

View File

@@ -0,0 +1,117 @@
import { prisma } from "@/module/_global";
import _ from "lodash";
import { NextResponse } from "next/server";
// GET ONE DETAIL DISKUSI UMUM
export async function GET(request: Request, context: { params: { id: string } }) {
try {
let dataFix
const { id } = context.params
const { searchParams } = new URL(request.url);
const kategori = searchParams.get("cat");
const idVillage = searchParams.get("desa");
const cek = await prisma.discussion.count({
where: {
id,
idVillage: String(idVillage)
}
})
if (cek == 0) {
return NextResponse.json({ success: false, message: "Gagal mendapatkan diskusi, data tidak ditemukan" }, { status: 404 });
}
if (kategori == "comment") {
const data = await prisma.discussionComment.findMany({
where: {
idDiscussion: id,
isActive: true
},
select: {
id: true,
comment: true,
createdAt: true,
idUser: true,
User: {
select: {
name: true,
img: true
}
}
}
})
dataFix = data.map((v: any) => ({
..._.omit(v, ["User",]),
username: v.User.name,
img: v.User.img
}))
} else if (kategori == "member") {
const data = await prisma.discussionMember.findMany({
where: {
idDiscussion: id,
isActive: true
},
select: {
idUser: true,
User: {
select: {
name: true,
img: true
}
}
}
})
dataFix = data.map((v: any) => ({
..._.omit(v, ["User",]),
name: v.User.name,
img: v.User.img
}))
} else {
const data = await prisma.discussion.findUnique({
where: {
id,
idVillage: String(idVillage)
},
select: {
isActive: true,
id: true,
title: true,
idGroup: true,
desc: true,
status: true,
createdAt: true,
Group: {
select: {
name: true,
}
}
}
})
dataFix = {
id: data?.id,
isActive: data?.isActive,
idGroup: data?.idGroup,
group: data?.Group.name,
title: data?.title,
desc: data?.desc,
status: data?.status == 1 ? "Open" : "Close",
createdAt: data?.createdAt
}
}
return NextResponse.json({ success: true, message: "Berhasil mendapatkan diskusi", data: dataFix }, { status: 200 });
} catch (error) {
console.error(error);
return NextResponse.json({ success: false, message: "Gagal mendapatkan diskusi, coba lagi nanti (error: 500)", reason: (error as Error).message, }, { status: 500 });
}
}

View File

@@ -0,0 +1,92 @@
import { prisma } from "@/module/_global";
import _ from "lodash";
import "moment/locale/id";
import { NextResponse } from "next/server";
// GET ALL DISCUSSION GENERAL
export async function GET(request: Request) {
try {
const { searchParams } = new URL(request.url);
const idGroup = searchParams.get("group");
const idVillage = searchParams.get("desa");
const search = searchParams.get('search');
const page = searchParams.get('page');
const status = searchParams.get('status');
const active = searchParams.get('active');
const get = searchParams.get('get')
let getFix = 10;
if (get == null || get == undefined || get == "" || _.isNaN(Number(get))) {
getFix = 10;
} else {
getFix = Number(get);
}
const dataSkip = page == null || page == undefined ? 0 : Number(page) * getFix - getFix;
let kondisi: any = {
isActive: active == "false" ? false : true,
status: status == "close" ? 2 : 1,
idVillage: String(idVillage),
title: {
contains: (search == undefined || search == "null") ? "" : search,
mode: "insensitive"
},
}
if (idGroup != "null" && idGroup != undefined && idGroup != "") {
kondisi = {
...kondisi,
idGroup: String(idGroup)
}
}
const data = await prisma.discussion.findMany({
skip: dataSkip,
take: getFix,
where: kondisi,
orderBy: [
{
status: 'desc'
},
{
createdAt: 'desc'
}
],
select: {
id: true,
title: true,
desc: true,
status: true,
createdAt: true,
DiscussionComment: {
select: {
id: true,
}
},
Group: {
select: {
name: true,
}
}
}
});
const fixData = data.map((v: any) => ({
..._.omit(v, ["DiscussionComment", "status", "Group"]),
totalKomentar: v.DiscussionComment.length,
status: v.status == 1 ? "Open" : "Close",
group: v.Group.name,
}))
return NextResponse.json({ success: true, message: "Berhasil mendapatkan diskusi", data: fixData }, { status: 200 });
} catch (error) {
console.error(error);
return NextResponse.json({ success: false, message: "Gagal mendapatkan diskusi, coba lagi nanti (error: 500)", reason: (error as Error).message, }, { status: 500 });
}
}

View File

@@ -0,0 +1,92 @@
import { prisma } from "@/module/_global";
import { NextResponse } from "next/server";
// GET ONE DISCUSSION BY ID
export async function GET(request: Request, context: { params: { id: string } }) {
try {
const { id } = context.params
const cek = await prisma.divisionDisscussion.count({
where: { id }
})
if (cek == 0) {
return NextResponse.json(
{ success: false, message: "Gagal mendapatkan diskusi, data tidak ditemukan" },
{ status: 404 }
);
}
const data = await prisma.divisionDisscussion.findUnique({
where: { id },
select: {
isActive: true,
id: true,
desc: true,
status: true,
createdAt: true,
idDivision: true,
Division: {
select: {
name: true,
}
},
User: { select: { name: true, img: true } },
DivisionDisscussionComment: {
select: {
id: true,
comment: true,
createdAt: true,
User: { select: { name: true, img: true } }
}
},
}
});
if (!data) {
return NextResponse.json(
{ success: false, message: "Diskusi tidak ditemukan" },
{ status: 404 }
);
}
// ambil nama creator
const createdBy = data.User.name;
const status = data.status == 1 ? "Open" : "Close"
const division = data.Division.name
// mapping komentar → hilangkan nested User
const komentar = data.DivisionDisscussionComment.map((comment: any) => ({
id: comment.id,
comment: comment.comment,
createdAt: comment.createdAt,
username: comment.User.name,
userimg: comment.User.img,
}));
// bentuk hasil akhir sesuai request
const result = {
id: data.id,
idDivision: data.idDivision,
division,
isActive: data.isActive,
desc: data.desc,
status,
createdAt: data.createdAt,
createdBy,
komentar,
};
return NextResponse.json(
{ success: true, message: "Berhasil mendapatkan diskusi", data: result },
{ status: 200 }
);
} catch (error) {
console.error(error);
return NextResponse.json(
{ success: false, message: "Gagal mendapatkan diskusi, coba lagi nanti (error: 500)", reason: (error as Error).message },
{ status: 500 }
);
}
}

View File

@@ -0,0 +1,95 @@
import { prisma } from "@/module/_global";
import _ from "lodash";
import "moment/locale/id";
import { NextResponse } from "next/server";
// GET ALL DISCUSSION DIVISION ACTIVE = TRUE
export async function GET(request: Request) {
try {
const { searchParams } = new URL(request.url);
const idDivision = searchParams.get("division");
const search = searchParams.get('search');
const page = searchParams.get('page');
const status = searchParams.get('status');
const isActive = searchParams.get('active');
const villageId = searchParams.get('desa');
const get = searchParams.get('get');
let getFix = 0;
if (get == null || get == undefined || get == "" || _.isNaN(Number(get))) {
getFix = 10;
} else {
getFix = Number(get);
}
const dataSkip = page == null || page == undefined ? 0 : Number(page) * getFix - getFix;
let kondisi: any = {
isActive: isActive == "false" ? false : true,
status: status == "close" ? 2 : 1,
Division: {
idVillage: String(villageId)
},
desc: {
contains: (search == undefined || search == "null") ? "" : search,
mode: "insensitive"
},
}
if (idDivision != "null" && idDivision != null && idDivision != undefined) {
kondisi = {
isActive: isActive == "false" ? false : true,
status: status == "close" ? 2 : 1,
idDivision: idDivision,
Division: {
idVillage: String(villageId)
},
desc: {
contains: (search == undefined || search == "null") ? "" : search,
mode: "insensitive"
},
}
}
const data = await prisma.divisionDisscussion.findMany({
skip: dataSkip,
take: getFix,
where: kondisi,
orderBy: {
createdAt: 'desc'
},
select: {
id: true,
desc: true,
status: true,
createdAt: true,
idDivision: true,
Division: {
select: {
name: true,
}
},
DivisionDisscussionComment: {
select: {
id: true,
}
}
}
});
const fixData = data.map((v: any) => ({
..._.omit(v, ["DivisionDisscussionComment", "status", "Division"]),
totalKomentar: v.DivisionDisscussionComment.length,
status: v.status == 1 ? "Open" : "Close",
division: v.Division.name
}))
return NextResponse.json({ success: true, message: "Berhasil mendapatkan diskusi", data: fixData, }, { status: 200 });
} catch (error) {
console.error(error);
return NextResponse.json({ success: false, message: "Gagal mendapatkan diskusi, coba lagi nanti (error: 500)", reason: (error as Error).message, }, { status: 500 });
}
}

View File

@@ -0,0 +1,63 @@
import { prisma } from "@/module/_global";
import _ from "lodash";
import { NextResponse } from "next/server";
// GET ONE DATA DIVISI :: UNTUK TAMPIL DATA DI HALAMAN EDIT DAN INFO
export async function GET(request: Request, context: { params: { id: string } }) {
try {
const { id } = context.params;
const { searchParams } = new URL(request.url);
const idVillage = searchParams.get("desa");
const data = await prisma.division.findUnique({
where: {
id: String(id),
idVillage: String(idVillage)
}
});
if (!data) {
return NextResponse.json({ success: false, message: "Gagal mendapatkan divisi, data tidak ditemukan", }, { status: 404 });
}
const member = await prisma.divisionMember.findMany({
where: {
idDivision: String(id),
isActive: true,
},
select: {
id: true,
isAdmin: true,
idUser: true,
User: {
select: {
name: true,
img: true
}
}
},
orderBy: {
isAdmin: 'desc',
}
})
const fixMember = member.map((v: any) => ({
..._.omit(v, ["User"]),
name: v.User.name,
img: v.User.img
}))
const dataFix = {
...data,
member: fixMember
}
return NextResponse.json({ success: true, message: "Berhasil mendapatkan divisi", data: dataFix, }, { status: 200 });
} catch (error) {
console.error(error);
return NextResponse.json({ success: false, message: "Gagal mendapatkan divisi, coba lagi nanti (error: 500)", reason: (error as Error).message, }, { status: 500 });
}
}

View File

@@ -0,0 +1,269 @@
import { prisma } from "@/module/_global";
import _ from "lodash";
import { NextResponse } from "next/server";
export async function GET(request: Request) {
try {
const { searchParams } = new URL(request.url)
const idVillage = searchParams.get("desa")
const idGroup = searchParams.get("group")
const division = searchParams.get("division")
const date = searchParams.get("date-start")
const dateAkhir = searchParams.get("date-end")
const kat = searchParams.get("cat")
// CHART PROGRESS
if (kat == "dokumen") {
// CHART DOKUMEN
let kondisi: any = {
isActive: true,
category: 'FILE',
Division: {
idVillage: String(idVillage)
},
createdAt: {
gte: new Date(String(date)),
lte: new Date(String(dateAkhir))
},
}
if (idGroup != undefined && idGroup != null && idGroup != "") {
kondisi = {
isActive: true,
category: 'FILE',
Division: {
idGroup: String(idGroup)
},
createdAt: {
gte: new Date(String(date)),
lte: new Date(String(dateAkhir))
},
}
}
if (division != undefined && division != null && division != "") {
kondisi = {
...kondisi,
idDivision: String(division)
}
}
const dataDokumen = await prisma.divisionDocumentFolderFile.findMany({
where: kondisi,
})
const groupData = _.map(_.groupBy(dataDokumen, "extension"), (v: any) => ({
file: v[0].extension,
jumlah: v.length,
}))
const image = ['jpg', 'jpeg', 'png', 'heic']
let hasilImage = {
name: 'Gambar',
value: 0
}
let hasilFile = {
name: 'Dokumen',
value: 0
}
groupData.map((v: any) => {
if (image.some((i: any) => i == v.file)) {
hasilImage = {
name: 'Gambar',
value: hasilImage.value + v.jumlah
}
} else {
hasilFile = {
name: 'Dokumen',
value: hasilFile.value + v.jumlah
}
}
})
const hasilDokumen = { gambar: hasilImage.value, dokumen: hasilFile.value }
return NextResponse.json({ success: true, message: "Berhasil mendapatkan data", data: hasilDokumen }, { status: 200 });
} else if (kat == "event") {
// CHART EVENT
let kondisiSelesai: any = {
isActive: true,
Division: {
idVillage: String(idVillage)
},
DivisionCalendarReminder: {
some: {
dateStart: {
gte: new Date(String(date)),
lte: new Date()
}
}
}
}
let kondisiComingSoon: any = {
isActive: true,
Division: {
idVillage: String(idVillage)
},
DivisionCalendarReminder: {
some: {
dateStart: {
gt: new Date(),
lte: new Date(String(dateAkhir))
}
}
}
}
if (idGroup != undefined && idGroup != null && idGroup != "") {
kondisiSelesai = {
isActive: true,
Division: {
idGroup: String(idGroup)
},
DivisionCalendarReminder: {
some: {
dateStart: {
gte: new Date(String(date)),
lte: new Date()
}
}
}
}
kondisiComingSoon = {
isActive: true,
Division: {
idGroup: String(idGroup)
},
DivisionCalendarReminder: {
some: {
dateStart: {
gt: new Date(),
lte: new Date(String(dateAkhir))
}
}
}
}
}
if (division != undefined && division != null && division != "") {
kondisiSelesai = {
...kondisiSelesai,
idDivision: String(division)
}
kondisiComingSoon = {
...kondisiComingSoon,
idDivision: String(division)
}
}
const eventSelesai = await prisma.divisionCalendar.count({
where: kondisiSelesai
})
const eventComingSoon = await prisma.divisionCalendar.count({
where: kondisiComingSoon
})
const hasilEvent = {
selesai: eventSelesai,
akan_datang: eventComingSoon
}
return NextResponse.json({ success: true, message: "Berhasil mendapatkan data", data: hasilEvent }, { status: 200 });
} else {
let kondisiProgress: any = {
isActive: true,
Division: {
idVillage: String(idVillage)
},
DivisionProjectTask: {
some: {
dateStart: {
gte: new Date(String(date))
},
dateEnd: {
lte: new Date(String(dateAkhir))
}
}
}
}
if (idGroup != undefined && idGroup != null && idGroup != "") {
kondisiProgress = {
isActive: true,
Division: {
idGroup: String(idGroup)
},
DivisionProjectTask: {
some: {
dateStart: {
gte: new Date(String(date))
},
dateEnd: {
lte: new Date(String(dateAkhir))
}
}
}
}
}
if (division != undefined && division != null && division != "") {
kondisiProgress = {
...kondisiProgress,
idDivision: String(division)
}
}
const data = await prisma.divisionProject.groupBy({
where: kondisiProgress,
by: ["status"],
_count: true
})
const dataStatus = [{ name: 'Segera', status: 0 }, { name: 'Dikerjakan', status: 1 }, { name: 'Selesai', status: 2 }, { name: 'Dibatalkan', status: 3 }]
const hasilProgres: any[] = []
let input
for (let index = 0; index < dataStatus.length; index++) {
const cek = data.some((i: any) => i.status == dataStatus[index].status)
if (cek) {
const find = ((Number(data.find((i: any) => i.status == dataStatus[index].status)?._count) * 100) / data.reduce((n, { _count }) => n + _count, 0)).toFixed(2)
const fix = find != "100.00" ? find.substr(-2, 2) == "00" ? find.substr(0, 2) : find : "100"
input = {
name: dataStatus[index].name,
value: fix
}
} else {
input = {
name: dataStatus[index].name,
value: 0
}
}
hasilProgres.push(input)
}
const dataFixProgress = hasilProgres.reduce((acc: any, curr: any) => {
acc[curr.name] = curr.value
return acc
}, {})
return NextResponse.json({ success: true, message: "Berhasil mendapatkan data", data: dataFixProgress }, { status: 200 });
}
}
catch (error) {
console.error(error);
return NextResponse.json({ success: false, message: "Gagal mendapatkan data, coba lagi nanti (error: 500)", reason: (error as Error).message, }, { status: 500 });
}
}

View File

@@ -0,0 +1,84 @@
import { prisma } from "@/module/_global";
import _ from "lodash";
import { NextResponse } from "next/server";
// GET ALL DATA DIVISI == LIST DATA DIVISI
export async function GET(request: Request) {
try {
const { searchParams } = new URL(request.url);
const idVillage = searchParams.get("desa");
const idGroup = searchParams.get("group");
const name = searchParams.get('search');
const page = searchParams.get('page');
const active = searchParams.get("active");
const get = searchParams.get('get')
let getFix = 10;
if (get == null || get == undefined || get == "" || _.isNaN(Number(get))) {
getFix = 10;
} else {
getFix = Number(get);
}
const dataSkip = page == null || page == undefined ? 0 : Number(page) * getFix - getFix;
let kondisi: any = {
isActive: active == 'false' ? false : true,
idVillage: String(idVillage),
name: {
contains: (name == undefined || name == "null") ? "" : name,
mode: "insensitive"
}
}
if (idGroup != "null" && idGroup != undefined && idGroup != "") {
kondisi = {
...kondisi,
idGroup: String(idGroup)
}
}
const data = await prisma.division.findMany({
skip: dataSkip,
take: getFix,
where: kondisi,
select: {
id: true,
name: true,
desc: true,
idGroup: true,
Group: {
select: {
name: true
}
},
DivisionMember: {
where: {
isActive: true
},
select: {
idUser: true
}
}
},
orderBy: {
createdAt: 'desc'
}
});
const allData = data.map((v: any) => ({
..._.omit(v, ["DivisionMember", "Group"]),
group: v.Group.name,
jumlahMember: v.DivisionMember.length,
}))
return NextResponse.json({ success: true, message: "Berhasil mendapatkan divisi", data: allData }, { status: 200 });
} catch (error) {
console.error(error);
return NextResponse.json({ success: false, message: "Gagal mendapatkan divisi, coba lagi nanti (error: 500)", reason: (error as Error).message, }, { status: 500 });
}
}

View File

@@ -0,0 +1,145 @@
import { prisma } from "@/module/_global";
import _ from "lodash";
import moment from "moment";
import { NextResponse } from "next/server";
// GET ALL DOCUMENT
export async function GET(request: Request) {
try {
const { searchParams } = new URL(request.url);
const idDivision = searchParams.get("division");
const villageId = searchParams.get("desa");
const path = searchParams.get("path");
const active = searchParams.get("active");
const search = searchParams.get("search");
const page = searchParams.get("page");
const get = searchParams.get("get");
let getFix = 10;
if (get == null || get == undefined || get == "" || _.isNaN(Number(get))) {
getFix = 10;
} else {
getFix = Number(get);
}
const dataSkip = page == null || page == undefined ? 0 : Number(page) * getFix - getFix;
let kondisi: any = {
Division: {
idVillage: String(villageId)
},
isActive: active == 'false' ? false : true,
path: (path == "undefined" || path == "null" || path == "" || path == null || path == undefined) ? "home" : path,
name: {
contains: (search == undefined || search == "null") ? "" : search,
mode: "insensitive"
}
}
if (idDivision != "null" && idDivision != undefined && idDivision != "") {
kondisi = {
...kondisi,
idDivision: String(idDivision)
}
}
let formatDataShare: any[] = [];
if (path == "home" || path == "null" || path == "undefined" || path == null || path == undefined || path == "") {
const dataShare = await prisma.divisionDocumentShare.findMany({
where: {
isActive: true,
idDivision: String(idDivision),
DivisionDocumentFolderFile: {
isActive: true
}
},
select: {
DivisionDocumentFolderFile: {
select: {
idStorage: true,
id: true,
category: true,
name: true,
extension: true,
path: true,
User: {
select: {
name: true
}
},
createdAt: true,
updatedAt: true
}
}
},
orderBy: {
DivisionDocumentFolderFile: {
createdAt: 'desc'
}
}
})
formatDataShare = dataShare.map((v: any) => ({
..._.omit(v, ["DivisionDocumentFolderFile"]),
idStorage: v.DivisionDocumentFolderFile.idStorage,
id: v.DivisionDocumentFolderFile.id,
category: v.DivisionDocumentFolderFile.category,
name: v.DivisionDocumentFolderFile.name,
extension: v.DivisionDocumentFolderFile.extension,
path: v.DivisionDocumentFolderFile.path,
createdBy: v.DivisionDocumentFolderFile.User.name,
createdAt: v.DivisionDocumentFolderFile.createdAt,
updatedAt: v.DivisionDocumentFolderFile.updatedAt,
share: true
}))
}
const data = await prisma.divisionDocumentFolderFile.findMany({
skip: dataSkip,
take: getFix,
where: kondisi,
select: {
id: true,
category: true,
name: true,
extension: true,
idStorage: true,
path: true,
User: {
select: {
name: true
}
},
createdAt: true,
updatedAt: true
},
orderBy: {
createdAt: 'desc'
}
})
const allData = data.map((v: any) => ({
..._.omit(v, ["User", "createdAt", "updatedAt"]),
createdBy: v.User.name,
createdAt: v.createdAt,
updatedAt: v.updatedAt,
share: false
}))
if (formatDataShare.length > 0) {
allData.push(...formatDataShare)
}
const formatData = _.orderBy(allData, ['category', 'createdAt'], ['desc', 'desc']);
return NextResponse.json({ success: true, message: "Berhasil mendapatkan item", data: formatData }, { status: 200 });
} catch (error) {
console.error(error);
return NextResponse.json({ success: false, message: "Gagal mendapatkan item, coba lagi nanti (error: 500)", reason: (error as Error).message, }, { status: 500 });
}
}

View File

@@ -0,0 +1,45 @@
import { prisma } from "@/module/_global";
import _ from "lodash";
import { NextResponse } from "next/server";
export async function GET(request: Request) {
try {
const { searchParams } = new URL(request.url);
const villageId = searchParams.get("desa");
const isActive = searchParams.get("active");
const search = searchParams.get('search');
const page = searchParams.get('page')
const get = searchParams.get('get')
let getFix = 10;
if (get == null || get == undefined || get == "" || _.isNaN(Number(get))) {
getFix = 10;
} else {
getFix = Number(get);
}
const dataSkip = page == null || page == undefined ? 0 : Number(page) * getFix - getFix;
const data = await prisma.group.findMany({
skip: dataSkip,
take: getFix,
where: {
isActive: isActive == 'false' ? false : true,
idVillage: String(villageId),
name: {
contains: (search == undefined || search == null) ? "" : search,
mode: "insensitive"
}
},
orderBy: {
name: 'asc'
}
});
return NextResponse.json({ success: true, message: "Berhasil mendapatkan grup", data, }, { status: 200 });
} catch (error) {
console.error(error);
return NextResponse.json({ success: false, message: "Gagal mendapatkan grup, coba lagi nanti (error: 500)", reason: (error as Error).message, }, { status: 500 });
}
}

View File

@@ -0,0 +1,79 @@
import { prisma } from "@/module/_global";
import _ from "lodash";
import { NextResponse } from "next/server";
// GET ALL POSITION
export async function GET(request: Request) {
try {
const { searchParams } = new URL(request.url);
const idVillage = searchParams.get("desa");
const idGroup = searchParams.get("group");
const active = searchParams.get('active');
const search = searchParams.get('search')
const page = searchParams.get('page')
const get = searchParams.get('get')
let getFix = 10;
if (get == null || get == undefined || get == "" || _.isNaN(Number(get))) {
getFix = 10;
} else {
getFix = Number(get);
}
const dataSkip = page == null || page == undefined ? 0 : Number(page) * getFix - getFix;
let kondisi: any = {
isActive: active == 'false' ? false : true,
Group: {
idVillage: String(idVillage)
},
name: {
contains: (search == undefined || search == null) ? "" : search,
mode: "insensitive"
}
}
if (idGroup != "null" && idGroup != undefined && idGroup != "") {
kondisi = {
...kondisi,
idGroup: String(idGroup)
}
}
const positions = await prisma.position.findMany({
skip: dataSkip,
take: getFix,
where: kondisi,
select: {
id: true,
name: true,
idGroup: true,
isActive: true,
createdAt: true,
updatedAt: true,
Group: {
select: {
name: true
}
}
},
orderBy: {
name: 'asc'
}
});
const allData = positions.map((v: any) => ({
..._.omit(v, ["Group"]),
group: v.Group.name
}))
return NextResponse.json({ success: true, message: "Berhasil mendapatkan jabatan", data: allData }, { status: 200 });
} catch (error) {
console.error(error);
return NextResponse.json({ success: false, message: "Gagal mendapatkan jabatan, coba lagi nanti (error: 500)", reason: (error as Error).message, }, { status: 500 });
}
}

View File

@@ -0,0 +1,172 @@
import { prisma } from "@/module/_global";
import _ from "lodash";
import moment from "moment";
import { NextResponse } from "next/server";
// GET DETAIL PROJECT / GET ONE PROJECT
export async function GET(request: Request, context: { params: { id: string } }) {
try {
let allData
const { id } = context.params;
const { searchParams } = new URL(request.url);
const kategori = searchParams.get("cat");
const data = await prisma.project.findUnique({
where: {
id: String(id),
},
select: {
id: true,
idVillage: true,
idGroup: true,
title: true,
status: true,
desc: true,
reason: true,
report: true,
isActive: true,
Group: {
select: {
name: true
}
}
}
});
if (!data) {
return NextResponse.json({ success: false, message: "Gagal mendapatkan kegiatan, data tidak ditemukan", }, { status: 404 });
}
if (kategori == "data") {
const dataProgress = await prisma.projectTask.findMany({
where: {
isActive: true,
idProject: String(id)
},
orderBy: {
updatedAt: 'desc'
}
})
const semua = dataProgress.length
const selesai = _.filter(dataProgress, { status: 1 }).length
const progress = Math.ceil((selesai / semua) * 100)
allData = {
id: data.id,
idVillage: data.idVillage,
idGroup: data.idGroup,
group: data.Group.name,
title: data.title,
status: data.status == 3 ? "batal" : data.status == 2 ? "selesai" : data.status == 1 ? "dikerjakan" : "segera",
desc: data.desc,
reason: data.reason,
report: data.report,
isActive: data.isActive,
progress: (_.isNaN(progress)) ? 0 : progress,
}
} else if (kategori == "task") {
const dataProgress = await prisma.projectTask.findMany({
where: {
isActive: true,
idProject: String(id)
},
select: {
id: true,
title: true,
desc: true,
status: true,
dateStart: true,
dateEnd: true,
createdAt: true
},
orderBy: {
createdAt: 'asc'
}
})
const formatData = dataProgress.map((v: any) => ({
..._.omit(v, ["dateStart", "dateEnd", "createdAt", "status"]),
status: v.status == 1 ? "selesai" : "belum selesai",
dateStart: moment(v.dateStart).format("DD-MM-YYYY"),
dateEnd: moment(v.dateEnd).format("DD-MM-YYYY"),
createdAt: moment(v.createdAt).format("DD-MM-YYYY HH:mm"),
}))
const dataFix = _.orderBy(formatData, 'createdAt', 'asc')
allData = dataFix
} else if (kategori == "file") {
const dataFile = await prisma.projectFile.findMany({
where: {
isActive: true,
idProject: String(id)
},
orderBy: {
createdAt: 'asc'
},
select: {
id: true,
name: true,
extension: true,
idStorage: true
}
})
allData = dataFile
} else if (kategori == "member") {
const dataMember = await prisma.projectMember.findMany({
where: {
isActive: true,
idProject: String(id)
},
select: {
id: true,
idUser: true,
User: {
select: {
name: true,
email: true,
img: true,
Position: {
select: {
name: true
}
}
}
},
}
})
const fix = dataMember.map((v: any) => ({
..._.omit(v, ["User"]),
name: v.User.name,
email: v.User.email,
img: v.User.img,
position: v.User.Position.name
}))
allData = fix
} else if (kategori == "link") {
const dataLink = await prisma.projectLink.findMany({
where: {
isActive: true,
idProject: String(id)
},
orderBy: {
createdAt: 'asc'
}
})
allData = dataLink
}
return NextResponse.json({ success: true, message: "Berhasil mendapatkan kegiatan", data: allData }, { status: 200 });
} catch (error) {
console.error(error);
return NextResponse.json({ success: false, message: "Gagal mendapatkan kegiatan, coba lagi nanti (error: 500)", reason: (error as Error).message, }, { status: 500 });
}
}

View File

@@ -0,0 +1,107 @@
import { prisma } from "@/module/_global";
import _, { ceil } from "lodash";
import { NextResponse } from "next/server";
// GET ALL DATA PROJECT
export async function GET(request: Request) {
try {
const { searchParams } = new URL(request.url);
const idVillage = searchParams.get('desa');
const name = searchParams.get('search');
const status = searchParams.get('status');
const idGroup = searchParams.get("group");
const page = searchParams.get('page');
const get = searchParams.get('get');
let getFix = 10;
if (get == null || get == undefined || get == "" || _.isNaN(Number(get))) {
getFix = 10;
} else {
getFix = Number(get);
}
const dataSkip = page == null || page == undefined ? 0 : Number(page) * getFix - getFix;
let kondisi: any = {
isActive: true,
idVillage: String(idVillage),
title: {
contains: (name == undefined || name == "null") ? "" : name,
mode: "insensitive"
},
}
if (status != "null" && status != undefined && status != "") {
kondisi = {
...kondisi,
status: status == "segera" ? 0 : status == "dikerjakan" ? 1 : status == "selesai" ? 2 : status == "batal" ? 3 : 0
}
}
if (idGroup != "null" && idGroup != undefined && idGroup != "") {
kondisi = {
...kondisi,
idGroup: String(idGroup)
}
}
const data = await prisma.project.findMany({
skip: dataSkip,
take: getFix,
where: kondisi,
select: {
id: true,
idGroup: true,
title: true,
desc: true,
status: true,
ProjectMember: {
where: {
isActive: true
},
select: {
idUser: true
}
},
ProjectTask: {
where: {
isActive: true
},
select: {
title: true,
status: true
}
},
Group: {
select: {
name: true
}
}
},
orderBy: {
createdAt: 'desc'
}
})
const omitData = data.map((v: any) => ({
..._.omit(v, ["ProjectMember", "ProjectTask", "status", "Group"]),
group: v.Group.name,
status: v.status == 1 ? "dikerjakan" : v.status == 2 ? "selesai" : v.status == 3 ? "batal" : "segera",
progress: ceil((v.ProjectTask.filter((i: any) => i.status == 1).length * 100) / v.ProjectTask.length),
member: v.ProjectMember.length
}))
return NextResponse.json({ success: true, message: "Berhasil mendapatkan kegiatan", data: omitData }, { status: 200 });
} catch (error) {
console.error(error);
return NextResponse.json({ success: false, message: "Gagal mendapatkan kegiatan, coba lagi nanti (error: 500)", reason: (error as Error).message, }, { status: 500 });
}
}

View File

@@ -0,0 +1,180 @@
import { prisma } from "@/module/_global";
import _ from "lodash";
import moment from "moment";
import "moment/locale/id";
import { NextResponse } from "next/server";
// GET DETAIL TASK DIVISI / GET ONE
export async function GET(request: Request, context: { params: { id: string } }) {
try {
let allData
const { id } = context.params;
const { searchParams } = new URL(request.url);
const kategori = searchParams.get("cat");
const data = await prisma.divisionProject.findUnique({
where: {
id: String(id),
},
select: {
id: true,
idDivision: true,
title: true,
status: true,
desc: true,
reason: true,
report: true,
isActive: true,
Division: {
select: {
name: true
}
}
}
});
if (!data) {
return NextResponse.json({ success: false, message: "Gagal mendapatkan kegiatan, data tidak ditemukan", }, { status: 404 });
}
if (kategori == "data") {
const dataProgress = await prisma.divisionProjectTask.findMany({
where: {
isActive: true,
idProject: String(id)
},
orderBy: {
updatedAt: 'desc'
}
})
const semua = dataProgress.length
const selesai = _.filter(dataProgress, { status: 1 }).length
const progress = Math.ceil((selesai / semua) * 100)
allData = {
id: data.id,
idDivision: data.idDivision,
division: data.Division.name,
title: data.title,
status: data.status == 3 ? "batal" : data.status == 2 ? "selesai" : data.status == 1 ? "dikerjakan" : "segera",
desc: data.desc,
reason: data.reason,
report: data.report,
isActive: data.isActive,
progress: progress,
}
} else if (kategori == "task") {
const dataProgress = await prisma.divisionProjectTask.findMany({
where: {
isActive: true,
idProject: String(id)
},
select: {
id: true,
title: true,
status: true,
dateStart: true,
dateEnd: true,
},
orderBy: {
createdAt: 'asc'
}
})
const fix = dataProgress.map((v: any) => ({
..._.omit(v, ["dateStart", "dateEnd", "status"]),
status: v.status == 1 ? "selesai" : "belum selesai",
dateStart: moment(v.dateStart).format("DD-MM-YYYY"),
dateEnd: moment(v.dateEnd).format("DD-MM-YYYY"),
}))
allData = fix
} else if (kategori == "file") {
const dataFile = await prisma.divisionProjectFile.findMany({
where: {
isActive: true,
idProject: String(id)
},
select: {
id: true,
ContainerFileDivision: {
select: {
id: true,
name: true,
extension: true,
idStorage: true
}
}
}
})
const fix = dataFile.map((v: any) => ({
..._.omit(v, ["ContainerFileDivision"]),
nameInStorage: v.ContainerFileDivision.id,
name: v.ContainerFileDivision.name,
extension: v.ContainerFileDivision.extension,
idStorage: v.ContainerFileDivision.idStorage,
}))
allData = fix
} else if (kategori == "member") {
const dataMember = await prisma.divisionProjectMember.findMany({
where: {
isActive: true,
idProject: String(id)
},
select: {
id: true,
idUser: true,
User: {
select: {
name: true,
email: true,
img: true,
Position: {
select: {
name: true
}
}
}
}
}
})
const fix = dataMember.map((v: any) => ({
..._.omit(v, ["User"]),
name: v.User.name,
email: v.User.email,
img: v.User.img,
position: v.User.Position.name
}))
allData = fix
} else if (kategori == "link") {
const dataLink = await prisma.divisionProjectLink.findMany({
where: {
isActive: true,
idProject: String(id)
},
orderBy: {
createdAt: 'asc'
}
})
allData = dataLink
}
return NextResponse.json({ success: true, message: "Berhasil mendapatkan tugas divisi", data: allData }, { status: 200 });
}
catch (error) {
console.error(error);
return NextResponse.json({ success: false, message: "Gagal mendapatkan tugas divisi, coba lagi nanti (error: 500)", reason: (error as Error).message, }, { status: 500 });
}
}

View File

@@ -0,0 +1,104 @@
import { prisma } from "@/module/_global";
import _, { ceil } from "lodash";
import { NextResponse } from "next/server";
// GET ALL DATA TUGAS DIVISI
export async function GET(request: Request) {
try {
const { searchParams } = new URL(request.url);
const villageId = searchParams.get('desa');
const division = searchParams.get('division');
const search = searchParams.get('search');
const status = searchParams.get('status');
const page = searchParams.get('page');
const get = searchParams.get('get');
let getFix = 10;
if (get == null || get == undefined || get == "" || _.isNaN(Number(get))) {
getFix = 10;
} else {
getFix = Number(get);
}
const dataSkip = page == null || page == undefined ? 0 : Number(page) * getFix - getFix;
let kondisi: any = {
isActive: true,
Division: {
idVillage: String(villageId)
},
title: {
contains: (search == undefined || search == "null") ? "" : search,
mode: "insensitive"
}
}
if (status != "null" && status != undefined && status != "" && status != null) {
kondisi = {
...kondisi,
status: status == "segera" ? 0 : status == "dikerjakan" ? 1 : status == "selesai" ? 2 : status == "batal" ? 3 : 0
}
}
if (division != "null" && division != undefined && division != "" && division != null) {
kondisi = {
...kondisi,
idDivision: String(division)
}
}
const data = await prisma.divisionProject.findMany({
skip: dataSkip,
take: getFix,
where: kondisi,
select: {
id: true,
idDivision: true,
title: true,
desc: true,
status: true,
DivisionProjectTask: {
where: {
isActive: true
},
select: {
title: true,
status: true
}
},
DivisionProjectMember: {
where: {
isActive: true
},
select: {
idUser: true
}
},
Division: {
select: {
name: true
}
}
},
orderBy: {
createdAt: "desc"
}
});
const formatData = data.map((v: any) => ({
..._.omit(v, ["DivisionProjectTask", "DivisionProjectMember", "status", "Division"]),
division: v.Division.name,
status: v.status == 1 ? "dikerjakan" : v.status == 2 ? "selesai" : v.status == 3 ? "batal" : "segera",
progress: ceil((v.DivisionProjectTask.filter((i: any) => i.status == 1).length * 100) / v.DivisionProjectTask.length),
member: v.DivisionProjectMember.length,
}))
return NextResponse.json({ success: true, message: "Berhasil mendapatkan divisi", data: formatData }, { status: 200 });
} catch (error) {
console.error(error);
return NextResponse.json({ success: false, message: "Gagal mendapatkan divisi, coba lagi nanti (error: 500)", reason: (error as Error).message, }, { status: 500 });
}
}

View File

@@ -0,0 +1,75 @@
import { prisma } from "@/module/_global";
import _ from "lodash";
import { NextResponse } from "next/server";
// GET ONE MEMBER / USER
export async function GET(request: Request, context: { params: { id: string } }) {
try {
const { id } = context.params;
const users = await prisma.user.findUnique({
where: {
id: id,
},
select: {
id: true,
nik: true,
name: true,
phone: true,
email: true,
gender: true,
img: true,
idGroup: true,
isActive: true,
idPosition: true,
createdAt: true,
updatedAt: true,
UserRole: {
select: {
name: true,
id: true
}
},
Position: {
select: {
name: true,
id: true
},
},
Group: {
select: {
name: true,
id: true
},
},
},
});
const { ...userData } = users;
const group = users?.Group.name
const position = users?.Position?.name
const idUserRole = users?.UserRole.id
const phone = '+62' + users?.phone
const role = users?.UserRole.name
const gender = users?.gender == "F" ? "Perempuan" : "Laki-Laki"
const result = { ...userData, gender, group, position, idUserRole, phone, role };
const omitData = _.omit(result, ["Group", "Position", "UserRole"]);
return NextResponse.json(
{
success: true,
message: "Berhasil mendapatkan anggota",
data: omitData,
},
{ status: 200 }
);
} catch (error) {
console.error(error);
return NextResponse.json({ success: false, message: "Gagal mendapatkan anggota, coba lagi nanti (error: 500)", reason: (error as Error).message, }, { status: 500 });
}
}

View File

@@ -0,0 +1,88 @@
import { prisma } from "@/module/_global";
import _ from "lodash";
import { NextResponse } from "next/server";
// GET ALL MEMBER / USER
export async function GET(request: Request) {
try {
const { searchParams } = new URL(request.url);
const search = searchParams.get('search')
const idVillage = searchParams.get("desa");
const idGroup = searchParams.get("group");
const active = searchParams.get("active");
const page = searchParams.get('page');
const get = searchParams.get('get');
let getFix = 10;
if (get == null || get == undefined || get == "" || _.isNaN(Number(get))) {
getFix = 10;
} else {
getFix = Number(get);
}
const dataSkip = page == null || page == undefined ? 0 : Number(page) * getFix - getFix;
let kondisi: any = {
isActive: active == 'false' ? false : true,
idVillage: String(idVillage),
name: {
contains: (search == undefined || search == null) ? "" : search,
mode: "insensitive",
},
NOT: {
idUserRole: 'developer'
}
}
if (idGroup != "null" && idGroup != undefined && idGroup != "" && idGroup != null) {
kondisi = {
...kondisi,
idGroup: String(idGroup)
}
}
const users = await prisma.user.findMany({
skip: dataSkip,
take: getFix,
where: kondisi,
select: {
id: true,
idUserRole: true,
isActive: true,
nik: true,
name: true,
phone: true,
Position: {
select: {
name: true,
},
},
Group: {
select: {
name: true,
},
},
},
orderBy: {
name: 'asc'
}
});
const allData = users.map((v: any) => ({
..._.omit(v, ["phone", "gender", "Group", "Position"]),
gender: v.gender == "F" ? "Perempuan" : "Laki-Laki",
phone: "+" + v.phone,
group: v.Group.name,
position: v?.Position?.name
}))
return NextResponse.json({ success: true, message: "Berhasil member", data: allData }, { status: 200 });
} catch (error) {
console.error(error);
return NextResponse.json({ success: false, message: "Gagal mendapatkan anggota, coba lagi nanti (error: 500)", reason: (error as Error).message, }, { status: 500 });
}
}

View File

@@ -2,7 +2,7 @@ import { NextResponse } from "next/server";
export async function GET(request: Request) {
try {
return NextResponse.json({ success: true, version: "1.8.0", tahap: "beta", update: "-api mobile; -login tanpa otp (mobile app); -tambah laporan pada project dan tugas divisi; -tambah upload link pada project dan tugas divisi; -tambah detail tanggal dan jam pada project dan tugas divisi" }, { status: 200 });
return NextResponse.json({ success: true, version: "2.0.0", tahap: "beta", update: "-api mobile; -login tanpa otp (mobile app); -tambah laporan pada project dan tugas divisi; -tambah upload link pada project dan tugas divisi; -tambah detail tanggal dan jam pada project dan tugas divisi; -api jenna ai; -privacy policy" }, { status: 200 });
} catch (error) {
console.error(error);
return NextResponse.json({ success: false, version: "Gagal mendapatkan version, coba lagi nanti (error: 500)", reason: (error as Error).message, }, { status: 500 });