3
.gitignore
vendored
3
.gitignore
vendored
@@ -40,4 +40,5 @@ next-env.d.ts
|
||||
|
||||
# folder foto kandidat
|
||||
/public/image/
|
||||
/public/file/
|
||||
/public/file/
|
||||
certificates
|
||||
@@ -3,7 +3,7 @@
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "next dev",
|
||||
"dev": "next dev --experimental-https",
|
||||
"build": "next build",
|
||||
"start": "next start",
|
||||
"lint": "next lint"
|
||||
@@ -77,4 +77,4 @@
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC"
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,6 @@ 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 {
|
||||
@@ -72,7 +71,9 @@ export async function GET(request: Request, context: { params: { id: string } })
|
||||
division: v.Division.name
|
||||
}))
|
||||
|
||||
const fixMember = Object.groupBy(formatMember, ({ group }) => group);
|
||||
// const fixMember = Object.groupBy(formatMember, ({ group }) => group);
|
||||
const fixMember = _.groupBy(formatMember, ({ group }) => group);
|
||||
|
||||
|
||||
return NextResponse.json(
|
||||
{
|
||||
@@ -88,7 +89,7 @@ export async function GET(request: Request, context: { params: { id: string } })
|
||||
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
return NextResponse.json({ success: false, message: "Gagal mendapatkan pengumuman, coba lagi nanti", reason: (error as Error).message, }, { status: 500 });
|
||||
return NextResponse.json({ success: false, message: "Gagal mendapatkan pengumuman, coba lagi nanti (error: 500)", reason: (error as Error).message, }, { status: 500 });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -140,7 +141,7 @@ export async function DELETE(request: Request, context: { params: { id: string }
|
||||
);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
return NextResponse.json({ success: false, message: "Gagal mendapatkan pengumuman, coba lagi nanti", reason: (error as Error).message, }, { status: 500 });
|
||||
return NextResponse.json({ success: false, message: "Gagal mendapatkan pengumuman, coba lagi nanti (error: 500)", reason: (error as Error).message, }, { status: 500 });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -217,7 +218,7 @@ export async function PUT(request: Request, context: { params: { id: string } })
|
||||
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
return NextResponse.json({ success: false, message: "Gagal mengeupdate pengumuman, coba lagi nanti", reason: (error as Error).message, }, { status: 500 });
|
||||
return NextResponse.json({ success: false, message: "Gagal mengeupdate pengumuman, coba lagi nanti (error: 500)", reason: (error as Error).message, }, { status: 500 });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import { prisma } from "@/module/_global";
|
||||
import { funGetUserByCookies } from "@/module/auth";
|
||||
import { NextResponse } from "next/server";
|
||||
|
||||
export const dynamic = 'force-dynamic'
|
||||
export const revalidate = true
|
||||
|
||||
|
||||
export async function GET(request: Request) {
|
||||
try {
|
||||
const user = await funGetUserByCookies()
|
||||
@@ -32,6 +33,9 @@ export async function GET(request: Request) {
|
||||
id: true,
|
||||
name: true,
|
||||
Division: {
|
||||
where: {
|
||||
isActive: true
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
name: true
|
||||
@@ -44,6 +48,6 @@ export async function GET(request: Request) {
|
||||
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
return NextResponse.json({ success: false, message: "Gagal mendapatkan grup, coba lagi nanti", reason: (error as Error).message, }, { status: 500 });
|
||||
return NextResponse.json({ success: false, message: "Gagal mendapatkan grup, coba lagi nanti (error: 500)", reason: (error as Error).message, }, { status: 500 });
|
||||
}
|
||||
}
|
||||
@@ -287,6 +287,7 @@ export async function GET(request: Request) {
|
||||
isActive: true,
|
||||
dateStart: new Date(),
|
||||
Division: {
|
||||
isActive: true,
|
||||
idVillage: idVillage,
|
||||
Group: {
|
||||
isActive: true,
|
||||
@@ -301,6 +302,7 @@ export async function GET(request: Request) {
|
||||
isActive: true,
|
||||
dateStart: new Date(),
|
||||
Division: {
|
||||
isActive: true,
|
||||
idGroup: idGroup
|
||||
},
|
||||
DivisionCalendar: {
|
||||
|
||||
@@ -49,7 +49,7 @@ export async function POST(request: Request, context: { params: { id: string } }
|
||||
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
return NextResponse.json({ success: false, message: "Gagal menambah anggota kegiatan, coba lagi nanti", reason: (error as Error).message, }, { status: 500 });
|
||||
return NextResponse.json({ success: false, message: "Gagal menambah anggota kegiatan, coba lagi nanti (error: 500)", reason: (error as Error).message, }, { status: 500 });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,7 +95,7 @@ export async function DELETE(request: Request, context: { params: { id: string }
|
||||
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
return NextResponse.json({ success: false, message: "Gagal mengeluarkan anggota kegiatan, coba lagi nanti", reason: (error as Error).message, }, { status: 500 });
|
||||
return NextResponse.json({ success: false, message: "Gagal mengeluarkan anggota kegiatan, coba lagi nanti (error: 500)", reason: (error as Error).message, }, { status: 500 });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -141,13 +141,16 @@ export async function GET(request: Request, context: { params: { id: string } })
|
||||
contains: (name == undefined || name == "null") ? "" : name,
|
||||
mode: 'insensitive'
|
||||
}
|
||||
|
||||
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
name: true,
|
||||
email: true,
|
||||
img: true
|
||||
},
|
||||
orderBy: {
|
||||
name: 'asc'
|
||||
}
|
||||
})
|
||||
|
||||
@@ -167,6 +170,6 @@ export async function GET(request: Request, context: { params: { id: string } })
|
||||
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
return NextResponse.json({ success: false, message: "Gagal mendapatkan project, coba lagi nanti", reason: (error as Error).message, }, { status: 500 });
|
||||
return NextResponse.json({ success: false, message: "Gagal mendapatkan project, coba lagi nanti (error: 500)", reason: (error as Error).message, }, { status: 500 });
|
||||
}
|
||||
}
|
||||
@@ -27,7 +27,7 @@ export async function GET(request: Request, context: { params: { id: string } })
|
||||
});
|
||||
|
||||
if (!data) {
|
||||
return NextResponse.json({ success: false, message: "Gagal mendapatkan project, data tidak ditemukan", }, { status: 404 });
|
||||
return NextResponse.json({ success: false, message: "Gagal mendapatkan kegiatan, data tidak ditemukan", }, { status: 404 });
|
||||
}
|
||||
|
||||
|
||||
@@ -133,11 +133,11 @@ export async function GET(request: Request, context: { params: { id: string } })
|
||||
allData = fix
|
||||
}
|
||||
|
||||
return NextResponse.json({ success: true, message: "Berhasil mendapatkan project", data: allData, }, { status: 200 });
|
||||
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 project, coba lagi nantiiiiii", reason: (error as Error).message, }, { status: 500 });
|
||||
return NextResponse.json({ success: false, message: "Gagal mendapatkan kegiatan, coba lagi nanti (error: 500)", reason: (error as Error).message, }, { status: 500 });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -186,7 +186,7 @@ export async function POST(request: Request, context: { params: { id: string } }
|
||||
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
return NextResponse.json({ success: false, message: "Gagal tambah tahapan kegiatan, coba lagi nanti", reason: (error as Error).message, }, { status: 500 });
|
||||
return NextResponse.json({ success: false, message: "Gagal tambah tahapan kegiatan, coba lagi nanti (error: 500)", reason: (error as Error).message, }, { status: 500 });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -210,7 +210,7 @@ export async function DELETE(request: Request, context: { params: { id: string }
|
||||
if (data == 0) {
|
||||
return NextResponse.json(
|
||||
{
|
||||
success: false, message: "Gagal mendapatkan project, data tidak ditemukan",
|
||||
success: false, message: "Gagal mendapatkan kegiatan, data tidak ditemukan",
|
||||
},
|
||||
{ status: 404 }
|
||||
);
|
||||
@@ -232,7 +232,7 @@ export async function DELETE(request: Request, context: { params: { id: string }
|
||||
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
return NextResponse.json({ success: false, message: "Gagal membatalkan kegiatan, coba lagi nanti", reason: (error as Error).message, }, { status: 500 });
|
||||
return NextResponse.json({ success: false, message: "Gagal membatalkan kegiatan, coba lagi nanti (error: 500)", reason: (error as Error).message, }, { status: 500 });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -278,6 +278,6 @@ export async function PUT(request: Request, context: { params: { id: string } })
|
||||
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
return NextResponse.json({ success: false, message: "Gagal mengupdate kegiatan, coba lagi nanti", reason: (error as Error).message, }, { status: 500 });
|
||||
return NextResponse.json({ success: false, message: "Gagal mengupdate kegiatan, coba lagi nanti (error: 500)", reason: (error as Error).message, }, { status: 500 });
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@ import { NextResponse } from "next/server";
|
||||
|
||||
export async function GET(request: Request) {
|
||||
try {
|
||||
return NextResponse.json({ success: true, version: "0.1.4", mode: "staging" }, { status: 200 });
|
||||
return NextResponse.json({ success: true, version: "0.1.5", mode: "staging" }, { status: 200 });
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
return NextResponse.json({ success: false, version: "Gagal mendapatkan version, coba lagi nanti", reason: (error as Error).message, }, { status: 500 });
|
||||
|
||||
@@ -48,8 +48,8 @@ export default function CreateDivision() {
|
||||
const cek = checkAll()
|
||||
if (!cek)
|
||||
return false
|
||||
if (member.length == 0)
|
||||
return toast.error("Error! belum ada anggota yang terdaftar")
|
||||
if (member.length <= 1)
|
||||
return toast.error("Error! Silahkan pilih anggota lebih dari 1")
|
||||
|
||||
setChooseAdmin(true)
|
||||
}
|
||||
|
||||
@@ -152,14 +152,8 @@ export default function DrawerListPosition({ onCreated }: { onCreated: (val: boo
|
||||
}
|
||||
</SimpleGrid>
|
||||
</Stack>
|
||||
<LayoutDrawer opened={openDrawerGroup} onClose={() => setOpenDrawerGroup(false)} title={'Tambah Jabatan'} size="lg">
|
||||
<Box pt={10} pos={"relative"} h={{
|
||||
base: "65vh",
|
||||
sm: "67vh",
|
||||
lg: "67vh",
|
||||
xl: "70vh"
|
||||
|
||||
}}>
|
||||
<LayoutDrawer opened={openDrawerGroup} onClose={() => setOpenDrawerGroup(false)} title={'Tambah Jabatan'}>
|
||||
<Box pt={10} pos={"relative"} h={"28.5vh"}>
|
||||
{
|
||||
roleLogin.get() == "supadmin" &&
|
||||
<Select
|
||||
|
||||
@@ -16,6 +16,7 @@ export default function AddDetailTaskProject() {
|
||||
const router = useRouter()
|
||||
const [name, setName] = useState("")
|
||||
const [openModal, setOpenModal] = useState(false)
|
||||
const [loadingModal, setLoadingModal] = useState(false)
|
||||
const param = useParams<{ id: string }>()
|
||||
const tema = useHookstate(TEMA)
|
||||
const [touched, setTouched] = useState({
|
||||
@@ -38,6 +39,7 @@ export default function AddDetailTaskProject() {
|
||||
|
||||
async function onSubmit() {
|
||||
try {
|
||||
setLoadingModal(true)
|
||||
const res = await funCreateDetailProject(param.id, {
|
||||
name,
|
||||
dateStart: (value[0] != null) ? value[0] : new Date,
|
||||
@@ -50,7 +52,6 @@ export default function AddDetailTaskProject() {
|
||||
id: param.id,
|
||||
}])
|
||||
toast.success(res.message)
|
||||
setOpenModal(false)
|
||||
router.push(`/project/${param.id}`)
|
||||
} else {
|
||||
toast.error(res.message)
|
||||
@@ -58,6 +59,9 @@ export default function AddDetailTaskProject() {
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
toast.error("Gagal menambahkan tugas, coba lagi nanti")
|
||||
} finally {
|
||||
setOpenModal(false)
|
||||
setLoadingModal(false)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -148,13 +152,14 @@ export default function AddDetailTaskProject() {
|
||||
</Box>
|
||||
|
||||
|
||||
<LayoutModal opened={openModal} onClose={() => setOpenModal(false)}
|
||||
<LayoutModal loading={loadingModal} opened={openModal} onClose={() => setOpenModal(false)}
|
||||
description="Apakah Anda yakin ingin menambahkan tugas?"
|
||||
onYes={(val) => {
|
||||
if (val) {
|
||||
onSubmit()
|
||||
} else {
|
||||
setOpenModal(false)
|
||||
}
|
||||
setOpenModal(false)
|
||||
}} />
|
||||
</Box>
|
||||
);
|
||||
|
||||
@@ -18,6 +18,7 @@ import { useWibuRealtime } from "wibu-realtime";
|
||||
|
||||
export default function AddFileDetailProject() {
|
||||
const router = useRouter()
|
||||
const [loadingModal, setLoadingModal] = useState(false)
|
||||
const [openModal, setOpenModal] = useState(false)
|
||||
const [fileForm, setFileForm] = useState<any[]>([])
|
||||
const [listFile, setListFile] = useState<IListFileTaskProject[]>([])
|
||||
@@ -57,6 +58,7 @@ export default function AddFileDetailProject() {
|
||||
|
||||
async function onSubmit() {
|
||||
try {
|
||||
setLoadingModal(true)
|
||||
const fd = new FormData();
|
||||
for (let i = 0; i < fileForm.length; i++) {
|
||||
fd.append(`file${i}`, fileForm[i]);
|
||||
@@ -79,6 +81,9 @@ export default function AddFileDetailProject() {
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
toast.error("Gagal menambahkan file, coba lagi nanti");
|
||||
} finally {
|
||||
setOpenModal(false)
|
||||
setLoadingModal(false)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -183,13 +188,14 @@ export default function AddFileDetailProject() {
|
||||
</Stack>
|
||||
</LayoutDrawer>
|
||||
|
||||
<LayoutModal opened={openModal} onClose={() => setOpenModal(false)}
|
||||
<LayoutModal loading={loadingModal} opened={openModal} onClose={() => setOpenModal(false)}
|
||||
description="Apakah Anda yakin ingin menambahkan file?"
|
||||
onYes={(val) => {
|
||||
if (val) {
|
||||
onSubmit()
|
||||
} else {
|
||||
setOpenModal(false)
|
||||
}
|
||||
setOpenModal(false)
|
||||
}} />
|
||||
|
||||
</Box>
|
||||
|
||||
@@ -27,7 +27,8 @@ export default function AddMemberDetailProject() {
|
||||
const [onClickSearch, setOnClickSearch] = useState(false)
|
||||
const [searchQuery, setSearchQuery] = useState('')
|
||||
const tema = useHookstate(TEMA)
|
||||
const isMobile2 = useMediaQuery("(max-width: 438px)");
|
||||
const isMobile2 = useMediaQuery("(max-width: 438px)")
|
||||
const [loadingModal, setLoadingModal] = useState(false)
|
||||
const [dataRealTime, setDataRealtime] = useWibuRealtime({
|
||||
WIBU_REALTIME_TOKEN: keyWibu,
|
||||
project: "sdm"
|
||||
@@ -102,6 +103,7 @@ export default function AddMemberDetailProject() {
|
||||
|
||||
async function onSubmit() {
|
||||
try {
|
||||
setLoadingModal(true)
|
||||
const res = await funAddMemberProject(param.id, { member: selectedFiles });
|
||||
if (res.success) {
|
||||
setDataRealtime([{
|
||||
@@ -116,6 +118,9 @@ export default function AddMemberDetailProject() {
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
toast.error("Gagal menambahkan anggota, coba lagi nanti");
|
||||
} finally {
|
||||
setOpenModal(false)
|
||||
setLoadingModal(true)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -307,13 +312,14 @@ export default function AddMemberDetailProject() {
|
||||
}
|
||||
</Box>
|
||||
|
||||
<LayoutModal opened={openModal} onClose={() => setOpenModal(false)}
|
||||
<LayoutModal loading={loadingModal} opened={openModal} onClose={() => setOpenModal(false)}
|
||||
description="Apakah Anda yakin ingin menambahkan anggota?"
|
||||
onYes={(val) => {
|
||||
if (val) {
|
||||
onSubmit()
|
||||
} else {
|
||||
setOpenModal(false)
|
||||
}
|
||||
setOpenModal(false)
|
||||
}} />
|
||||
</Box>
|
||||
);
|
||||
|
||||
@@ -144,8 +144,8 @@ export default function CreateProject() {
|
||||
if (dataTask.length == 0)
|
||||
return toast.error("Error! silahkan tambahkan tugas")
|
||||
|
||||
if (memberValue.length == 0)
|
||||
return toast.error("Error! silahkan pilih anggota")
|
||||
if (memberValue.length <= 1)
|
||||
return toast.error("Error! Silahkan pilih anggota lebih dari 1")
|
||||
|
||||
setModal(true)
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ export default function ListAnggotaDetailProject() {
|
||||
const [isData, setData] = useState<IDataMemberProject[]>([])
|
||||
const param = useParams<{ id: string }>()
|
||||
const [loading, setLoading] = useState(true)
|
||||
const [loadingDelete, setLoadingDelete] = useState(false)
|
||||
const [openDrawer, setOpenDrawer] = useState(false)
|
||||
const [isOpenModal, setOpenModal] = useState(false)
|
||||
const [dataChoose, setDataChoose] = useState({ id: '', name: '' })
|
||||
@@ -76,6 +77,7 @@ export default function ListAnggotaDetailProject() {
|
||||
|
||||
async function onSubmit() {
|
||||
try {
|
||||
setLoadingDelete(true)
|
||||
const res = await funDeleteMemberProject(param.id, { idUser: dataChoose.id });
|
||||
if (res.success) {
|
||||
setDataRealtime([{
|
||||
@@ -92,6 +94,9 @@ export default function ListAnggotaDetailProject() {
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
toast.error("Gagal menghapus anggota Kegiatan, coba lagi nanti");
|
||||
} finally {
|
||||
setOpenModal(false)
|
||||
setLoadingDelete(false)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -129,7 +134,7 @@ export default function ListAnggotaDetailProject() {
|
||||
</Box>
|
||||
))
|
||||
:
|
||||
isData.length === 0 ? <Text>Tidak ada anggota</Text> :
|
||||
isData.length === 0 ? <Text c={"dimmed"} ta={"center"}>Tidak ada anggota</Text> :
|
||||
isData.map((v, i) => {
|
||||
return (
|
||||
<Box key={i}>
|
||||
@@ -198,13 +203,14 @@ export default function ListAnggotaDetailProject() {
|
||||
</Box>
|
||||
</LayoutDrawer>
|
||||
|
||||
<LayoutModal opened={isOpenModal} onClose={() => setOpenModal(false)}
|
||||
<LayoutModal loading={loadingDelete} opened={isOpenModal} onClose={() => setOpenModal(false)}
|
||||
description="Apakah Anda yakin ingin mengeluarkan anggota?"
|
||||
onYes={(val) => {
|
||||
if (val) {
|
||||
onSubmit()
|
||||
} else {
|
||||
setOpenModal(false)
|
||||
}
|
||||
setOpenModal(false)
|
||||
}} />
|
||||
|
||||
</Box>
|
||||
|
||||
@@ -17,6 +17,7 @@ export default function ListFileDetailProject() {
|
||||
const [isData, setData] = useState<IDataFileProject[]>([])
|
||||
const param = useParams<{ id: string }>()
|
||||
const [loading, setLoading] = useState(true)
|
||||
const [loadingDelete, setLoadingDelete] = useState(false)
|
||||
const [idData, setIdData] = useState('')
|
||||
const [idStorage, setIdStorage] = useState('')
|
||||
const [nameData, setNameData] = useState('')
|
||||
@@ -76,6 +77,7 @@ export default function ListFileDetailProject() {
|
||||
|
||||
async function onDelete() {
|
||||
try {
|
||||
setLoadingDelete(true)
|
||||
const res = await funDeleteFileProject(idData);
|
||||
if (res.success) {
|
||||
setDataRealtime([{
|
||||
@@ -93,6 +95,9 @@ export default function ListFileDetailProject() {
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
toast.error("Gagal menghapus file, coba lagi nanti");
|
||||
} finally {
|
||||
setOpenModal(false)
|
||||
setLoadingDelete(false)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -128,7 +133,7 @@ export default function ListFileDetailProject() {
|
||||
</Box>
|
||||
))
|
||||
:
|
||||
isData.length === 0 ? <Text>Tidak ada file</Text> :
|
||||
isData.length === 0 ? <Text c={"dimmed"} ta={"center"}>Tidak ada file</Text> :
|
||||
isData.map((item, index) => {
|
||||
return (
|
||||
<Box
|
||||
@@ -225,13 +230,14 @@ export default function ListFileDetailProject() {
|
||||
</LayoutDrawer>
|
||||
|
||||
|
||||
<LayoutModal opened={isOpenModal} onClose={() => setOpenModal(false)}
|
||||
<LayoutModal loading={loadingDelete} opened={isOpenModal} onClose={() => setOpenModal(false)}
|
||||
description="Apakah Anda yakin ingin menghapus file ini? File yang dihapus tidak dapat dikembalikan"
|
||||
onYes={(val) => {
|
||||
if (val) {
|
||||
onDelete()
|
||||
} else {
|
||||
setOpenModal(false)
|
||||
}
|
||||
setOpenModal(false)
|
||||
}} />
|
||||
|
||||
<LayoutModalViewFile opened={isOpenModalView} onClose={() => setOpenModalView(false)} file={idStorage} extension={isExtension} fitur='project' />
|
||||
|
||||
@@ -24,6 +24,7 @@ export default function ListTugasDetailProject() {
|
||||
const [statusData, setStatusData] = useState(0)
|
||||
const [openDrawerStatus, setOpenDrawerStatus] = useState(false)
|
||||
const [isOpenModal, setOpenModal] = useState(false)
|
||||
const [loadingDelete, setLoadingDelete] = useState(false)
|
||||
const router = useRouter()
|
||||
const tema = useHookstate(TEMA)
|
||||
const [reason, setReason] = useState("")
|
||||
@@ -75,6 +76,7 @@ export default function ListTugasDetailProject() {
|
||||
|
||||
async function onDelete() {
|
||||
try {
|
||||
setLoadingDelete(true)
|
||||
const res = await funDeleteDetailProject(idData, { idProject: param.id });
|
||||
if (res.success) {
|
||||
setDataRealtime([{
|
||||
@@ -92,6 +94,9 @@ export default function ListTugasDetailProject() {
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
toast.error("Gagal hapus tugas Kegiatan, coba lagi nanti");
|
||||
} finally {
|
||||
setOpenModal(false)
|
||||
setLoadingDelete(false)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,7 +143,6 @@ export default function ListTugasDetailProject() {
|
||||
style={{
|
||||
borderRadius: 10,
|
||||
border: `1px solid ${"#D6D8F6"}`,
|
||||
// padding: 10,
|
||||
}}
|
||||
pl={20}
|
||||
pr={20}
|
||||
@@ -149,7 +153,7 @@ export default function ListTugasDetailProject() {
|
||||
<SkeletonDetailListTugasTask />
|
||||
</Box>
|
||||
</> :
|
||||
isData.length === 0 ? <Text>Tidak ada tugas</Text> :
|
||||
isData.length === 0 ? <Text py={20} c={"dimmed"} ta={"center"}>Tidak ada tugas</Text> :
|
||||
isData.map((item, index) => {
|
||||
return (
|
||||
<Box key={index}>
|
||||
@@ -256,13 +260,14 @@ export default function ListTugasDetailProject() {
|
||||
</Box>
|
||||
</LayoutDrawer>
|
||||
|
||||
<LayoutModal opened={isOpenModal} onClose={() => setOpenModal(false)}
|
||||
description="Apakah Anda yakin ingin menghapus Tahapan Tugas ini?"
|
||||
<LayoutModal loading={loadingDelete} opened={isOpenModal} onClose={() => setOpenModal(false)}
|
||||
description="Apakah Anda yakin ingin menghapus tahapan tugas ini?"
|
||||
onYes={(val) => {
|
||||
if (val) {
|
||||
onDelete()
|
||||
} else {
|
||||
setOpenModal(false)
|
||||
}
|
||||
setOpenModal(false)
|
||||
}} />
|
||||
|
||||
<LayoutDrawer opened={openDrawerStatus} title={'Status'} onClose={() => setOpenDrawerStatus(false)}>
|
||||
|
||||
@@ -89,7 +89,7 @@ export default function ProgressDetailProject() {
|
||||
<>
|
||||
<Box mt={10}>
|
||||
{loading ? "" :
|
||||
reason !== null ?
|
||||
(reason !== null && reason != "") ?
|
||||
(
|
||||
<Box mb={10}>
|
||||
<Box p={15} bg={"#FFF2CD"} style={{
|
||||
|
||||
@@ -25,12 +25,32 @@ export default function CancelTask() {
|
||||
})
|
||||
|
||||
function onVerification() {
|
||||
if (alasan == "")
|
||||
return toast.error("Error! harus memasukkan alasan pembatalan tugas")
|
||||
|
||||
const cek = checkAll()
|
||||
if (!cek) {
|
||||
return false
|
||||
}
|
||||
setOpenModal(true)
|
||||
}
|
||||
|
||||
function onValidation(kategori: string, val: string) {
|
||||
if (kategori == 'alasan') {
|
||||
setAlasan(val)
|
||||
if (val == "") {
|
||||
setTouched({ ...touched, reason: true })
|
||||
} else {
|
||||
setTouched({ ...touched, reason: false })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function checkAll() {
|
||||
if (alasan == "") {
|
||||
setTouched({ ...touched, reason: true })
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
async function onSubmit() {
|
||||
try {
|
||||
const res = await funCancelTask(param.detail, { reason: alasan })
|
||||
@@ -38,7 +58,7 @@ export default function CancelTask() {
|
||||
setDataRealtime([{
|
||||
category: "tugas-detail-status",
|
||||
id: param.detail,
|
||||
}])
|
||||
}])
|
||||
toast.success(res.message)
|
||||
router.push("./")
|
||||
} else {
|
||||
@@ -66,12 +86,8 @@ export default function CancelTask() {
|
||||
value={alasan}
|
||||
size="md" placeholder='Contoh : Tugas tidak sesuai' label="Alasan Pembatalan"
|
||||
required
|
||||
onChange={(event) => {
|
||||
setAlasan(event.target.value)
|
||||
setTouched({ ...touched, reason: false })
|
||||
}}
|
||||
onChange={(event) => { onValidation('alasan', event.target.value) }}
|
||||
error={touched.reason ? "Error! harus memasukkan alasan pembatalan tugas" : ""}
|
||||
onBlur={() => setTouched({ ...touched, reason: true })}
|
||||
/>
|
||||
</Stack>
|
||||
</Box>
|
||||
|
||||
@@ -108,8 +108,8 @@ export default function CreateTask() {
|
||||
if (dataTask.length == 0)
|
||||
return toast.error("Error! silahkan tambahkan tugas")
|
||||
|
||||
if (memberValue.length == 0)
|
||||
return toast.error("Error! silahkan pilih anggota")
|
||||
if (memberValue.length <= 1)
|
||||
return toast.error("Error! silahkan pilih anggota lebih dari 1")
|
||||
|
||||
setOpenModal(true)
|
||||
}
|
||||
|
||||
@@ -392,7 +392,7 @@ export default function EditMember({ id }: { id: string }) {
|
||||
value={data.gender}
|
||||
error={
|
||||
touched.gender && (
|
||||
data.gender == "" || String(data.gender) == "null" ? "Gender Tidak Boleh Kosong" : null
|
||||
data.gender == "" || String(data.gender) == "null" ? "Jenis Kelamin Tidak Boleh Kosong" : null
|
||||
)
|
||||
}
|
||||
/>
|
||||
|
||||
@@ -125,7 +125,7 @@ export default function EditProfile() {
|
||||
}
|
||||
} else if (kategori == 'gender') {
|
||||
setData({ ...data, gender: val })
|
||||
if (val == "" || val == "null") {
|
||||
if (val == "" || String(val) == "null") {
|
||||
setTouched({ ...touched, gender: true })
|
||||
} else {
|
||||
setTouched({ ...touched, gender: false })
|
||||
|
||||
Reference in New Issue
Block a user