16 Commits

Author SHA1 Message Date
d82f0c5b20 feat: redesign halaman detail user dan profile dengan tampilan modern
- Pindahkan badge APPROVER & AKTIF ke dalam header gradient
- Ganti card berlatar menjadi list dengan border bottom saja
- Gunakan icon colors.icon agar terlihat pada tema gelap
- Tambahkan class baru di Styles.ts: memberAvatarRing, memberBadgeRow,
  memberBadgeApprover, memberBadgePill, memberInfoRow, memberInfoIcon,
  memberInfoContent, cWhiteDimmed, pv14, mb08
- Terapkan design yang sama pada halaman profile
2026-05-07 16:45:52 +08:00
fad89fc910 feat: persist view mode (grid/list) across division, project, dan division/task
- Simpan preferensi tampilan ke AsyncStorage dengan key 'division_view_mode'
- Load preferensi saat halaman dibuka agar tidak reset
- Samakan style list item division/task dengan project (bg transparent, icon hitam)
- Sejajarkan toggle dengan input pencarian pada halaman division/task
2026-05-07 16:16:21 +08:00
e48456ea7f feat: tambah fitur approval task pada project dan divisi
- tambah komponen ModalRiwayatApproval dan ModalTolakApproval
- update itemSectionTanggalTugas untuk mendukung status menunggu persetujuan
- update sectionTanggalTugas (project) dan sectionTanggalTugasTask (divisi) dengan alur approval lengkap
- tambah API approval project task dan division task di lib/api.ts
- tambah toggle approver di headerMemberDetail dan tampilkan badge approver di detail member
- update carouselHome untuk dispatch isApprover ke Redux
- update drawerBottom untuk mendukung scroll pada modal
- ganti label 'Belum dimulai' menjadi 'Belum ada tugas yang diselesaikan'
2026-05-07 16:04:02 +08:00
d2e1663f9f Merge pull request 'amalia/06-mei-26' (#44) from amalia/06-mei-26 into join
Reviewed-on: #44
2026-05-06 17:15:40 +08:00
bdfb3a8b2b feat: redesign halaman create project dan task divisi dengan section card
- Ganti ButtonSelect dengan section card (Tanggal & Tugas, File, Anggota)
- Tiap card: header pressable dengan icon, badge count, chevron, dan preview isi
- Background item list (file & anggota) dibuat transparan (hanya border)
- Badge file seragam dengan badge tugas dan orang
- Tambah prop showTitle pada SectionListAddTask
- Ekstrak inline style ke Styles.ts: sectionActionRow, sectionBadge, positionBadge, listItemCard

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-06 17:10:08 +08:00
11bb1ddc98 feat: terapkan design baru pada halaman create project dan create task divisi
- Ganti file list (BorderBottomItem) dengan fileGrid/fileCard bergaya baru
  dengan icon berwarna sesuai tipe file
- Ganti member section dengan card individual per anggota (avatar + nama + badge jabatan)
- Header anggota: label kiri + jumlah orang di kanan
- Simpan field position saat memilih anggota di modalSelect
- Hapus wrapper wrapPaper di SectionListAddTask

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-06 16:50:54 +08:00
97726609e1 feat: redesign section member dan fix warna dimmed
- SectionMember & SectionMemberTask: ganti BorderBottomItem dengan card item
  custom (avatar + nama + badge jabatan), skeleton baru, label jumlah anggota
- Colors.ts: hapus suffix alpha '#707887ff' → '#707887' pada warna dimmed

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-06 16:23:35 +08:00
b61cd51628 feat: redesign section progress, report, link, file, dan cancel pada project & division/task
- SectionProgress: progress bar animated, badge persentase, label status, task count
- SectionReport: header ikon, left accent border, TextExpandable dengan label Indonesia
- SectionLink: tap langsung buka URL, ikon per domain, long press untuk hapus
- SectionFile: icon container konsisten 30×30 di semua section
- SectionCancel: card subtle dengan warna error, konsisten dengan visual language baru
- TextExpandable: fix bug show/hide tidak muncul setelah content diupdate
- Tambah 14 style class baru di Styles.ts untuk menggantikan inline style
- Terapkan semua perubahan ke fitur division/task
- Fix menu "Edit Tugas" di sectionTanggalTugasTask yang terpotong karena overflow

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-06 16:22:52 +08:00
eccfe29387 feat: tambah fitur lampiran file pada tugas kegiatan dan tugas divisi 2026-05-06 12:32:33 +08:00
a090a85142 Merge pull request 'amalia/05-mei-26' (#43) from amalia/05-mei-26 into join
Reviewed-on: #43
2026-05-05 17:29:50 +08:00
bbacc2a5bd fix: sesuaikan warna panah navigasi kalender dengan tema gelap
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-05 16:50:13 +08:00
5ad7874a92 fix: disable tombol detail jika tanggal mulai atau berakhir belum diisi
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-05 16:46:14 +08:00
a5e379cc7f fix: tampilkan ikon search dan ikon x secara bersamaan di input pencarian
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-05 16:26:07 +08:00
4d464adb2e Merge pull request 'upd: search' (#42) from amalia/04-mei-26 into join
Reviewed-on: #42
2026-05-04 17:56:53 +08:00
36c2519fa0 upd: search 2026-05-04 17:55:49 +08:00
e2ffef1085 Merge pull request 'amalia/23-apr-26' (#41) from amalia/23-apr-26 into join
Reviewed-on: #41
2026-04-23 17:32:41 +08:00
46 changed files with 3127 additions and 1113 deletions

View File

@@ -206,6 +206,8 @@ export default function TaskDivisionAddTask() {
day_label: { color: colors.text },
time_label: { color: colors.text },
weekday_label: { color: colors.text },
button_next_image: { tintColor: colors.text },
button_prev_image: { tintColor: colors.text },
}}
/>
</View>
@@ -238,7 +240,7 @@ export default function TaskDivisionAddTask() {
>
<Text style={[dsbButton ? Styles.cGray : Styles.cWhite]}>Detail</Text>
</Pressable> */}
<ButtonSelect value="Detail" onPress={() => { setModalDetail(true) }} />
<ButtonSelect value="Detail" onPress={() => { setModalDetail(true) }} disabled={from == "" || to == ""} />
</View>
<InputForm
label="Judul Tugas"

View File

@@ -32,6 +32,7 @@ export default function DetailTaskDivision() {
const [data, setData] = useState<Props>()
const [loading, setLoading] = useState(true)
const [progress, setProgress] = useState(0)
const [taskStats, setTaskStats] = useState<{ done: number, total: number } | undefined>()
const update = useSelector((state: any) => state.taskUpdate)
const [refreshing, setRefreshing] = useState(false)
const [isMemberDivision, setIsMemberDivision] = useState(false);
@@ -65,6 +66,17 @@ export default function DetailTaskDivision() {
}, [])
async function handleLoadTaskStats() {
try {
const hasil = await decryptToken(String(token?.current))
const response = await apiGetTaskOne({ id: detail, user: hasil, cat: 'task' })
const tasks: { status: number }[] = response.data
setTaskStats({ done: tasks.filter(t => t.status === 1).length, total: tasks.length })
} catch (error) {
console.error(error)
}
}
async function handleLoad(cat: 'data' | 'progress') {
try {
if (cat == 'data') setLoading(true)
@@ -90,10 +102,15 @@ export default function DetailTaskDivision() {
handleLoad('progress')
}, [update.progress])
useEffect(() => {
handleLoadTaskStats()
}, [update.task])
const handleRefresh = async () => {
setRefreshing(true)
await handleLoad('data')
await handleLoad('progress')
await handleLoadTaskStats()
await new Promise(resolve => setTimeout(resolve, 2000));
setRefreshing(false)
};
@@ -135,9 +152,9 @@ export default function DetailTaskDivision() {
{
data?.reason != null && data?.reason != "" && <SectionCancel text={data?.reason} />
}
<SectionProgress text={`Kemajuan Kegiatan ${progress}%`} progress={progress} />
<SectionProgress progress={progress} doneCount={taskStats?.done} totalCount={taskStats?.total} />
<SectionReportTask refreshing={refreshing} />
<SectionTanggalTugasTask refreshing={refreshing} isMemberDivision={isMemberDivision} />
<SectionTanggalTugasTask refreshing={refreshing} isMemberDivision={isMemberDivision} isAdminDivision={isAdminDivision} status={data?.status} />
<SectionFileTask refreshing={refreshing} isMemberDivision={isMemberDivision} />
<SectionLinkTask refreshing={refreshing} isMemberDivision={isMemberDivision} />
<SectionMemberTask refreshing={refreshing} isAdminDivision={isAdminDivision} />

View File

@@ -0,0 +1,382 @@
import AppHeader from "@/components/AppHeader";
import BorderBottomItem from "@/components/borderBottomItem";
import { ButtonForm } from "@/components/buttonForm";
import ButtonSelect from "@/components/buttonSelect";
import DrawerBottom from "@/components/drawerBottom";
import ModalConfirmation from "@/components/ModalConfirmation";
import ModalLoading from "@/components/modalLoading";
import MenuItemRow from "@/components/menuItemRow";
import Skeleton from "@/components/skeleton";
import Text from "@/components/Text";
import { ConstEnv } from "@/constants/ConstEnv";
import Styles from "@/constants/Styles";
import {
apiAddTugasTaskFile,
apiDeleteTugasTaskFile,
apiGetTaskOne,
apiGetTugasTaskFile,
apiLinkTugasTaskFile,
} from "@/lib/api";
import { setUpdateTask } from "@/lib/taskUpdate";
import { useAuthSession } from "@/providers/AuthProvider";
import { useTheme } from "@/providers/ThemeProvider";
import { Ionicons, MaterialCommunityIcons } from "@expo/vector-icons";
import * as DocumentPicker from "expo-document-picker";
import * as FileSystem from "expo-file-system";
import { startActivityAsync } from "expo-intent-launcher";
import { router, Stack, useLocalSearchParams } from "expo-router";
import * as Sharing from "expo-sharing";
import { useEffect, useState } from "react";
import {
ActivityIndicator,
Alert,
Platform,
SafeAreaView,
ScrollView,
View,
} from "react-native";
import * as mime from "react-native-mime-types";
import Toast from "react-native-toast-message";
import { useDispatch, useSelector } from "react-redux";
type FileItem = {
id: string; // DivisionProjectTaskFile.id
idFile: string; // DivisionProjectFile.id
name: string;
extension: string;
idStorage: string;
};
type ProjectFile = {
id: string;
name: string;
extension: string;
idStorage: string;
};
export default function TugasFileScreen() {
const { colors } = useTheme();
const { id, detail, taskId, member: memberParam } = useLocalSearchParams<{
id: string;
detail: string;
taskId: string;
member: string;
}>();
const { token, decryptToken } = useAuthSession();
const dispatch = useDispatch();
const update = useSelector((state: any) => state.taskUpdate);
const entityUser = useSelector((state: any) => state.user);
const isMember = memberParam === "true";
const canEdit = isMember || (entityUser.role !== "user" && entityUser.role !== "coadmin");
const [data, setData] = useState<FileItem[]>([]);
const [loading, setLoading] = useState(true);
const [loadingOpen, setLoadingOpen] = useState(false);
const [loadingUpload, setLoadingUpload] = useState(false);
const [loadingLink, setLoadingLink] = useState(false);
const [selectFile, setSelectFile] = useState<FileItem | null>(null);
const [isMenuModal, setMenuModal] = useState(false);
const [showDeleteModal, setShowDeleteModal] = useState(false);
const [projectFiles, setProjectFiles] = useState<ProjectFile[]>([]);
const [isPickerModal, setPickerModal] = useState(false);
const [loadingProjectFiles, setLoadingProjectFiles] = useState(false);
const [selectedProjectFiles, setSelectedProjectFiles] = useState<string[]>([]);
const arrSkeleton = Array.from({ length: 4 });
async function loadFiles() {
try {
setLoading(true);
const hasil = await decryptToken(String(token?.current));
const response = await apiGetTugasTaskFile({ user: hasil, id: taskId });
setData(response.data ?? []);
} catch (error) {
console.error(error);
} finally {
setLoading(false);
}
}
async function loadProjectFiles() {
try {
setLoadingProjectFiles(true);
const hasil = await decryptToken(String(token?.current));
const response = await apiGetTaskOne({ id: detail, user: hasil, cat: "file" });
setProjectFiles(response.data ?? []);
} catch (error) {
console.error(error);
} finally {
setLoadingProjectFiles(false);
}
}
useEffect(() => {
loadFiles();
}, []);
const openFile = () => {
setMenuModal(false);
setLoadingOpen(true);
const remoteUrl = ConstEnv.url_storage + "/files/" + selectFile?.idStorage;
const fileName = selectFile?.name + "." + selectFile?.extension;
const localPath = `${FileSystem.documentDirectory}/${fileName}`;
const mimeType = mime.lookup(fileName);
FileSystem.downloadAsync(remoteUrl, localPath).then(async ({ uri }) => {
const contentURL = await FileSystem.getContentUriAsync(uri);
try {
if (Platform.OS === "android") {
await startActivityAsync("android.intent.action.VIEW", {
data: contentURL,
flags: 1,
type: mimeType as string,
});
} else {
Sharing.shareAsync(localPath);
}
} catch {
Alert.alert("INFO", "Gagal membuka file, tidak ada aplikasi yang dapat membuka file ini");
} finally {
setLoadingOpen(false);
}
});
};
async function handleDelete() {
try {
const hasil = await decryptToken(String(token?.current));
const response = await apiDeleteTugasTaskFile({ user: hasil }, String(selectFile?.id));
if (response.success) {
Toast.show({ type: "small", text1: "Berhasil menghapus file" });
dispatch(setUpdateTask({ ...update, task: !update.task }));
loadFiles();
} else {
Toast.show({ type: "small", text1: response.message });
}
} catch (error: any) {
const message = error?.response?.data?.message || "Gagal menghapus file";
Toast.show({ type: "small", text1: message });
} finally {
setMenuModal(false);
}
}
async function handleUpload() {
const result = await DocumentPicker.getDocumentAsync({ type: ["*/*"], multiple: true });
if (result.canceled) return;
try {
setLoadingUpload(true);
const hasil = await decryptToken(String(token?.current));
const fd = new FormData();
for (let i = 0; i < result.assets.length; i++) {
fd.append(`file${i}`, {
uri: result.assets[i].uri,
type: "application/octet-stream",
name: result.assets[i].name,
} as any);
}
fd.append("data", JSON.stringify({ user: hasil }));
const response = await apiAddTugasTaskFile({ data: fd, id: taskId });
if (response.success) {
Toast.show({ type: "small", text1: "Berhasil menambahkan file" });
dispatch(setUpdateTask({ ...update, task: !update.task }));
loadFiles();
} else {
Toast.show({ type: "small", text1: response.message });
}
} catch (error: any) {
const message = error?.response?.data?.message || "Gagal menambahkan file";
Toast.show({ type: "small", text1: message });
} finally {
setLoadingUpload(false);
}
}
function toggleProjectFileSelect(id: string) {
setSelectedProjectFiles((prev) =>
prev.includes(id) ? prev.filter((v) => v !== id) : [...prev, id]
);
}
async function handleLinkFiles() {
if (selectedProjectFiles.length === 0) return;
try {
setLoadingLink(true);
const hasil = await decryptToken(String(token?.current));
for (const idFile of selectedProjectFiles) {
await apiLinkTugasTaskFile({ user: hasil, idFile, id: taskId });
}
Toast.show({ type: "small", text1: "Berhasil menambahkan file" });
dispatch(setUpdateTask({ ...update, task: !update.task }));
setPickerModal(false);
setSelectedProjectFiles([]);
loadFiles();
} catch (error: any) {
const message = error?.response?.data?.message || "Gagal menambahkan file";
Toast.show({ type: "small", text1: message });
} finally {
setLoadingLink(false);
}
}
const attachedFileIds = new Set(data.map((f) => f.idFile));
return (
<SafeAreaView style={{ flex: 1, backgroundColor: colors.background }}>
<Stack.Screen
options={{
header: () => (
<AppHeader
title="File Tugas"
showBack={true}
onPressLeft={() => router.back()}
/>
),
}}
/>
<ModalLoading isVisible={loadingOpen} setVisible={setLoadingOpen} />
<ScrollView>
<View style={[Styles.p15, Styles.mb100]}>
{canEdit && (
<>
<ButtonSelect
value="Upload dari Perangkat"
onPress={handleUpload}
disabled={loadingUpload}
/>
<ButtonSelect
value="Pilih dari File Proyek"
onPress={() => {
setSelectedProjectFiles([]);
setPickerModal(true);
loadProjectFiles();
}}
/>
</>
)}
{loadingUpload && <ActivityIndicator size="small" style={Styles.mv05} />}
<View style={[Styles.mb15, Styles.mt10]}>
<Text style={[Styles.textDefaultSemiBold, Styles.mv05]}>File Terlampir</Text>
<View style={[Styles.wrapPaper, { backgroundColor: colors.card, borderColor: colors.background }]}>
{loading ? (
arrSkeleton.map((_, index) => (
<Skeleton key={index} width={100} height={40} widthType="percent" borderRadius={10} />
))
) : data.length > 0 ? (
data.map((item, index) => (
<BorderBottomItem
key={index}
borderType="all"
icon={<MaterialCommunityIcons name="file-outline" size={25} color={colors.text} />}
title={item.name + "." + item.extension}
titleWeight="normal"
onPress={() => {
setSelectFile(item);
setMenuModal(true);
}}
/>
))
) : (
<Text style={[Styles.textDefault, { textAlign: "center", color: colors.dimmed }]}>
Tidak ada file
</Text>
)}
</View>
</View>
</View>
</ScrollView>
{/* Menu per file */}
<DrawerBottom animation="slide" isVisible={isMenuModal} setVisible={setMenuModal} title="Menu">
<View style={Styles.rowItemsCenter}>
<MenuItemRow
icon={<MaterialCommunityIcons name="file-eye" color={colors.text} size={25} />}
title="Lihat / Share"
onPress={openFile}
/>
{canEdit && (
<MenuItemRow
icon={<Ionicons name="trash-outline" color={colors.text} size={25} />}
title="Hapus"
onPress={() => {
setMenuModal(false);
setTimeout(() => setShowDeleteModal(true), 600);
}}
/>
)}
</View>
</DrawerBottom>
<ModalConfirmation
visible={showDeleteModal}
title="Konfirmasi"
message="Apakah Anda yakin ingin menghapus file ini?"
onConfirm={() => {
setShowDeleteModal(false);
handleDelete();
}}
onCancel={() => setShowDeleteModal(false)}
confirmText="Hapus"
cancelText="Batal"
/>
{/* Picker file dari proyek */}
<DrawerBottom
animation="slide"
isVisible={isPickerModal}
setVisible={setPickerModal}
title="Pilih File Proyek"
height={60}
>
<ScrollView>
{loadingProjectFiles ? (
<ActivityIndicator size="small" />
) : projectFiles.length > 0 ? (
projectFiles.map((item, index) => {
const isAttached = attachedFileIds.has(item.id);
const isSelected = selectedProjectFiles.includes(item.id);
return (
<View key={index} style={isAttached ? { opacity: 0.4 } : undefined}>
<BorderBottomItem
borderType="bottom"
icon={
isAttached || isSelected ? (
<Ionicons name="checkmark-circle" size={25} color={colors.primary} />
) : (
<MaterialCommunityIcons name="file-outline" size={25} color={colors.text} />
)
}
title={item.name + "." + item.extension}
titleWeight="normal"
onPress={() => !isAttached && toggleProjectFileSelect(item.id)}
bgColor="transparent"
/>
</View>
);
})
) : (
<Text style={[Styles.textDefault, { textAlign: "center", color: colors.dimmed }]}>
Tidak ada file tersedia
</Text>
)}
</ScrollView>
{projectFiles.length > 0 && (
<View>
<ButtonForm
text={loadingLink ? "Menyimpan..." : `Tambahkan (${selectedProjectFiles.length})`}
disabled={selectedProjectFiles.length === 0 || loadingLink}
onPress={handleLinkFiles} />
</View>
)}
</DrawerBottom>
</SafeAreaView>
);
}

View File

@@ -1,7 +1,5 @@
import AppHeader from "@/components/AppHeader";
import BorderBottomItem from "@/components/borderBottomItem";
import ButtonSaveHeader from "@/components/buttonSaveHeader";
import ButtonSelect from "@/components/buttonSelect";
import DrawerBottom from "@/components/drawerBottom";
import ImageUser from "@/components/imageNew";
import { InputForm } from "@/components/inputForm";
@@ -21,11 +19,31 @@ import { Ionicons, MaterialCommunityIcons } from "@expo/vector-icons";
import * as DocumentPicker from "expo-document-picker";
import { router, Stack, useLocalSearchParams } from "expo-router";
import { useEffect, useState } from "react";
import { SafeAreaView, ScrollView, View } from "react-native";
import { Pressable, SafeAreaView, ScrollView, View } from "react-native";
import Toast from "react-native-toast-message";
import { useDispatch, useSelector } from "react-redux";
function getFileIcon(ext: string): keyof typeof MaterialCommunityIcons.glyphMap {
if (['jpg', 'jpeg', 'png', 'gif', 'webp', 'heic', 'heif'].includes(ext)) return 'image-outline'
if (ext === 'pdf') return 'file-pdf-box'
if (['mp4', 'mov', 'avi', 'mkv'].includes(ext)) return 'video-outline'
if (['doc', 'docx'].includes(ext)) return 'file-word-outline'
if (['xls', 'xlsx'].includes(ext)) return 'file-excel-outline'
if (['zip', 'rar', '7z'].includes(ext)) return 'zip-box-outline'
return 'file-outline'
}
function getFileColor(ext: string): string {
if (['jpg', 'jpeg', 'png', 'gif', 'webp', 'heic', 'heif'].includes(ext)) return '#339AF0'
if (ext === 'pdf') return '#F03E3E'
if (['mp4', 'mov', 'avi', 'mkv'].includes(ext)) return '#AE3EC9'
if (['doc', 'docx'].includes(ext)) return '#1C7ED6'
if (['xls', 'xlsx'].includes(ext)) return '#2F9E44'
if (['zip', 'rar', '7z'].includes(ext)) return '#E8590C'
return '#868E96'
}
export default function CreateTaskDivision() {
const { colors } = useTheme();
const { id } = useLocalSearchParams();
@@ -168,59 +186,131 @@ export default function CreateTaskDivision() {
bg={colors.card}
errorText="Judul Tugas tidak boleh kosong"
/>
<ButtonSelect value="Tambah Tanggal & Tugas" onPress={() => { router.push(`/division/${id}/task/create/task`); }} />
<ButtonSelect value="Upload File" onPress={pickDocumentAsync} />
<ButtonSelect value="Tambah Anggota" onPress={() => { router.push(`/division/${id}/task/create/member`); }} />
<SectionListAddTask />
{
fileForm.length > 0 && (
<View style={[Styles.mb15]}>
<Text style={[Styles.textDefaultSemiBold, Styles.mv05]}>File</Text>
<View style={[Styles.wrapPaper, { backgroundColor: colors.card, borderColor: colors.background }]}>
{
fileForm.map((item, index) => (
<BorderBottomItem
key={index}
borderType="all"
icon={<MaterialCommunityIcons name="file-outline" size={25} color={colors.text} />}
title={item.name}
titleWeight="normal"
onPress={() => { setIndexDelFile(index); setModal(true) }}
/>
))
}
</View>
</View>
)
}
{entitiesMember.length > 0 && (
<View>
<View style={[Styles.rowSpaceBetween, Styles.mv05]}>
<Text>Anggota</Text>
<Text>Total {entitiesMember.length} Anggota</Text>
</View>
<View style={[Styles.borderAll, Styles.round05, Styles.p10, { backgroundColor: colors.card, borderColor: colors.background }]}>
{entitiesMember.map(
(item: { img: any; name: any }, index: any) => {
return (
<BorderBottomItem
key={index}
borderType="bottom"
icon={
<ImageUser
src={`${ConstEnv.url_storage}/files/${item.img}`}
size="sm"
/>
}
title={item.name}
/>
);
}
{/* Tanggal & Tugas */}
<View style={[
Styles.wrapPaper, Styles.mb15, Styles.sectionCard,
{ backgroundColor: colors.card, borderColor: colors.icon + '18' }
]}>
<Pressable
onPress={() => router.push(`/division/${id}/task/create/task`)}
style={[Styles.sectionActionRow, { marginBottom: taskCreate.length > 0 ? 12 : 0 }]}
>
<View style={[Styles.sectionIconBox, { backgroundColor: colors.tabActive + '18' }]}>
<MaterialCommunityIcons name="calendar-check-outline" size={18} color={colors.tabActive} />
</View>
<View style={Styles.flex1}>
<Text style={[Styles.textDefaultSemiBold, { color: colors.text }]}>Tanggal & Tugas</Text>
{taskCreate.length === 0 && (
<Text style={[Styles.textMediumNormal, { color: colors.dimmed }]}>Belum ada tugas ditambahkan</Text>
)}
</View>
</View>
)}
{taskCreate.length > 0 && (
<View style={[Styles.sectionBadge, { backgroundColor: colors.tabActive + '18' }]}>
<Text style={[Styles.textSmallSemiBold, { color: colors.tabActive }]}>{taskCreate.length} tugas</Text>
</View>
)}
<MaterialCommunityIcons name="chevron-right" size={18} color={colors.dimmed} />
</Pressable>
{taskCreate.length > 0 && <SectionListAddTask showTitle={false} />}
</View>
{/* File */}
<View style={[
Styles.wrapPaper, Styles.mb15, Styles.sectionCard,
{ backgroundColor: colors.card, borderColor: colors.icon + '18' }
]}>
<Pressable
onPress={pickDocumentAsync}
style={[Styles.sectionActionRow, { marginBottom: fileForm.length > 0 ? 12 : 0 }]}
>
<View style={[Styles.sectionIconBox, { backgroundColor: colors.icon + '15' }]}>
<MaterialCommunityIcons name="paperclip" size={18} color={colors.dimmed} />
</View>
<View style={Styles.flex1}>
<Text style={[Styles.textDefaultSemiBold, { color: colors.text }]}>File</Text>
{fileForm.length === 0 && (
<Text style={[Styles.textMediumNormal, { color: colors.dimmed }]}>Opsional ketuk untuk upload</Text>
)}
</View>
{fileForm.length > 0 && (
<View style={[Styles.sectionBadge, { backgroundColor: colors.dimmed + '18' }]}>
<Text style={[Styles.textSmallSemiBold, { color: colors.dimmed }]}>{fileForm.length} file</Text>
</View>
)}
<MaterialCommunityIcons name="chevron-right" size={18} color={colors.dimmed} />
</Pressable>
{fileForm.length > 0 && (
<View style={Styles.fileGrid}>
{fileForm.map((item, index) => {
const ext = item.name.split('.').pop()?.toLowerCase() ?? ''
const baseName = item.name.includes('.') ? item.name.split('.').slice(0, -1).join('.') : item.name
const iconName = getFileIcon(ext)
const iconColor = getFileColor(ext)
return (
<Pressable
key={index}
onPress={() => { setIndexDelFile(index); setModal(true) }}
style={[Styles.fileCard, { backgroundColor: 'transparent', borderColor: colors.icon + '18' }]}
>
<View style={[Styles.sectionIconBox, { backgroundColor: iconColor + '20' }]}>
<MaterialCommunityIcons name={iconName} size={18} color={iconColor} />
</View>
<View style={Styles.flex1}>
<Text style={Styles.textDefault} numberOfLines={1}>{baseName}</Text>
<Text style={[Styles.textSmallSemiBold, { color: colors.dimmed }]}>{ext.toUpperCase()}</Text>
</View>
</Pressable>
)
})}
</View>
)}
</View>
{/* Anggota */}
<View style={[
Styles.wrapPaper, Styles.mb15, Styles.sectionCard,
{ backgroundColor: colors.card, borderColor: colors.icon + '18' }
]}>
<Pressable
onPress={() => router.push(`/division/${id}/task/create/member`)}
style={[Styles.sectionActionRow, { marginBottom: entitiesMember.length > 0 ? 12 : 0 }]}
>
<View style={[Styles.sectionIconBox, { backgroundColor: colors.tabActive + '18' }]}>
<MaterialCommunityIcons name="account-group-outline" size={18} color={colors.tabActive} />
</View>
<View style={Styles.flex1}>
<Text style={[Styles.textDefaultSemiBold, { color: colors.text }]}>Anggota</Text>
{entitiesMember.length === 0 && (
<Text style={[Styles.textMediumNormal, { color: colors.dimmed }]}>Belum ada anggota dipilih</Text>
)}
</View>
{entitiesMember.length > 0 && (
<View style={[Styles.sectionBadge, { backgroundColor: colors.tabActive + '18' }]}>
<Text style={[Styles.textSmallSemiBold, { color: colors.tabActive }]}>{entitiesMember.length} orang</Text>
</View>
)}
<MaterialCommunityIcons name="chevron-right" size={18} color={colors.dimmed} />
</Pressable>
{entitiesMember.length > 0 && (
<View style={{ gap: 6 }}>
{entitiesMember.map((item: { img: any; name: any; position?: string }, index: any) => (
<View
key={index}
style={[Styles.listItemCard, { borderColor: colors.icon + '18' }]}
>
<ImageUser src={`${ConstEnv.url_storage}/files/${item.img}`} size="xs" />
<Text style={[Styles.textDefault, Styles.flex1, { color: colors.text }]} numberOfLines={1}>{item.name}</Text>
{item.position && (
<View style={[Styles.positionBadge, { backgroundColor: colors.dimmed + '15' }]}>
<Text style={[Styles.textSmallSemiBold, { color: colors.dimmed }]} numberOfLines={1}>{item.position}</Text>
</View>
)}
</View>
))}
</View>
)}
</View>
</View>
</ScrollView>

View File

@@ -177,6 +177,8 @@ export default function CreateTaskAddTugas() {
day_label: { color: colors.text },
time_label: { color: colors.text },
weekday_label: { color: colors.text },
button_next_image: { tintColor: colors.text },
button_prev_image: { tintColor: colors.text },
}}
/>
</View>
@@ -209,7 +211,7 @@ export default function CreateTaskAddTugas() {
>
<Text style={[dsbButton ? Styles.cGray : Styles.cWhite]}>Detail</Text>
</Pressable> */}
<ButtonSelect value="Detail" onPress={() => { setModalDetail(true) }} />
<ButtonSelect value="Detail" onPress={() => { setModalDetail(true) }} disabled={from == "" || to == ""} />
</View>
<InputForm
label="Judul Tugas"

View File

@@ -21,6 +21,7 @@ import { router, useLocalSearchParams } from "expo-router";
import { useEffect, useState } from "react";
import { Pressable, RefreshControl, ScrollView, View, VirtualizedList } from "react-native";
import { useSelector } from "react-redux";
import AsyncStorage from "@react-native-async-storage/async-storage";
type Props = {
id: string;
@@ -36,6 +37,18 @@ export default function ListTask() {
const { id, status, year } = useLocalSearchParams<{ id: string; status: string; year: string }>()
const [isList, setList] = useState(false)
const { token, decryptToken } = useAuthSession()
useEffect(() => {
AsyncStorage.getItem('division_view_mode').then((val) => {
if (val !== null) setList(val === 'list')
})
}, [])
function toggleView() {
const next = !isList
setList(next)
AsyncStorage.setItem('division_view_mode', next ? 'list' : 'grid')
}
const [data, setData] = useState<Props[]>([])
const [search, setSearch] = useState("")
const update = useSelector((state: any) => state.taskUpdate)
@@ -172,13 +185,9 @@ export default function ListTask() {
n={4}
/>
</ScrollView>
<View style={[Styles.rowSpaceBetween]}>
<View style={[Styles.rowSpaceBetween, { alignItems: 'center' }]}>
<InputSearch width={68} onChange={setSearch} />
<Pressable
onPress={() => {
setList(!isList);
}}
>
<Pressable onPress={toggleView}>
<MaterialCommunityIcons
name={isList ? "format-list-bulleted" : "view-grid"}
color={colors.text}
@@ -219,9 +228,10 @@ export default function ListTask() {
router.push(`./task/${item.id}`);
}}
borderType="bottom"
bgColor="transparent"
icon={
<View style={[Styles.iconContent, ColorsStatus.lightGreen]}>
<AntDesign name="areachart" size={25} color={"#384288"} />
<View style={[Styles.iconContent]}>
<AntDesign name="areachart" size={25} color={"black"} />
</View>
}
title={item.title}

View File

@@ -255,6 +255,8 @@ export default function UpdateProjectTaskDivision() {
day_label: { color: colors.text },
time_label: { color: colors.text },
weekday_label: { color: colors.text },
button_next_image: { tintColor: colors.text },
button_prev_image: { tintColor: colors.text },
}}
/>
)}
@@ -290,7 +292,7 @@ export default function UpdateProjectTaskDivision() {
>
<Text style={[dsbButton ? Styles.cGray : Styles.cWhite]}>Detail</Text>
</Pressable> */}
<ButtonSelect value="Detail" onPress={() => { setModalDetail(true) }} />
<ButtonSelect value="Detail" onPress={() => { setModalDetail(true) }} disabled={from == "" || to == ""} />
</View>
<InputForm
label="Judul Tugas"

View File

@@ -17,6 +17,7 @@ import {
Ionicons,
MaterialCommunityIcons
} from "@expo/vector-icons";
import AsyncStorage from "@react-native-async-storage/async-storage";
import { useInfiniteQuery, useQueryClient } from "@tanstack/react-query";
import { router, useLocalSearchParams } from "expo-router";
import { useEffect, useMemo, useState } from "react";
@@ -37,6 +38,18 @@ export default function ListDivision() {
cat?: string;
}>();
const [isList, setList] = useState(false);
useEffect(() => {
AsyncStorage.getItem('division_view_mode').then((val) => {
if (val !== null) setList(val === 'list')
})
}, [])
function toggleView() {
const next = !isList
setList(next)
AsyncStorage.setItem('division_view_mode', next ? 'list' : 'grid')
}
const entityUser = useSelector((state: any) => state.user)
const { token, decryptToken } = useAuthSession()
const { colors } = useTheme();
@@ -184,11 +197,7 @@ export default function ListDivision() {
<View style={[Styles.rowSpaceBetween, { alignItems: 'center' }]}>
<InputSearch width={68} onChange={setSearch} />
<Pressable
onPress={() => {
setList(!isList);
}}
>
<Pressable onPress={toggleView}>
<MaterialCommunityIcons
name={isList ? "format-list-bulleted" : "view-grid"}
color={colors.text}

View File

@@ -1,6 +1,5 @@
import AppHeader from "@/components/AppHeader";
import ImageUser from "@/components/imageNew";
import ItemDetailMember from "@/components/itemDetailMember";
import LabelStatus from "@/components/labelStatus";
import HeaderRightMemberDetail from "@/components/member/headerMemberDetail";
import Skeleton from "@/components/skeleton";
@@ -11,6 +10,7 @@ import { valueRoleUser } from "@/constants/RoleUser";
import Styles from "@/constants/Styles";
import { apiGetProfile } from "@/lib/api";
import { useTheme } from "@/providers/ThemeProvider";
import { AntDesign, MaterialCommunityIcons, MaterialIcons } from "@expo/vector-icons";
import { LinearGradient } from "expo-linear-gradient";
import { router, Stack, useLocalSearchParams } from "expo-router";
import React, { useEffect, useState } from "react";
@@ -30,6 +30,7 @@ type Props = {
group: string,
img: string,
isActive: boolean,
isApprover: boolean,
role: string
}
@@ -89,7 +90,7 @@ export default function MemberDetail() {
showBack={true}
onPressLeft={() => router.back()}
right={
(entityUser.role != "user") && isEdit ? <HeaderRightMemberDetail active={data?.isActive} id={id} /> : <></>
(entityUser.role != "user") && isEdit ? <HeaderRightMemberDetail active={data?.isActive} id={id} isApprover={data?.isApprover ?? false} /> : <></>
}
/>
)
@@ -109,51 +110,71 @@ export default function MemberDetail() {
colors={[colors.header, colors.homeGradient]}
style={[Styles.wrapHeadViewMember]}
>
{
loading ?
<>
<Skeleton width={100} height={100} borderRadius={100} />
<Skeleton width={200} height={10} borderRadius={5} />
<Skeleton width={150} height={10} borderRadius={5} />
</>
:
<>
<Pressable onPress={() => setPreview(true)}>
{loading ? (
<>
<Skeleton width={100} height={100} borderRadius={100} />
<Skeleton width={200} height={10} borderRadius={5} />
<Skeleton width={150} height={10} borderRadius={5} />
</>
) : (
<>
<Pressable onPress={() => setPreview(true)}>
<View style={[Styles.memberAvatarRing]}>
<ImageUser src={`${ConstEnv.url_storage}/files/${data?.img}`} size="lg" onError={setErrorImg} />
</Pressable>
<Text style={[Styles.textSubtitle, Styles.cWhite, Styles.mt10, Styles.textCenter]}>{data?.name}</Text>
<Text style={[Styles.textMediumNormal, Styles.cWhite]}>{data?.role}</Text>
</>
}
</View>
</Pressable>
<Text style={[Styles.textSubtitle, Styles.cWhite, Styles.mt10, Styles.textCenter]}>{data?.name}</Text>
<Text style={[Styles.textMediumNormal, Styles.cWhiteDimmed]}>{data?.role}</Text>
<View style={[Styles.memberBadgeRow]}>
{data?.isApprover && (
<View style={[Styles.memberBadgeApprover]}>
<Text style={[Styles.textSmallSemiBold, Styles.cWhite]}>APPROVER</Text>
</View>
)}
<View style={[Styles.memberBadgePill, { backgroundColor: data?.isActive ? colors.success : colors.error }]}>
<Text style={[Styles.textSmallSemiBold, Styles.cWhite]}>{data?.isActive ? 'AKTIF' : 'TIDAK AKTIF'}</Text>
</View>
</View>
</>
)}
</LinearGradient>
<View style={[Styles.p15]}>
<View style={[Styles.rowSpaceBetween]}>
<Text style={[Styles.textDefaultSemiBold, { color: colors.text }]}>Informasi</Text>
<LabelStatus
size="small"
category={data?.isActive ? 'success' : 'error'}
text={data?.isActive ? 'AKTIF' : 'TIDAK AKTIF'}
/>
</View>
{
loading ?
arrSkeleton.map((item, index) => {
return (
<Skeleton key={index} width={100} widthType="percent" height={25} borderRadius={5} />
)
})
:
<>
<ItemDetailMember category="nik" value={data?.nik} />
<ItemDetailMember category="group" value={data?.group} />
<ItemDetailMember category="position" value={data?.position} />
<ItemDetailMember category="phone" value={`+62${data?.phone}`} />
<ItemDetailMember category="email" value={data?.email} />
<ItemDetailMember category="gender" value={data?.gender == "F" ? "Perempuan" : "Laki-Laki"} />
</>
}
<View style={[Styles.p15]}>
<Text style={[Styles.textDefaultSemiBold, Styles.mb08, { color: colors.dimmed }]}>Informasi</Text>
<View>
{loading ? (
arrSkeleton.map((_, index) => (
<View key={index} style={[Styles.pv14, { borderBottomWidth: index < arrSkeleton.length - 1 ? 1 : 0, borderBottomColor: `${colors.dimmed}30` }]}>
<Skeleton width={80} height={8} borderRadius={4} />
<View style={[Styles.mt05]}>
<Skeleton width={60} widthType="percent" height={10} borderRadius={4} />
</View>
</View>
))
) : (
[
{ icon: <MaterialCommunityIcons name="card-account-details" size={20} color={colors.icon} />, label: 'NIK', value: data?.nik },
{ icon: <MaterialCommunityIcons name="office-building-outline" size={20} color={colors.icon} />, label: 'Lembaga Desa', value: data?.group },
{ icon: <MaterialCommunityIcons name="account-tie" size={20} color={colors.icon} />, label: 'Jabatan', value: data?.position },
{ icon: <MaterialIcons name="phone" size={20} color={colors.icon} />, label: 'No Telepon', value: `+62${data?.phone}` },
{ icon: <MaterialIcons name="email" size={20} color={colors.icon} />, label: 'Email', value: data?.email },
{ icon: <MaterialCommunityIcons name="gender-male-female" size={20} color={colors.icon} />, label: 'Jenis Kelamin', value: data?.gender == "F" ? "Perempuan" : "Laki-Laki" },
].map((item, index, arr) => (
<View
key={index}
style={[Styles.memberInfoRow, { borderBottomWidth: index < arr.length - 1 ? 1 : 0, borderBottomColor: `${colors.dimmed}30` }]}
>
<View style={[Styles.memberInfoIcon]}>
{item.icon}
</View>
<View style={[Styles.memberInfoContent]}>
<Text style={[Styles.textInformation, { color: colors.dimmed }]}>{item.label}</Text>
<Text style={[Styles.textDefault, Styles.mt02, { color: colors.text }]} numberOfLines={1}>{item.value ?? '-'}</Text>
</View>
</View>
))
)}
</View>
</View>
</ScrollView>

View File

@@ -1,6 +1,5 @@
import AppHeader from "@/components/AppHeader";
import { ButtonHeader } from "@/components/buttonHeader";
import ItemDetailMember from "@/components/itemDetailMember";
import Text from "@/components/Text";
import { assetUserImage } from "@/constants/AssetsError";
import { ConstEnv } from "@/constants/ConstEnv";
@@ -9,7 +8,7 @@ import { apiGetProfile } from "@/lib/api";
import { setEntities } from "@/lib/entitiesSlice";
import { useAuthSession } from "@/providers/AuthProvider";
import { useTheme } from "@/providers/ThemeProvider";
import { Feather } from "@expo/vector-icons";
import { Feather, MaterialCommunityIcons, MaterialIcons } from "@expo/vector-icons";
import { LinearGradient } from "expo-linear-gradient";
import { router, Stack } from "expo-router";
import { useState } from "react";
@@ -42,6 +41,15 @@ export default function Profile() {
setRefreshing(false)
};
const infoRows = [
{ icon: <MaterialCommunityIcons name="card-account-details" size={20} color={colors.icon} />, label: 'NIK', value: entities.nik },
{ icon: <MaterialCommunityIcons name="office-building-outline" size={20} color={colors.icon} />, label: 'Lembaga Desa', value: entities.group },
{ icon: <MaterialCommunityIcons name="account-tie" size={20} color={colors.icon} />, label: 'Jabatan', value: entities.position },
{ icon: <MaterialIcons name="phone" size={20} color={colors.icon} />, label: 'No Telepon', value: `0${entities.phone}` },
{ icon: <MaterialIcons name="email" size={20} color={colors.icon} />, label: 'Email', value: entities.email },
{ icon: <MaterialCommunityIcons name="gender-male-female" size={20} color={colors.icon} />, label: 'Jenis Kelamin', value: entities.gender == "F" ? 'Perempuan' : 'Laki-laki' },
]
return (
<SafeAreaView style={[Styles.flex1, { backgroundColor: colors.background }]}>
<Stack.Screen
@@ -56,9 +64,7 @@ export default function Profile() {
right={
<ButtonHeader
item={<Feather name="settings" size={20} color="white" />}
onPress={() => {
router.push('/setting')
}}
onPress={() => router.push('/setting')}
/>
}
/>
@@ -75,32 +81,47 @@ export default function Profile() {
}
style={[Styles.h100, { backgroundColor: colors.background }]}
>
<View style={[Styles.flexColumn]}>
<LinearGradient
colors={[colors.header, colors.homeGradient]}
style={[Styles.wrapHeadViewMember]}
>
<Pressable onPress={() => setPreview(true)}>
<LinearGradient
colors={[colors.header, colors.homeGradient]}
style={[Styles.wrapHeadViewMember]}
>
<Pressable onPress={() => setPreview(true)}>
<View style={[Styles.memberAvatarRing]}>
<Image
source={error ? require("../../assets/images/user.jpg") : { uri: `${ConstEnv.url_storage}/files/${entities.img}` }}
onError={() => { setError(true) }}
onError={() => setError(true)}
style={[Styles.userProfileBig]}
/>
</Pressable>
<Text style={[Styles.textSubtitle, Styles.cWhite, Styles.mt10]}>{entities.name}</Text>
<Text style={[Styles.textMediumNormal, Styles.cWhite]}>{entities.role}</Text>
</LinearGradient>
<View style={[Styles.p15]}>
<View style={[Styles.rowSpaceBetween]}>
<Text style={[Styles.textDefaultSemiBold, { color: colors.text }]}>Informasi</Text>
</View>
{/* Note: ItemDetailMember might need updates to support dynamic colors if it uses default text colors */}
<ItemDetailMember category="nik" value={entities.nik} />
<ItemDetailMember category="group" value={entities.group} />
<ItemDetailMember category="position" value={entities.position} />
<ItemDetailMember category="phone" value={`0${entities.phone}`} />
<ItemDetailMember category="email" value={entities.email} />
<ItemDetailMember category="gender" value={entities.gender == "F" ? 'Perempuan' : 'Laki-laki'} />
</Pressable>
<Text style={[Styles.textSubtitle, Styles.cWhite, Styles.mt10, Styles.textCenter]}>{entities.name}</Text>
<Text style={[Styles.textMediumNormal, Styles.cWhiteDimmed]}>{entities.role}</Text>
{entities.isApprover && (
<View style={[Styles.memberBadgeRow, { justifyContent: 'center' }]}>
<View style={[Styles.memberBadgeApprover]}>
<Text style={[Styles.textSmallSemiBold, Styles.cWhite]}>APPROVER</Text>
</View>
</View>
)}
</LinearGradient>
<View style={[Styles.p15]}>
<Text style={[Styles.textDefaultSemiBold, Styles.mb08, { color: colors.dimmed }]}>Informasi</Text>
<View>
{infoRows.map((item, index, arr) => (
<View
key={index}
style={[Styles.memberInfoRow, { borderBottomWidth: index < arr.length - 1 ? 1 : 0, borderBottomColor: `${colors.dimmed}30` }]}
>
<View style={[Styles.memberInfoIcon]}>
{item.icon}
</View>
<View style={[Styles.memberInfoContent]}>
<Text style={[Styles.textInformation, { color: colors.dimmed }]}>{item.label}</Text>
<Text style={[Styles.textDefault, Styles.mt02, { color: colors.text }]} numberOfLines={1}>{item.value ?? '-'}</Text>
</View>
</View>
))}
</View>
</View>
</ScrollView>
@@ -114,4 +135,4 @@ export default function Profile() {
/>
</SafeAreaView>
)
}
}

View File

@@ -195,6 +195,8 @@ export default function ProjectAddTask() {
day_label: { color: colors.text },
time_label: { color: colors.text },
weekday_label: { color: colors.text },
button_next_image: { tintColor: colors.text },
button_prev_image: { tintColor: colors.text },
}}
/>
</View>
@@ -227,7 +229,7 @@ export default function ProjectAddTask() {
>
<Text style={[dsbButton ? Styles.cGray : Styles.cWhite]}>Detail</Text>
</Pressable> */}
<ButtonSelect value="Detail" onPress={() => { setModalDetail(true) }} />
<ButtonSelect value="Detail" onPress={() => { setModalDetail(true) }} disabled={from == "" || to == ""} />
</View>
<InputForm
label="Judul Tugas"

View File

@@ -37,6 +37,7 @@ export default function DetailProject() {
const { id } = useLocalSearchParams<{ id: string }>();
const [data, setData] = useState<Props>()
const [progress, setProgress] = useState(0)
const [taskStats, setTaskStats] = useState<{ done: number, total: number } | undefined>()
const [loading, setLoading] = useState(true)
const update = useSelector((state: any) => state.projectUpdate)
const [isMember, setIsMember] = useState(false)
@@ -60,6 +61,17 @@ export default function DetailProject() {
}
}
async function handleLoadTaskStats() {
try {
const hasil = await decryptToken(String(token?.current))
const response = await apiGetProjectOne({ user: hasil, cat: 'task', id: id })
const tasks: { status: number }[] = response.data
setTaskStats({ done: tasks.filter(t => t.status === 1).length, total: tasks.length })
} catch (error) {
console.error(error)
}
}
async function checkMember() {
try {
const hasil = await decryptToken(String(token?.current))
@@ -79,6 +91,10 @@ export default function DetailProject() {
handleLoad('progress')
}, [update.progress])
useEffect(() => {
handleLoadTaskStats()
}, [update.task])
useEffect(() => {
checkMember()
}, [])
@@ -88,6 +104,7 @@ export default function DetailProject() {
setRefreshing(true)
await handleLoad('data')
await handleLoad('progress')
await handleLoadTaskStats()
await new Promise(resolve => setTimeout(resolve, 2000));
setRefreshing(false)
};
@@ -126,7 +143,7 @@ export default function DetailProject() {
{
data?.reason != null && data?.reason != "" && <SectionCancel text={data?.reason} />
}
<SectionProgress text={`Kemajuan Kegiatan ${progress}%`} progress={progress} />
<SectionProgress progress={progress} doneCount={taskStats?.done} totalCount={taskStats?.total} />
<SectionReportProject refreshing={refreshing} />
<SectionTanggalTugasProject status={data?.status} member={isMember} refreshing={refreshing} />
<SectionFile status={data?.status} member={isMember} refreshing={refreshing} />

View File

@@ -0,0 +1,377 @@
import AppHeader from "@/components/AppHeader";
import BorderBottomItem from "@/components/borderBottomItem";
import { ButtonForm } from "@/components/buttonForm";
import ButtonSelect from "@/components/buttonSelect";
import DrawerBottom from "@/components/drawerBottom";
import MenuItemRow from "@/components/menuItemRow";
import ModalConfirmation from "@/components/ModalConfirmation";
import ModalLoading from "@/components/modalLoading";
import Skeleton from "@/components/skeleton";
import Text from "@/components/Text";
import { ConstEnv } from "@/constants/ConstEnv";
import Styles from "@/constants/Styles";
import {
apiAddProjectTaskFile,
apiDeleteProjectTaskFile,
apiGetProjectOne,
apiGetProjectTaskFile,
apiLinkProjectTaskFile,
} from "@/lib/api";
import { setUpdateProject } from "@/lib/projectUpdate";
import { useAuthSession } from "@/providers/AuthProvider";
import { useTheme } from "@/providers/ThemeProvider";
import { Ionicons, MaterialCommunityIcons } from "@expo/vector-icons";
import * as DocumentPicker from "expo-document-picker";
import * as FileSystem from "expo-file-system";
import { startActivityAsync } from "expo-intent-launcher";
import { router, Stack, useLocalSearchParams } from "expo-router";
import * as Sharing from "expo-sharing";
import { useEffect, useState } from "react";
import {
ActivityIndicator,
Alert,
Platform,
SafeAreaView,
ScrollView,
View,
} from "react-native";
import * as mime from "react-native-mime-types";
import Toast from "react-native-toast-message";
import { useDispatch, useSelector } from "react-redux";
type FileItem = {
id: string; // ProjectTaskFile.id
idFile: string; // ProjectFile.id
name: string;
extension: string;
idStorage: string;
};
type ProjectFile = {
id: string;
name: string;
extension: string;
idStorage: string;
};
export default function ProjectTugasFileScreen() {
const { colors } = useTheme();
const { id, taskId, member: memberParam } = useLocalSearchParams<{ id: string; taskId: string; member: string }>();
const { token, decryptToken } = useAuthSession();
const dispatch = useDispatch();
const update = useSelector((state: any) => state.projectUpdate);
const entityUser = useSelector((state: any) => state.user);
const isMember = memberParam === "true";
const canEdit = isMember || (entityUser.role !== "user" && entityUser.role !== "coadmin");
const [data, setData] = useState<FileItem[]>([]);
const [loading, setLoading] = useState(true);
const [loadingOpen, setLoadingOpen] = useState(false);
const [loadingUpload, setLoadingUpload] = useState(false);
const [loadingLink, setLoadingLink] = useState(false);
const [selectFile, setSelectFile] = useState<FileItem | null>(null);
const [isMenuModal, setMenuModal] = useState(false);
const [showDeleteModal, setShowDeleteModal] = useState(false);
const [projectFiles, setProjectFiles] = useState<ProjectFile[]>([]);
const [isPickerModal, setPickerModal] = useState(false);
const [loadingProjectFiles, setLoadingProjectFiles] = useState(false);
const [selectedProjectFiles, setSelectedProjectFiles] = useState<string[]>([]);
const arrSkeleton = Array.from({ length: 4 });
async function loadFiles() {
try {
setLoading(true);
const hasil = await decryptToken(String(token?.current));
const response = await apiGetProjectTaskFile({ user: hasil, id: taskId });
setData(response.data ?? []);
} catch (error) {
console.error(error);
} finally {
setLoading(false);
}
}
async function loadProjectFiles() {
try {
setLoadingProjectFiles(true);
const hasil = await decryptToken(String(token?.current));
const response = await apiGetProjectOne({ user: hasil, cat: "file", id });
setProjectFiles(response.data ?? []);
} catch (error) {
console.error(error);
} finally {
setLoadingProjectFiles(false);
}
}
useEffect(() => {
loadFiles();
}, []);
const openFile = () => {
setMenuModal(false);
setLoadingOpen(true);
const remoteUrl = ConstEnv.url_storage + "/files/" + selectFile?.idStorage;
const fileName = selectFile?.name + "." + selectFile?.extension;
const localPath = `${FileSystem.documentDirectory}/${fileName}`;
const mimeType = mime.lookup(fileName);
FileSystem.downloadAsync(remoteUrl, localPath).then(async ({ uri }) => {
const contentURL = await FileSystem.getContentUriAsync(uri);
try {
if (Platform.OS === "android") {
await startActivityAsync("android.intent.action.VIEW", {
data: contentURL,
flags: 1,
type: mimeType as string,
});
} else {
Sharing.shareAsync(localPath);
}
} catch {
Alert.alert("INFO", "Gagal membuka file, tidak ada aplikasi yang dapat membuka file ini");
} finally {
setLoadingOpen(false);
}
});
};
async function handleDelete() {
try {
const hasil = await decryptToken(String(token?.current));
const response = await apiDeleteProjectTaskFile({ user: hasil }, String(selectFile?.id));
if (response.success) {
Toast.show({ type: "small", text1: "Berhasil menghapus file" });
dispatch(setUpdateProject({ ...update, task: !update.task }));
loadFiles();
} else {
Toast.show({ type: "small", text1: response.message });
}
} catch (error: any) {
const message = error?.response?.data?.message || "Gagal menghapus file";
Toast.show({ type: "small", text1: message });
} finally {
setMenuModal(false);
}
}
async function handleUpload() {
const result = await DocumentPicker.getDocumentAsync({ type: ["*/*"], multiple: true });
if (result.canceled) return;
try {
setLoadingUpload(true);
const hasil = await decryptToken(String(token?.current));
const fd = new FormData();
for (let i = 0; i < result.assets.length; i++) {
fd.append(`file${i}`, {
uri: result.assets[i].uri,
type: "application/octet-stream",
name: result.assets[i].name,
} as any);
}
fd.append("data", JSON.stringify({ user: hasil }));
const response = await apiAddProjectTaskFile({ data: fd, id: taskId });
if (response.success) {
Toast.show({ type: "small", text1: "Berhasil menambahkan file" });
dispatch(setUpdateProject({ ...update, task: !update.task }));
loadFiles();
} else {
Toast.show({ type: "small", text1: response.message });
}
} catch (error: any) {
const message = error?.response?.data?.message || "Gagal menambahkan file";
Toast.show({ type: "small", text1: message });
} finally {
setLoadingUpload(false);
}
}
function toggleProjectFileSelect(fileId: string) {
setSelectedProjectFiles((prev) =>
prev.includes(fileId) ? prev.filter((v) => v !== fileId) : [...prev, fileId]
);
}
async function handleLinkFiles() {
if (selectedProjectFiles.length === 0) return;
try {
setLoadingLink(true);
const hasil = await decryptToken(String(token?.current));
for (const idFile of selectedProjectFiles) {
await apiLinkProjectTaskFile({ user: hasil, idFile, id: taskId });
}
Toast.show({ type: "small", text1: "Berhasil menambahkan file" });
dispatch(setUpdateProject({ ...update, task: !update.task }));
setPickerModal(false);
setSelectedProjectFiles([]);
loadFiles();
} catch (error: any) {
const message = error?.response?.data?.message || "Gagal menambahkan file";
Toast.show({ type: "small", text1: message });
} finally {
setLoadingLink(false);
}
}
const attachedFileIds = new Set(data.map((f) => f.idFile));
return (
<SafeAreaView style={{ flex: 1, backgroundColor: colors.background }}>
<Stack.Screen
options={{
header: () => (
<AppHeader
title="File Tugas"
showBack={true}
onPressLeft={() => router.back()}
/>
),
}}
/>
<ModalLoading isVisible={loadingOpen} setVisible={setLoadingOpen} />
<ScrollView>
<View style={[Styles.p15, Styles.mb100]}>
{canEdit && (
<>
<ButtonSelect
value="Upload dari Perangkat"
onPress={handleUpload}
disabled={loadingUpload}
/>
<ButtonSelect
value="Pilih dari File Proyek"
onPress={() => {
setSelectedProjectFiles([]);
setPickerModal(true);
loadProjectFiles();
}}
/>
</>
)}
{loadingUpload && <ActivityIndicator size="small" style={Styles.mv05} />}
<View style={[Styles.mb15, Styles.mt10]}>
<Text style={[Styles.textDefaultSemiBold, Styles.mv05]}>File Terlampir</Text>
<View style={[Styles.wrapPaper, { backgroundColor: colors.card, borderColor: colors.background }]}>
{loading ? (
arrSkeleton.map((_, index) => (
<Skeleton key={index} width={100} height={40} widthType="percent" borderRadius={10} />
))
) : data.length > 0 ? (
data.map((item, index) => (
<BorderBottomItem
key={index}
borderType="all"
icon={<MaterialCommunityIcons name="file-outline" size={25} color={colors.text} />}
title={item.name + "." + item.extension}
titleWeight="normal"
onPress={() => {
setSelectFile(item);
setMenuModal(true);
}}
/>
))
) : (
<Text style={[Styles.textDefault, { textAlign: "center", color: colors.dimmed }]}>
Tidak ada file
</Text>
)}
</View>
</View>
</View>
</ScrollView>
{/* Menu per file */}
<DrawerBottom animation="slide" isVisible={isMenuModal} setVisible={setMenuModal} title="Menu">
<View style={Styles.rowItemsCenter}>
<MenuItemRow
icon={<MaterialCommunityIcons name="file-eye" color={colors.text} size={25} />}
title="Lihat / Share"
onPress={openFile}
/>
{canEdit && (
<MenuItemRow
icon={<Ionicons name="trash-outline" color={colors.text} size={25} />}
title="Hapus"
onPress={() => {
setMenuModal(false);
setTimeout(() => setShowDeleteModal(true), 600);
}}
/>
)}
</View>
</DrawerBottom>
<ModalConfirmation
visible={showDeleteModal}
title="Konfirmasi"
message="Apakah Anda yakin ingin menghapus file ini?"
onConfirm={() => {
setShowDeleteModal(false);
handleDelete();
}}
onCancel={() => setShowDeleteModal(false)}
confirmText="Hapus"
cancelText="Batal"
/>
{/* Picker file dari proyek */}
<DrawerBottom
animation="slide"
isVisible={isPickerModal}
setVisible={setPickerModal}
title="Pilih File Proyek"
height={60}
>
<ScrollView>
{loadingProjectFiles ? (
<ActivityIndicator size="small" />
) : projectFiles.length > 0 ? (
projectFiles.map((item, index) => {
const isAttached = attachedFileIds.has(item.id);
const isSelected = selectedProjectFiles.includes(item.id);
return (
<View key={index} style={isAttached ? { opacity: 0.4 } : undefined}>
<BorderBottomItem
borderType="bottom"
icon={
isAttached || isSelected ? (
<Ionicons name="checkmark-circle" size={25} color={colors.primary} />
) : (
<MaterialCommunityIcons name="file-outline" size={25} color={colors.text} />
)
}
title={item.name + "." + item.extension}
titleWeight="normal"
onPress={() => !isAttached && toggleProjectFileSelect(item.id)}
bgColor="transparent"
/>
</View>
);
})
) : (
<Text style={[Styles.textDefault, { textAlign: "center", color: colors.dimmed }]}>
Tidak ada file tersedia
</Text>
)}
</ScrollView>
{projectFiles.length > 0 && (
<View>
<ButtonForm
text={loadingLink ? "Menyimpan..." : `Tambahkan (${selectedProjectFiles.length})`}
disabled={selectedProjectFiles.length === 0 || loadingLink}
onPress={handleLinkFiles} />
</View>
)}
</DrawerBottom>
</SafeAreaView>
);
}

View File

@@ -1,7 +1,5 @@
import AppHeader from "@/components/AppHeader";
import BorderBottomItem from "@/components/borderBottomItem";
import ButtonSaveHeader from "@/components/buttonSaveHeader";
import ButtonSelect from "@/components/buttonSelect";
import DrawerBottom from "@/components/drawerBottom";
import ImageUser from "@/components/imageNew";
import { InputForm } from "@/components/inputForm";
@@ -25,6 +23,7 @@ import * as DocumentPicker from "expo-document-picker";
import { router, Stack } from "expo-router";
import { useEffect, useState } from "react";
import {
Pressable,
SafeAreaView,
ScrollView,
View
@@ -32,6 +31,26 @@ import {
import Toast from "react-native-toast-message";
import { useDispatch, useSelector } from "react-redux";
function getFileIcon(ext: string): keyof typeof MaterialCommunityIcons.glyphMap {
if (['jpg', 'jpeg', 'png', 'gif', 'webp', 'heic', 'heif'].includes(ext)) return 'image-outline'
if (ext === 'pdf') return 'file-pdf-box'
if (['mp4', 'mov', 'avi', 'mkv'].includes(ext)) return 'video-outline'
if (['doc', 'docx'].includes(ext)) return 'file-word-outline'
if (['xls', 'xlsx'].includes(ext)) return 'file-excel-outline'
if (['zip', 'rar', '7z'].includes(ext)) return 'zip-box-outline'
return 'file-outline'
}
function getFileColor(ext: string): string {
if (['jpg', 'jpeg', 'png', 'gif', 'webp', 'heic', 'heif'].includes(ext)) return '#339AF0'
if (ext === 'pdf') return '#F03E3E'
if (['mp4', 'mov', 'avi', 'mkv'].includes(ext)) return '#AE3EC9'
if (['doc', 'docx'].includes(ext)) return '#1C7ED6'
if (['xls', 'xlsx'].includes(ext)) return '#2F9E44'
if (['zip', 'rar', '7z'].includes(ext)) return '#E8590C'
return '#868E96'
}
export default function CreateProject() {
const { colors } = useTheme();
const [loading, setLoading] = useState(false)
@@ -241,26 +260,23 @@ export default function CreateProject() {
style={[Styles.h100, { backgroundColor: colors.background }]}
>
<View style={[Styles.p15]}>
{
(entityUser.role == "supadmin" || entityUser.role == "developer")
&&
(
<SelectForm
label="Lembaga Desa"
placeholder="Pilih Lembaga Desa"
value={chooseGroup.label}
required
bg={colors.card}
onPress={() => {
setValChoose(chooseGroup.val);
setValSelect("group");
setSelect(true);
}}
error={error.group}
errorText="Lembaga Desa tidak boleh kosong"
/>
)
}
{(entityUser.role == "supadmin" || entityUser.role == "developer") && (
<SelectForm
label="Lembaga Desa"
placeholder="Pilih Lembaga Desa"
value={chooseGroup.label}
required
bg={colors.card}
onPress={() => {
setValChoose(chooseGroup.val);
setValSelect("group");
setSelect(true);
}}
error={error.group}
errorText="Lembaga Desa tidak boleh kosong"
/>
)}
<InputForm
label="Kegiatan"
type="default"
@@ -270,85 +286,154 @@ export default function CreateProject() {
value={dataForm.title}
error={error.title}
errorText="Nama kegiatan tidak boleh kosong"
onChange={(val) => {
validationForm("title", val);
}}
onChange={(val) => validationForm("title", val)}
/>
<ButtonSelect
value="Tambah Tanggal & Tugas"
onPress={() => {
router.push(`/project/create/task`);
}}
error={error.task}
errorText="Tanggal & Tugas tidak boleh kosong"
/>
<ButtonSelect value="Upload File" onPress={pickDocumentAsync} />
<ButtonSelect
value="Pilih Anggota"
onPress={() => {
if (entityUser.role == "supadmin" || entityUser.role == "developer") {
if (chooseGroup.val != "") {
router.push(`/project/create/member`);
} else {
Toast.show({ type: 'small', text1: "Pilih Lembaga Desa terlebih dahulu", })
}
} else {
router.push(`/project/create/member`);
}
}}
error={error.member}
errorText="Anggota tidak boleh kosong"
/>
<SectionListAddTask />
{
fileForm.length > 0 && (
<View style={[Styles.mb15]}>
<Text style={[Styles.textDefaultSemiBold, Styles.mv05]}>File</Text>
<View style={[Styles.wrapPaper, { backgroundColor: colors.card, borderColor: colors.background }]}>
{
fileForm.map((item, index) => (
<BorderBottomItem
key={index}
borderType="all"
icon={<MaterialCommunityIcons name="file-outline" size={25} color={colors.text} />}
title={item.name}
titleWeight="normal"
onPress={() => { setIndexDelFile(index); setModal(true) }}
/>
))
}
</View>
</View>
)
}
{entitiesMember.length > 0 && (
<View>
<View style={[Styles.rowSpaceBetween, Styles.mv05]}>
<Text>Anggota</Text>
<Text>Total {entitiesMember.length} Anggota</Text>
</View>
<View style={[Styles.borderAll, Styles.round05, Styles.p10, { borderColor: colors.icon + '20', backgroundColor: colors.card }]}>
{entitiesMember.map(
(item: { img: any; name: any }, index: any) => {
return (
<BorderBottomItem
key={index}
borderType="bottom"
icon={
<ImageUser
src={`${ConstEnv.url_storage}/files/${item.img}`}
size="sm"
/>
}
title={item.name}
/>
);
}
{/* Tanggal & Tugas */}
<View style={[
Styles.wrapPaper, Styles.mb15, Styles.sectionCard,
{ backgroundColor: colors.card, borderColor: error.task ? colors.error + '50' : colors.icon + '18' }
]}>
<Pressable
onPress={() => router.push(`/project/create/task`)}
style={[Styles.sectionActionRow, { marginBottom: taskCreate.length > 0 ? 12 : 0 }]}
>
<View style={[Styles.sectionIconBox, { backgroundColor: colors.tabActive + '18' }]}>
<MaterialCommunityIcons name="calendar-check-outline" size={18} color={colors.tabActive} />
</View>
<View style={Styles.flex1}>
<Text style={[Styles.textDefaultSemiBold, { color: colors.text }]}>Tanggal & Tugas</Text>
{taskCreate.length === 0 && (
<Text style={[Styles.textMediumNormal, { color: colors.dimmed }]}>Belum ada tugas ditambahkan</Text>
)}
</View>
</View>
)}
{taskCreate.length > 0 && (
<View style={[Styles.sectionBadge, { backgroundColor: colors.tabActive + '18' }]}>
<Text style={[Styles.textSmallSemiBold, { color: colors.tabActive }]}>{taskCreate.length} tugas</Text>
</View>
)}
<MaterialCommunityIcons name="chevron-right" size={18} color={colors.dimmed} />
</Pressable>
{taskCreate.length > 0 && <SectionListAddTask showTitle={false} />}
{error.task && (
<Text style={[Styles.textMediumNormal, Styles.mt05, { color: colors.error }]}>
Tanggal & Tugas tidak boleh kosong
</Text>
)}
</View>
{/* File */}
<View style={[
Styles.wrapPaper, Styles.mb15, Styles.sectionCard,
{ backgroundColor: colors.card, borderColor: colors.icon + '18' }
]}>
<Pressable
onPress={pickDocumentAsync}
style={[Styles.sectionActionRow, { marginBottom: fileForm.length > 0 ? 12 : 0 }]}
>
<View style={[Styles.sectionIconBox, { backgroundColor: colors.icon + '15' }]}>
<MaterialCommunityIcons name="paperclip" size={18} color={colors.dimmed} />
</View>
<View style={Styles.flex1}>
<Text style={[Styles.textDefaultSemiBold, { color: colors.text }]}>File</Text>
{fileForm.length === 0 && (
<Text style={[Styles.textMediumNormal, { color: colors.dimmed }]}>Opsional ketuk untuk upload</Text>
)}
</View>
{fileForm.length > 0 && (
<View style={[Styles.sectionBadge, { backgroundColor: colors.dimmed + '18' }]}>
<Text style={[Styles.textSmallSemiBold, { color: colors.dimmed }]}>{fileForm.length} file</Text>
</View>
)}
<MaterialCommunityIcons name="chevron-right" size={18} color={colors.dimmed} />
</Pressable>
{fileForm.length > 0 && (
<View style={Styles.fileGrid}>
{fileForm.map((item, index) => {
const ext = item.name.split('.').pop()?.toLowerCase() ?? ''
const baseName = item.name.includes('.') ? item.name.split('.').slice(0, -1).join('.') : item.name
const iconName = getFileIcon(ext)
const iconColor = getFileColor(ext)
return (
<Pressable
key={index}
onPress={() => { setIndexDelFile(index); setModal(true) }}
style={[Styles.fileCard, { backgroundColor: 'transparent', borderColor: colors.icon + '18' }]}
>
<View style={[Styles.sectionIconBox, { backgroundColor: iconColor + '20' }]}>
<MaterialCommunityIcons name={iconName} size={18} color={iconColor} />
</View>
<View style={Styles.flex1}>
<Text style={Styles.textDefault} numberOfLines={1}>{baseName}</Text>
<Text style={[Styles.textSmallSemiBold, { color: colors.dimmed }]}>{ext.toUpperCase()}</Text>
</View>
</Pressable>
)
})}
</View>
)}
</View>
{/* Anggota */}
<View style={[
Styles.wrapPaper, Styles.mb15, Styles.sectionCard,
{ backgroundColor: colors.card, borderColor: error.member ? colors.error + '50' : colors.icon + '18' }
]}>
<Pressable
onPress={() => {
if (entityUser.role == "supadmin" || entityUser.role == "developer") {
if (chooseGroup.val != "") {
router.push(`/project/create/member`);
} else {
Toast.show({ type: 'small', text1: "Pilih Lembaga Desa terlebih dahulu" })
}
} else {
router.push(`/project/create/member`);
}
}}
style={[Styles.sectionActionRow, { marginBottom: entitiesMember.length > 0 ? 12 : 0 }]}
>
<View style={[Styles.sectionIconBox, { backgroundColor: colors.tabActive + '18' }]}>
<MaterialCommunityIcons name="account-group-outline" size={18} color={colors.tabActive} />
</View>
<View style={Styles.flex1}>
<Text style={[Styles.textDefaultSemiBold, { color: colors.text }]}>Anggota</Text>
{entitiesMember.length === 0 && (
<Text style={[Styles.textMediumNormal, { color: colors.dimmed }]}>Belum ada anggota dipilih</Text>
)}
</View>
{entitiesMember.length > 0 && (
<View style={[Styles.sectionBadge, { backgroundColor: colors.tabActive + '18' }]}>
<Text style={[Styles.textSmallSemiBold, { color: colors.tabActive }]}>{entitiesMember.length} orang</Text>
</View>
)}
<MaterialCommunityIcons name="chevron-right" size={18} color={colors.dimmed} />
</Pressable>
{entitiesMember.length > 0 && (
<View style={{ gap: 6 }}>
{entitiesMember.map((item: { img: any; name: any; position?: string }, index: any) => (
<View
key={index}
style={[Styles.listItemCard, { borderColor: colors.icon + '18' }]}
>
<ImageUser src={`${ConstEnv.url_storage}/files/${item.img}`} size="xs" />
<Text style={[Styles.textDefault, Styles.flex1, { color: colors.text }]} numberOfLines={1}>{item.name}</Text>
{item.position && (
<View style={[Styles.positionBadge, { backgroundColor: colors.dimmed + '15' }]}>
<Text style={[Styles.textSmallSemiBold, { color: colors.dimmed }]} numberOfLines={1}>{item.position}</Text>
</View>
)}
</View>
))}
</View>
)}
{error.member && (
<Text style={[Styles.textMediumNormal, Styles.mt05, { color: colors.error }]}>
Anggota tidak boleh kosong
</Text>
)}
</View>
</View>
</ScrollView>
<DrawerBottom animation="slide" isVisible={isModal} setVisible={setModal} title="Menu">

View File

@@ -179,6 +179,8 @@ export default function CreateProjectAddTask() {
day_label: { color: colors.text },
time_label: { color: colors.text },
weekday_label: { color: colors.text },
button_next_image: { tintColor: colors.text },
button_prev_image: { tintColor: colors.text },
}}
/>
</View>
@@ -204,14 +206,7 @@ export default function CreateProjectAddTask() {
{
(error.endDate || error.startDate) && <Text style={[Styles.textInformation, Styles.mt05, { color: colors.error }]}>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> */}
<ButtonSelect value="Detail" onPress={() => { setModalDetail(true) }} />
<ButtonSelect value="Detail" onPress={() => { setModalDetail(true) }} disabled={from == "" || to == ""} />
</View>
<InputForm
label="Judul Tugas"

View File

@@ -23,6 +23,7 @@ import { router, useLocalSearchParams } from "expo-router";
import { useEffect, useMemo, useState } from "react";
import { Pressable, RefreshControl, ScrollView, View, VirtualizedList } from "react-native";
import { useSelector } from "react-redux";
import AsyncStorage from "@react-native-async-storage/async-storage";
type Props = {
id: string;
@@ -50,6 +51,18 @@ export default function ListProject() {
const [search, setSearch] = useState("")
const [isList, setList] = useState(false)
const update = useSelector((state: any) => state.projectUpdate)
useEffect(() => {
AsyncStorage.getItem('division_view_mode').then((val) => {
if (val !== null) setList(val === 'list')
})
}, [])
function toggleView() {
const next = !isList
setList(next)
AsyncStorage.setItem('division_view_mode', next ? 'list' : 'grid')
}
const queryClient = useQueryClient()
const [refreshing, setRefreshing] = useState(false)
@@ -188,11 +201,7 @@ export default function ListProject() {
<View style={[Styles.rowSpaceBetween, Styles.rowItemsCenter]}>
<InputSearch width={68} onChange={setSearch} />
<Pressable
onPress={() => {
setList(!isList);
}}
>
<Pressable onPress={toggleView}>
<MaterialCommunityIcons
name={isList ? "format-list-bulleted" : "view-grid"}
color={colors.text}

View File

@@ -229,6 +229,8 @@ export default function UpdateProjectTask() {
day_label: { color: colors.text },
time_label: { color: colors.text },
weekday_label: { color: colors.text },
button_next_image: { tintColor: colors.text },
button_prev_image: { tintColor: colors.text },
}}
/>
}
@@ -259,7 +261,7 @@ export default function UpdateProjectTask() {
>
<Text style={[dsbButton ? Styles.cGray : Styles.cWhite]}>Detail</Text>
</Pressable> */}
<ButtonSelect value="Detail" onPress={() => { setModalDetail(true) }} />
<ButtonSelect value="Detail" onPress={() => { setModalDetail(true) }} disabled={from == "" || to == ""} />
</View>
<InputForm
label="Judul Tugas"

View File

@@ -0,0 +1,140 @@
import Styles from "@/constants/Styles"
import { useTheme } from "@/providers/ThemeProvider"
import { MaterialCommunityIcons } from "@expo/vector-icons"
import { useRef, useState } from "react"
import { ScrollView, View } from "react-native"
import DrawerBottom from "./drawerBottom"
import Skeleton from "./skeleton"
import Text from "./Text"
type ApprovalRecord = {
id: string
status: number // 0=pending, 1=approved, 2=rejected
note?: string
submitter: { name: string }
approver?: { name: string }
createdAt: string
}
type Props = {
isVisible: boolean
setVisible: (value: boolean) => void
data: ApprovalRecord[]
loading: boolean
}
function ApprovalStatusBadge({ status }: { status: number }) {
const { colors } = useTheme()
const config =
status === 1
? { label: 'Disetujui', color: colors.success }
: status === 2
? { label: 'Ditolak', color: colors.error }
: { label: 'Menunggu', color: '#FFA94D' }
return (
<View style={{
backgroundColor: config.color + '20',
borderRadius: 20,
paddingHorizontal: 10,
paddingVertical: 3,
alignSelf: 'flex-start',
}}>
<Text style={[Styles.textSmallSemiBold, { color: config.color }]}>
{config.label}
</Text>
</View>
)
}
export default function ModalRiwayatApproval({ isVisible, setVisible, data, loading }: Props) {
const { colors } = useTheme()
const arrSkeleton = Array.from({ length: 3 })
const scrollRef = useRef<ScrollView>(null)
const [scrollOffset, setScrollOffset] = useState(0)
return (
<DrawerBottom
isVisible={isVisible}
setVisible={setVisible}
title="Riwayat Persetujuan"
animation="slide"
height={60}
scrollOffset={scrollOffset}
scrollTo={(p) => scrollRef.current?.scrollTo(p)}
>
<ScrollView
ref={scrollRef}
showsVerticalScrollIndicator={false}
onScroll={({ nativeEvent }) => setScrollOffset(nativeEvent.contentOffset.y)}
scrollEventThrottle={16}
>
{loading ? (
arrSkeleton.map((_, i) => (
<View key={i} style={[Styles.mb10]}>
<Skeleton width={100} widthType="percent" height={80} borderRadius={10} />
</View>
))
) : data.length > 0 ? (
data.map((item, index) => (
<View
key={item.id}
style={{
borderWidth: 1,
borderColor: colors.icon + '30',
borderRadius: 10,
padding: 12,
marginBottom: 10,
}}
>
{/* Status + tanggal */}
<View style={[Styles.rowItemsCenter, { justifyContent: 'space-between', marginBottom: 8 }]}>
<ApprovalStatusBadge status={item.status} />
<Text style={[Styles.textSmallSemiBold, { color: colors.dimmed }]}>
{item.createdAt}
</Text>
</View>
{/* Pengaju */}
<View style={[Styles.rowItemsCenter, Styles.mb05]}>
<MaterialCommunityIcons name="account-arrow-up-outline" size={15} color={colors.dimmed} style={{ marginRight: 6 }} />
<Text style={[Styles.textMediumSemiBold, { color: colors.dimmed }]}>Diajukan Oleh: </Text>
<Text style={[Styles.textMediumNormal]}>{item.submitter.name}</Text>
</View>
{/* Approver */}
<View style={[Styles.rowItemsCenter, item.note ? Styles.mb05 : {}]}>
<MaterialCommunityIcons name="account-check-outline" size={15} color={colors.dimmed} style={{ marginRight: 6 }} />
<Text style={[Styles.textMediumSemiBold, { color: colors.dimmed }]}>Disetujui Oleh: </Text>
<Text style={[Styles.textMediumNormal]}>
{item.approver?.name ?? '-'}
</Text>
</View>
{/* Catatan penolakan */}
{item.note && (
<View style={{
backgroundColor: colors.error + '12',
borderRadius: 8,
padding: 8,
marginTop: 4,
}}>
<Text style={[Styles.textSmallSemiBold, { color: colors.error, marginBottom: 2 }]}>
Alasan Penolakan
</Text>
<Text style={[Styles.textMediumNormal, { color: colors.text }]}>
{item.note}
</Text>
</View>
)}
</View>
))
) : (
<Text style={[Styles.textDefault, { textAlign: 'center', color: colors.dimmed }]}>
Belum ada riwayat persetujuan
</Text>
)}
</ScrollView>
</DrawerBottom>
)
}

View File

@@ -0,0 +1,78 @@
import Styles from "@/constants/Styles"
import { useTheme } from "@/providers/ThemeProvider"
import { useState } from "react"
import { TouchableOpacity, View } from "react-native"
import DrawerBottom from "./drawerBottom"
import { InputForm } from "./inputForm"
import Text from "./Text"
type Props = {
isVisible: boolean
setVisible: (value: boolean) => void
onTolak: (note: string) => void
loading?: boolean
}
export default function ModalTolakApproval({ isVisible, setVisible, onTolak, loading }: Props) {
const { colors } = useTheme()
const [note, setNote] = useState('')
const [error, setError] = useState(false)
function handleClose(value: boolean) {
setNote('')
setError(false)
setVisible(value)
}
function handleSubmit() {
if (!note.trim()) {
setError(true)
return
}
onTolak(note.trim())
setNote('')
setError(false)
}
return (
<DrawerBottom
isVisible={isVisible}
setVisible={handleClose}
title="Tolak Tugas"
animation="slide"
height={45}
keyboard
>
<View style={{ flex: 1 }}>
<InputForm
label="Alasan Penolakan"
placeholder="Tuliskan alasan penolakan..."
type="default"
multiline
bg="transparent"
value={note}
onChange={setNote}
error={error}
errorText="Alasan penolakan wajib diisi"
required
/>
</View>
<TouchableOpacity
onPress={handleSubmit}
disabled={loading}
style={{
backgroundColor: loading ? colors.error + '60' : colors.error,
borderRadius: 30,
paddingVertical: 10,
alignItems: 'center',
marginTop: 8,
}}
>
<Text style={[Styles.textDefaultSemiBold, Styles.cWhite]}>
{loading ? 'Memproses...' : 'Tolak Tugas'}
</Text>
</TouchableOpacity>
</DrawerBottom>
)
}

View File

@@ -10,20 +10,22 @@ type Props = {
round?: boolean
error?: boolean
errorText?: string
disabled?: boolean
}
export default function ButtonSelect({ value, onPress, round, error, errorText }: Props) {
export default function ButtonSelect({ value, onPress, round, error, errorText, disabled }: Props) {
const { colors } = useTheme();
return (
<View style={[Styles.mv05]}>
<Pressable onPress={onPress}>
<Pressable onPress={onPress} disabled={disabled}>
<View style={[
Styles.inputRoundForm,
Styles.inputRoundFormRight,
round && Styles.round30,
Styles.pv10,
{ borderColor: colors.icon + '20', backgroundColor: colors.input },
error && { borderColor: "red" }
error && { borderColor: "red" },
disabled && { opacity: 0.4 }
]}>
<Feather name="arrow-right-circle" size={20} color={colors.text} />
<Text style={[{ color: colors.text }]}>{value}</Text>

View File

@@ -14,9 +14,11 @@ type Props = {
height?: number
backdropPressable?: boolean
keyboard?: boolean
scrollOffset?: number
scrollTo?: (p: any) => void
}
export default function DrawerBottom({ isVisible, setVisible, title, children, animation, height, backdropPressable = true, keyboard = false }: Props) {
export default function DrawerBottom({ isVisible, setVisible, title, children, animation, height, backdropPressable = true, keyboard = false, scrollOffset, scrollTo }: Props) {
const tinggiScreen = Dimensions.get("window").height;
const { colors } = useTheme();
const tinggiInput = height != undefined ? height : 25
@@ -38,6 +40,9 @@ export default function DrawerBottom({ isVisible, setVisible, title, children, a
backdropTransitionOutTiming={500}
useNativeDriverForBackdrop={true}
propagateSwipe={true}
scrollTo={scrollTo}
scrollOffset={scrollOffset}
scrollOffsetMax={200}
>
{
keyboard ?

View File

@@ -36,7 +36,7 @@ export default function CaraouselHome({ refreshing }: { refreshing: boolean }) {
async function handleUser() {
const hasil = await decryptToken(String(token?.current))
const response = await apiGetProfile({ id: hasil })
dispatch(setEntityUser({ role: response.data.idUserRole, admin: false }))
dispatch(setEntityUser({ role: response.data.idUserRole, admin: false, isApprover: response.data.isApprover ?? false }))
}
useEffect(() => {

View File

@@ -59,7 +59,7 @@ export default function CaraouselHome2({ refreshing }: { refreshing: boolean })
// Sync User Role to Redux
useEffect(() => {
if (profile) {
dispatch(setEntityUser({ role: profile.idUserRole, admin: false }))
dispatch(setEntityUser({ role: profile.idUserRole, admin: false, isApprover: profile.isApprover ?? false }))
}
}, [profile, dispatch])

View File

@@ -30,6 +30,10 @@ export function InputForm({ label, value, placeholder, onChange, info, disable,
const { colors } = useTheme();
if (itemLeft != undefined || itemRight != undefined) {
const hasBothItems = itemLeft != undefined && itemRight != undefined;
const baseInputWidth = width ? lebar * width / 100 : lebar * 0.78;
// When both icons present, shrink TextInput by right icon size to keep container width stable
const textInputWidth = hasBothItems ? baseInputWidth - 30 : baseInputWidth;
return (
<View style={[mb && Styles.mb10]}>
{
@@ -42,7 +46,7 @@ export function InputForm({ label, value, placeholder, onChange, info, disable,
}
<View style={[
Styles.inputRoundForm,
itemRight != undefined ? Styles.inputRoundFormRight : Styles.inputRoundFormLeft,
hasBothItems ? Styles.inputRoundFormLeft : itemRight != undefined ? Styles.inputRoundFormRight : Styles.inputRoundFormLeft,
multiline && { alignItems: 'flex-end' },
round && Styles.round30,
{
@@ -50,12 +54,11 @@ export function InputForm({ label, value, placeholder, onChange, info, disable,
},
error ? { borderColor: colors.error } : { borderColor: colors.icon + '20' },
Platform.OS == 'ios' ? { paddingVertical: 10 } : { paddingVertical: 0, minHeight: 40 },
{ alignItems: 'center' },
multiline
? { alignItems: "flex-end" }
: { alignItems: "center" },
]}>
{itemRight != undefined ? itemRight : itemLeft}
{hasBothItems ? itemLeft : (itemRight != undefined ? itemRight : itemLeft)}
<TextInput
editable={!disable}
value={value}
@@ -68,10 +71,11 @@ export function InputForm({ label, value, placeholder, onChange, info, disable,
style={[
Styles.mh05,
multiline && { height: '100%', maxHeight: 100 },
{ width: width ? lebar * width / 100 : lebar * 0.78, color: colors.text },
{ width: textInputWidth, color: colors.text },
Platform.OS == 'ios' ? { paddingVertical: 1, paddingTop: 4 } : { paddingVertical: 0 },
]}
/>
{hasBothItems && itemRight}
</View>
{error && (<Text style={[Styles.textInformation, { color: colors.error }, Styles.mt05]}>{errorText}</Text>)}
{info != undefined && (<Text style={[Styles.textInformation, { color: colors.dimmed }, Styles.mt05]}>{info}</Text>)}

View File

@@ -1,19 +1,42 @@
import { useTheme } from "@/providers/ThemeProvider";
import { Feather } from "@expo/vector-icons";
import { useState } from "react";
import { TouchableOpacity } from "react-native";
import { InputForm } from "./inputForm";
export default function InputSearch({ onChange, width, value, bg }: { onChange?: (val: string) => void, width?: number, value?: string, bg?: string }) {
const { colors } = useTheme();
const [internalValue, setInternalValue] = useState(value ?? "");
const displayValue = value !== undefined ? value : internalValue;
const handleChange = (val: string) => {
setInternalValue(val);
onChange?.(val);
};
const handleClear = () => {
setInternalValue("");
onChange?.("");
};
return (
<InputForm
type="default"
placeholder="Pencarian"
round
itemLeft={<Feather name="search" size={20} color={colors.dimmed} />}
onChange={onChange}
itemRight={
displayValue ? (
<TouchableOpacity onPress={handleClear}>
<Feather name="x" size={20} color={colors.dimmed} />
</TouchableOpacity>
) : undefined
}
onChange={handleChange}
width={width}
bg={bg}
value={value}
value={displayValue}
mb={false}
/>
)

View File

@@ -1,62 +1,192 @@
import Styles from "@/constants/Styles";
import { useTheme } from "@/providers/ThemeProvider";
import { MaterialCommunityIcons } from "@expo/vector-icons";
import { Pressable, View } from "react-native";
import { useState } from "react";
import { LayoutChangeEvent, Pressable, View } from "react-native";
import Text from "./Text";
type FileItem = {
name: string
extension: string
}
type Props = {
done?: boolean
status?: number // 0=belum selesai, 1=selesai, 2=menunggu persetujuan
title: string
dateStart: string
dateEnd: string
files?: FileItem[]
onPress?: () => void
}
export default function ItemSectionTanggalTugas({ done, title, dateStart, dateEnd, onPress }: Props) {
const { colors } = useTheme();
const CHAR_W = 6.5
const ICON_W = 17
const PAD_H = 16
const GAP = 6
const PLUS_W = 72
function estimateChipWidth(label: string) {
return PAD_H + ICON_W + label.length * CHAR_W
}
function getVisibleChips(files: FileItem[], containerWidth: number) {
if (containerWidth === 0) return { visible: [], extra: files.length }
let used = 0
const visible: FileItem[] = []
for (let i = 0; i < files.length; i++) {
const label = `${files[i].name}.${files[i].extension}`
const chipW = estimateChipWidth(label)
const isLast = i === files.length - 1
const plusChipW = isLast ? 0 : PLUS_W + GAP
const gapW = visible.length > 0 ? GAP : 0
if (used + gapW + chipW + plusChipW <= containerWidth) {
visible.push(files[i])
used += gapW + chipW
} else {
break
}
}
return { visible, extra: files.length - visible.length }
}
function getFileIcon(extension: string): keyof typeof MaterialCommunityIcons.glyphMap {
const ext = extension.toLowerCase()
if (['jpg', 'jpeg', 'png', 'gif', 'webp', 'heic', 'heif'].includes(ext)) return 'image-outline'
if (ext === 'pdf') return 'file-pdf-box'
if (['mp4', 'mov', 'avi', 'mkv'].includes(ext)) return 'video-outline'
if (['doc', 'docx'].includes(ext)) return 'file-word-outline'
if (['xls', 'xlsx'].includes(ext)) return 'file-excel-outline'
if (['zip', 'rar', '7z'].includes(ext)) return 'zip-box-outline'
return 'file-outline'
}
const AMBER = '#FFA94D'
function getStatusStyle(status: number | undefined, successColor: string, dimmed: string) {
if (status === 1) return { accent: successColor, badge: successColor + '25', text: successColor, label: 'Selesai' }
if (status === 2) return { accent: AMBER, badge: AMBER + '25', text: AMBER, label: 'Menunggu Persetujuan' }
return { accent: dimmed + '80', badge: dimmed + '18', text: dimmed, label: 'Belum Selesai' }
}
export default function ItemSectionTanggalTugas({ status, title, dateStart, dateEnd, files = [], onPress }: Props) {
const { colors, activeTheme } = useTheme()
const [containerWidth, setContainerWidth] = useState(0)
const { visible, extra } = getVisibleChips(files, containerWidth)
function onChipsLayout(e: LayoutChangeEvent) {
const w = e.nativeEvent.layout.width
if (w !== containerWidth) setContainerWidth(w)
}
const dimmed = colors.dimmed.slice(0, 7)
const successColor = activeTheme === 'dark' ? '#51CF66' : colors.success
const statusStyle = getStatusStyle(status, successColor, dimmed)
return (
<Pressable style={[Styles.mb15, { borderBottomColor: colors.icon + '20', borderBottomWidth: 1 }]} onPress={onPress}>
<View style={[Styles.rowItemsCenter]}>
{
done != undefined ?
done ?
<>
<MaterialCommunityIcons name="checkbox-marked-circle-outline" size={22} color={colors.text} style={[Styles.mr10]} />
<Text>Selesai</Text>
</>
:
<>
<MaterialCommunityIcons name="checkbox-blank-circle-outline" size={22} color={colors.text} style={[Styles.mr10]} />
<Text>Belum Selesai</Text>
</>
:
<></>
}
<Pressable
onPress={onPress}
style={{
flexDirection: 'row',
borderRadius: 10,
overflow: 'hidden',
borderWidth: 1,
borderColor: colors.icon + '18',
backgroundColor: colors.card,
marginBottom: 10,
}}
>
{/* Accent bar kiri */}
{status !== undefined && (
<View style={{ width: 4, backgroundColor: statusStyle.accent }} />
)}
</View>
<View style={[Styles.wrapPaper, Styles.noShadow, Styles.borderAll, Styles.mv10, Styles.p10, { backgroundColor: colors.card, borderColor: colors.icon + '20' }]}>
<View style={[Styles.rowItemsCenter, { alignItems: 'flex-start' }]}>
<MaterialCommunityIcons name="file-table-outline" size={25} color={colors.text} style={[Styles.mr10]} />
<View style={[Styles.w90]}>
<Text style={[Styles.textDefault]}>{title}</Text>
</View>
{/* Konten */}
<View style={{ flex: 1, padding: 12 }}>
{/* Judul + badge status */}
<View style={{ flexDirection: 'row', justifyContent: 'space-between', alignItems: 'flex-start', marginBottom: 8 }}>
<Text style={[Styles.textDefault, { flex: 1, marginRight: 8 }]}>{title}</Text>
{status !== undefined && (
<View style={{
backgroundColor: statusStyle.badge,
borderRadius: 20,
paddingHorizontal: 8,
paddingVertical: 3,
alignSelf: 'flex-start',
}}>
<Text style={[Styles.textSmallSemiBold, { color: statusStyle.text }]}>
{statusStyle.label}
</Text>
</View>
)}
</View>
</View>
<View style={[Styles.rowSpaceBetween, Styles.mb15]}>
<View style={[{ width: '48%' }]}>
<Text style={[Styles.mb05]}>Tanggal Mulai</Text>
<View style={[Styles.wrapPaper, Styles.noShadow, Styles.borderAll, Styles.p10, { backgroundColor: colors.card, borderColor: colors.icon + '20' }]}>
<Text style={{ textAlign: 'center' }}>{dateStart}</Text>
</View>
{/* Tanggal */}
<View style={{ flexDirection: 'row', alignItems: 'center', marginBottom: files.length > 0 ? 8 : 0 }}>
<MaterialCommunityIcons name="calendar-outline" size={13} color={colors.dimmed} style={{ marginRight: 4 }} />
<Text style={[Styles.textSmallSemiBold, { color: colors.dimmed }]}>{dateStart}</Text>
<MaterialCommunityIcons name="arrow-right" size={13} color={colors.dimmed} style={{ marginHorizontal: 4 }} />
<Text style={[Styles.textSmallSemiBold, { color: colors.dimmed }]}>{dateEnd}</Text>
</View>
<View style={[{ width: '48%' }]}>
<Text style={[Styles.mb05]}>Tanggal Berakhir</Text>
<View style={[Styles.wrapPaper, Styles.noShadow, Styles.borderAll, Styles.p10, { backgroundColor: colors.card, borderColor: colors.icon + '20' }]}>
<Text style={{ textAlign: 'center' }}>{dateEnd}</Text>
{/* Chips lampiran */}
{files.length > 0 && (
<View
style={{ flexDirection: 'row', gap: GAP, overflow: 'hidden' }}
onLayout={onChipsLayout}
>
{visible.map((file, index) => {
const label = `${file.name}.${file.extension}`
const chipW = Math.min(estimateChipWidth(label), containerWidth * 0.55)
return (
<View
key={index}
style={{
flexDirection: 'row',
alignItems: 'center',
backgroundColor: dimmed + '18',
borderRadius: 6,
paddingHorizontal: 8,
paddingVertical: 3,
width: chipW,
}}
>
<MaterialCommunityIcons
name={getFileIcon(file.extension)}
size={13}
color={colors.dimmed}
style={{ marginRight: 4 }}
/>
<Text
style={[Styles.textSmallSemiBold, { color: colors.dimmed, flex: 1 }]}
numberOfLines={1}
ellipsizeMode="tail"
>
{label}
</Text>
</View>
)
})}
{extra > 0 && (
<View style={{
backgroundColor: dimmed + '18',
borderRadius: 6,
paddingHorizontal: 8,
paddingVertical: 3,
}}>
<Text style={[Styles.textSmallSemiBold, { color: colors.dimmed }]}>
+{extra} lainnya
</Text>
</View>
)}
</View>
</View>
)}
</View>
</Pressable>
)
}
}

View File

@@ -1,5 +1,5 @@
import Styles from "@/constants/Styles"
import { apiDeleteUser } from "@/lib/api"
import { apiDeleteUser, apiToggleApprover } from "@/lib/api"
import { setUpdateMember } from "@/lib/memberSlice"
import { useAuthSession } from "@/providers/AuthProvider"
import { useTheme } from "@/providers/ThemeProvider"
@@ -16,14 +16,17 @@ import MenuItemRow from "../menuItemRow"
type Props = {
active: any,
id: string
id: string,
isApprover: boolean,
}
export default function HeaderRightMemberDetail({ active, id }: Props) {
export default function HeaderRightMemberDetail({ active, id, isApprover }: Props) {
const { token, decryptToken } = useAuthSession()
const [isVisible, setVisible] = useState(false)
const update = useSelector((state: any) => state.memberUpdate)
const [showModal, setShowModal] = useState(false)
const entityUser = useSelector((state: any) => state.user)
const [showModalActive, setShowModalActive] = useState(false)
const [showModalApprover, setShowModalApprover] = useState(false)
const { colors } = useTheme();
const dispatch = useDispatch()
@@ -37,17 +40,36 @@ export default function HeaderRightMemberDetail({ active, id }: Props) {
} else {
Toast.show({ type: 'small', text1: response.message, })
}
} catch (error : any ) {
} catch (error: any) {
console.error(error);
const message = error?.response?.data?.message || "Gagal mengupdate data"
Toast.show({ type: 'small', text1: message })
} finally {
setVisible(false)
}
}
async function handleToggleApprover() {
try {
const hasil = await decryptToken(String(token?.current))
const response = await apiToggleApprover({ user: hasil, isApprover: !isApprover }, id)
if (response.success) {
Toast.show({ type: 'small', text1: response.message })
dispatch(setUpdateMember(!update))
} else {
Toast.show({ type: 'small', text1: response.message })
}
} catch (error: any) {
console.error(error);
const message = error?.response?.data?.message || "Gagal mengupdate data"
Toast.show({ type: 'small', text1: message })
} finally {
setShowModalApprover(false)
}
}
const canManageApprover = ['supadmin', 'developer'].includes(entityUser.role)
return (
<>
<ButtonMenuHeader onPress={() => { setVisible(true) }} />
@@ -55,12 +77,10 @@ export default function HeaderRightMemberDetail({ active, id }: Props) {
<View style={Styles.rowItemsCenter}>
<MenuItemRow
icon={<MaterialCommunityIcons name="toggle-switch-off-outline" color={colors.text} size={25} />}
title={active ? "Non Aktifkan" : "Aktifkan"}
title={active ? "Nonaktifkan" : "Aktifkan"}
onPress={() => {
setVisible(false)
setTimeout(() => {
setShowModal(true)
}, 600)
setTimeout(() => setShowModalActive(true), 600)
}}
/>
<MenuItemRow
@@ -71,18 +91,39 @@ export default function HeaderRightMemberDetail({ active, id }: Props) {
router.push(`/member/edit/${id}`)
}}
/>
{canManageApprover && (
<MenuItemRow
icon={<MaterialCommunityIcons name="shield-check-outline" color={colors.text} size={25} />}
title={isApprover ? "Revoke Approver" : "Jadikan Approver"}
color={colors.text}
onPress={() => {
setVisible(false)
setTimeout(() => setShowModalApprover(true), 600)
}}
/>
)}
</View>
</DrawerBottom>
<ModalConfirmation
visible={showModal}
visible={showModalActive}
title="Konfirmasi"
message={active ? 'Apakah anda yakin ingin menonaktifkan user?' : 'Apakah anda yakin ingin mengaktifkan user?'}
message={active ? 'Apakah anda yakin ingin menonaktifkan anggota ini?' : 'Apakah anda yakin ingin mengaktifkan anggota ini?'}
onConfirm={() => {
setShowModal(false)
setShowModalActive(false)
handleActive()
}}
onCancel={() => setShowModal(false)}
onCancel={() => setShowModalActive(false)}
confirmText="Konfirmasi"
cancelText="Batal"
/>
<ModalConfirmation
visible={showModalApprover}
title="Konfirmasi"
message={isApprover ? 'Apakah anda yakin ingin mencabut status approver user ini?' : 'Apakah anda yakin ingin menjadikan user ini sebagai approver?'}
onConfirm={handleToggleApprover}
onCancel={() => setShowModalApprover(false)}
confirmText="Konfirmasi"
cancelText="Batal"
/>

View File

@@ -108,12 +108,12 @@ export default function ModalSelect({ open, close, title, category, idParent, on
setChooseValue({ ...chooseValue, val: valChoose })
}, [dispatch, open, search]);
function onChoose(val: string, label: string, img?: string) {
function onChoose(val: string, label: string, img?: string, position?: string) {
if (category == "member") {
if (selectMember.some((i: any) => i.idUser == val)) {
setSelectMember(selectMember.filter((i: any) => i.idUser != val))
} else {
setSelectMember([...selectMember, { idUser: val, name: label, img }])
setSelectMember([...selectMember, { idUser: val, name: label, img, position }])
}
} else {
setChooseValue({ val, label })
@@ -144,7 +144,7 @@ export default function ModalSelect({ open, close, title, category, idParent, on
key={index}
label={item.name}
src={`${ConstEnv.url_storage}/files/${item.img}`}
onClick={() => onChoose(item.idUser, item.name, item.img)}
onClick={() => onChoose(item.idUser, item.name, item.img, item.position)}
/>
))
}
@@ -162,7 +162,7 @@ export default function ModalSelect({ open, close, title, category, idParent, on
category != 'status-task' ?
data.length > 0 ?
data.map((item: any, index: any) => (
<Pressable key={index} style={[Styles.itemSelectModal, {borderColor:colors.icon+'20'}]} onPress={() => { onChoose(item.id, item.name, item.img) }}>
<Pressable key={index} style={[Styles.itemSelectModal, {borderColor:colors.icon+'20'}]} onPress={() => { onChoose(item.id, item.name, item.img, item.position) }}>
{
category == 'member'
?

View File

@@ -0,0 +1,100 @@
import { urlCompleted } from "@/lib/fun_urlCompleted";
import { useTheme } from "@/providers/ThemeProvider";
import { MaterialCommunityIcons } from "@expo/vector-icons";
import { Linking, Pressable, View } from "react-native";
import Text from "../Text";
import Styles from "@/constants/Styles";
type Props = {
link: string
canDelete: boolean
onLongPress: () => void
}
type DomainConfig = {
icon: keyof typeof MaterialCommunityIcons.glyphMap
color: string
label: string
}
function getDomainConfig(url: string): DomainConfig {
try {
const hostname = new URL(urlCompleted(url)).hostname.replace('www.', '')
if (hostname.includes('youtube.com') || hostname.includes('youtu.be'))
return { icon: 'youtube', color: '#FF0000', label: 'YouTube' }
if (hostname.includes('drive.google.com'))
return { icon: 'google-drive', color: '#4285F4', label: 'Google Drive' }
if (hostname.includes('docs.google.com'))
return { icon: 'google', color: '#4285F4', label: 'Google Docs' }
if (hostname.includes('sheets.google.com'))
return { icon: 'google-spreadsheet', color: '#0F9D58', label: 'Google Sheets' }
if (hostname.includes('github.com'))
return { icon: 'github', color: '#24292E', label: 'GitHub' }
if (hostname.includes('wa.me') || hostname.includes('whatsapp.com'))
return { icon: 'whatsapp', color: '#25D366', label: 'WhatsApp' }
if (hostname.includes('instagram.com'))
return { icon: 'instagram', color: '#E1306C', label: 'Instagram' }
if (hostname.includes('facebook.com'))
return { icon: 'facebook', color: '#1877F2', label: 'Facebook' }
if (hostname.includes('figma.com'))
return { icon: 'vector-bezier', color: '#F24E1E', label: 'Figma' }
if (hostname.includes('notion.so'))
return { icon: 'notebook-outline', color: '#000000', label: 'Notion' }
return { icon: 'link-variant', color: '#6366F1', label: hostname }
} catch {
return { icon: 'link-variant', color: '#6366F1', label: url }
}
}
function getDisplayUrl(url: string) {
try {
const full = urlCompleted(url)
const parsed = new URL(full)
const path = parsed.pathname + parsed.search
return path.length > 1 ? path : ''
} catch {
return ''
}
}
export default function ItemSectionLink({ link, canDelete, onLongPress }: Props) {
const { colors, activeTheme } = useTheme()
const config = getDomainConfig(link)
const displayPath = getDisplayUrl(link)
const iconBg = activeTheme === 'dark' ? config.color + '25' : config.color + '15'
const iconColor = activeTheme === 'dark' && config.color === '#24292E' ? '#ECEDEE' : config.color
return (
<Pressable
onPress={() => Linking.openURL(urlCompleted(link))}
onLongPress={canDelete ? onLongPress : undefined}
style={({ pressed }) => ([
Styles.fileCard,
{
width: '100%',
marginBottom: 10,
borderColor: colors.icon + '18',
backgroundColor: pressed ? colors.icon + '10' : colors.card,
},
])}
>
<View style={[Styles.sectionIconBox, { backgroundColor: iconBg }]}>
<MaterialCommunityIcons name={config.icon} size={18} color={iconColor} />
</View>
<View style={Styles.flex1}>
<Text style={[Styles.textDefaultSemiBold, { color: colors.text }]} numberOfLines={1}>
{config.label}
</Text>
{displayPath.length > 0 && (
<Text style={[Styles.textSmallSemiBold, { color: colors.dimmed, marginTop: 2 }]} numberOfLines={1} ellipsizeMode="tail">
{displayPath}
</Text>
)}
</View>
<MaterialCommunityIcons name="arrow-top-right" size={16} color={colors.dimmed} />
</Pressable>
)
}

View File

@@ -10,19 +10,17 @@ import { startActivityAsync } from 'expo-intent-launcher';
import { useLocalSearchParams } from "expo-router";
import * as Sharing from 'expo-sharing';
import { useEffect, useState } from "react";
import { Alert, Platform, View } from "react-native";
import { Alert, Platform, Pressable, View } from "react-native";
import * as mime from 'react-native-mime-types';
import Toast from "react-native-toast-message";
import { useDispatch, useSelector } from "react-redux";
import ModalConfirmation from "../ModalConfirmation";
import BorderBottomItem from "../borderBottomItem";
import DrawerBottom from "../drawerBottom";
import MenuItemRow from "../menuItemRow";
import ModalConfirmation from "../ModalConfirmation";
import ModalLoading from "../modalLoading";
import Skeleton from "../skeleton";
import Text from "../Text";
type Props = {
id: string
name: string
@@ -30,6 +28,28 @@ type Props = {
idStorage: string
}
function getFileIcon(extension: string): keyof typeof MaterialCommunityIcons.glyphMap {
const ext = extension.toLowerCase()
if (['jpg', 'jpeg', 'png', 'gif', 'webp', 'heic', 'heif'].includes(ext)) return 'image-outline'
if (ext === 'pdf') return 'file-pdf-box'
if (['mp4', 'mov', 'avi', 'mkv'].includes(ext)) return 'video-outline'
if (['doc', 'docx'].includes(ext)) return 'file-word-outline'
if (['xls', 'xlsx'].includes(ext)) return 'file-excel-outline'
if (['zip', 'rar', '7z'].includes(ext)) return 'zip-box-outline'
return 'file-outline'
}
function getFileColor(extension: string): string {
const ext = extension.toLowerCase()
if (['jpg', 'jpeg', 'png', 'gif', 'webp', 'heic', 'heif'].includes(ext)) return '#339AF0'
if (ext === 'pdf') return '#F03E3E'
if (['mp4', 'mov', 'avi', 'mkv'].includes(ext)) return '#AE3EC9'
if (['doc', 'docx'].includes(ext)) return '#1C7ED6'
if (['xls', 'xlsx'].includes(ext)) return '#2F9E44'
if (['zip', 'rar', '7z'].includes(ext)) return '#E8590C'
return '#868E96'
}
export default function SectionFile({ status, member, refreshing }: { status: number | undefined, member: boolean, refreshing?: boolean }) {
const { colors } = useTheme();
const entityUser = useSelector((state: any) => state.user)
@@ -40,7 +60,7 @@ export default function SectionFile({ status, member, refreshing }: { status: nu
const update = useSelector((state: any) => state.projectUpdate)
const dispatch = useDispatch()
const [loading, setLoading] = useState(true)
const arrSkeleton = Array.from({ length: 3 })
const arrSkeleton = Array.from({ length: 4 })
const [selectFile, setSelectFile] = useState<Props | null>(null)
const [showDeleteModal, setShowDeleteModal] = useState(false)
const [loadingOpen, setLoadingOpen] = useState(false)
@@ -49,11 +69,7 @@ export default function SectionFile({ status, member, refreshing }: { status: nu
try {
setLoading(loading)
const hasil = await decryptToken(String(token?.current));
const response = await apiGetProjectOne({
user: hasil,
cat: "file",
id: id,
});
const response = await apiGetProjectOne({ user: hasil, cat: "file", id });
setData(response.data);
} catch (error) {
console.error(error);
@@ -62,110 +78,90 @@ export default function SectionFile({ status, member, refreshing }: { status: nu
}
}
useEffect(() => {
handleLoad(false);
}, [update.file]);
useEffect(() => {
if (refreshing)
handleLoad(false);
}, [refreshing]);
useEffect(() => {
handleLoad(true);
}, []);
useEffect(() => { handleLoad(false) }, [update.file]);
useEffect(() => { if (refreshing) handleLoad(false) }, [refreshing]);
useEffect(() => { handleLoad(true) }, []);
async function handleDelete() {
try {
const hasil = await decryptToken(String(token?.current));
const response = await apiDeleteFileProject({ user: hasil }, String(selectFile?.id));
if (response.success) {
Toast.show({ type: 'small', text1: 'Berhasil menghapus file', })
Toast.show({ type: 'small', text1: 'Berhasil menghapus file' })
dispatch(setUpdateProject({ ...update, file: !update.file }))
} else {
Toast.show({ type: 'small', text1: response.message, })
Toast.show({ type: 'small', text1: response.message })
}
} catch (error : any ) {
console.error(error);
const message = error?.response?.data?.message || "Gagal menghapus file"
Toast.show({ type: 'small', text1: message })
} catch (error: any) {
Toast.show({ type: 'small', text1: error?.response?.data?.message || "Gagal menghapus file" })
} finally {
setModal(false)
}
}
const openFile = () => {
setModal(false)
setLoadingOpen(true)
let remoteUrl = ConstEnv.url_storage + '/files/' + selectFile?.idStorage;
const fileName = selectFile?.name + '.' + selectFile?.extension;
let localPath = `${FileSystem.documentDirectory}/${fileName}`;
const remoteUrl = ConstEnv.url_storage + '/files/' + selectFile?.idStorage
const fileName = selectFile?.name + '.' + selectFile?.extension
const localPath = `${FileSystem.documentDirectory}/${fileName}`
const mimeType = mime.lookup(fileName)
FileSystem.downloadAsync(remoteUrl, localPath).then(async ({ uri }) => {
const contentURL = await FileSystem.getContentUriAsync(uri);
const contentURL = await FileSystem.getContentUriAsync(uri)
try {
if (Platform.OS == 'android') {
// open with android intent
await startActivityAsync(
'android.intent.action.VIEW',
{
data: contentURL,
flags: 1,
type: mimeType as string,
}
);
// or
// Sharing.shareAsync(localPath);
} else if (Platform.OS == 'ios') {
Sharing.shareAsync(localPath);
if (Platform.OS === 'android') {
await startActivityAsync('android.intent.action.VIEW', { data: contentURL, flags: 1, type: mimeType as string })
} else {
Sharing.shareAsync(localPath)
}
} catch (error) {
Alert.alert('INFO', 'Gagal membuka file, tidak ada aplikasi yang dapat membuka file ini');
} catch {
Alert.alert('INFO', 'Gagal membuka file, tidak ada aplikasi yang dapat membuka file ini')
} finally {
setLoadingOpen(false)
}
});
};
})
}
return (
<>
<ModalLoading isVisible={loadingOpen} setVisible={setLoadingOpen} />
<View style={[Styles.mb15]}>
<Text style={[Styles.textDefaultSemiBold, Styles.mv05]}>File</Text>
<View style={[Styles.wrapPaper, { backgroundColor: colors.card, borderColor: colors.background }]}>
{
loading ?
arrSkeleton.map((item, index) => {
return (
<Skeleton key={index} width={100} height={40} widthType="percent" borderRadius={10} />
)
})
:
data.length > 0 ?
data.map((item, index) => {
return (
<BorderBottomItem
key={index}
borderType="all"
icon={<MaterialCommunityIcons name="file-outline" size={25} color={colors.text} />}
title={item.name + '.' + item.extension}
titleWeight="normal"
onPress={() => { setSelectFile(item); setModal(true) }}
/>
)
})
:
<Text style={[Styles.textDefault, { textAlign: 'center', color: colors.dimmed }]}>Tidak ada file</Text>
}
</View>
{loading ? (
<View style={Styles.fileGrid}>
{arrSkeleton.map((_, index) => (
<Skeleton key={index} width={48} height={68} widthType="percent" borderRadius={10} />
))}
</View>
) : data.length > 0 ? (
<View style={Styles.fileGrid}>
{data.map((item, index) => {
const iconName = getFileIcon(item.extension)
const iconColor = getFileColor(item.extension)
return (
<Pressable
key={index}
onPress={() => { setSelectFile(item); setModal(true) }}
style={[Styles.fileCard, { backgroundColor: colors.card, borderColor: colors.icon + '18' }]}
>
<View style={[Styles.sectionIconBox, { backgroundColor: iconColor + '20' }]}>
<MaterialCommunityIcons name={iconName} size={18} color={iconColor} />
</View>
<View style={Styles.flex1}>
<Text style={Styles.textDefault} numberOfLines={1}>{item.name}</Text>
<Text style={[Styles.textSmallSemiBold, { color: colors.dimmed }]}>
{item.extension.toUpperCase()}
</Text>
</View>
</Pressable>
)
})}
</View>
) : (
<Text style={[Styles.textDefault, { textAlign: 'center', color: colors.dimmed }]}>Tidak ada file</Text>
)}
</View>
<DrawerBottom animation="slide" isVisible={isModal} setVisible={setModal} title="Menu">
@@ -173,26 +169,20 @@ export default function SectionFile({ status, member, refreshing }: { status: nu
<MenuItemRow
icon={<MaterialCommunityIcons name="file-eye" color={colors.text} size={25} />}
title="Lihat / Share"
onPress={() => {
openFile()
}}
onPress={openFile}
/>
{
!member && (entityUser.role == "user" || entityUser.role == "coadmin") ? <></>
:
<MenuItemRow
icon={<Ionicons name="trash-outline" color={colors.text} size={25} />}
title="Hapus"
disabled={status == 3}
onPress={() => {
if (status == 3) return
setModal(false)
setTimeout(() => {
setShowDeleteModal(true)
}, 600)
}}
/>
}
{(!member && (entityUser.role === "user" || entityUser.role === "coadmin")) ? null : (
<MenuItemRow
icon={<Ionicons name="trash-outline" color={colors.text} size={25} />}
title="Hapus"
disabled={status === 3}
onPress={() => {
if (status === 3) return
setModal(false)
setTimeout(() => setShowDeleteModal(true), 600)
}}
/>
)}
</View>
</DrawerBottom>
@@ -200,14 +190,11 @@ export default function SectionFile({ status, member, refreshing }: { status: nu
visible={showDeleteModal}
title="Konfirmasi"
message="Apakah Anda yakin ingin menghapus file ini? File yang dihapus tidak dapat dikembalikan"
onConfirm={() => {
setShowDeleteModal(false)
handleDelete()
}}
onConfirm={() => { setShowDeleteModal(false); handleDelete() }}
onCancel={() => setShowDeleteModal(false)}
confirmText="Hapus"
cancelText="Batal"
/>
</>
)
}
}

View File

@@ -1,20 +1,19 @@
import Styles from "@/constants/Styles";
import { apiDeleteLinkProject, apiGetProjectOne } from "@/lib/api";
import { urlCompleted } from "@/lib/fun_urlCompleted";
import { setUpdateProject } from "@/lib/projectUpdate";
import { useAuthSession } from "@/providers/AuthProvider";
import { useTheme } from "@/providers/ThemeProvider";
import { Feather, Ionicons } from "@expo/vector-icons";
import { Ionicons } from "@expo/vector-icons";
import { useLocalSearchParams } from "expo-router";
import { useEffect, useState } from "react";
import { Linking, View } from "react-native";
import { View } from "react-native";
import Toast from "react-native-toast-message";
import { useDispatch, useSelector } from "react-redux";
import ModalConfirmation from "../ModalConfirmation";
import BorderBottomItem from "../borderBottomItem";
import DrawerBottom from "../drawerBottom";
import MenuItemRow from "../menuItemRow";
import Text from "../Text";
import ItemSectionLink from "./itemSectionLink";
type Props = {
@@ -87,17 +86,16 @@ export default function SectionLink({ status, member, refreshing }: { status: nu
<>
<View style={[Styles.mb15]}>
<Text style={[Styles.textDefaultSemiBold, Styles.mv05]}>Link</Text>
<View style={[Styles.wrapPaper, { backgroundColor: colors.card, borderColor: colors.background }]}>
<View>
{
data.map((item, index) => {
const canDelete = member || (entityUser.role !== "user" && entityUser.role !== "coadmin")
return (
<BorderBottomItem
<ItemSectionLink
key={index}
borderType="all"
icon={<Feather name="link" size={25} color={colors.text} />}
title={item.link}
titleWeight="normal"
onPress={() => { setSelectLink(item); setModal(true) }}
link={item.link}
canDelete={canDelete && status !== 3}
onLongPress={() => { setSelectLink(item); setModal(true) }}
/>
)
})
@@ -108,28 +106,13 @@ export default function SectionLink({ status, member, refreshing }: { status: nu
<DrawerBottom animation="slide" isVisible={isModal} setVisible={setModal} title="Menu">
<View style={Styles.rowItemsCenter}>
<MenuItemRow
icon={<Feather name="external-link" color={colors.text} size={25} />}
title="Buka Link"
icon={<Ionicons name="trash-outline" color={colors.text} size={25} />}
title="Hapus Link"
onPress={() => {
Linking.openURL(urlCompleted(String(selectLink?.link)))
setModal(false)
setTimeout(() => setShowDeleteModal(true), 600)
}}
/>
{
!member && (entityUser.role == "user" || entityUser.role == "coadmin") ? <></>
:
<MenuItemRow
icon={<Ionicons name="trash-outline" color={colors.text} size={25} />}
title="Hapus"
disabled={status == 3}
onPress={() => {
if (status == 3) return
setModal(false)
setTimeout(() => {
setShowDeleteModal(true)
}, 600)
}}
/>
}
</View>
</DrawerBottom>

View File

@@ -10,7 +10,7 @@ import ItemSectionTanggalTugas from "../itemSectionTanggalTugas";
import MenuItemRow from "../menuItemRow";
import Text from "../Text";
export default function SectionListAddTask() {
export default function SectionListAddTask({ showTitle = true }: { showTitle?: boolean }) {
const { colors } = useTheme();
const taskCreate = useSelector((state: any) => state.taskCreate)
const [select, setSelect] = useState<any>(null)
@@ -22,42 +22,32 @@ export default function SectionListAddTask() {
setModal(false)
}
const items = taskCreate.map((item: { status: number; title: string; dateStart: string; dateEnd: string; }, index: Key | null | undefined) => (
<ItemSectionTanggalTugas
key={index}
title={item.title}
dateStart={item.dateStart}
dateEnd={item.dateEnd}
onPress={() => {
setSelect(index)
setModal(true)
}}
/>
))
return (
<>
{
taskCreate.length > 0
&&
{taskCreate.length > 0 && (
<>
<View style={[Styles.mb15, Styles.mt10]}>
<Text style={[Styles.textDefaultSemiBold, Styles.mv05]}>
Tanggal & Tugas
</Text>
<View style={[Styles.wrapPaper, { backgroundColor: colors.card, borderColor: colors.background }]}>
{
taskCreate.map((item: { status: number; title: string; dateStart: string; dateEnd: string; }, index: Key | null | undefined) => {
return (
<ItemSectionTanggalTugas
key={index}
title={item.title}
dateStart={item.dateStart}
dateEnd={item.dateEnd}
onPress={() => {
setSelect(index)
setModal(true)
}}
/>
);
})
}
{showTitle ? (
<View style={[Styles.mb15, Styles.mt10]}>
<Text style={[Styles.textDefaultSemiBold, Styles.mv05]}>Tanggal & Tugas</Text>
{items}
</View>
</View>
<DrawerBottom
animation="slide"
isVisible={isModal}
setVisible={setModal}
title="Menu"
>
) : (
<View>{items}</View>
)}
<DrawerBottom animation="slide" isVisible={isModal} setVisible={setModal} title="Menu">
<View style={Styles.rowItemsCenter}>
<MenuItemRow
icon={<Ionicons name="trash-outline" color={colors.text} size={25} />}
@@ -67,7 +57,7 @@ export default function SectionListAddTask() {
</View>
</DrawerBottom>
</>
}
)}
</>
)
}

View File

@@ -7,15 +7,14 @@ import { useTheme } from "@/providers/ThemeProvider";
import { MaterialCommunityIcons } from "@expo/vector-icons";
import { router, useLocalSearchParams } from "expo-router";
import { useEffect, useState } from "react";
import { View } from "react-native";
import { Pressable, View } from "react-native";
import Toast from "react-native-toast-message";
import { useDispatch, useSelector } from "react-redux";
import ModalConfirmation from "../ModalConfirmation";
import BorderBottomItem from "../borderBottomItem";
import DrawerBottom from "../drawerBottom";
import ImageUser from "../imageNew";
import MenuItemRow from "../menuItemRow";
import SkeletonTwoItem from "../skeletonTwoItem";
import ModalConfirmation from "../ModalConfirmation";
import Skeleton from "../skeleton";
import Text from "../Text";
type Props = {
@@ -35,26 +34,17 @@ export default function SectionMember({ status, refreshing }: { status: number |
const [isModal, setModal] = useState(false);
const { token, decryptToken } = useAuthSession();
const { id } = useLocalSearchParams<{ id: string }>();
const [selectLink, setSelectLink] = useState<Props | null>(null);
const [showDeleteModal, setShowDeleteModal] = useState(false);
const [data, setData] = useState<Props[]>([]);
const [loading, setLoading] = useState(true)
const arrSkeleton = Array.from({ length: 3 })
const [memberChoose, setMemberChoose] = useState({
id: '',
name: '',
})
const arrSkeleton = Array.from({ length: 4 })
const [memberChoose, setMemberChoose] = useState({ id: '', name: '' })
async function handleLoad(loading: boolean) {
try {
setLoading(loading)
const hasil = await decryptToken(String(token?.current));
const response = await apiGetProjectOne({
user: hasil,
cat: "member",
id: id,
});
const response = await apiGetProjectOne({ user: hasil, cat: "member", id });
setData(response.data);
} catch (error) {
console.error(error);
@@ -63,36 +53,21 @@ export default function SectionMember({ status, refreshing }: { status: number |
}
}
useEffect(() => {
handleLoad(false);
}, [update.member]);
useEffect(() => {
if (refreshing)
handleLoad(false);
}, [refreshing]);
useEffect(() => {
handleLoad(true);
}, []);
useEffect(() => { handleLoad(false) }, [update.member]);
useEffect(() => { if (refreshing) handleLoad(false) }, [refreshing]);
useEffect(() => { handleLoad(true) }, []);
async function handleDeleteMember() {
try {
const hasil = await decryptToken(String(token?.current));
const response = await apiDeleteProjectMember({
user: hasil,
idUser: memberChoose.id,
}, id)
const response = await apiDeleteProjectMember({ user: hasil, idUser: memberChoose.id }, id)
if (response.success) {
Toast.show({ type: 'small', text1: 'Berhasil menghapus anggota', })
Toast.show({ type: 'small', text1: 'Berhasil menghapus anggota' })
dispatch(setUpdateProject({ ...update, member: !update.member }))
setModal(false);
}
} catch (error : any ) {
console.error(error);
const message = error?.response?.data?.message || "Gagal menghapus anggota"
Toast.show({ type: 'small', text1: message })
} catch (error: any) {
Toast.show({ type: 'small', text1: error?.response?.data?.message || "Gagal menghapus anggota" })
}
}
@@ -101,84 +76,85 @@ export default function SectionMember({ status, refreshing }: { status: number |
<View style={[Styles.mb15]}>
<View style={[Styles.rowSpaceBetween, Styles.mv05]}>
<Text style={[Styles.textDefaultSemiBold]}>Anggota</Text>
<Text style={[Styles.textDefault]}>Total {data.length} Anggota</Text>
{!loading && data.length > 0 && (
<Text style={[Styles.textDefault, { color: colors.dimmed }]}>{data.length} orang</Text>
)}
</View>
<View style={[Styles.wrapPaper, { backgroundColor: colors.card, borderColor: colors.background }]}>
{
loading ?
arrSkeleton.map((item, index) => {
return (
<SkeletonTwoItem key={index} />
)
})
:
data.length > 0
?
data.map((item, index) => {
return (
<BorderBottomItem
key={index}
borderType="bottom"
icon={<ImageUser src={`${ConstEnv.url_storage}/files/${item.img}`} />}
title={item.name}
onPress={() => {
if (status == 3) return
setMemberChoose({
id: item.idUser,
name: item.name,
})
setModal(true);
}}
/>
);
})
:
<Text style={[Styles.textDefault, { textAlign: 'center', color: colors.dimmed }]}>Tidak ada anggota</Text>
}
<View style={{ gap: 6 }}>
{loading ? (
arrSkeleton.map((_, index) => (
<View key={index} style={{ flexDirection: 'row', alignItems: 'center', gap: 10 }}>
<Skeleton width={40} height={40} borderRadius={20} />
<View style={{ flex: 1, gap: 5 }}>
<Skeleton width={60} height={12} widthType="percent" borderRadius={6} />
<Skeleton width={35} height={10} widthType="percent" borderRadius={6} />
</View>
</View>
))
) : data.length > 0 ? (
data.map((item, index) => (
<Pressable
key={index}
onPress={() => {
if (status === 3) return
setMemberChoose({ id: item.idUser, name: item.name })
setModal(true)
}}
style={{
flexDirection: 'row',
alignItems: 'center',
backgroundColor: colors.card,
borderRadius: 10,
borderWidth: 1,
borderColor: colors.icon + '18',
paddingHorizontal: 12,
paddingVertical: 10,
gap: 12,
}}
>
<ImageUser src={`${ConstEnv.url_storage}/files/${item.img}`} size="xs" />
<View style={{ flex: 1 }}>
<Text style={[Styles.textDefault]} numberOfLines={1}>{item.name}</Text>
</View>
<View style={{
backgroundColor: colors.dimmed + '15',
borderRadius: 20,
paddingHorizontal: 8,
paddingVertical: 3,
}}>
<Text style={[Styles.textSmallSemiBold, { color: colors.dimmed }]} numberOfLines={1}>
{item.position}
</Text>
</View>
</Pressable>
))
) : (
<Text style={[Styles.textDefault, { textAlign: 'center', color: colors.dimmed }]}>Tidak ada anggota</Text>
)}
</View>
</View>
<DrawerBottom
animation="slide"
isVisible={isModal}
setVisible={setModal}
title={memberChoose.name}
>
<DrawerBottom animation="slide" isVisible={isModal} setVisible={setModal} title={memberChoose.name}>
<View style={Styles.rowItemsCenter}>
<MenuItemRow
icon={
<MaterialCommunityIcons
name="account-eye"
color={colors.text}
size={25}
/>
}
icon={<MaterialCommunityIcons name="account-eye" color={colors.text} size={25} />}
title="Lihat Profil"
onPress={() => {
setModal(false);
router.push(`/member/${memberChoose.id}`);
setModal(false)
router.push(`/member/${memberChoose.id}`)
}}
/>
{
entityUser.role != "user" && entityUser.role != "coadmin" &&
{entityUser.role !== "user" && entityUser.role !== "coadmin" && (
<MenuItemRow
icon={
<MaterialCommunityIcons
name="account-remove"
color={colors.text}
size={25}
/>
}
icon={<MaterialCommunityIcons name="account-remove" color={colors.text} size={25} />}
title="Keluarkan"
onPress={() => {
setModal(false)
setTimeout(() => {
setShowDeleteModal(true)
}, 600)
setTimeout(() => setShowDeleteModal(true), 600)
}}
/>
}
)}
</View>
</DrawerBottom>
@@ -186,10 +162,7 @@ export default function SectionMember({ status, refreshing }: { status: number |
visible={showDeleteModal}
title="Konfirmasi"
message="Apakah Anda yakin ingin mengeluarkan anggota?"
onConfirm={() => {
setShowDeleteModal(false)
handleDeleteMember()
}}
onConfirm={() => { setShowDeleteModal(false); handleDeleteMember() }}
onCancel={() => setShowDeleteModal(false)}
confirmText="Keluarkan"
cancelText="Batal"

View File

@@ -2,6 +2,7 @@ import Styles from "@/constants/Styles";
import { apiGetProjectOne } from "@/lib/api";
import { useAuthSession } from "@/providers/AuthProvider";
import { useTheme } from "@/providers/ThemeProvider";
import { MaterialCommunityIcons } from "@expo/vector-icons";
import { useLocalSearchParams } from "expo-router";
import { useEffect, useState } from "react";
import { View } from "react-native";
@@ -19,39 +20,37 @@ export default function SectionReportProject({ refreshing }: { refreshing?: bool
async function handleLoad() {
try {
const hasil = await decryptToken(String(token?.current));
const response = await apiGetProjectOne({
user: hasil,
cat: "data",
id: id,
});
const response = await apiGetProjectOne({ user: hasil, cat: "data", id: id });
setData(response.data.report);
} catch (error) {
console.error(error);
}
}
useEffect(() => {
handleLoad();
}, [update.report]);
useEffect(() => { handleLoad() }, [update.report]);
useEffect(() => { if (refreshing) handleLoad() }, [refreshing]);
useEffect(() => {
if (refreshing)
handleLoad();
}, [refreshing]);
if (!data || data === "") return null;
return (
<>
{
data != "" && data != null &&
<View style={[Styles.mb15, Styles.mt10]}>
<Text style={[Styles.textDefaultSemiBold, Styles.mv05]}>
Laporan Kegiatan
</Text>
<View style={[Styles.wrapPaper, { backgroundColor: colors.card, borderColor: colors.background }]}>
<TextExpandable content={data} maxLines={2} />
</View>
<View style={[
Styles.wrapPaper,
Styles.mb15,
Styles.sectionCard,
{ backgroundColor: colors.card, borderColor: colors.icon + '18' },
]}>
<View style={Styles.sectionHeader}>
<View style={[Styles.sectionIconBox, Styles.mr10, { backgroundColor: colors.tabActive + '18' }]}>
<MaterialCommunityIcons name="text-box-outline" size={18} color={colors.tabActive} />
</View>
}
</>
<Text style={[Styles.textDefaultSemiBold, { color: colors.text }]}>
Laporan Kegiatan
</Text>
</View>
<View style={[Styles.reportContent, { borderLeftColor: colors.tabActive + '50' }]}>
<TextExpandable content={data} maxLines={2} />
</View>
</View>
);
}

View File

@@ -1,5 +1,5 @@
import Styles from "@/constants/Styles";
import { apiDeleteProjectTask, apiGetProjectOne, apiUpdateStatusProjectTask } from "@/lib/api";
import { apiApproveRejectProjectTask, apiDeleteProjectTask, apiGetProjectOne, apiGetProjectTaskApprovals, apiSubmitProjectTask } from "@/lib/api";
import { setUpdateProject } from "@/lib/projectUpdate";
import { useAuthSession } from "@/providers/AuthProvider";
import { useTheme } from "@/providers/ThemeProvider";
@@ -9,11 +9,12 @@ import { useEffect, useState } from "react";
import { View } from "react-native";
import Toast from "react-native-toast-message";
import { useDispatch, useSelector } from "react-redux";
import ModalConfirmation from "../ModalConfirmation";
import DrawerBottom from "../drawerBottom";
import ItemSectionTanggalTugas from "../itemSectionTanggalTugas";
import MenuItemRow from "../menuItemRow";
import ModalSelect from "../modalSelect";
import ModalConfirmation from "../ModalConfirmation";
import ModalRiwayatApproval from "../ModalRiwayatApproval";
import ModalTolakApproval from "../ModalTolakApproval";
import SkeletonTask from "../skeletonTask";
import Text from "../Text";
import ModalListDetailTugasProject from "./modalListDetailTugasProject";
@@ -22,40 +23,52 @@ type Props = {
id: string;
title: string;
desc: string;
status: 1;
status: number;
dateStart: string;
dateEnd: string;
createdAt: string;
files?: { name: string; extension: string }[];
};
type ApprovalRecord = {
id: string
status: number
note?: string
submitter: { name: string }
approver?: { name: string }
createdAt: string
}
export default function SectionTanggalTugasProject({ status, member, refreshing }: { status: number | undefined, member: boolean, refreshing?: boolean }) {
const { colors } = useTheme();
const entityUser = useSelector((state: any) => state.user)
const dispatch = useDispatch()
const update = useSelector((state: any) => state.projectUpdate)
const [isModal, setModal] = useState(false);
const [isSelect, setSelect] = useState(false);
const { token, decryptToken } = useAuthSession();
const [modalDetail, setModalDetail] = useState(false)
const [modalRiwayat, setModalRiwayat] = useState(false)
const [modalTolak, setModalTolak] = useState(false)
const [modalKonfirmasiSetujui, setModalKonfirmasiSetujui] = useState(false)
const [modalPersetujuan, setModalPersetujuan] = useState(false)
const { id } = useLocalSearchParams<{ id: string }>();
const [data, setData] = useState<Props[]>([]);
const [loading, setLoading] = useState(true)
const [loadingAction, setLoadingAction] = useState(false)
const [loadingRiwayat, setLoadingRiwayat] = useState(false)
const [riwayatData, setRiwayatData] = useState<ApprovalRecord[]>([])
const arrSkeleton = Array.from({ length: 5 });
const [tugas, setTugas] = useState({
id: '',
status: 0,
})
const [tugas, setTugas] = useState({ id: '', status: 0 })
const [showDeleteModal, setShowDeleteModal] = useState(false)
const isApprover = entityUser.isApprover || ['supadmin', 'developer'].includes(entityUser.role)
const isAdmin = entityUser.role !== 'user' && entityUser.role !== 'coadmin'
async function handleLoad(loading: boolean) {
try {
setLoading(loading)
const hasil = await decryptToken(String(token?.current));
const response = await apiGetProjectOne({
user: hasil,
cat: "task",
id: id,
});
const response = await apiGetProjectOne({ user: hasil, cat: "task", id: id });
setData(response.data);
} catch (error) {
console.error(error);
@@ -64,167 +77,231 @@ export default function SectionTanggalTugasProject({ status, member, refreshing
}
}
useEffect(() => {
handleLoad(false);
}, [update.task]);
useEffect(() => { handleLoad(false) }, [update.task]);
useEffect(() => { if (refreshing) handleLoad(false) }, [refreshing]);
useEffect(() => { handleLoad(true) }, []);
useEffect(() => {
if (refreshing)
handleLoad(false);
}, [refreshing]);
useEffect(() => {
handleLoad(true);
}, []);
async function handleUpdate(status: number) {
async function handleLoadRiwayat() {
try {
const hasil = await decryptToken(String(token?.current));
const response = await apiUpdateStatusProjectTask({
user: hasil,
idProject: id,
status: status,
}, tugas.id);
setLoadingRiwayat(true)
const hasil = await decryptToken(String(token?.current))
const response = await apiGetProjectTaskApprovals({ user: hasil, id: tugas.id })
setRiwayatData(response.data ?? [])
} catch (error) {
console.error(error)
} finally {
setLoadingRiwayat(false)
}
}
async function handleSubmitAjukan() {
try {
setLoadingAction(true)
const hasil = await decryptToken(String(token?.current))
const response = await apiSubmitProjectTask({ user: hasil, id: tugas.id })
if (response.success) {
dispatch(setUpdateProject({ ...update, progress: !update.progress, task: !update.task }))
setSelect(false);
Toast.show({ type: 'small', text1: 'Berhasil mengubah data', })
Toast.show({ type: 'small', text1: 'Berhasil mengajukan task untuk persetujuan' })
} else {
Toast.show({ type: 'small', text1: response.message })
}
} catch (error : any ) {
console.error(error);
const message = error?.response?.data?.message || "Gagal mengubah data"
} catch (error: any) {
const message = error?.response?.data?.message || "Gagal mengajukan persetujuan"
Toast.show({ type: 'small', text1: message })
} finally {
setLoadingAction(false)
setModal(false)
}
}
async function handleSetujui() {
try {
setLoadingAction(true)
const hasil = await decryptToken(String(token?.current))
const response = await apiApproveRejectProjectTask({ user: hasil, id: tugas.id, action: 'approve' })
if (response.success) {
dispatch(setUpdateProject({ ...update, progress: !update.progress, task: !update.task }))
Toast.show({ type: 'small', text1: 'Tugas berhasil disetujui' })
} else {
Toast.show({ type: 'small', text1: response.message })
}
} catch (error: any) {
const message = error?.response?.data?.message || "Gagal menyetujui tugas"
Toast.show({ type: 'small', text1: message })
} finally {
setLoadingAction(false)
setModalKonfirmasiSetujui(false)
}
}
async function handleTolak(note: string) {
try {
setLoadingAction(true)
const hasil = await decryptToken(String(token?.current))
const response = await apiApproveRejectProjectTask({ user: hasil, id: tugas.id, action: 'reject', note })
if (response.success) {
dispatch(setUpdateProject({ ...update, progress: !update.progress, task: !update.task }))
Toast.show({ type: 'small', text1: 'Tugas berhasil ditolak' })
} else {
Toast.show({ type: 'small', text1: response.message })
}
} catch (error: any) {
const message = error?.response?.data?.message || "Gagal menolak tugas"
Toast.show({ type: 'small', text1: message })
} finally {
setLoadingAction(false)
setModalTolak(false)
}
}
async function handleDelete() {
try {
const hasil = await decryptToken(String(token?.current));
const response = await apiDeleteProjectTask({
user: hasil,
idProject: id,
}, tugas.id);
const response = await apiDeleteProjectTask({ user: hasil, idProject: id }, tugas.id);
if (response.success) {
dispatch(setUpdateProject({ ...update, progress: !update.progress, task: !update.task }))
setModal(false);
Toast.show({ type: 'small', text1: 'Berhasil menghapus data', })
Toast.show({ type: 'small', text1: 'Berhasil menghapus data' })
}
} catch (error : any ) {
console.error(error);
} catch (error: any) {
const message = error?.response?.data?.message || "Gagal menghapus data"
Toast.show({ type: 'small', text1: message })
}
}
const canTakeAction = member || isAdmin
const showAjukan = (member || isApprover) && tugas.status === 0 && status !== 3
const showApproverActions = isApprover && tugas.status === 2
return (
<>
<View style={[Styles.mb15, Styles.mt10]}>
<Text style={[Styles.textDefaultSemiBold, Styles.mv05]}>
Tanggal & Tugas
</Text>
<View style={[Styles.wrapPaper, { backgroundColor: colors.card, borderColor: colors.background }]}>
{
loading ?
arrSkeleton.map((item, index) => {
return (
<SkeletonTask key={index} />
)
})
:
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={() => {
if (status == 3 || (!member && (entityUser.role == "user" || entityUser.role == "coadmin"))) return
setTugas({
id: item.id,
status: item.status
})
setModal(true)
}}
/>
);
})
:
<Text style={[Styles.textDefault, { textAlign: 'center', color: colors.dimmed }]}>Tidak ada tugas</Text>
<Text style={[Styles.textDefaultSemiBold, Styles.mv05]}>Tanggal & Tugas</Text>
<View>
{loading
? arrSkeleton.map((_, index) => <SkeletonTask key={index} />)
: data.length > 0
? data.map((item, index) => (
<ItemSectionTanggalTugas
key={index}
status={item.status}
title={item.title}
dateStart={item.dateStart}
dateEnd={item.dateEnd}
files={item.files ?? []}
onPress={() => {
setTugas({ id: item.id, status: item.status })
setModal(true)
}}
/>
))
: <Text style={[Styles.textDefault, { textAlign: 'center', color: colors.dimmed }]}>Tidak ada tugas</Text>
}
</View>
</View>
<DrawerBottom
animation="slide"
isVisible={isModal}
setVisible={setModal}
title="Menu"
>
<View style={Styles.rowItemsCenter}>
{/* Drawer menu */}
<DrawerBottom animation="slide" isVisible={isModal} setVisible={setModal} title="Menu" height={40}>
<View style={{ flexDirection: 'row', flexWrap: 'wrap' }}>
{/* Baris 1 — selalu tampil */}
<MenuItemRow
icon={
<MaterialCommunityIcons
name="list-status"
color={colors.text}
size={25}
/>
}
title="Update Status"
icon={<MaterialCommunityIcons name="file-multiple-outline" color={colors.text} size={25} />}
title="File Tugas"
onPress={() => {
setModal(false);
setTimeout(() => {
setSelect(true);
}, 600)
setModal(false)
router.push(`/project/${id}/tugas-file/${tugas.id}?member=${member}`)
}}
/>
<MenuItemRow
icon={
<MaterialCommunityIcons
name="pencil-outline"
color={colors.text}
size={25}
/>
}
title="Edit Tugas"
icon={<MaterialCommunityIcons name="clock-time-three-outline" color={colors.text} size={25} />}
title="Detail Waktu"
onPress={() => {
setModal(false);
router.push(`/project/update/${tugas.id}`);
setModal(false)
setTimeout(() => setModalDetail(true), 600)
}}
/>
<MenuItemRow
icon={<MaterialCommunityIcons name="history" color={colors.text} size={25} />}
title="Riwayat"
onPress={() => {
setModal(false)
handleLoadRiwayat()
setTimeout(() => setModalRiwayat(true), 600)
}}
/>
<MenuItemRow
icon={
<MaterialCommunityIcons
name="clock-time-three-outline"
color={colors.text}
size={25}
{/* Separator antar baris */}
{(showAjukan || showApproverActions || (canTakeAction && isAdmin && status !== 3)) && (
<View style={{ width: '100%', height: 15 }} />
)}
{/* Baris 2 — semua aksi kondisional dalam satu baris */}
{showAjukan && (
<MenuItemRow
icon={<MaterialCommunityIcons name="check-circle-outline" color={colors.text} size={25} />}
title="Ajukan Selesai"
disabled={loadingAction}
onPress={() => {
setModal(false)
setTimeout(() => handleSubmitAjukan(), 600)
}}
/>
)}
{showApproverActions && (
<MenuItemRow
icon={<MaterialCommunityIcons name="shield-check-outline" color={colors.text} size={25} />}
title="Persetujuan"
disabled={loadingAction}
onPress={() => {
setModal(false)
setTimeout(() => setModalPersetujuan(true), 600)
}}
/>
)}
{canTakeAction && isAdmin && status !== 3 && (
<>
<MenuItemRow
icon={<MaterialCommunityIcons name="pencil-outline" color={colors.text} size={25} />}
title="Edit Tugas"
onPress={() => {
setModal(false)
router.push(`/project/update/${tugas.id}`)
}}
/>
}
title="Detail Waktu"
<MenuItemRow
icon={<Ionicons name="trash-outline" color={colors.text} size={25} />}
title="Hapus Tugas"
onPress={() => {
setModal(false)
setTimeout(() => setShowDeleteModal(true), 600)
}}
/>
</>
)}
</View>
</DrawerBottom>
{/* Drawer persetujuan */}
<DrawerBottom animation="slide" isVisible={modalPersetujuan} setVisible={setModalPersetujuan} title="Persetujuan Tugas" height={25}>
<View style={{ flexDirection: 'row', flexWrap: 'wrap' }}>
<MenuItemRow
icon={<MaterialCommunityIcons name="check-circle" color={colors.success} size={25} />}
title="Setujui"
color={colors.success}
disabled={loadingAction}
onPress={() => {
setModal(false);
setTimeout(() => {
setModalDetail(true)
}, 600)
setModalPersetujuan(false)
setTimeout(() => setModalKonfirmasiSetujui(true), 600)
}}
/>
</View>
<View style={[Styles.rowItemsCenter, Styles.mt15]}>
<MenuItemRow
icon={<Ionicons name="trash-outline" color={colors.text} size={25} />}
title="Hapus Tugas"
icon={<MaterialCommunityIcons name="close-circle-outline" color={colors.error} size={25} />}
title="Tolak"
color={colors.error}
disabled={loadingAction}
onPress={() => {
setModal(false)
setTimeout(() => {
setShowDeleteModal(true)
}, 600)
setModalPersetujuan(false)
setTimeout(() => setModalTolak(true), 600)
}}
/>
</View>
@@ -234,24 +311,34 @@ export default function SectionTanggalTugasProject({ status, member, refreshing
visible={showDeleteModal}
title="Konfirmasi"
message="Apakah anda yakin ingin menghapus data ini?"
onConfirm={() => {
setShowDeleteModal(false)
handleDelete()
}}
onConfirm={() => { setShowDeleteModal(false); handleDelete() }}
onCancel={() => setShowDeleteModal(false)}
confirmText="Hapus"
cancelText="Batal"
/>
<ModalSelect
category="status-task"
close={() => { setSelect(false) }}
onSelect={(value) => {
handleUpdate(Number(value.val))
}}
title="Status"
open={isSelect}
valChoose={String(tugas.status)}
<ModalConfirmation
visible={modalKonfirmasiSetujui}
title="Konfirmasi"
message="Apakah anda yakin ingin menyetujui tugas ini?"
onConfirm={handleSetujui}
onCancel={() => setModalKonfirmasiSetujui(false)}
confirmText="Setujui"
cancelText="Batal"
/>
<ModalRiwayatApproval
isVisible={modalRiwayat}
setVisible={setModalRiwayat}
data={riwayatData}
loading={loadingRiwayat}
/>
<ModalTolakApproval
isVisible={modalTolak}
setVisible={setModalTolak}
onTolak={handleTolak}
loading={loadingAction}
/>
<ModalListDetailTugasProject

View File

@@ -1,12 +1,11 @@
import { ColorsStatus } from "@/constants/ColorsStatus";
import Styles from "@/constants/Styles";
import { useTheme } from "@/providers/ThemeProvider";
import { AntDesign } from "@expo/vector-icons";
import Text from "./Text";
import { MaterialCommunityIcons } from "@expo/vector-icons";
import { View } from "react-native";
import Text from "./Text";
type Props = {
text?: string,
text?: string
title?: string
}
@@ -14,18 +13,26 @@ export default function SectionCancel({ text, title }: Props) {
const { colors } = useTheme();
return (
<View style={[Styles.p10, Styles.round05, Styles.mb15, { backgroundColor: colors.error + '70' }]}>
<View style={[Styles.rowItemsCenter]}>
<AntDesign name="warning" size={22} style={[Styles.mr10]} color={colors.text} />
<Text style={[Styles.textDefaultSemiBold]}>{title ? title : 'Kegiatan Dibatalkan'}</Text>
<View style={[
Styles.wrapPaper,
Styles.mb15,
Styles.sectionCard,
{ backgroundColor: colors.error + '12', borderColor: colors.error + '40' },
]}>
<View style={[Styles.sectionHeader, !text && { marginBottom: 0 }]}>
<View style={[Styles.sectionIconBox, Styles.mr10, { backgroundColor: colors.error + '20' }]}>
<MaterialCommunityIcons name="close-circle-outline" size={18} color={colors.error} />
</View>
<Text style={[Styles.textDefaultSemiBold, { color: colors.error }]}>
{title ?? 'Kegiatan Dibatalkan'}
</Text>
</View>
{
text && (
<View>
<Text style={[Styles.mt05]}>{text}</Text>
</View>
)
}
{text && (
<View style={[Styles.reportContent, { borderLeftColor: colors.error + '50' }]}>
<Text style={[Styles.textDefault, { color: colors.text }]}>{text}</Text>
</View>
)}
</View>
)
}
}

View File

@@ -1,27 +1,87 @@
import Styles from "@/constants/Styles";
import { useTheme } from "@/providers/ThemeProvider";
import { AntDesign } from "@expo/vector-icons";
import { View } from "react-native";
import ProgressBar from "./progressBar";
import { MaterialCommunityIcons } from "@expo/vector-icons";
import { useEffect, useRef } from "react";
import { Animated, View } from "react-native";
import Text from "./Text";
type Props = {
text: string,
progress: number
doneCount?: number
totalCount?: number
}
export default function SectionProgress({ text, progress }: Props) {
export default function SectionProgress({ progress, doneCount, totalCount }: Props) {
const { colors } = useTheme();
const animatedWidth = useRef(new Animated.Value(0)).current;
const progressColor = colors.tabActive;
const statusLabel = progress === 100
? 'Selesai'
: progress > 0
? 'Sedang berlangsung'
: 'Belum ada tugas yang diselesaikan';
useEffect(() => {
animatedWidth.setValue(0);
Animated.timing(animatedWidth, {
toValue: progress,
duration: 900,
useNativeDriver: false,
}).start();
}, [progress]);
return (
<View style={[Styles.wrapPaper, Styles.rowItemsCenter, { backgroundColor: colors.card }]}>
<View style={[Styles.iconContent]}>
<AntDesign name="areachart" size={30} color={'black'} />
<View style={[
Styles.wrapPaper,
Styles.mb15,
Styles.sectionCard,
{ backgroundColor: colors.card, borderColor: progressColor + '30' },
]}>
<View style={Styles.sectionHeaderRow}>
<View style={Styles.flex1}>
<View style={Styles.rowItemsCenter}>
<View style={[Styles.sectionIconBox, Styles.mr10, { backgroundColor: progressColor + '22' }]}>
<MaterialCommunityIcons name="chart-line" size={18} color={progressColor} />
</View>
<Text style={[Styles.textDefaultSemiBold, { color: colors.text }]}>
Kemajuan Kegiatan
</Text>
</View>
<Text style={[Styles.textMediumNormal, { color: colors.dimmed, marginLeft: 42 }]}>
{statusLabel}
</Text>
</View>
<View style={Styles.badgeCol}>
<View style={[Styles.progressBadge, { backgroundColor: progressColor + '18', borderColor: progressColor + '45' }]}>
<Text style={[Styles.textProgressPercent, { color: progressColor }]}>
{progress}%
</Text>
</View>
{totalCount !== undefined && doneCount !== undefined && (
<View style={[Styles.taskCountBadge, { backgroundColor: progressColor + '18' }]}>
<Text style={[Styles.textSmallSemiBold, { color: progressColor }]}>
{doneCount}/{totalCount} tugas
</Text>
</View>
)}
</View>
</View>
<View style={[Styles.ml10, { flex: 1 }]}>
<Text style={[Styles.mb05]}>{text}</Text>
<ProgressBar margin={0} category="page" value={progress} />
<View style={[Styles.progressTrack, { backgroundColor: colors.icon + '20' }]}>
<Animated.View style={[
Styles.progressFill,
{
backgroundColor: progressColor,
width: animatedWidth.interpolate({
inputRange: [0, 100],
outputRange: ['0%', '100%'],
}),
},
]} />
</View>
</View>
)
}
);
}

View File

@@ -10,15 +10,13 @@ import { startActivityAsync } from 'expo-intent-launcher';
import { useLocalSearchParams } from "expo-router";
import * as Sharing from 'expo-sharing';
import { useEffect, useState } from "react";
import { Alert, Platform, View } from "react-native";
import { Alert, Platform, Pressable, View } from "react-native";
import * as mime from 'react-native-mime-types';
import Toast from "react-native-toast-message";
import { useDispatch, useSelector } from "react-redux";
import ModalConfirmation from "../ModalConfirmation";
import ButtonMenuHeader from "../buttonMenuHeader";
import BorderBottomItem from "../borderBottomItem";
import DrawerBottom from "../drawerBottom";
import MenuItemRow from "../menuItemRow";
import ModalConfirmation from "../ModalConfirmation";
import ModalLoading from "../modalLoading";
import Skeleton from "../skeleton";
import Text from "../Text";
@@ -30,6 +28,28 @@ type Props = {
idStorage: string
}
function getFileIcon(extension: string): keyof typeof MaterialCommunityIcons.glyphMap {
const ext = extension.toLowerCase()
if (['jpg', 'jpeg', 'png', 'gif', 'webp', 'heic', 'heif'].includes(ext)) return 'image-outline'
if (ext === 'pdf') return 'file-pdf-box'
if (['mp4', 'mov', 'avi', 'mkv'].includes(ext)) return 'video-outline'
if (['doc', 'docx'].includes(ext)) return 'file-word-outline'
if (['xls', 'xlsx'].includes(ext)) return 'file-excel-outline'
if (['zip', 'rar', '7z'].includes(ext)) return 'zip-box-outline'
return 'file-outline'
}
function getFileColor(extension: string): string {
const ext = extension.toLowerCase()
if (['jpg', 'jpeg', 'png', 'gif', 'webp', 'heic', 'heif'].includes(ext)) return '#339AF0'
if (ext === 'pdf') return '#F03E3E'
if (['mp4', 'mov', 'avi', 'mkv'].includes(ext)) return '#AE3EC9'
if (['doc', 'docx'].includes(ext)) return '#1C7ED6'
if (['xls', 'xlsx'].includes(ext)) return '#2F9E44'
if (['zip', 'rar', '7z'].includes(ext)) return '#E8590C'
return '#868E96'
}
export default function SectionFileTask({ refreshing, isMemberDivision }: { refreshing: boolean, isMemberDivision: boolean }) {
const { colors } = useTheme()
const [isModal, setModal] = useState(false)
@@ -119,7 +139,7 @@ export default function SectionFileTask({ refreshing, isMemberDivision }: { refr
} else {
Toast.show({ type: 'small', text1: response.message, })
}
} catch (error : any ) {
} catch (error: any) {
console.error(error);
const message = error?.response?.data?.message || "Gagal menghapus file"
@@ -134,32 +154,39 @@ export default function SectionFileTask({ refreshing, isMemberDivision }: { refr
<ModalLoading isVisible={loadingOpen} setVisible={setLoadingOpen} />
<View style={[Styles.mb15]}>
<Text style={[Styles.textDefaultSemiBold, Styles.mv05]}>File</Text>
<View style={[Styles.wrapPaper, { backgroundColor: colors.card, borderColor: colors.background }]}>
{
loading ?
arrSkeleton.map((item, index) => {
return (
<Skeleton key={index} width={100} height={40} widthType="percent" borderRadius={10} />
)
})
:
data.length > 0 ?
data.map((item, index) => {
return (
<BorderBottomItem
key={index}
borderType="all"
icon={<MaterialCommunityIcons name="file-outline" size={25} color={colors.text} />}
title={item.name + '.' + item.extension}
titleWeight="normal"
onPress={() => { setSelectFile(item); setModal(true) }}
/>
)
})
:
<Text style={[Styles.textDefault, { textAlign: 'center', color: colors.dimmed }]}>Tidak ada file</Text>
}
</View>
{loading ? (
<View style={Styles.fileGrid}>
{arrSkeleton.map((_, index) => (
<Skeleton key={index} width={48} height={68} widthType="percent" borderRadius={10} />
))}
</View>
) : data.length > 0 ? (
<View style={Styles.fileGrid}>
{data.map((item, index) => {
const iconName = getFileIcon(item.extension)
const iconColor = getFileColor(item.extension)
return (
<Pressable
key={index}
onPress={() => { setSelectFile(item); setModal(true) }}
style={[Styles.fileCard, { backgroundColor: colors.card, borderColor: colors.icon + '18' }]}
>
<View style={[Styles.sectionIconBox, { backgroundColor: iconColor + '20' }]}>
<MaterialCommunityIcons name={iconName} size={18} color={iconColor} />
</View>
<View style={Styles.flex1}>
<Text style={Styles.textDefault} numberOfLines={1}>{item.name}</Text>
<Text style={[Styles.textSmallSemiBold, { color: colors.dimmed }]}>
{item.extension.toUpperCase()}
</Text>
</View>
</Pressable>
)
})}
</View>
) : (
<Text style={[Styles.textDefault, { textAlign: 'center', color: colors.dimmed }]}>Tidak ada file</Text>
)}
</View>
<DrawerBottom animation="slide" isVisible={isModal} setVisible={setModal} title="Menu">

View File

@@ -1,20 +1,19 @@
import Styles from "@/constants/Styles";
import { apiDeleteLinkTask, apiGetTaskOne } from "@/lib/api";
import { urlCompleted } from "@/lib/fun_urlCompleted";
import { setUpdateTask } from "@/lib/taskUpdate";
import { useAuthSession } from "@/providers/AuthProvider";
import { useTheme } from "@/providers/ThemeProvider";
import { Feather, Ionicons } from "@expo/vector-icons";
import { Ionicons } from "@expo/vector-icons";
import { useLocalSearchParams } from "expo-router";
import { useEffect, useState } from "react";
import { Linking, View } from "react-native";
import { View } from "react-native";
import Toast from "react-native-toast-message";
import { useDispatch, useSelector } from "react-redux";
import ModalConfirmation from "../ModalConfirmation";
import BorderBottomItem from "../borderBottomItem";
import DrawerBottom from "../drawerBottom";
import MenuItemRow from "../menuItemRow";
import Text from "../Text";
import ItemSectionLink from "../project/itemSectionLink";
type Props = {
id: string
@@ -62,84 +61,60 @@ export default function SectionLinkTask({ refreshing, isMemberDivision }: { refr
} else {
Toast.show({ type: 'small', text1: response.message, })
}
} catch (error : any ) {
} catch (error: any) {
console.error(error);
const message = error?.response?.data?.message || "Gagal menghapus link"
Toast.show({ type: 'small', text1: message })
} finally {
setModal(false)
}
}
if (data.length === 0) return null;
const canDelete = (entityUser.role !== "user" && entityUser.role !== "coadmin") || isMemberDivision;
return (
<>
{
data.length > 0 &&
<>
<View style={[Styles.mb15]}>
<Text style={[Styles.textDefaultSemiBold, Styles.mv05]}>Link</Text>
<View style={[Styles.wrapPaper, { backgroundColor: colors.card, borderColor: colors.background }]}>
{
data.map((item, index) => {
return (
<BorderBottomItem
key={index}
borderType="all"
icon={<Feather name="link" size={25} color={colors.text} />}
title={item.link}
titleWeight="normal"
onPress={() => { setSelectLink(item); setModal(true) }}
/>
)
})
}
</View>
</View>
<View style={[Styles.mb15]}>
<Text style={[Styles.textDefaultSemiBold, Styles.mv05]}>Link</Text>
<View>
{data.map((item, index) => (
<ItemSectionLink
key={index}
link={item.link}
canDelete={canDelete}
onLongPress={() => { setSelectLink(item); setModal(true) }}
/>
))}
</View>
</View>
<DrawerBottom animation="slide" isVisible={isModal} setVisible={setModal} title="Menu">
<View style={Styles.rowItemsCenter}>
<MenuItemRow
icon={<Feather name="external-link" color={colors.text} size={25} />}
title="Buka Link"
onPress={() => {
Linking.openURL(urlCompleted(String(selectLink?.link)))
}}
/>
{
(entityUser.role != "user" && entityUser.role != "coadmin") || isMemberDivision
?
<MenuItemRow
icon={<Ionicons name="trash-outline" color={colors.text} size={25} />}
title="Hapus"
onPress={() => {
setModal(false)
setTimeout(() => {
setShowDeleteModal(true)
}, 600)
}}
/>
:
<></>
}
</View>
</DrawerBottom>
<ModalConfirmation
visible={showDeleteModal}
title="Konfirmasi"
message="Apakah Anda yakin ingin menghapus link ini? Link yang dihapus tidak dapat dikembalikan"
onConfirm={() => {
setShowDeleteModal(false)
handleDelete()
<DrawerBottom animation="slide" isVisible={isModal} setVisible={setModal} title="Menu">
<View style={Styles.rowItemsCenter}>
<MenuItemRow
icon={<Ionicons name="trash-outline" color={colors.text} size={25} />}
title="Hapus Link"
onPress={() => {
setModal(false)
setTimeout(() => setShowDeleteModal(true), 600)
}}
onCancel={() => setShowDeleteModal(false)}
confirmText="Hapus"
cancelText="Batal"
/>
</>
}
</View>
</DrawerBottom>
<ModalConfirmation
visible={showDeleteModal}
title="Konfirmasi"
message="Apakah Anda yakin ingin menghapus link ini? Link yang dihapus tidak dapat dikembalikan"
onConfirm={() => {
setShowDeleteModal(false)
handleDelete()
}}
onCancel={() => setShowDeleteModal(false)}
confirmText="Hapus"
cancelText="Batal"
/>
</>
)
}
}

View File

@@ -7,15 +7,14 @@ import { useTheme } from "@/providers/ThemeProvider";
import { MaterialCommunityIcons } from "@expo/vector-icons";
import { router, useLocalSearchParams } from "expo-router";
import { useEffect, useState } from "react";
import { View } from "react-native";
import { Pressable, View } from "react-native";
import Toast from "react-native-toast-message";
import { useDispatch, useSelector } from "react-redux";
import ModalConfirmation from "../ModalConfirmation";
import BorderBottomItem from "../borderBottomItem";
import DrawerBottom from "../drawerBottom";
import ImageUser from "../imageNew";
import MenuItemRow from "../menuItemRow";
import SkeletonTwoItem from "../skeletonTwoItem";
import ModalConfirmation from "../ModalConfirmation";
import Skeleton from "../skeleton";
import Text from "../Text";
type Props = {
@@ -88,7 +87,7 @@ export default function SectionMemberTask({ refreshing, isAdminDivision }: { ref
} else {
Toast.show({ type: 'small', text1: response.message, })
}
} catch (error : any ) {
} catch (error: any) {
console.error(error);
const message = error?.response?.data?.message || "Gagal menghapus anggota"
@@ -103,28 +102,46 @@ export default function SectionMemberTask({ refreshing, isAdminDivision }: { ref
<View style={[Styles.mb15]}>
<View style={[Styles.rowSpaceBetween, Styles.mv05]}>
<Text style={[Styles.textDefaultSemiBold]}>Anggota</Text>
<Text style={[Styles.textDefault]}>Total {data.length} Anggota</Text>
{!loading && data.length > 0 && (
<Text style={[Styles.textDefault, { color: colors.dimmed }]}>{data.length} orang</Text>
)}
</View>
<View style={[Styles.wrapPaper, { backgroundColor: colors.card, borderColor: colors.background }]}>
<View style={{ gap: 6 }}>
{
loading ?
arrSkeleton.map((item, index) => {
return (
<SkeletonTwoItem key={index} />
<View key={index} style={{ flexDirection: 'row', alignItems: 'center', gap: 10 }}>
<Skeleton width={40} height={40} borderRadius={20} />
<View style={{ flex: 1, gap: 5 }}>
<Skeleton width={60} height={12} widthType="percent" borderRadius={6} />
<Skeleton width={35} height={10} widthType="percent" borderRadius={6} />
</View>
</View>
)
})
:
data.length > 0 ? (
data.map((item, index) => {
return (
<BorderBottomItem
// <BorderBottomItem
// key={index}
// borderType="bottom"
// icon={
// <ImageUser src={`${ConstEnv.url_storage}/files/${item.img}`} />
// }
// title={item.name}
// onPress={() => {
// setMemberChoose({
// id: item.idUser,
// name: item.name,
// });
// setModal(true);
// }}
// />
<Pressable
key={index}
borderType="bottom"
icon={
<ImageUser src={`${ConstEnv.url_storage}/files/${item.img}`} />
}
title={item.name}
onPress={() => {
setMemberChoose({
id: item.idUser,
@@ -132,7 +149,33 @@ export default function SectionMemberTask({ refreshing, isAdminDivision }: { ref
});
setModal(true);
}}
/>
style={{
flexDirection: 'row',
alignItems: 'center',
backgroundColor: colors.card,
borderRadius: 10,
borderWidth: 1,
borderColor: colors.icon + '18',
paddingHorizontal: 12,
paddingVertical: 10,
gap: 12,
}}
>
<ImageUser src={`${ConstEnv.url_storage}/files/${item.img}`} size="xs" />
<View style={{ flex: 1 }}>
<Text style={[Styles.textDefault]} numberOfLines={1}>{item.name}</Text>
</View>
<View style={{
backgroundColor: colors.dimmed + '15',
borderRadius: 20,
paddingHorizontal: 8,
paddingVertical: 3,
}}>
<Text style={[Styles.textSmallSemiBold, { color: colors.dimmed }]} numberOfLines={1}>
{item.position}
</Text>
</View>
</Pressable>
);
})
) : (

View File

@@ -2,6 +2,7 @@ import Styles from "@/constants/Styles";
import { apiGetTaskOne } from "@/lib/api";
import { useAuthSession } from "@/providers/AuthProvider";
import { useTheme } from "@/providers/ThemeProvider";
import { MaterialCommunityIcons } from "@expo/vector-icons";
import { useLocalSearchParams } from "expo-router";
import { useEffect, useState } from "react";
import { View } from "react-native";
@@ -9,7 +10,6 @@ import { useSelector } from "react-redux";
import Text from "../Text";
import TextExpandable from "../textExpandable";
export default function SectionReportTask({ refreshing }: { refreshing: boolean }) {
const { colors } = useTheme()
const update = useSelector((state: any) => state.taskUpdate)
@@ -27,29 +27,30 @@ export default function SectionReportTask({ refreshing }: { refreshing: boolean
}
}
useEffect(() => {
handleLoad()
}, [update.report])
useEffect(() => {
if (refreshing)
handleLoad();
}, [refreshing]);
useEffect(() => { handleLoad() }, [update.report])
useEffect(() => { if (refreshing) handleLoad() }, [refreshing])
if (!data || data === "") return null;
return (
<>
{
data != "" && data != null &&
<View style={[Styles.mb15, Styles.mt10]}>
<Text style={[Styles.textDefaultSemiBold, Styles.mv05]}>
Laporan Kegiatan
</Text>
<View style={[Styles.wrapPaper, { backgroundColor: colors.card, borderColor: colors.background }]}>
<TextExpandable content={data} maxLines={2} />
</View>
<View style={[
Styles.wrapPaper,
Styles.mb15,
Styles.sectionCard,
{ backgroundColor: colors.card, borderColor: colors.icon + '18' },
]}>
<View style={Styles.sectionHeader}>
<View style={[Styles.sectionIconBox, Styles.mr10, { backgroundColor: colors.tabActive + '18' }]}>
<MaterialCommunityIcons name="text-box-outline" size={18} color={colors.tabActive} />
</View>
}
</>
<Text style={[Styles.textDefaultSemiBold, { color: colors.text }]}>
Laporan Kegiatan
</Text>
</View>
<View style={[Styles.reportContent, { borderLeftColor: colors.tabActive + '50' }]}>
<TextExpandable content={data} maxLines={2} />
</View>
</View>
)
}
}

View File

@@ -1,5 +1,5 @@
import Styles from "@/constants/Styles";
import { apiDeleteTaskTugas, apiGetTaskOne, apiUpdateStatusTaskDivision } from "@/lib/api";
import { apiApproveRejectTaskTugas, apiDeleteTaskTugas, apiGetTaskOne, apiGetTaskTugasApprovals, apiSubmitTaskTugas } from "@/lib/api";
import { setUpdateTask } from "@/lib/taskUpdate";
import { useAuthSession } from "@/providers/AuthProvider";
import { useTheme } from "@/providers/ThemeProvider";
@@ -9,11 +9,12 @@ import { useEffect, useState } from "react";
import { View } from "react-native";
import Toast from "react-native-toast-message";
import { useDispatch, useSelector } from "react-redux";
import ModalConfirmation from "../ModalConfirmation";
import DrawerBottom from "../drawerBottom";
import ItemSectionTanggalTugas from "../itemSectionTanggalTugas";
import MenuItemRow from "../menuItemRow";
import ModalSelect from "../modalSelect";
import ModalConfirmation from "../ModalConfirmation";
import ModalRiwayatApproval from "../ModalRiwayatApproval";
import ModalTolakApproval from "../ModalTolakApproval";
import SkeletonTask from "../skeletonTask";
import Text from "../Text";
import ModalListDetailTugasTask from "./modalListDetailTugasTask";
@@ -25,27 +26,44 @@ type Props = {
status: number;
dateStart: string;
dateEnd: string;
files?: { name: string; extension: string }[];
}
export default function SectionTanggalTugasTask({ refreshing, isMemberDivision }: { refreshing: boolean, isMemberDivision: boolean }) {
type ApprovalRecord = {
id: string
status: number
note?: string
submitter: { name: string }
approver?: { name: string }
createdAt: string
}
export default function SectionTanggalTugasTask({ refreshing, isMemberDivision, isAdminDivision, status }: { refreshing: boolean, isMemberDivision: boolean, isAdminDivision: boolean, status?: number }) {
const { colors } = useTheme()
const dispatch = useDispatch()
const entityUser = useSelector((state: any) => state.user);
const update = useSelector((state: any) => state.taskUpdate)
const [isModal, setModal] = useState(false)
const [isSelect, setSelect] = useState(false)
const { token, decryptToken } = useAuthSession()
const [loading, setLoading] = useState(true)
const [loadingAction, setLoadingAction] = useState(false)
const [loadingRiwayat, setLoadingRiwayat] = useState(false)
const arrSkeleton = Array.from({ length: 5 })
const [modalDetail, setModalDetail] = useState(false)
const [modalRiwayat, setModalRiwayat] = useState(false)
const [modalTolak, setModalTolak] = useState(false)
const [modalKonfirmasiSetujui, setModalKonfirmasiSetujui] = useState(false)
const [modalPersetujuan, setModalPersetujuan] = useState(false)
const [riwayatData, setRiwayatData] = useState<ApprovalRecord[]>([])
const { id, detail } = useLocalSearchParams<{ id: string, detail: string }>();
const [data, setData] = useState<Props[]>([])
const [tugas, setTugas] = useState({
id: '',
status: 0,
})
const [tugas, setTugas] = useState({ id: '', status: 0 })
const [showDeleteModal, setShowDeleteModal] = useState(false)
const isApprover = entityUser.isApprover || ['supadmin', 'developer'].includes(entityUser.role)
const isAdmin = entityUser.role !== 'user' && entityUser.role !== 'coadmin'
const canTakeAction = isMemberDivision || isAdmin
async function handleLoad(loading: boolean) {
try {
setLoading(loading)
@@ -59,194 +77,266 @@ export default function SectionTanggalTugasTask({ refreshing, isMemberDivision }
}
}
async function handleUpdate(status: number) {
try {
const hasil = await decryptToken(String(token?.current));
const response = await apiUpdateStatusTaskDivision({
user: hasil,
idProject: detail,
status: status,
}, tugas.id);
if (response.success) {
dispatch(setUpdateTask({ ...update, progress: !update.progress, task: !update.task }))
Toast.show({ type: 'small', text1: 'Berhasil mengubah data', })
} else {
Toast.show({ type: 'small', text1: response.message, })
}
} catch (error : any ) {
console.error(error);
const message = error?.response?.data?.message || "Gagal mengubah data"
useEffect(() => { handleLoad(false) }, [update.task])
useEffect(() => { if (refreshing) handleLoad(false) }, [refreshing])
useEffect(() => { handleLoad(true) }, [])
Toast.show({ type: 'small', text1: message })
async function handleLoadRiwayat() {
try {
setLoadingRiwayat(true)
const hasil = await decryptToken(String(token?.current))
const response = await apiGetTaskTugasApprovals({ user: hasil, id: tugas.id })
setRiwayatData(response.data ?? [])
} catch (error) {
console.error(error)
} finally {
setSelect(false)
setLoadingRiwayat(false)
}
}
useEffect(() => {
handleLoad(false)
}, [update.task])
async function handleSubmitAjukan() {
try {
setLoadingAction(true)
const hasil = await decryptToken(String(token?.current))
const response = await apiSubmitTaskTugas({ user: hasil, id: tugas.id })
if (response.success) {
dispatch(setUpdateTask({ ...update, progress: !update.progress, task: !update.task }))
Toast.show({ type: 'small', text1: 'Berhasil mengajukan task untuk persetujuan' })
} else {
Toast.show({ type: 'small', text1: response.message })
}
} catch (error: any) {
Toast.show({ type: 'small', text1: error?.response?.data?.message || "Gagal mengajukan persetujuan" })
} finally {
setLoadingAction(false)
setModal(false)
}
}
useEffect(() => {
if (refreshing)
handleLoad(false);
}, [refreshing]);
useEffect(() => {
handleLoad(true)
}, [])
async function handleSetujui() {
try {
setLoadingAction(true)
const hasil = await decryptToken(String(token?.current))
const response = await apiApproveRejectTaskTugas({ user: hasil, id: tugas.id, action: 'approve' })
if (response.success) {
dispatch(setUpdateTask({ ...update, progress: !update.progress, task: !update.task }))
Toast.show({ type: 'small', text1: 'Tugas berhasil disetujui' })
} else {
Toast.show({ type: 'small', text1: response.message })
}
} catch (error: any) {
Toast.show({ type: 'small', text1: error?.response?.data?.message || "Gagal menyetujui tugas" })
} finally {
setLoadingAction(false)
setModalKonfirmasiSetujui(false)
}
}
async function handleTolak(note: string) {
try {
setLoadingAction(true)
const hasil = await decryptToken(String(token?.current))
const response = await apiApproveRejectTaskTugas({ user: hasil, id: tugas.id, action: 'reject', note })
if (response.success) {
dispatch(setUpdateTask({ ...update, progress: !update.progress, task: !update.task }))
Toast.show({ type: 'small', text1: 'Tugas berhasil ditolak' })
} else {
Toast.show({ type: 'small', text1: response.message })
}
} catch (error: any) {
Toast.show({ type: 'small', text1: error?.response?.data?.message || "Gagal menolak tugas" })
} finally {
setLoadingAction(false)
setModalTolak(false)
}
}
async function handleDelete() {
try {
const hasil = await decryptToken(String(token?.current));
const response = await apiDeleteTaskTugas({
user: hasil,
idProject: detail,
}, tugas.id);
const response = await apiDeleteTaskTugas({ user: hasil, idProject: detail }, tugas.id);
if (response.success) {
dispatch(setUpdateTask({ ...update, progress: !update.progress, task: !update.task }))
Toast.show({ type: 'small', text1: 'Berhasil menghapus data', })
Toast.show({ type: 'small', text1: 'Berhasil menghapus data' })
} else {
Toast.show({ type: 'small', text1: response.message, })
Toast.show({ type: 'small', text1: response.message })
}
} catch (error : any ) {
console.error(error);
const message = error?.response?.data?.message || "Gagal menghapus data"
Toast.show({ type: 'small', text1: message })
} finally {
setModal(false);
} catch (error: any) {
Toast.show({ type: 'small', text1: error?.response?.data?.message || "Gagal menghapus data" })
}
}
const canApprove = isApprover || isAdminDivision
const showAjukan = (isMemberDivision || canApprove) && tugas.status === 0 && status !== 3
const showApproverActions = canApprove && tugas.status === 2
return (
<>
<View style={[Styles.mb15, Styles.mt10]}>
<Text style={[Styles.textDefaultSemiBold, Styles.mv05]}>Tanggal & Tugas</Text>
<View style={[Styles.wrapPaper, { backgroundColor: colors.card, borderColor: colors.background }]}>
{
loading ?
arrSkeleton.map((item, index) => {
return (
<SkeletonTask key={index} />
)
})
:
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, { textAlign: 'center', color: colors.dimmed }]}>Tidak ada tugas</Text>
<View>
{loading
? arrSkeleton.map((_, index) => <SkeletonTask key={index} />)
: data.length > 0
? data.map((item, index) => (
<ItemSectionTanggalTugas
key={index}
status={item.status}
title={item.title}
dateStart={item.dateStart}
dateEnd={item.dateEnd}
files={item.files ?? []}
onPress={() => {
setTugas({ id: item.id, status: item.status })
setModal(true)
}}
/>
))
: <Text style={[Styles.textDefault, { textAlign: 'center', color: colors.dimmed }]}>Tidak ada tugas</Text>
}
</View>
</View>
<DrawerBottom animation="slide" isVisible={isModal} setVisible={setModal} title="Menu">
<View style={Styles.rowItemsCenter}>
{/* Drawer menu */}
<DrawerBottom animation="slide" isVisible={isModal} setVisible={setModal} title="Menu" height={40}>
<View style={{ flexDirection: 'row', flexWrap: 'wrap' }}>
{/* Baris 1 — selalu tampil */}
<MenuItemRow
icon={
<MaterialCommunityIcons
name="clock-time-three-outline"
color={colors.text}
size={25}
/>
}
title="Detail Waktu"
icon={<MaterialCommunityIcons name="file-multiple-outline" color={colors.text} size={25} />}
title="File Tugas"
onPress={() => {
setModal(false);
setTimeout(() => {
setModalDetail(true)
}, 600)
setModal(false)
router.push(`/division/${id}/task/${detail}/tugas-file/${tugas.id}?member=${isMemberDivision}`)
}}
/>
<MenuItemRow
icon={<MaterialCommunityIcons name="clock-time-three-outline" color={colors.text} size={25} />}
title="Detail Waktu"
onPress={() => {
setModal(false)
setTimeout(() => setModalDetail(true), 600)
}}
/>
<MenuItemRow
icon={<MaterialCommunityIcons name="history" color={colors.text} size={25} />}
title="Riwayat"
onPress={() => {
setModal(false)
handleLoadRiwayat()
setTimeout(() => setModalRiwayat(true), 600)
}}
/>
{
(entityUser.role != "user" && entityUser.role != "coadmin") || isMemberDivision
?
<>
<MenuItemRow
icon={<MaterialCommunityIcons name="list-status" color={colors.text} size={25} />}
title="Update Status"
onPress={() => {
setModal(false)
setTimeout(() => {
setSelect(true)
}, 600);
}}
/>
<MenuItemRow
icon={<MaterialCommunityIcons name="pencil-outline" color={colors.text} size={25} />}
title="Edit Tugas"
onPress={() => {
setModal(false)
router.push(`./update/${tugas.id}`)
}}
/>
</>
:
<></>
}
</View>
{
(entityUser.role != "user" && entityUser.role != "coadmin") || isMemberDivision
?
<View style={[Styles.rowItemsCenter, Styles.mt15]}>
{/* Separator */}
{(showAjukan || showApproverActions || (canTakeAction && isAdmin && status !== 3)) && (
<View style={{ width: '100%', height: 15 }} />
)}
{/* Baris 2 — aksi kondisional */}
{showAjukan && (
<MenuItemRow
icon={<MaterialCommunityIcons name="check-circle-outline" color={colors.text} size={25} />}
title="Ajukan Selesai"
disabled={loadingAction}
onPress={() => {
setModal(false)
setTimeout(() => handleSubmitAjukan(), 600)
}}
/>
)}
{showApproverActions && (
<MenuItemRow
icon={<MaterialCommunityIcons name="shield-check-outline" color={colors.text} size={25} />}
title="Persetujuan"
disabled={loadingAction}
onPress={() => {
setModal(false)
setTimeout(() => setModalPersetujuan(true), 600)
}}
/>
)}
{canTakeAction && isAdmin && status !== 3 && (
<>
<MenuItemRow
icon={<MaterialCommunityIcons name="pencil-outline" color={colors.text} size={25} />}
title="Edit Tugas"
onPress={() => {
setModal(false)
router.push(`./update/${tugas.id}`)
}}
/>
<MenuItemRow
icon={<Ionicons name="trash-outline" color={colors.text} size={25} />}
title="Hapus Tugas"
onPress={() => {
setModal(false)
setTimeout(() => {
setShowDeleteModal(true)
}, 600)
setTimeout(() => setShowDeleteModal(true), 600)
}}
/>
</View>
:
<></>
}
</>
)}
</View>
</DrawerBottom>
{/* Drawer persetujuan */}
<DrawerBottom animation="slide" isVisible={modalPersetujuan} setVisible={setModalPersetujuan} title="Persetujuan Tugas" height={25}>
<View style={{ flexDirection: 'row', flexWrap: 'wrap' }}>
<MenuItemRow
icon={<MaterialCommunityIcons name="check-circle" color={colors.success} size={25} />}
title="Setujui"
color={colors.success}
disabled={loadingAction}
onPress={() => {
setModalPersetujuan(false)
setTimeout(() => setModalKonfirmasiSetujui(true), 600)
}}
/>
<MenuItemRow
icon={<MaterialCommunityIcons name="close-circle-outline" color={colors.error} size={25} />}
title="Tolak"
color={colors.error}
disabled={loadingAction}
onPress={() => {
setModalPersetujuan(false)
setTimeout(() => setModalTolak(true), 600)
}}
/>
</View>
</DrawerBottom>
<ModalConfirmation
visible={showDeleteModal}
title="Konfirmasi"
message="Apakah anda yakin ingin menghapus data ini?"
onConfirm={() => {
setShowDeleteModal(false)
handleDelete()
}}
onConfirm={() => { setShowDeleteModal(false); handleDelete() }}
onCancel={() => setShowDeleteModal(false)}
confirmText="Hapus"
cancelText="Batal"
/>
<ModalSelect
category="status-task"
close={() => setSelect(false)}
onSelect={(value) => { handleUpdate(Number(value.val)) }}
title="Status"
open={isSelect}
valChoose={String(tugas.status)}
<ModalConfirmation
visible={modalKonfirmasiSetujui}
title="Konfirmasi"
message="Apakah anda yakin ingin menyetujui tugas ini?"
onConfirm={handleSetujui}
onCancel={() => setModalKonfirmasiSetujui(false)}
confirmText="Setujui"
cancelText="Batal"
/>
<ModalRiwayatApproval
isVisible={modalRiwayat}
setVisible={setModalRiwayat}
data={riwayatData}
loading={loadingRiwayat}
/>
<ModalTolakApproval
isVisible={modalTolak}
setVisible={setModalTolak}
onTolak={handleTolak}
loading={loadingAction}
/>
<ModalListDetailTugasTask
@@ -256,4 +346,4 @@ export default function SectionTanggalTugasTask({ refreshing, isMemberDivision }
/>
</>
)
}
}

View File

@@ -1,32 +1,38 @@
import Styles from "@/constants/Styles";
import { useTheme } from "@/providers/ThemeProvider";
import { MaterialCommunityIcons } from "@expo/vector-icons";
import { useRef, useState, useEffect } from "react";
import { Animated, Pressable, View } from "react-native";
import Text from "./Text";
export default function TextExpandable({ content, maxLines }: { content: string, maxLines: number }) {
const { colors } = useTheme();
const [isExpanded, setIsExpanded] = useState(false);
const [shouldShowMore, setShouldShowMore] = useState(false);
const [collapsedHeight, setCollapsedHeight] = useState(0);
const [fullHeight, setFullHeight] = useState(0);
const animatedHeight = useRef(new Animated.Value(0)).current;
useEffect(() => {
setCollapsedHeight(0);
setFullHeight(0);
setShouldShowMore(false);
setIsExpanded(false);
}, [content]);
const measureCollapsed = (e: any) => {
if (collapsedHeight === 0) {
setCollapsedHeight(e.nativeEvent.layout.height);
animatedHeight.setValue(e.nativeEvent.layout.height);
}
const h = e.nativeEvent.layout.height;
setCollapsedHeight(h);
animatedHeight.setValue(h);
};
const measureFull = (e: any) => {
if (fullHeight === 0) {
setFullHeight(e.nativeEvent.layout.height);
}
setFullHeight(e.nativeEvent.layout.height);
};
// Cek apakah memang perlu "View More"
useEffect(() => {
if (collapsedHeight > 0 && fullHeight > 0) {
setShouldShowMore(fullHeight > collapsedHeight + 1); // +1 untuk toleransi float
setShouldShowMore(fullHeight > collapsedHeight + 1);
}
}, [collapsedHeight, fullHeight]);
@@ -41,41 +47,34 @@ export default function TextExpandable({ content, maxLines }: { content: string,
return (
<View>
{/* Hidden full text for measurement */}
<View style={Styles.hidden}>
<Text style={Styles.textDefault} onLayout={measureFull}>
{content}
</Text>
</View>
{/* Collapsed text for measurement */}
<View style={Styles.hidden}>
<Text
numberOfLines={maxLines}
style={Styles.textDefault}
onLayout={measureCollapsed}
ellipsizeMode="tail"
>
<Text numberOfLines={maxLines} style={Styles.textDefault} onLayout={measureCollapsed} ellipsizeMode="tail">
{content}
</Text>
</View>
{/* Animated visible text */}
<Animated.View style={{ height: animatedHeight, overflow: 'hidden' }}>
<Text
style={Styles.textDefault}
numberOfLines={isExpanded ? undefined : maxLines}
ellipsizeMode="tail"
>
<Text style={Styles.textDefault} numberOfLines={isExpanded ? undefined : maxLines} ellipsizeMode="tail">
{content}
</Text>
</Animated.View>
{shouldShowMore && (
<Pressable onPress={toggleExpand}>
<Text style={Styles.textLink}>
{isExpanded ? 'View Less' : 'View More'}
<Pressable onPress={toggleExpand} style={Styles.expandBtn}>
<Text style={[Styles.textMediumSemiBold, { color: colors.tabActive }]}>
{isExpanded ? 'Sembunyikan' : 'Lihat selengkapnya'}
</Text>
<MaterialCommunityIcons
name={isExpanded ? 'chevron-up' : 'chevron-down'}
size={16}
color={colors.tabActive}
/>
</Pressable>
)}
</View>

View File

@@ -13,7 +13,7 @@ export const Colors = {
tabActive: '#2563EB',
header: '#234881',
homeGradient: '#346CC4',
dimmed: '#707887ff',
dimmed: '#707887',
success: '#40C057',
warning: '#FBBF24',
error: '#F87171',

View File

@@ -813,6 +813,109 @@ const Styles = StyleSheet.create({
width: '48.5%',
marginBottom: 10,
},
sectionCard: {
borderRadius: 12,
padding: 16,
borderWidth: 1,
},
sectionHeader: {
flexDirection: 'row',
alignItems: 'center',
marginBottom: 12,
},
sectionHeaderRow: {
flexDirection: 'row',
justifyContent: 'space-between',
alignItems: 'center',
marginBottom: 10,
},
sectionIconBox: {
width: 30,
height: 30,
borderRadius: 8,
alignItems: 'center',
justifyContent: 'center',
},
badgeCol: {
alignItems: 'center',
gap: 6,
},
progressBadge: {
borderRadius: 10,
paddingHorizontal: 12,
paddingVertical: 5,
borderWidth: 1,
alignItems: 'center',
},
taskCountBadge: {
borderRadius: 6,
paddingHorizontal: 7,
paddingVertical: 2,
},
textProgressPercent: {
fontSize: 22,
fontWeight: 'bold',
lineHeight: 28,
},
progressTrack: {
height: 8,
borderRadius: 4,
overflow: 'hidden',
},
progressFill: {
height: '100%',
borderRadius: 4,
},
reportContent: {
borderLeftWidth: 3,
paddingLeft: 12,
},
expandBtn: {
flexDirection: 'row',
alignItems: 'center',
alignSelf: 'flex-start',
marginTop: 8,
gap: 4,
},
fileGrid: {
flexDirection: 'row',
flexWrap: 'wrap',
gap: 8,
},
fileCard: {
width: '48%',
borderRadius: 10,
borderWidth: 1,
padding: 12,
flexDirection: 'row',
alignItems: 'center',
gap: 10,
},
sectionActionRow: {
flexDirection: 'row',
alignItems: 'center',
gap: 10,
},
sectionBadge: {
borderRadius: 10,
paddingHorizontal: 8,
paddingVertical: 2,
},
positionBadge: {
borderRadius: 20,
paddingHorizontal: 8,
paddingVertical: 3,
},
listItemCard: {
flexDirection: 'row',
alignItems: 'center',
backgroundColor: 'transparent',
borderRadius: 10,
borderWidth: 1,
paddingHorizontal: 12,
paddingVertical: 10,
gap: 12,
},
flex1: {
flex: 1
},
@@ -965,6 +1068,51 @@ const Styles = StyleSheet.create({
color: 'white',
fontWeight: '500',
},
pv14: {
paddingVertical: 14,
},
mb08: {
marginBottom: 8,
},
cWhiteDimmed: {
color: 'rgba(255,255,255,0.7)',
},
memberAvatarRing: {
borderWidth: 3,
borderColor: 'rgba(255,255,255,0.4)',
borderRadius: 100,
},
memberBadgeRow: {
flexDirection: 'row',
gap: 8,
marginTop: 12,
},
memberBadgeApprover: {
paddingHorizontal: 10,
paddingVertical: 4,
borderRadius: 20,
borderWidth: 1,
borderColor: 'rgba(255,255,255,0.6)',
backgroundColor: 'rgba(255,255,255,0.15)',
},
memberBadgePill: {
paddingHorizontal: 10,
paddingVertical: 4,
borderRadius: 20,
},
memberInfoRow: {
flexDirection: 'row',
alignItems: 'center',
paddingVertical: 14,
},
memberInfoIcon: {
width: 36,
alignItems: 'center',
},
memberInfoContent: {
flex: 1,
marginLeft: 10,
},
})
export default Styles;

View File

@@ -166,6 +166,11 @@ export const apiDeleteUser = async (data: { user: string, isActive: boolean }, i
return response.data
};
export const apiToggleApprover = async (data: { user: string, isApprover: boolean }, id: string) => {
const response = await api.patch(`mobile/user/${id}`, data)
return response.data
};
export const apiEditUser = async (data: FormData, id: string) => {
const response = await api.put(`/mobile/user/${id}`, data, {
headers: {
@@ -357,6 +362,43 @@ export const apiDeleteProjectMember = async (data: { user: string, idUser: strin
return response.data
};
export const apiGetProjectTaskFile = async ({ user, id }: { user: string, id: string }) => {
const response = await api.get(`/mobile/project/task/file/${id}`, { params: { user } })
return response.data;
};
export const apiAddProjectTaskFile = async ({ data, id }: { data: FormData, id: string }) => {
const response = await api.post(`/mobile/project/task/file/${id}`, data, {
headers: { 'Content-Type': 'multipart/form-data' },
})
return response.data;
};
export const apiLinkProjectTaskFile = async ({ user, idFile, id }: { user: string, idFile: string, id: string }) => {
const response = await api.patch(`/mobile/project/task/file/${id}`, { user, idFile })
return response.data;
};
export const apiDeleteProjectTaskFile = async (data: { user: string }, id: string) => {
const response = await api.delete(`/mobile/project/task/file/${id}`, { data })
return response.data;
};
export const apiGetProjectTaskApprovals = async ({ user, id }: { user: string, id: string }) => {
const response = await api.get(`/mobile/project/task/${id}/approval`, { params: { user } })
return response.data;
};
export const apiSubmitProjectTask = async ({ user, id }: { user: string, id: string }) => {
const response = await api.post(`/mobile/project/task/${id}/approval`, { user })
return response.data;
};
export const apiApproveRejectProjectTask = async ({ user, id, action, note }: { user: string, id: string, action: 'approve' | 'reject', note?: string }) => {
const response = await api.put(`/mobile/project/task/${id}/approval`, { user, action, note })
return response.data;
};
export const apiAddMemberProject = async ({ data, id }: { data: { user: string, member: any[] }, id: string }) => {
const response = await api.post(`/mobile/project/${id}/member`, data)
@@ -664,6 +706,43 @@ export const apiAddFileTask = async ({ data, id }: { data: FormData, id: string
return response.data;
};
export const apiGetTaskTugasApprovals = async ({ user, id }: { user: string, id: string }) => {
const response = await api.get(`/mobile/task/tugas/${id}/approval`, { params: { user } })
return response.data;
};
export const apiSubmitTaskTugas = async ({ user, id }: { user: string, id: string }) => {
const response = await api.post(`/mobile/task/tugas/${id}/approval`, { user })
return response.data;
};
export const apiApproveRejectTaskTugas = async ({ user, id, action, note }: { user: string, id: string, action: 'approve' | 'reject', note?: string }) => {
const response = await api.put(`/mobile/task/tugas/${id}/approval`, { user, action, note })
return response.data;
};
export const apiGetTugasTaskFile = async ({ user, id }: { user: string, id: string }) => {
const response = await api.get(`/mobile/task/tugas/file/${id}`, { params: { user } })
return response.data;
};
export const apiAddTugasTaskFile = async ({ data, id }: { data: FormData, id: string }) => {
const response = await api.post(`/mobile/task/tugas/file/${id}`, data, {
headers: { 'Content-Type': 'multipart/form-data' },
})
return response.data;
};
export const apiLinkTugasTaskFile = async ({ user, idFile, id }: { user: string, idFile: string, id: string }) => {
const response = await api.patch(`/mobile/task/tugas/file/${id}`, { user, idFile })
return response.data;
};
export const apiDeleteTugasTaskFile = async (data: { user: string }, id: string) => {
const response = await api.delete(`/mobile/task/tugas/file/${id}`, { data })
return response.data;
};
export const apiEditTask = async (data: { title: string, user: string }, id: string) => {
const response = await api.put(`/mobile/task/${id}`, data)
return response.data;