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 { NextRequest } from "next/server";
|
||||
|
||||
export const dynamic = 'force-dynamic'
|
||||
export async function GET(req: NextRequest) {
|
||||
return apiDivision(req, "GET")
|
||||
}
|
||||
@@ -37,6 +37,8 @@ export async function getOneAnnouncement(req: NextRequest) {
|
||||
group: v.Group.name,
|
||||
}))
|
||||
|
||||
console.log(allAnnouncementMember)
|
||||
|
||||
return Response.json({ announcement, allAnnouncementMember });
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
|
||||
@@ -29,6 +29,7 @@ export async function createAnnouncement(req: NextRequest) {
|
||||
const announcementMember = await prisma.announcementMember.createMany({
|
||||
data: dataMember,
|
||||
});
|
||||
console.log(announcementMember)
|
||||
|
||||
return Response.json({
|
||||
announcement: announcement,
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
import { WARNA } from "@/module/_global";
|
||||
import LayoutModal from "@/module/_global/layout/layout_modal";
|
||||
import { Box, Button, Group, Stack, Text, Textarea, TextInput } from "@mantine/core";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
import toast from "react-hot-toast";
|
||||
import { HiOutlineChevronRight } from "react-icons/hi2";
|
||||
@@ -9,6 +10,7 @@ import { IoIosArrowForward } from "react-icons/io";
|
||||
|
||||
export default function CreateAnnouncement() {
|
||||
const [isOpen, setOpen] = useState(false)
|
||||
const router = useRouter()
|
||||
|
||||
function onTrue(val: boolean) {
|
||||
if (val) {
|
||||
@@ -52,7 +54,9 @@ export default function CreateAnnouncement() {
|
||||
border: `1px solid ${WARNA.biruTua}`,
|
||||
padding: 10,
|
||||
borderRadius: 10
|
||||
}}>
|
||||
}}
|
||||
onClick={() => router.push("/announcement/create-user")}
|
||||
>
|
||||
<Text size="sm">
|
||||
Tambah Anggota
|
||||
</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 { NextRequest } from "next/server";
|
||||
|
||||
export const dynamic = 'force-dynamic'
|
||||
export default async function getOneDetailDivision(req: NextRequest) {
|
||||
try {
|
||||
const searchParams = req.nextUrl.searchParams
|
||||
const id = searchParams.get('divisionId');
|
||||
|
||||
console.log('aaaaa',id)
|
||||
const division = await prisma.division.findUnique({
|
||||
where: {
|
||||
id: String(id),
|
||||
@@ -65,8 +65,8 @@ export default async function getOneDetailDivision(req: NextRequest) {
|
||||
|
||||
const allData = {
|
||||
// division: division,
|
||||
division:{name:id},
|
||||
jumlah:{
|
||||
division: { name: name },
|
||||
jumlah: {
|
||||
tugas: 1,
|
||||
dokumen: dokumen,
|
||||
diskusi: diskusi,
|
||||
|
||||
@@ -12,22 +12,18 @@ import { API_ADDRESS } from '@/module/_global';
|
||||
export default async function ViewDetailDivision({ id }: { id: string }) {
|
||||
|
||||
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();
|
||||
|
||||
console.log('amalia', data);
|
||||
console.log(data)
|
||||
|
||||
return (
|
||||
// <DetailDivision />
|
||||
<Box>
|
||||
<NavbarDetailDivision title={
|
||||
// data?.division?.name
|
||||
""
|
||||
} />
|
||||
<NavbarDetailDivision title={ data?.division?.name } />
|
||||
<Box p={20}>
|
||||
<Stack>
|
||||
<CarouselDivision />
|
||||
<FeatureDetailDivision id={id}/>
|
||||
<FeatureDetailDivision id={id} />
|
||||
<ListTaskOnDetailDivision />
|
||||
<ListDocumentOnDetailDivision />
|
||||
<ListDiscussionOnDetailDivision />
|
||||
|
||||
@@ -14,7 +14,7 @@ export async function listGroups(req: NextRequest): Promise<Response> {
|
||||
isActive: (active == "true" ? true : false),
|
||||
idVillage: String(villaId),
|
||||
name: {
|
||||
contains: String(name),
|
||||
contains: (name == undefined || name == null) ? "" : name,
|
||||
mode: "insensitive"
|
||||
}
|
||||
},
|
||||
|
||||
@@ -24,7 +24,7 @@ export async function getAllPosition(req: NextRequest) {
|
||||
idGroup: String(grupFix),
|
||||
isActive: (active == "true" ? true : false),
|
||||
name: {
|
||||
contains: String(name),
|
||||
contains: (name == undefined || name == null) ? "" : name,
|
||||
mode: "insensitive"
|
||||
}
|
||||
},
|
||||
|
||||
@@ -23,7 +23,7 @@ export async function getAllUser(req: NextRequest) {
|
||||
isActive: active == "true" ? true : false,
|
||||
idGroup: String(fixGroup),
|
||||
name: {
|
||||
contains: String(name),
|
||||
contains: (name == undefined || name == null) ? "" : name,
|
||||
mode: "insensitive",
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user