Merge pull request #258 from bipproduction/amalia/26-september-24
Amalia/26 september 24
This commit is contained in:
@@ -1,10 +1,6 @@
|
|||||||
import { CreateTask, FileSave } from "@/module/task";
|
import { CreateTask } from "@/module/task";
|
||||||
|
|
||||||
function Page({ searchParams }: { searchParams: any }) {
|
function Page({ searchParams }: { searchParams: any }) {
|
||||||
|
|
||||||
// if (searchParams.page == "file-save")
|
|
||||||
// return <FileSave kategori="task" />
|
|
||||||
|
|
||||||
return <CreateTask />
|
return <CreateTask />
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -40,12 +40,10 @@ export async function GET(request: Request) {
|
|||||||
where: {
|
where: {
|
||||||
isActive: true,
|
isActive: true,
|
||||||
idDivision: idDivision,
|
idDivision: idDivision,
|
||||||
User: {
|
desc: {
|
||||||
name: {
|
contains: (name == undefined || name == "null") ? "" : name,
|
||||||
contains: (name == undefined || name == "null") ? "" : name,
|
mode: "insensitive"
|
||||||
mode: "insensitive"
|
},
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
orderBy: {
|
orderBy: {
|
||||||
createdAt: 'desc'
|
createdAt: 'desc'
|
||||||
|
|||||||
@@ -86,7 +86,12 @@ export async function GET(request: Request, context: { params: { id: string } })
|
|||||||
idDivision: String(id),
|
idDivision: String(id),
|
||||||
status: 0,
|
status: 0,
|
||||||
isActive: true,
|
isActive: true,
|
||||||
dateStart: new Date()
|
dateStart: new Date(),
|
||||||
|
DivisionProject: {
|
||||||
|
status: {
|
||||||
|
lt: 3
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
select: {
|
select: {
|
||||||
id: true,
|
id: true,
|
||||||
|
|||||||
@@ -38,6 +38,9 @@ export async function GET(request: Request) {
|
|||||||
select: {
|
select: {
|
||||||
id: true,
|
id: true,
|
||||||
name: true,
|
name: true,
|
||||||
|
},
|
||||||
|
orderBy: {
|
||||||
|
name: "asc"
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -44,14 +44,23 @@ export async function GET(request: Request, context: { params: { id: string } })
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const semua = dataProgress.length
|
if (dataProgress.length > 0) {
|
||||||
const selesai = _.filter(dataProgress, { status: 1 }).length
|
const semua = dataProgress.length
|
||||||
const progress = Math.ceil((selesai / semua) * 100)
|
const selesai = _.filter(dataProgress, { status: 1 }).length
|
||||||
|
const progress = Math.ceil((selesai / semua) * 100)
|
||||||
|
|
||||||
allData = {
|
allData = {
|
||||||
progress: progress,
|
progress: progress,
|
||||||
lastUpdate: moment(dataProgress[0].updatedAt).format("DD MMMM YYYY"),
|
lastUpdate: moment(dataProgress[0]?.updatedAt).format("DD MMMM YYYY"),
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
allData = {
|
||||||
|
progress: 0,
|
||||||
|
lastUpdate: '1 Januari 1999',
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} else if (kategori == "task") {
|
} else if (kategori == "task") {
|
||||||
const dataProgress = await prisma.divisionProjectTask.findMany({
|
const dataProgress = await prisma.divisionProjectTask.findMany({
|
||||||
where: {
|
where: {
|
||||||
@@ -66,7 +75,7 @@ export async function GET(request: Request, context: { params: { id: string } })
|
|||||||
dateEnd: true,
|
dateEnd: true,
|
||||||
},
|
},
|
||||||
orderBy: {
|
orderBy: {
|
||||||
status: 'desc'
|
createdAt: 'asc'
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -192,6 +201,34 @@ export async function POST(request: Request, context: { params: { id: string } }
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// const cek progress
|
||||||
|
const dataTask = await prisma.divisionProjectTask.findMany({
|
||||||
|
where: {
|
||||||
|
isActive: true,
|
||||||
|
idProject: id
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const semua = dataTask.length
|
||||||
|
const selesai = _.filter(dataTask, { status: 1 }).length
|
||||||
|
const progress = Math.ceil((selesai / semua) * 100)
|
||||||
|
let statusProject = 1
|
||||||
|
|
||||||
|
if (progress == 100) {
|
||||||
|
statusProject = 2
|
||||||
|
} else if (progress == 0) {
|
||||||
|
statusProject = 0
|
||||||
|
}
|
||||||
|
|
||||||
|
const updProject = await prisma.divisionProject.update({
|
||||||
|
where: {
|
||||||
|
id: id
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
status: statusProject
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
// create log user
|
// create log user
|
||||||
const log = await createLogUser({ act: 'CREATE', desc: 'User menambahkan detail tugas divisi', table: 'divisionProjectTask', data: create.id })
|
const log = await createLogUser({ act: 'CREATE', desc: 'User menambahkan detail tugas divisi', table: 'divisionProjectTask', data: create.id })
|
||||||
|
|
||||||
|
|||||||
@@ -68,6 +68,9 @@ export async function GET(request: Request) {
|
|||||||
idUser: true
|
idUser: true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
orderBy: {
|
||||||
|
createdAt: "desc"
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ export default function LayoutModal({ opened, onClose, description, onYes }: { o
|
|||||||
<Button loading={loading} fullWidth size="lg" radius={'xl'} bg={'green'} onClick={() => {
|
<Button loading={loading} fullWidth size="lg" radius={'xl'} bg={'green'} onClick={() => {
|
||||||
setLoading(true)
|
setLoading(true)
|
||||||
onYes(true)
|
onYes(true)
|
||||||
|
setLoading(false)
|
||||||
}}>YA</Button>
|
}}>YA</Button>
|
||||||
<Button fullWidth size="lg" radius={'xl'} bg={'#F1C1CF'} c={'#D30B30'} onClick={() => onYes(false)}>TIDAK</Button>
|
<Button fullWidth size="lg" radius={'xl'} bg={'#F1C1CF'} c={'#D30B30'} onClick={() => onYes(false)}>TIDAK</Button>
|
||||||
</>
|
</>
|
||||||
@@ -39,6 +40,7 @@ export default function LayoutModal({ opened, onClose, description, onYes }: { o
|
|||||||
<Button loading={loading} fullWidth size="lg" radius={'xl'} bg={'green'} onClick={() => {
|
<Button loading={loading} fullWidth size="lg" radius={'xl'} bg={'green'} onClick={() => {
|
||||||
setLoading(true)
|
setLoading(true)
|
||||||
onYes(true)
|
onYes(true)
|
||||||
|
setLoading(false)
|
||||||
}}>YA</Button>
|
}}>YA</Button>
|
||||||
</>
|
</>
|
||||||
|
|
||||||
|
|||||||
@@ -26,12 +26,12 @@ export default function TabProject() {
|
|||||||
{
|
{
|
||||||
id: "0",
|
id: "0",
|
||||||
title: "Segera",
|
title: "Segera",
|
||||||
icon: <RiProgress3Line style={iconStyle} />
|
icon: <TbClockPause style={iconStyle} />
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: "1",
|
id: "1",
|
||||||
title: "Dikerjakan",
|
title: "Dikerjakan",
|
||||||
icon: <TbClockPause style={iconStyle} />
|
icon: <RiProgress3Line style={iconStyle} />
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: "2",
|
id: "2",
|
||||||
@@ -73,7 +73,7 @@ export default function TabProject() {
|
|||||||
color={
|
color={
|
||||||
status == item.id
|
status == item.id
|
||||||
? "white"
|
? "white"
|
||||||
: tema.get().utama
|
: (status == null && item.id == "0") ? "white" : tema.get().utama
|
||||||
}
|
}
|
||||||
key={index}
|
key={index}
|
||||||
onClick={() => { router.push("?status=" + item.id + "&group=" + group) }}
|
onClick={() => { router.push("?status=" + item.id + "&group=" + group) }}
|
||||||
@@ -81,8 +81,8 @@ export default function TabProject() {
|
|||||||
radius={"xl"}
|
radius={"xl"}
|
||||||
bg={
|
bg={
|
||||||
status == item.id
|
status == item.id
|
||||||
? tema.get().utama
|
? tema.get().bgFiturDivision
|
||||||
: "transparent"
|
: (status == null && item.id == "0") ? tema.get().bgFiturDivision : "transparent"
|
||||||
}
|
}
|
||||||
leftSection={item.icon}
|
leftSection={item.icon}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -98,9 +98,9 @@ export default function AddFileDetailTask() {
|
|||||||
}}
|
}}
|
||||||
activateOnClick={false}
|
activateOnClick={false}
|
||||||
maxSize={3 * 1024 ** 2}
|
maxSize={3 * 1024 ** 2}
|
||||||
accept={['text/csv', 'image/png', 'image/jpeg', 'image/heic', 'application/pdf']}
|
accept={['image/png', 'image/jpeg', 'image/heic', 'application/pdf']}
|
||||||
onReject={(files) => {
|
onReject={(files) => {
|
||||||
return toast.error('File yang diizinkan: .csv, .png, .jpg, .heic, .pdf dengan ukuran maksimal 3 MB')
|
return toast.error('File yang diizinkan: .png, .jpg, .heic, .pdf dengan ukuran maksimal 3 MB')
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
</Dropzone>
|
</Dropzone>
|
||||||
|
|||||||
@@ -304,9 +304,9 @@ export default function CreateTask() {
|
|||||||
}}
|
}}
|
||||||
activateOnClick={false}
|
activateOnClick={false}
|
||||||
maxSize={3 * 1024 ** 2}
|
maxSize={3 * 1024 ** 2}
|
||||||
accept={['text/csv', 'image/png', 'image/jpeg', 'image/heic', 'application/pdf']}
|
accept={['image/png', 'image/jpeg', 'image/heic', 'application/pdf']}
|
||||||
onReject={(files) => {
|
onReject={(files) => {
|
||||||
return toast.error('File yang diizinkan: .csv, .png, .jpg, .heic, .pdf dengan ukuran maksimal 3 MB')
|
return toast.error('File yang diizinkan: .png, .jpg, .heic, .pdf dengan ukuran maksimal 3 MB')
|
||||||
}}
|
}}
|
||||||
></Dropzone>
|
></Dropzone>
|
||||||
|
|
||||||
|
|||||||
@@ -100,9 +100,8 @@ export default function ListAnggotaDetailTask() {
|
|||||||
style={{
|
style={{
|
||||||
border: `1px solid ${"#C7D6E8"}`,
|
border: `1px solid ${"#C7D6E8"}`,
|
||||||
borderRadius: 10,
|
borderRadius: 10,
|
||||||
|
padding: 20
|
||||||
}}
|
}}
|
||||||
px={20}
|
|
||||||
py={10}
|
|
||||||
>
|
>
|
||||||
{
|
{
|
||||||
loading ?
|
loading ?
|
||||||
@@ -114,7 +113,7 @@ export default function ListAnggotaDetailTask() {
|
|||||||
</Box>
|
</Box>
|
||||||
))
|
))
|
||||||
:
|
:
|
||||||
isData.length === 0 ? <Text>Tidak ada anggota</Text> :
|
isData.length === 0 ? <Text c={"dimmed"} ta={"center"} fs={"italic"}>Tidak ada anggota</Text> :
|
||||||
isData.map((v, i) => {
|
isData.map((v, i) => {
|
||||||
return (
|
return (
|
||||||
<Box key={i}>
|
<Box key={i}>
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ export default function ListFileDetailTask() {
|
|||||||
</Box>
|
</Box>
|
||||||
))
|
))
|
||||||
:
|
:
|
||||||
isData.length === 0 ? <Text>Tidak ada file</Text> :
|
isData.length === 0 ? <Text c={"dimmed"} ta={"center"} fs={"italic"}>Tidak ada file</Text> :
|
||||||
isData.map((item, index) => {
|
isData.map((item, index) => {
|
||||||
return (
|
return (
|
||||||
<Box
|
<Box
|
||||||
|
|||||||
@@ -118,9 +118,8 @@ export default function ListTugasDetailTask() {
|
|||||||
style={{
|
style={{
|
||||||
borderRadius: 10,
|
borderRadius: 10,
|
||||||
border: `1px solid ${"#D6D8F6"}`,
|
border: `1px solid ${"#D6D8F6"}`,
|
||||||
|
padding:20
|
||||||
}}
|
}}
|
||||||
pl={20}
|
|
||||||
pr={20}
|
|
||||||
>
|
>
|
||||||
{
|
{
|
||||||
loading ?
|
loading ?
|
||||||
@@ -130,7 +129,7 @@ export default function ListTugasDetailTask() {
|
|||||||
</Box>
|
</Box>
|
||||||
</>
|
</>
|
||||||
:
|
:
|
||||||
isData.length === 0 ? <Text>Tidak ada tugas</Text> :
|
isData.length === 0 ? <Text c={"dimmed"} ta={"center"} fs={"italic"}>Tidak ada tugas</Text> :
|
||||||
isData.map((item, index) => {
|
isData.map((item, index) => {
|
||||||
return (
|
return (
|
||||||
<Box key={index}>
|
<Box key={index}>
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ export default function EditDetailTask() {
|
|||||||
const param = useParams<{ id: string, detail: string }>()
|
const param = useParams<{ id: string, detail: string }>()
|
||||||
const [openModal, setOpenModal] = useState(false)
|
const [openModal, setOpenModal] = useState(false)
|
||||||
const [loading, setLoading] = useState(true)
|
const [loading, setLoading] = useState(true)
|
||||||
|
const [idTugas, setIdTugas] = useState("")
|
||||||
const tema = useHookstate(TEMA)
|
const tema = useHookstate(TEMA)
|
||||||
|
|
||||||
async function onSubmit() {
|
async function onSubmit() {
|
||||||
@@ -50,6 +51,7 @@ export default function EditDetailTask() {
|
|||||||
|
|
||||||
if (res.success) {
|
if (res.success) {
|
||||||
toast.success(res.message);
|
toast.success(res.message);
|
||||||
|
router.push(`/division/${param.id}/task/${idTugas}`)
|
||||||
} else {
|
} else {
|
||||||
toast.error(res.message);
|
toast.error(res.message);
|
||||||
}
|
}
|
||||||
@@ -65,6 +67,7 @@ export default function EditDetailTask() {
|
|||||||
setLoading(true)
|
setLoading(true)
|
||||||
const res = await funGetDetailTask(param.detail);
|
const res = await funGetDetailTask(param.detail);
|
||||||
if (res.success) {
|
if (res.success) {
|
||||||
|
setIdTugas(res.data.idProject)
|
||||||
setTitle(res.data.title)
|
setTitle(res.data.title)
|
||||||
setValue([
|
setValue([
|
||||||
new Date(moment(res.data.dateStart).format('YYYY-MM-DD')),
|
new Date(moment(res.data.dateStart).format('YYYY-MM-DD')),
|
||||||
|
|||||||
Reference in New Issue
Block a user