Merge pull request #99 from bipproduction/lukman/8-agustus-2024
Lukman/8 agustus 2024
This commit is contained in:
10
src/app/(application)/announcement/create-user/page.tsx
Normal file
10
src/app/(application)/announcement/create-user/page.tsx
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
import CreateUsersAnnouncement from '@/module/announcement/component/create_users_announcement';
|
||||||
|
import React from 'react';
|
||||||
|
|
||||||
|
function Page() {
|
||||||
|
return (
|
||||||
|
<CreateUsersAnnouncement />
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Page;
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
import { apiDivision } from "@/module/division_new";
|
import { apiDivision } from "@/module/division_new";
|
||||||
import { NextRequest } from "next/server";
|
import { NextRequest } from "next/server";
|
||||||
|
|
||||||
|
export const dynamic = 'force-dynamic'
|
||||||
export async function GET(req: NextRequest) {
|
export async function GET(req: NextRequest) {
|
||||||
return apiDivision(req, "GET")
|
return apiDivision(req, "GET")
|
||||||
}
|
}
|
||||||
@@ -37,6 +37,8 @@ export async function getOneAnnouncement(req: NextRequest) {
|
|||||||
group: v.Group.name,
|
group: v.Group.name,
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
console.log(allAnnouncementMember)
|
||||||
|
|
||||||
return Response.json({ announcement, allAnnouncementMember });
|
return Response.json({ announcement, allAnnouncementMember });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ export async function createAnnouncement(req: NextRequest) {
|
|||||||
const announcementMember = await prisma.announcementMember.createMany({
|
const announcementMember = await prisma.announcementMember.createMany({
|
||||||
data: dataMember,
|
data: dataMember,
|
||||||
});
|
});
|
||||||
|
console.log(announcementMember)
|
||||||
|
|
||||||
return Response.json({
|
return Response.json({
|
||||||
announcement: announcement,
|
announcement: announcement,
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
import { WARNA } from "@/module/_global";
|
import { WARNA } from "@/module/_global";
|
||||||
import LayoutModal from "@/module/_global/layout/layout_modal";
|
import LayoutModal from "@/module/_global/layout/layout_modal";
|
||||||
import { Box, Button, Group, Stack, Text, Textarea, TextInput } from "@mantine/core";
|
import { Box, Button, Group, Stack, Text, Textarea, TextInput } from "@mantine/core";
|
||||||
|
import { useRouter } from "next/navigation";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import toast from "react-hot-toast";
|
import toast from "react-hot-toast";
|
||||||
import { HiOutlineChevronRight } from "react-icons/hi2";
|
import { HiOutlineChevronRight } from "react-icons/hi2";
|
||||||
@@ -9,6 +10,7 @@ import { IoIosArrowForward } from "react-icons/io";
|
|||||||
|
|
||||||
export default function CreateAnnouncement() {
|
export default function CreateAnnouncement() {
|
||||||
const [isOpen, setOpen] = useState(false)
|
const [isOpen, setOpen] = useState(false)
|
||||||
|
const router = useRouter()
|
||||||
|
|
||||||
function onTrue(val: boolean) {
|
function onTrue(val: boolean) {
|
||||||
if (val) {
|
if (val) {
|
||||||
@@ -52,7 +54,9 @@ export default function CreateAnnouncement() {
|
|||||||
border: `1px solid ${WARNA.biruTua}`,
|
border: `1px solid ${WARNA.biruTua}`,
|
||||||
padding: 10,
|
padding: 10,
|
||||||
borderRadius: 10
|
borderRadius: 10
|
||||||
}}>
|
}}
|
||||||
|
onClick={() => router.push("/announcement/create-user")}
|
||||||
|
>
|
||||||
<Text size="sm">
|
<Text size="sm">
|
||||||
Tambah Anggota
|
Tambah Anggota
|
||||||
</Text>
|
</Text>
|
||||||
|
|||||||
148
src/module/announcement/component/create_users_announcement.tsx
Normal file
148
src/module/announcement/component/create_users_announcement.tsx
Normal file
@@ -0,0 +1,148 @@
|
|||||||
|
"use client"
|
||||||
|
import { LayoutNavbarNew, WARNA } from '@/module/_global';
|
||||||
|
import { Box, Button, Divider, Flex, Group, Stack, Text } from '@mantine/core';
|
||||||
|
import React, { useState } from 'react';
|
||||||
|
import { FaCheck } from 'react-icons/fa';
|
||||||
|
|
||||||
|
interface GroupData {
|
||||||
|
group: string;
|
||||||
|
divisions: string[];
|
||||||
|
}
|
||||||
|
|
||||||
|
const groupData: GroupData[] = [
|
||||||
|
{
|
||||||
|
group: "Group 1",
|
||||||
|
divisions: ["Division 1", "Division 2", "Division 3"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
group: "Group 2",
|
||||||
|
divisions: ["Division 4", "Division 5"]
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
interface CheckedState {
|
||||||
|
[key: string]: string[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function CreateUsersAnnouncement() {
|
||||||
|
const [checked, setChecked] = useState<CheckedState>({});
|
||||||
|
const [selectAll, setSelectAll] = useState(false);
|
||||||
|
|
||||||
|
const handleCheck = (group: string, division: string) => {
|
||||||
|
const newChecked = { ...checked };
|
||||||
|
if (newChecked[group]) {
|
||||||
|
if (newChecked[group].includes(division)) {
|
||||||
|
newChecked[group] = newChecked[group].filter(item => item !== division);
|
||||||
|
} else {
|
||||||
|
newChecked[group].push(division);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
newChecked[group] = [division];
|
||||||
|
}
|
||||||
|
setChecked(newChecked);
|
||||||
|
console.log(newChecked)
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleGroupCheck = (group: string) => {
|
||||||
|
const newChecked = { ...checked };
|
||||||
|
if (newChecked[group]) {
|
||||||
|
delete newChecked[group];
|
||||||
|
} else {
|
||||||
|
newChecked[group] = groupData.find(item => item.group === group)?.divisions || [];
|
||||||
|
}
|
||||||
|
setChecked(newChecked);
|
||||||
|
console.log(newChecked)
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleSelectAll = () => {
|
||||||
|
setSelectAll(!selectAll);
|
||||||
|
if (!selectAll) {
|
||||||
|
const newChecked: CheckedState = {};
|
||||||
|
groupData.forEach(item => {
|
||||||
|
newChecked[item.group] = item.divisions;
|
||||||
|
});
|
||||||
|
setChecked(newChecked);
|
||||||
|
console.log(newChecked)
|
||||||
|
} else {
|
||||||
|
setChecked({});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<LayoutNavbarNew back="" title="Tambah Anggota" menu={<></>} />
|
||||||
|
<Box p={20}>
|
||||||
|
<Group justify='flex-end' mb={20}>
|
||||||
|
<Text
|
||||||
|
onClick={handleSelectAll}
|
||||||
|
style={{
|
||||||
|
cursor: 'pointer',
|
||||||
|
display: 'flex',
|
||||||
|
alignItems: 'center',
|
||||||
|
}}
|
||||||
|
fw={selectAll ? 'bold' : 'normal'}
|
||||||
|
>
|
||||||
|
Pilih Semua
|
||||||
|
</Text>
|
||||||
|
</Group>
|
||||||
|
{groupData.map((item) => (
|
||||||
|
<Stack mb={30} key={item.group}>
|
||||||
|
<Group onClick={() => handleGroupCheck(item.group)} justify='space-between' align='center'>
|
||||||
|
<Text
|
||||||
|
style={{
|
||||||
|
cursor: 'pointer',
|
||||||
|
display: 'flex',
|
||||||
|
alignItems: 'center',
|
||||||
|
}}
|
||||||
|
fw={checked[item.group] && checked[item.group].length === item.divisions.length ? 'bold' : 'normal'}
|
||||||
|
>
|
||||||
|
{item.group}
|
||||||
|
</Text>
|
||||||
|
<Text
|
||||||
|
>
|
||||||
|
{checked[item.group] && checked[item.group].length === item.divisions.length ? <FaCheck style={{ marginRight: 10 }} /> : ""}
|
||||||
|
</Text>
|
||||||
|
</Group>
|
||||||
|
<Divider/>
|
||||||
|
{item.divisions.map((division) => (
|
||||||
|
<Box key={division}>
|
||||||
|
<Text
|
||||||
|
onClick={() => handleCheck(item.group, division)}
|
||||||
|
style={{
|
||||||
|
cursor: 'pointer',
|
||||||
|
display: 'flex',
|
||||||
|
alignItems: 'center',
|
||||||
|
paddingLeft: 20,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{checked[item.group] && checked[item.group].includes(division) ? <FaCheck style={{ marginRight: 10 }} /> : ""}
|
||||||
|
{division}
|
||||||
|
</Text>
|
||||||
|
<Box pt={15}>
|
||||||
|
<Divider />
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
|
|
||||||
|
))}
|
||||||
|
</Stack>
|
||||||
|
))}
|
||||||
|
|
||||||
|
<Box mt="xl">
|
||||||
|
<Button
|
||||||
|
color="white"
|
||||||
|
bg={WARNA.biruTua}
|
||||||
|
size="lg"
|
||||||
|
radius={30}
|
||||||
|
fullWidth
|
||||||
|
onClick={() => {
|
||||||
|
""
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Simpan
|
||||||
|
</Button>
|
||||||
|
</Box>
|
||||||
|
|
||||||
|
</Box>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,12 +1,12 @@
|
|||||||
import { prisma } from '@/module/_global';
|
import { prisma } from '@/module/_global';
|
||||||
import { NextRequest } from "next/server";
|
import { NextRequest } from "next/server";
|
||||||
|
|
||||||
|
export const dynamic = 'force-dynamic'
|
||||||
export default async function getOneDetailDivision(req: NextRequest) {
|
export default async function getOneDetailDivision(req: NextRequest) {
|
||||||
try {
|
try {
|
||||||
const searchParams = req.nextUrl.searchParams
|
const searchParams = req.nextUrl.searchParams
|
||||||
const id = searchParams.get('divisionId');
|
const id = searchParams.get('divisionId');
|
||||||
|
|
||||||
console.log('aaaaa',id)
|
|
||||||
const division = await prisma.division.findUnique({
|
const division = await prisma.division.findUnique({
|
||||||
where: {
|
where: {
|
||||||
id: String(id),
|
id: String(id),
|
||||||
@@ -65,8 +65,8 @@ export default async function getOneDetailDivision(req: NextRequest) {
|
|||||||
|
|
||||||
const allData = {
|
const allData = {
|
||||||
// division: division,
|
// division: division,
|
||||||
division:{name:id},
|
division: { name: name },
|
||||||
jumlah:{
|
jumlah: {
|
||||||
tugas: 1,
|
tugas: 1,
|
||||||
dokumen: dokumen,
|
dokumen: dokumen,
|
||||||
diskusi: diskusi,
|
diskusi: diskusi,
|
||||||
|
|||||||
@@ -12,22 +12,18 @@ import { API_ADDRESS } from '@/module/_global';
|
|||||||
export default async function ViewDetailDivision({ id }: { id: string }) {
|
export default async function ViewDetailDivision({ id }: { id: string }) {
|
||||||
|
|
||||||
const res = await fetch(`${process.env.URL + API_ADDRESS.apiGetOneDetailDivision}&divisionId=${id}`);
|
const res = await fetch(`${process.env.URL + API_ADDRESS.apiGetOneDetailDivision}&divisionId=${id}`);
|
||||||
console.log(process.env.URL + API_ADDRESS.apiGetOneDetailDivision+"&divisionId="+id)
|
|
||||||
const data = await res.json();
|
const data = await res.json();
|
||||||
|
|
||||||
console.log('amalia', data);
|
console.log(data)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
// <DetailDivision />
|
// <DetailDivision />
|
||||||
<Box>
|
<Box>
|
||||||
<NavbarDetailDivision title={
|
<NavbarDetailDivision title={ data?.division?.name } />
|
||||||
// data?.division?.name
|
|
||||||
""
|
|
||||||
} />
|
|
||||||
<Box p={20}>
|
<Box p={20}>
|
||||||
<Stack>
|
<Stack>
|
||||||
<CarouselDivision />
|
<CarouselDivision />
|
||||||
<FeatureDetailDivision id={id}/>
|
<FeatureDetailDivision id={id} />
|
||||||
<ListTaskOnDetailDivision />
|
<ListTaskOnDetailDivision />
|
||||||
<ListDocumentOnDetailDivision />
|
<ListDocumentOnDetailDivision />
|
||||||
<ListDiscussionOnDetailDivision />
|
<ListDiscussionOnDetailDivision />
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ export async function listGroups(req: NextRequest): Promise<Response> {
|
|||||||
isActive: (active == "true" ? true : false),
|
isActive: (active == "true" ? true : false),
|
||||||
idVillage: String(villaId),
|
idVillage: String(villaId),
|
||||||
name: {
|
name: {
|
||||||
contains: String(name),
|
contains: (name == undefined || name == null) ? "" : name,
|
||||||
mode: "insensitive"
|
mode: "insensitive"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ export async function getAllPosition(req: NextRequest) {
|
|||||||
idGroup: String(grupFix),
|
idGroup: String(grupFix),
|
||||||
isActive: (active == "true" ? true : false),
|
isActive: (active == "true" ? true : false),
|
||||||
name: {
|
name: {
|
||||||
contains: String(name),
|
contains: (name == undefined || name == null) ? "" : name,
|
||||||
mode: "insensitive"
|
mode: "insensitive"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ export async function getAllUser(req: NextRequest) {
|
|||||||
isActive: active == "true" ? true : false,
|
isActive: active == "true" ? true : false,
|
||||||
idGroup: String(fixGroup),
|
idGroup: String(fixGroup),
|
||||||
name: {
|
name: {
|
||||||
contains: String(name),
|
contains: (name == undefined || name == null) ? "" : name,
|
||||||
mode: "insensitive",
|
mode: "insensitive",
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user