upd: fitur baru project
Deskripsi: - tampilan list detail tugas project - tampilan tambah detail tugas project - tampilan edit detail tugas project - tampilan form tambah data project > detail tugas - integrasi api get list detail tugas project - integrasi api tambah detail tugas project - integrasi api edit detail tugas project - integrasi api tambah data project > detail tugas No Issues
This commit is contained in:
@@ -1,16 +1,19 @@
|
||||
import ButtonBackHeader from "@/components/buttonBackHeader";
|
||||
import ButtonSaveHeader from "@/components/buttonSaveHeader";
|
||||
import { InputForm } from "@/components/inputForm";
|
||||
import ModalAddDetailTugasProject from "@/components/project/modalAddDetailTugasProject";
|
||||
import Text from "@/components/Text";
|
||||
import Styles from "@/constants/Styles";
|
||||
import { apiCreateProjectTask } from "@/lib/api";
|
||||
import { formatDateOnly } from "@/lib/fun_formatDateOnly";
|
||||
import { getDatesInRange } from "@/lib/fun_getDatesInRange";
|
||||
import { setUpdateProject } from "@/lib/projectUpdate";
|
||||
import { useAuthSession } from "@/providers/AuthProvider";
|
||||
import { useHeaderHeight } from '@react-navigation/elements';
|
||||
import dayjs from "dayjs";
|
||||
import { router, Stack, useLocalSearchParams } from "expo-router";
|
||||
import 'intl';
|
||||
import 'intl/locale-data/jsonp/id';
|
||||
import moment from "moment";
|
||||
import { useEffect, useState } from "react";
|
||||
import {
|
||||
KeyboardAvoidingView,
|
||||
@@ -31,6 +34,8 @@ export default function ProjectAddTask() {
|
||||
const { token, decryptToken } = useAuthSession()
|
||||
const dispatch = useDispatch()
|
||||
const update = useSelector((state: any) => state.projectUpdate)
|
||||
const [dataDetail, setDataDetail] = useState<any>([])
|
||||
const [modalDetail, setModalDetail] = useState(false)
|
||||
const { id } = useLocalSearchParams<{ id: string }>();
|
||||
const [disable, setDisable] = useState(true);
|
||||
const [range, setRange] = useState<{
|
||||
@@ -44,11 +49,10 @@ export default function ProjectAddTask() {
|
||||
})
|
||||
const [title, setTitle] = useState('');
|
||||
const [loading, setLoading] = useState(false)
|
||||
const [dsbButton, setDsbButton] = useState(true)
|
||||
|
||||
const from = range.startDate
|
||||
? dayjs(range.startDate).format("DD-MM-YYYY")
|
||||
: "";
|
||||
const to = range.endDate ? dayjs(range.endDate).format("DD-MM-YYYY") : "";
|
||||
const from = formatDateOnly(range.startDate);
|
||||
const to = formatDateOnly(range.endDate);
|
||||
|
||||
function checkAll() {
|
||||
if (from == "" || to == "" || title == "" || title == "null" || error.startDate || error.endDate || error.title) {
|
||||
@@ -69,15 +73,50 @@ export default function ProjectAddTask() {
|
||||
}
|
||||
}
|
||||
|
||||
function checkButton() {
|
||||
if (range.startDate == null || range.endDate == null || range.startDate == undefined || range.endDate == undefined) {
|
||||
setDsbButton(true)
|
||||
setDataDetail([])
|
||||
} else {
|
||||
setDsbButton(false)
|
||||
const awal = formatDateOnly(range.startDate, "YYYY-MM-DD")
|
||||
const akhir = formatDateOnly(range.endDate, "YYYY-MM-DD")
|
||||
const datanya = getDatesInRange(awal, akhir)
|
||||
setDataDetail(datanya.map((item: any) => ({
|
||||
date: item,
|
||||
timeStart: null,
|
||||
timeEnd: null,
|
||||
})))
|
||||
}
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
checkAll()
|
||||
}, [from, to, title, error])
|
||||
|
||||
useEffect(() => {
|
||||
checkButton()
|
||||
}, [range])
|
||||
|
||||
|
||||
async function handleCreate() {
|
||||
try {
|
||||
setLoading(true)
|
||||
const dataDetailFix = dataDetail.map((item: any) => ({
|
||||
date: moment(item.date, "DD-MM-YYYY").format("YYYY-MM-DD"),
|
||||
timeStart: item.timeStart,
|
||||
timeEnd: item.timeEnd,
|
||||
}))
|
||||
const hasil = await decryptToken(String(token?.current));
|
||||
const response = await apiCreateProjectTask({ data: { name: title, dateStart: dayjs(range.startDate).format("YYYY-MM-DD"), dateEnd: dayjs(range.endDate).format("YYYY-MM-DD"), user: hasil }, id });
|
||||
const response = await apiCreateProjectTask({
|
||||
data: {
|
||||
name: title,
|
||||
dateStart: formatDateOnly(range.startDate, "YYYY-MM-DD"),
|
||||
dateEnd: formatDateOnly(range.endDate, "YYYY-MM-DD"),
|
||||
user: hasil,
|
||||
dataDetail: dataDetailFix
|
||||
}, id
|
||||
});
|
||||
if (response.success) {
|
||||
dispatch(setUpdateProject({ ...update, task: !update.task, progress: !update.progress }))
|
||||
Toast.show({ type: 'small', text1: 'Berhasil menambah data', })
|
||||
@@ -126,7 +165,7 @@ export default function ProjectAddTask() {
|
||||
mode="range"
|
||||
startDate={range.startDate}
|
||||
endDate={range.endDate}
|
||||
onChange={(param) => setRange(param)}
|
||||
onChange={(param) => { setRange(param) }}
|
||||
styles={{
|
||||
selected: Styles.selectedDate,
|
||||
selected_label: Styles.cWhite,
|
||||
@@ -163,9 +202,12 @@ export default function ProjectAddTask() {
|
||||
{
|
||||
(error.endDate || error.startDate) && <Text style={[Styles.textInformation, Styles.cError, Styles.mt05]}>Tanggal tidak boleh kosong</Text>
|
||||
}
|
||||
{/* TODO */}
|
||||
<Pressable style={[Styles.btnTab, Styles.btnLainnya]}>
|
||||
<Text style={[Styles.cWhite]}>Detail</Text>
|
||||
<Pressable
|
||||
style={[Styles.btnTab, Styles.btnLainnya, dsbButton && Styles.btnDisabled]}
|
||||
disabled={dsbButton}
|
||||
onPress={() => { setModalDetail(true) }}
|
||||
>
|
||||
<Text style={[dsbButton ? Styles.cGray : Styles.cWhite]}>Detail</Text>
|
||||
</Pressable>
|
||||
</View>
|
||||
<InputForm
|
||||
@@ -184,6 +226,14 @@ export default function ProjectAddTask() {
|
||||
</View>
|
||||
</ScrollView>
|
||||
</KeyboardAvoidingView>
|
||||
<ModalAddDetailTugasProject
|
||||
isVisible={modalDetail}
|
||||
setVisible={setModalDetail}
|
||||
dataTanggal={dataDetail}
|
||||
onSubmit={(data) => {
|
||||
setDataDetail(data)
|
||||
}}
|
||||
/>
|
||||
</SafeAreaView>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -251,18 +251,12 @@ export default function CreateProject() {
|
||||
onPress={() => {
|
||||
if (entityUser.role == "supadmin" || entityUser.role == "developer") {
|
||||
if (chooseGroup.val != "") {
|
||||
// setSelect(true);
|
||||
// setValSelect("member");
|
||||
router.push(`/project/create/member`);
|
||||
} else {
|
||||
Toast.show({ type: 'small', text1: "Pilih Lembaga Desa terlebih dahulu", })
|
||||
}
|
||||
} else {
|
||||
router.push(`/project/create/member`);
|
||||
// validationForm('group', userLogin.idGroup, userLogin.group);
|
||||
// setValChoose(userLogin.idGroup)
|
||||
// setSelect(true);
|
||||
// setValSelect("member");
|
||||
}
|
||||
}}
|
||||
error={error.member}
|
||||
|
||||
@@ -1,18 +1,22 @@
|
||||
import ButtonBackHeader from "@/components/buttonBackHeader";
|
||||
import ButtonSaveHeader from "@/components/buttonSaveHeader";
|
||||
import { InputForm } from "@/components/inputForm";
|
||||
import ModalAddDetailTugasProject from "@/components/project/modalAddDetailTugasProject";
|
||||
import Text from "@/components/Text";
|
||||
import Styles from "@/constants/Styles";
|
||||
import { formatDateOnly } from "@/lib/fun_formatDateOnly";
|
||||
import { getDatesInRange } from "@/lib/fun_getDatesInRange";
|
||||
import { setTaskCreate } from "@/lib/taskCreate";
|
||||
import { useHeaderHeight } from '@react-navigation/elements';
|
||||
import dayjs from "dayjs";
|
||||
import { router, Stack } from "expo-router";
|
||||
import 'intl';
|
||||
import 'intl/locale-data/jsonp/id';
|
||||
import moment from "moment";
|
||||
import { useEffect, useState } from "react";
|
||||
import {
|
||||
KeyboardAvoidingView,
|
||||
Platform,
|
||||
Pressable,
|
||||
SafeAreaView,
|
||||
ScrollView,
|
||||
View
|
||||
@@ -37,11 +41,12 @@ export default function CreateProjectAddTask() {
|
||||
})
|
||||
const [title, setTitle] = useState('');
|
||||
const taskCreate = useSelector((state: any) => state.taskCreate)
|
||||
const [dsbButton, setDsbButton] = useState(true)
|
||||
const [dataDetail, setDataDetail] = useState<any>([])
|
||||
const [modalDetail, setModalDetail] = useState(false)
|
||||
|
||||
const from = range.startDate
|
||||
? dayjs(range.startDate).format("DD-MM-YYYY")
|
||||
: "";
|
||||
const to = range.endDate ? dayjs(range.endDate).format("DD-MM-YYYY") : "";
|
||||
const from = formatDateOnly(range.startDate, "DD-MM-YYYY");
|
||||
const to = formatDateOnly(range.endDate, "DD-MM-YYYY");
|
||||
|
||||
function checkAll() {
|
||||
if (from == "" || to == "" || title == "" || title == "null" || error.startDate || error.endDate || error.title) {
|
||||
@@ -62,18 +67,45 @@ export default function CreateProjectAddTask() {
|
||||
}
|
||||
}
|
||||
|
||||
function checkButton() {
|
||||
if (range.startDate == null || range.endDate == null || range.startDate == undefined || range.endDate == undefined) {
|
||||
setDsbButton(true)
|
||||
setDataDetail([])
|
||||
} else {
|
||||
setDsbButton(false)
|
||||
const awal = formatDateOnly(range.startDate, "YYYY-MM-DD")
|
||||
const akhir = formatDateOnly(range.endDate, "YYYY-MM-DD")
|
||||
const datanya = getDatesInRange(awal, akhir)
|
||||
setDataDetail(datanya.map((item: any) => ({
|
||||
date: item,
|
||||
timeStart: null,
|
||||
timeEnd: null,
|
||||
})))
|
||||
}
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
checkAll()
|
||||
}, [from, to, title, error])
|
||||
|
||||
useEffect(() => {
|
||||
checkButton()
|
||||
}, [range])
|
||||
|
||||
async function handleCreate() {
|
||||
try {
|
||||
const dataDetailFix = dataDetail.map((item: any) => ({
|
||||
date: moment(item.date, "DD-MM-YYYY").format("YYYY-MM-DD"),
|
||||
timeStart: item.timeStart,
|
||||
timeEnd: item.timeEnd,
|
||||
}))
|
||||
dispatch(setTaskCreate([...taskCreate, {
|
||||
title: title,
|
||||
dateStart: from,
|
||||
dateEnd: to,
|
||||
dateStartFix: dayjs(range.startDate).format("YYYY-MM-DD"),
|
||||
dateEndFix: dayjs(range.endDate).format("YYYY-MM-DD"),
|
||||
dateStartFix: formatDateOnly(range.startDate, "YYYY-MM-DD"),
|
||||
dateEndFix: formatDateOnly(range.endDate, "YYYY-MM-DD"),
|
||||
dataDetail: dataDetailFix
|
||||
}]))
|
||||
router.back();
|
||||
} catch (error) {
|
||||
@@ -151,6 +183,13 @@ export default function CreateProjectAddTask() {
|
||||
{
|
||||
(error.endDate || error.startDate) && <Text style={[Styles.textInformation, Styles.cError, Styles.mt05]}>Tanggal tidak boleh kosong</Text>
|
||||
}
|
||||
<Pressable
|
||||
style={[Styles.btnTab, Styles.btnLainnya, dsbButton && Styles.btnDisabled]}
|
||||
disabled={dsbButton}
|
||||
onPress={() => { setModalDetail(true) }}
|
||||
>
|
||||
<Text style={[dsbButton ? Styles.cGray : Styles.cWhite]}>Detail</Text>
|
||||
</Pressable>
|
||||
</View>
|
||||
<InputForm
|
||||
label="Judul Tugas"
|
||||
@@ -168,6 +207,14 @@ export default function CreateProjectAddTask() {
|
||||
</View>
|
||||
</ScrollView>
|
||||
</KeyboardAvoidingView>
|
||||
<ModalAddDetailTugasProject
|
||||
isVisible={modalDetail}
|
||||
setVisible={setModalDetail}
|
||||
dataTanggal={dataDetail}
|
||||
onSubmit={(data) => {
|
||||
setDataDetail(data)
|
||||
}}
|
||||
/>
|
||||
</SafeAreaView>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,18 +1,21 @@
|
||||
import ButtonBackHeader from "@/components/buttonBackHeader";
|
||||
import ButtonSaveHeader from "@/components/buttonSaveHeader";
|
||||
import { InputForm } from "@/components/inputForm";
|
||||
import ModalAddDetailTugasProject from "@/components/project/modalAddDetailTugasProject";
|
||||
import Text from "@/components/Text";
|
||||
import Styles from "@/constants/Styles";
|
||||
import { apiEditProjectTask, apiGetProjectTask } from "@/lib/api";
|
||||
import { formatDateOnly } from "@/lib/fun_formatDateOnly";
|
||||
import { getDatesInRange } from "@/lib/fun_getDatesInRange";
|
||||
import { setUpdateProject } from "@/lib/projectUpdate";
|
||||
import { useAuthSession } from "@/providers/AuthProvider";
|
||||
import { useHeaderHeight } from '@react-navigation/elements';
|
||||
import dayjs from "dayjs";
|
||||
import { router, Stack, useLocalSearchParams } from "expo-router";
|
||||
import 'intl';
|
||||
import 'intl/locale-data/jsonp/id';
|
||||
import moment from "moment";
|
||||
import { useEffect, useState } from "react";
|
||||
import { KeyboardAvoidingView, Platform, SafeAreaView, ScrollView, View } from "react-native";
|
||||
import { KeyboardAvoidingView, Platform, Pressable, SafeAreaView, ScrollView, View } from "react-native";
|
||||
import Toast from "react-native-toast-message";
|
||||
import DateTimePicker, { DateType } from "react-native-ui-datepicker";
|
||||
import { useDispatch, useSelector } from "react-redux";
|
||||
@@ -29,6 +32,9 @@ export default function UpdateProjectTask() {
|
||||
const [loading, setLoading] = useState(true)
|
||||
const [disableBtn, setDisableBtn] = useState(false)
|
||||
const [loadingSubmit, setLoadingSubmit] = useState(false)
|
||||
const [dataDetail, setDataDetail] = useState<any>([])
|
||||
const [modalDetail, setModalDetail] = useState(false)
|
||||
const [dsbButton, setDsbButton] = useState(true)
|
||||
|
||||
const [title, setTitle] = useState('')
|
||||
const [error, setError] = useState({
|
||||
@@ -37,10 +43,8 @@ export default function UpdateProjectTask() {
|
||||
title: false,
|
||||
})
|
||||
|
||||
const from = range.startDate
|
||||
? dayjs(range.startDate).format("DD-MM-YYYY")
|
||||
: '';
|
||||
const to = range.endDate ? dayjs(range.endDate).format("DD-MM-YYYY") : '';
|
||||
const from = formatDateOnly(range.startDate);
|
||||
const to = formatDateOnly(range.endDate);
|
||||
|
||||
async function handleLoad() {
|
||||
try {
|
||||
@@ -57,6 +61,23 @@ export default function UpdateProjectTask() {
|
||||
})
|
||||
setMonth(new Date(response.data.dateStart).getMonth())
|
||||
setYear(new Date(response.data.dateStart).getFullYear())
|
||||
|
||||
const response2 = await apiGetProjectTask({
|
||||
user: hasil,
|
||||
id: detail,
|
||||
cat: "detailTask"
|
||||
});
|
||||
if (response2.data.length == 0) {
|
||||
const datanya = getDatesInRange(response.data.dateStart, response.data.dateEnd)
|
||||
setDataDetail(datanya.map((item: any) => ({
|
||||
date: item,
|
||||
timeStart: null,
|
||||
timeEnd: null,
|
||||
})))
|
||||
} else {
|
||||
setDataDetail(response2.data)
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
} finally {
|
||||
@@ -71,8 +92,22 @@ export default function UpdateProjectTask() {
|
||||
async function handleEdit() {
|
||||
try {
|
||||
setLoadingSubmit(true)
|
||||
const dataDetailFix = dataDetail.map((item: any) => ({
|
||||
date: moment(item.date, "DD-MM-YYYY").format("YYYY-MM-DD"),
|
||||
timeStart: item.timeStart,
|
||||
timeEnd: item.timeEnd,
|
||||
}))
|
||||
const hasil = await decryptToken(String(token?.current));
|
||||
const response = await apiEditProjectTask({ data: { title, dateStart: dayjs(range.startDate).format("YYYY-MM-DD"), dateEnd: dayjs(range.endDate).format("YYYY-MM-DD"), user: hasil }, id: detail });
|
||||
const response = await apiEditProjectTask({
|
||||
data: {
|
||||
title,
|
||||
dateStart: formatDateOnly(range.startDate, "YYYY-MM-DD"),
|
||||
dateEnd: formatDateOnly(range.endDate, "YYYY-MM-DD"),
|
||||
user: hasil,
|
||||
dataDetail: dataDetailFix
|
||||
},
|
||||
id: detail
|
||||
});
|
||||
if (response.success) {
|
||||
dispatch(setUpdateProject({ ...update, task: !update.task, progress: !update.progress }))
|
||||
Toast.show({ type: 'small', text1: 'Berhasil mengubah data', })
|
||||
@@ -107,10 +142,32 @@ export default function UpdateProjectTask() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function checkButton() {
|
||||
if (range.startDate == null || range.endDate == null || range.startDate == undefined || range.endDate == undefined) {
|
||||
setDsbButton(true)
|
||||
setDataDetail([])
|
||||
} else {
|
||||
setDsbButton(false)
|
||||
const awal = formatDateOnly(range.startDate, "YYYY-MM-DD")
|
||||
const akhir = formatDateOnly(range.endDate, "YYYY-MM-DD")
|
||||
const datanya = getDatesInRange(awal, akhir)
|
||||
setDataDetail(datanya.map((item: any) => ({
|
||||
date: item,
|
||||
timeStart: null,
|
||||
timeEnd: null,
|
||||
})))
|
||||
}
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
checkAll()
|
||||
}, [from, to, title, error])
|
||||
|
||||
useEffect(() => {
|
||||
checkButton()
|
||||
}, [range])
|
||||
|
||||
return (
|
||||
<SafeAreaView>
|
||||
<Stack.Screen
|
||||
@@ -176,6 +233,13 @@ export default function UpdateProjectTask() {
|
||||
{
|
||||
(error.endDate || error.startDate) && <Text style={[Styles.textInformation, Styles.cError, Styles.mt05]}>Tanggal tidak boleh kosong</Text>
|
||||
}
|
||||
<Pressable
|
||||
style={[Styles.btnTab, Styles.btnLainnya, dsbButton && Styles.btnDisabled]}
|
||||
disabled={dsbButton}
|
||||
onPress={() => { setModalDetail(true) }}
|
||||
>
|
||||
<Text style={[dsbButton ? Styles.cGray : Styles.cWhite]}>Detail</Text>
|
||||
</Pressable>
|
||||
</View>
|
||||
<InputForm
|
||||
label="Judul Tugas"
|
||||
@@ -193,6 +257,15 @@ export default function UpdateProjectTask() {
|
||||
</View>
|
||||
</ScrollView>
|
||||
</KeyboardAvoidingView>
|
||||
|
||||
<ModalAddDetailTugasProject
|
||||
isVisible={modalDetail}
|
||||
setVisible={setModalDetail}
|
||||
dataTanggal={dataDetail}
|
||||
onSubmit={(data) => {
|
||||
setDataDetail(data)
|
||||
}}
|
||||
/>
|
||||
</SafeAreaView>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user