upd: skeleton task divisi

Deskripsi:
- detail task divisi

No Issues
This commit is contained in:
amel
2025-06-09 10:47:28 +08:00
parent 68c6a745ef
commit 81e55ef74a
5 changed files with 125 additions and 69 deletions

View File

@@ -193,7 +193,7 @@ export default function ListDivision() {
{data.map((item, index) => ( {data.map((item, index) => (
<BorderBottomItem <BorderBottomItem
key={index} key={index}
onPress={() => { }} onPress={() => { router.push(`/division/${item.id}`) }}
borderType="bottom" borderType="bottom"
icon={ icon={
<View style={[Styles.iconContent, ColorsStatus.lightGreen]}> <View style={[Styles.iconContent, ColorsStatus.lightGreen]}>

View File

@@ -169,6 +169,7 @@ export default function SectionFile({ status, member }: { status: number | undef
title={item.name + '.' + item.extension} title={item.name + '.' + item.extension}
titleWeight="normal" titleWeight="normal"
onPress={() => { setIdSelect(item.id); setModal(true) }} onPress={() => { setIdSelect(item.id); setModal(true) }}
width={65}
/> />
) )
}) })

View File

@@ -11,6 +11,7 @@ import AlertKonfirmasi from "../alertKonfirmasi";
import BorderBottomItem from "../borderBottomItem"; import BorderBottomItem from "../borderBottomItem";
import DrawerBottom from "../drawerBottom"; import DrawerBottom from "../drawerBottom";
import MenuItemRow from "../menuItemRow"; import MenuItemRow from "../menuItemRow";
import Skeleton from "../skeleton";
type Props = { type Props = {
id: string id: string
@@ -27,21 +28,30 @@ export default function SectionFileTask() {
const [idSelect, setIdSelect] = useState('') const [idSelect, setIdSelect] = useState('')
const update = useSelector((state: any) => state.taskUpdate) const update = useSelector((state: any) => state.taskUpdate)
const dispatch = useDispatch() const dispatch = useDispatch()
const [loading, setLoading] = useState(true)
const arrSkeleton = Array.from({ length: 5 })
async function handleLoad() { async function handleLoad(loading: boolean) {
try { try {
setLoading(loading)
const hasil = await decryptToken(String(token?.current)) const hasil = await decryptToken(String(token?.current))
const response = await apiGetTaskOne({ id: detail, user: hasil, cat: 'file' }) const response = await apiGetTaskOne({ id: detail, user: hasil, cat: 'file' })
setData(response.data) setData(response.data)
} catch (error) { } catch (error) {
console.error(error) console.error(error)
} finally {
setLoading(false)
} }
} }
useEffect(() => { useEffect(() => {
handleLoad() handleLoad(false)
}, [update.file]) }, [update.file])
useEffect(() => {
handleLoad(true)
}, [])
async function handleDelete() { async function handleDelete() {
try { try {
const hasil = await decryptToken(String(token?.current)); const hasil = await decryptToken(String(token?.current));
@@ -66,21 +76,29 @@ export default function SectionFileTask() {
<Text style={[Styles.textDefaultSemiBold, Styles.mv05]}>File</Text> <Text style={[Styles.textDefaultSemiBold, Styles.mv05]}>File</Text>
<View style={[Styles.wrapPaper]}> <View style={[Styles.wrapPaper]}>
{ {
data.length > 0 ? loading ?
data.map((item, index) => { arrSkeleton.map((item, index) => {
return ( return (
<BorderBottomItem <Skeleton key={index} width={100} height={40} widthType="percent" borderRadius={10} />
key={index}
borderType="all"
icon={<MaterialCommunityIcons name="file-outline" size={25} color="black" />}
title={item.name + '.' + item.extension}
titleWeight="normal"
onPress={() => { setIdSelect(item.id); setModal(true) }}
/>
) )
}) })
: :
<Text style={[Styles.textDefault, Styles.cGray, { textAlign: 'center' }]}>Tidak ada file</Text> data.length > 0 ?
data.map((item, index) => {
return (
<BorderBottomItem
key={index}
borderType="all"
icon={<MaterialCommunityIcons name="file-outline" size={25} color="black" />}
title={item.name + '.' + item.extension}
titleWeight="normal"
onPress={() => { setIdSelect(item.id); setModal(true) }}
width={65}
/>
)
})
:
<Text style={[Styles.textDefault, Styles.cGray, { textAlign: 'center' }]}>Tidak ada file</Text>
} }
</View> </View>
</View> </View>

View File

@@ -12,6 +12,7 @@ import BorderBottomItem from "../borderBottomItem";
import DrawerBottom from "../drawerBottom"; import DrawerBottom from "../drawerBottom";
import ImageUser from "../imageNew"; import ImageUser from "../imageNew";
import MenuItemRow from "../menuItemRow"; import MenuItemRow from "../menuItemRow";
import SkeletonTwoItem from "../skeletonTwoItem";
type Props = { type Props = {
id: string; id: string;
@@ -29,13 +30,16 @@ export default function SectionMemberTask() {
const [data, setData] = useState<Props[]>([]); const [data, setData] = useState<Props[]>([]);
const dispatch = useDispatch(); const dispatch = useDispatch();
const update = useSelector((state: any) => state.taskUpdate); const update = useSelector((state: any) => state.taskUpdate);
const [loading, setLoading] = useState(true)
const arrSkeleton = Array.from({ length: 3 })
const [memberChoose, setMemberChoose] = useState({ const [memberChoose, setMemberChoose] = useState({
id: "", id: "",
name: "", name: "",
}); });
async function handleLoad() { async function handleLoad(loading: boolean) {
try { try {
setLoading(loading)
const hasil = await decryptToken(String(token?.current)); const hasil = await decryptToken(String(token?.current));
const response = await apiGetTaskOne({ const response = await apiGetTaskOne({
id: detail, id: detail,
@@ -45,13 +49,19 @@ export default function SectionMemberTask() {
setData(response.data); setData(response.data);
} catch (error) { } catch (error) {
console.error(error); console.error(error);
} finally {
setLoading(false)
} }
} }
useEffect(() => { useEffect(() => {
handleLoad(); handleLoad(false);
}, [update.member]); }, [update.member]);
useEffect(() => {
handleLoad(true);
}, [])
async function handleDeleteMember() { async function handleDeleteMember() {
try { try {
@@ -83,39 +93,48 @@ export default function SectionMemberTask() {
</View> </View>
<View style={[Styles.wrapPaper]}> <View style={[Styles.wrapPaper]}>
{data.length > 0 ? ( {
data.map((item, index) => { loading ?
return ( arrSkeleton.map((item, index) => {
<BorderBottomItem return (
key={index} <SkeletonTwoItem key={index} />
borderType="bottom" )
icon={ })
<ImageUser :
src={`https://wibu-storage.wibudev.com/api/files/${item.img}`} data.length > 0 ? (
data.map((item, index) => {
return (
<BorderBottomItem
key={index}
borderType="bottom"
icon={
<ImageUser
src={`https://wibu-storage.wibudev.com/api/files/${item.img}`}
/>
}
title={item.name}
onPress={() => {
setMemberChoose({
id: item.idUser,
name: item.name,
});
setModal(true);
}}
/> />
} );
title={item.name} })
onPress={() => { ) : (
setMemberChoose({ <Text
id: item.idUser, style={[
name: item.name, Styles.textDefault,
}); Styles.cGray,
setModal(true); { textAlign: "center" },
}} ]}
/> >
); Tidak ada anggota
}) </Text>
) : ( )
<Text }
style={[
Styles.textDefault,
Styles.cGray,
{ textAlign: "center" },
]}
>
Tidak ada anggota
</Text>
)}
</View> </View>
</View> </View>

View File

@@ -12,6 +12,7 @@ import DrawerBottom from "../drawerBottom";
import ItemSectionTanggalTugas from "../itemSectionTanggalTugas"; import ItemSectionTanggalTugas from "../itemSectionTanggalTugas";
import MenuItemRow from "../menuItemRow"; import MenuItemRow from "../menuItemRow";
import ModalSelect from "../modalSelect"; import ModalSelect from "../modalSelect";
import SkeletonTask from "../skeletonTask";
type Props = { type Props = {
@@ -28,6 +29,8 @@ export default function SectionTanggalTugasTask() {
const [isModal, setModal] = useState(false) const [isModal, setModal] = useState(false)
const [isSelect, setSelect] = useState(false) const [isSelect, setSelect] = useState(false)
const { token, decryptToken } = useAuthSession() const { token, decryptToken } = useAuthSession()
const [loading, setLoading] = useState(true)
const arrSkeleton = Array.from({ length: 5 })
const { id, detail } = useLocalSearchParams<{ id: string, detail: string }>(); const { id, detail } = useLocalSearchParams<{ id: string, detail: string }>();
const [data, setData] = useState<Props[]>([]) const [data, setData] = useState<Props[]>([])
const [tugas, setTugas] = useState({ const [tugas, setTugas] = useState({
@@ -35,13 +38,16 @@ export default function SectionTanggalTugasTask() {
status: 0, status: 0,
}) })
async function handleLoad() { async function handleLoad(loading: boolean) {
try { try {
setLoading(loading)
const hasil = await decryptToken(String(token?.current)) const hasil = await decryptToken(String(token?.current))
const response = await apiGetTaskOne({ id: detail, user: hasil, cat: 'task' }) const response = await apiGetTaskOne({ id: detail, user: hasil, cat: 'task' })
setData(response.data) setData(response.data)
} catch (error) { } catch (error) {
console.error(error) console.error(error)
} finally {
setLoading(false)
} }
} }
@@ -68,10 +74,15 @@ export default function SectionTanggalTugasTask() {
} }
useEffect(() => { useEffect(() => {
handleLoad() handleLoad(false)
}, [update.task]) }, [update.task])
useEffect(() => {
handleLoad(true)
}, [])
async function handleDelete() { async function handleDelete() {
try { try {
const hasil = await decryptToken(String(token?.current)); const hasil = await decryptToken(String(token?.current));
@@ -100,28 +111,35 @@ export default function SectionTanggalTugasTask() {
<Text style={[Styles.textDefaultSemiBold, Styles.mv05]}>Tanggal & Tugas</Text> <Text style={[Styles.textDefaultSemiBold, Styles.mv05]}>Tanggal & Tugas</Text>
<View style={[Styles.wrapPaper]}> <View style={[Styles.wrapPaper]}>
{ {
data.length > 0 loading ?
? arrSkeleton.map((item, index) => {
data.map((item, index) => {
return ( return (
<ItemSectionTanggalTugas <SkeletonTask key={index} />
key={index} )
done={item.status === 1}
title={item.title}
dateStart={item.dateStart}
dateEnd={item.dateEnd}
onPress={() => {
setTugas({
id: item.id,
status: item.status
})
setModal(true)
}}
/>
);
}) })
: :
<Text style={[Styles.textDefault, Styles.cGray, { textAlign: 'center' }]}>Tidak ada tugas</Text> data.length > 0
?
data.map((item, index) => {
return (
<ItemSectionTanggalTugas
key={index}
done={item.status === 1}
title={item.title}
dateStart={item.dateStart}
dateEnd={item.dateEnd}
onPress={() => {
setTugas({
id: item.id,
status: item.status
})
setModal(true)
}}
/>
);
})
:
<Text style={[Styles.textDefault, Styles.cGray, { textAlign: 'center' }]}>Tidak ada tugas</Text>
} }
</View> </View>
</View> </View>