Merge pull request 'revisi: tahun' (#15) from amalia/03-feb-26 into join
Reviewed-on: http://wibugit.wibudev.com/wibu/mobile-darmasaba/pulls/15
This commit is contained in:
@@ -31,7 +31,7 @@ type Props = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export default function ListTask() {
|
export default function ListTask() {
|
||||||
const { id, status } = useLocalSearchParams<{ id: string; status: string }>()
|
const { id, status, year } = useLocalSearchParams<{ id: string; status: string; year: string }>()
|
||||||
const [isList, setList] = useState(false)
|
const [isList, setList] = useState(false)
|
||||||
const { token, decryptToken } = useAuthSession()
|
const { token, decryptToken } = useAuthSession()
|
||||||
const [data, setData] = useState<Props[]>([])
|
const [data, setData] = useState<Props[]>([])
|
||||||
@@ -43,6 +43,8 @@ export default function ListTask() {
|
|||||||
const [page, setPage] = useState(1)
|
const [page, setPage] = useState(1)
|
||||||
const [waiting, setWaiting] = useState(false)
|
const [waiting, setWaiting] = useState(false)
|
||||||
const [refreshing, setRefreshing] = useState(false)
|
const [refreshing, setRefreshing] = useState(false)
|
||||||
|
const [isYear, setYear] = useState("")
|
||||||
|
|
||||||
|
|
||||||
async function handleLoad(loading: boolean, thisPage: number) {
|
async function handleLoad(loading: boolean, thisPage: number) {
|
||||||
try {
|
try {
|
||||||
@@ -55,8 +57,12 @@ export default function ListTask() {
|
|||||||
division: id,
|
division: id,
|
||||||
status: statusFix,
|
status: statusFix,
|
||||||
search,
|
search,
|
||||||
page: thisPage
|
page: thisPage,
|
||||||
|
year
|
||||||
});
|
});
|
||||||
|
|
||||||
|
setYear(response.tahun)
|
||||||
|
|
||||||
if (thisPage == 1) {
|
if (thisPage == 1) {
|
||||||
setData(response.data);
|
setData(response.data);
|
||||||
} else if (thisPage > 1 && response.data.length > 0) {
|
} else if (thisPage > 1 && response.data.length > 0) {
|
||||||
@@ -179,7 +185,13 @@ export default function ListTask() {
|
|||||||
</Pressable>
|
</Pressable>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
<View style={[{ flex: 2 }, Styles.mt05]}>
|
<View style={[Styles.mv05]}>
|
||||||
|
<View style={[Styles.rowOnly]}>
|
||||||
|
<Text style={[Styles.mr05]}>Filter :</Text>
|
||||||
|
<LabelStatus size="small" category="secondary" text={isYear} style={{ marginRight: 5 }} />
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
<View style={[{ flex: 2 }]}>
|
||||||
{
|
{
|
||||||
loading ?
|
loading ?
|
||||||
isList ?
|
isList ?
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import Styles from "@/constants/Styles"
|
import Styles from "@/constants/Styles"
|
||||||
import { apiGetGroup, apiGetTahunProject } from "@/lib/api"
|
import { apiGetGroup, apiGetTahunProject, apiGetTahunTask } from "@/lib/api"
|
||||||
import { setEntityFilterGroup } from "@/lib/filterSlice"
|
import { setEntityFilterGroup } from "@/lib/filterSlice"
|
||||||
import { useAuthSession } from "@/providers/AuthProvider"
|
import { useAuthSession } from "@/providers/AuthProvider"
|
||||||
import { router } from "expo-router"
|
import { router } from "expo-router"
|
||||||
@@ -14,13 +14,14 @@ import Text from './Text'
|
|||||||
type Props = {
|
type Props = {
|
||||||
open: boolean,
|
open: boolean,
|
||||||
close: (value: boolean) => void
|
close: (value: boolean) => void
|
||||||
page: 'position' | 'member' | 'discussion' | 'project' | 'division'
|
page: 'position' | 'member' | 'discussion' | 'project' | 'division' | 'division/task'
|
||||||
category?: 'filter-group' | 'filter-data' | 'year-only',
|
category?: 'filter-group' | 'filter-data' | 'year-only',
|
||||||
valueGroup?: string,
|
valueGroup?: string,
|
||||||
valueYear?: string,
|
valueYear?: string,
|
||||||
|
dataPassing?: any
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function ModalFilter({ open, close, page, category, valueGroup, valueYear }: Props) {
|
export default function ModalFilter({ open, close, page, category, valueGroup, valueYear, dataPassing }: Props) {
|
||||||
const data = [
|
const data = [
|
||||||
{
|
{
|
||||||
id: "data-saya",
|
id: "data-saya",
|
||||||
@@ -38,6 +39,7 @@ export default function ModalFilter({ open, close, page, category, valueGroup, v
|
|||||||
const [chooseGroup, setChooseGroup] = useState(valueGroup || '')
|
const [chooseGroup, setChooseGroup] = useState(valueGroup || '')
|
||||||
const [chooseYear, setChooseYear] = useState(valueYear || '')
|
const [chooseYear, setChooseYear] = useState(valueYear || '')
|
||||||
const [dataTahun, setDataTahun] = useState<{ id: string, name: string }[]>([])
|
const [dataTahun, setDataTahun] = useState<{ id: string, name: string }[]>([])
|
||||||
|
const [passingData, setPassingData] = useState(dataPassing)
|
||||||
|
|
||||||
async function handleLoad() {
|
async function handleLoad() {
|
||||||
const hasil = await decryptToken(String(token?.current))
|
const hasil = await decryptToken(String(token?.current))
|
||||||
@@ -47,6 +49,9 @@ export default function ModalFilter({ open, close, page, category, valueGroup, v
|
|||||||
if (page === 'project') {
|
if (page === 'project') {
|
||||||
const responseTahun = await apiGetTahunProject({ user: hasil })
|
const responseTahun = await apiGetTahunProject({ user: hasil })
|
||||||
setDataTahun(responseTahun.data)
|
setDataTahun(responseTahun.data)
|
||||||
|
} else if (page === 'division/task') {
|
||||||
|
const responseTahun = await apiGetTahunTask({ user: hasil, division: passingData })
|
||||||
|
setDataTahun(responseTahun.data)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -140,7 +145,7 @@ export default function ModalFilter({ open, close, page, category, valueGroup, v
|
|||||||
</View>
|
</View>
|
||||||
}
|
}
|
||||||
|
|
||||||
{page == "project" && (
|
{(page == "project" || page == "division/task") && (
|
||||||
<View>
|
<View>
|
||||||
<Text style={[Styles.textDefaultSemiBold, Styles.mb05]}>Tahun</Text>
|
<Text style={[Styles.textDefaultSemiBold, Styles.mb05]}>Tahun</Text>
|
||||||
<View style={[Styles.rowOnly, { flexWrap: 'wrap' }]}>
|
<View style={[Styles.rowOnly, { flexWrap: 'wrap' }]}>
|
||||||
@@ -184,7 +189,10 @@ export default function ModalFilter({ open, close, page, category, valueGroup, v
|
|||||||
:
|
:
|
||||||
router.replace(`/${page}?status=0&group=${chooseGroup}&year=${chooseYear}`)
|
router.replace(`/${page}?status=0&group=${chooseGroup}&year=${chooseYear}`)
|
||||||
:
|
:
|
||||||
router.replace(`/${page}?active=true&group=${chooseGroup}`)
|
page == "division/task" ?
|
||||||
|
router.replace(`/division/${dataPassing}/task?status=0&year=${chooseYear}`)
|
||||||
|
:
|
||||||
|
router.replace(`/${page}?active=true&group=${chooseGroup}`)
|
||||||
}} />
|
}} />
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import { useSelector } from "react-redux"
|
|||||||
import ButtonMenuHeader from "../buttonMenuHeader"
|
import ButtonMenuHeader from "../buttonMenuHeader"
|
||||||
import DrawerBottom from "../drawerBottom"
|
import DrawerBottom from "../drawerBottom"
|
||||||
import MenuItemRow from "../menuItemRow"
|
import MenuItemRow from "../menuItemRow"
|
||||||
|
import ModalFilter from "../modalFilter"
|
||||||
|
|
||||||
export default function HeaderRightTaskList() {
|
export default function HeaderRightTaskList() {
|
||||||
const [isVisible, setVisible] = useState(false)
|
const [isVisible, setVisible] = useState(false)
|
||||||
@@ -16,6 +17,8 @@ export default function HeaderRightTaskList() {
|
|||||||
const { token, decryptToken } = useAuthSession()
|
const { token, decryptToken } = useAuthSession()
|
||||||
const { id } = useLocalSearchParams<{ id: string }>();
|
const { id } = useLocalSearchParams<{ id: string }>();
|
||||||
const entityUser = useSelector((state: any) => state.user);
|
const entityUser = useSelector((state: any) => state.user);
|
||||||
|
const [isFilter, setFilter] = useState(false)
|
||||||
|
|
||||||
|
|
||||||
async function handleCheckAdmin() {
|
async function handleCheckAdmin() {
|
||||||
try {
|
try {
|
||||||
@@ -38,22 +41,44 @@ export default function HeaderRightTaskList() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{
|
{/* {
|
||||||
(entityUser.role != "user" && entityUser.role != "coadmin") || isAdminDivision
|
(entityUser.role != "user" && entityUser.role != "coadmin") || isAdminDivision
|
||||||
? <ButtonMenuHeader onPress={() => { setVisible(true) }} /> : <></>
|
? <ButtonMenuHeader onPress={() => { setVisible(true) }} /> : <></>
|
||||||
}
|
} */}
|
||||||
|
<ButtonMenuHeader onPress={() => { setVisible(true) }} />
|
||||||
<DrawerBottom animation="slide" isVisible={isVisible} setVisible={setVisible} title="Menu">
|
<DrawerBottom animation="slide" isVisible={isVisible} setVisible={setVisible} title="Menu">
|
||||||
<View style={Styles.rowItemsCenter}>
|
<View style={Styles.rowItemsCenter}>
|
||||||
|
{
|
||||||
|
(entityUser.role != "user" && entityUser.role != "coadmin") || isAdminDivision
|
||||||
|
&&
|
||||||
|
<MenuItemRow
|
||||||
|
icon={<AntDesign name="pluscircle" color="black" size={25} />}
|
||||||
|
title="Tambah Tugas Divisi"
|
||||||
|
onPress={() => {
|
||||||
|
setVisible(false)
|
||||||
|
router.push('./task/create')
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
}
|
||||||
<MenuItemRow
|
<MenuItemRow
|
||||||
icon={<AntDesign name="pluscircle" color="black" size={25} />}
|
icon={<AntDesign name="filter" color="black" size={25} />}
|
||||||
title="Tambah Tugas Divisi"
|
title="Filter"
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
setVisible(false)
|
setVisible(false)
|
||||||
router.push('./task/create')
|
setTimeout(() => {
|
||||||
|
setFilter(true)
|
||||||
|
}, 600)
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
</DrawerBottom>
|
</DrawerBottom>
|
||||||
|
<ModalFilter
|
||||||
|
close={() => { setFilter(false) }}
|
||||||
|
open={isFilter}
|
||||||
|
page="division/task"
|
||||||
|
category={"year-only"}
|
||||||
|
dataPassing={id}
|
||||||
|
/>
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -605,8 +605,13 @@ export const apiUpdateCalendar = async ({ data, id }: { data: { title: string, d
|
|||||||
return response.data;
|
return response.data;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const apiGetTask = async ({ user, status, search, division, page }: { user: string, status: string, search: string, division: string, page?: number }) => {
|
export const apiGetTask = async ({ user, status, search, division, page, year }: { user: string, status: string, search: string, division: string, page?: number, year?: string }) => {
|
||||||
const response = await api.get(`mobile/task?user=${user}&status=${status}&division=${division}&search=${search}&page=${page}`);
|
const response = await api.get(`mobile/task?user=${user}&status=${status}&division=${division}&search=${search}&page=${page}&year=${year}`);
|
||||||
|
return response.data;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const apiGetTahunTask = async ({ user, division }: { user: string, division: string }) => {
|
||||||
|
const response = await api.get(`mobile/task/tahun?user=${user}&division=${division}`);
|
||||||
return response.data;
|
return response.data;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user