Merge pull request 'amalia/06-mei-26' (#44) from amalia/06-mei-26 into join
Reviewed-on: #44
This commit is contained in:
@@ -32,6 +32,7 @@ export default function DetailTaskDivision() {
|
|||||||
const [data, setData] = useState<Props>()
|
const [data, setData] = useState<Props>()
|
||||||
const [loading, setLoading] = useState(true)
|
const [loading, setLoading] = useState(true)
|
||||||
const [progress, setProgress] = useState(0)
|
const [progress, setProgress] = useState(0)
|
||||||
|
const [taskStats, setTaskStats] = useState<{ done: number, total: number } | undefined>()
|
||||||
const update = useSelector((state: any) => state.taskUpdate)
|
const update = useSelector((state: any) => state.taskUpdate)
|
||||||
const [refreshing, setRefreshing] = useState(false)
|
const [refreshing, setRefreshing] = useState(false)
|
||||||
const [isMemberDivision, setIsMemberDivision] = 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') {
|
async function handleLoad(cat: 'data' | 'progress') {
|
||||||
try {
|
try {
|
||||||
if (cat == 'data') setLoading(true)
|
if (cat == 'data') setLoading(true)
|
||||||
@@ -90,10 +102,15 @@ export default function DetailTaskDivision() {
|
|||||||
handleLoad('progress')
|
handleLoad('progress')
|
||||||
}, [update.progress])
|
}, [update.progress])
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
handleLoadTaskStats()
|
||||||
|
}, [update.task])
|
||||||
|
|
||||||
const handleRefresh = async () => {
|
const handleRefresh = async () => {
|
||||||
setRefreshing(true)
|
setRefreshing(true)
|
||||||
await handleLoad('data')
|
await handleLoad('data')
|
||||||
await handleLoad('progress')
|
await handleLoad('progress')
|
||||||
|
await handleLoadTaskStats()
|
||||||
await new Promise(resolve => setTimeout(resolve, 2000));
|
await new Promise(resolve => setTimeout(resolve, 2000));
|
||||||
setRefreshing(false)
|
setRefreshing(false)
|
||||||
};
|
};
|
||||||
@@ -135,7 +152,7 @@ export default function DetailTaskDivision() {
|
|||||||
{
|
{
|
||||||
data?.reason != null && data?.reason != "" && <SectionCancel text={data?.reason} />
|
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} />
|
<SectionReportTask refreshing={refreshing} />
|
||||||
<SectionTanggalTugasTask refreshing={refreshing} isMemberDivision={isMemberDivision} />
|
<SectionTanggalTugasTask refreshing={refreshing} isMemberDivision={isMemberDivision} />
|
||||||
<SectionFileTask refreshing={refreshing} isMemberDivision={isMemberDivision} />
|
<SectionFileTask refreshing={refreshing} isMemberDivision={isMemberDivision} />
|
||||||
|
|||||||
@@ -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>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,7 +1,5 @@
|
|||||||
import AppHeader from "@/components/AppHeader";
|
import AppHeader from "@/components/AppHeader";
|
||||||
import BorderBottomItem from "@/components/borderBottomItem";
|
|
||||||
import ButtonSaveHeader from "@/components/buttonSaveHeader";
|
import ButtonSaveHeader from "@/components/buttonSaveHeader";
|
||||||
import ButtonSelect from "@/components/buttonSelect";
|
|
||||||
import DrawerBottom from "@/components/drawerBottom";
|
import DrawerBottom from "@/components/drawerBottom";
|
||||||
import ImageUser from "@/components/imageNew";
|
import ImageUser from "@/components/imageNew";
|
||||||
import { InputForm } from "@/components/inputForm";
|
import { InputForm } from "@/components/inputForm";
|
||||||
@@ -21,11 +19,31 @@ import { Ionicons, MaterialCommunityIcons } from "@expo/vector-icons";
|
|||||||
import * as DocumentPicker from "expo-document-picker";
|
import * as DocumentPicker from "expo-document-picker";
|
||||||
import { router, Stack, useLocalSearchParams } from "expo-router";
|
import { router, Stack, useLocalSearchParams } from "expo-router";
|
||||||
import { useEffect, useState } from "react";
|
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 Toast from "react-native-toast-message";
|
||||||
import { useDispatch, useSelector } from "react-redux";
|
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() {
|
export default function CreateTaskDivision() {
|
||||||
const { colors } = useTheme();
|
const { colors } = useTheme();
|
||||||
const { id } = useLocalSearchParams();
|
const { id } = useLocalSearchParams();
|
||||||
@@ -168,59 +186,131 @@ export default function CreateTaskDivision() {
|
|||||||
bg={colors.card}
|
bg={colors.card}
|
||||||
errorText="Judul Tugas tidak boleh kosong"
|
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 }]}>
|
{/* Tanggal & Tugas */}
|
||||||
{entitiesMember.map(
|
<View style={[
|
||||||
(item: { img: any; name: any }, index: any) => {
|
Styles.wrapPaper, Styles.mb15, Styles.sectionCard,
|
||||||
return (
|
{ backgroundColor: colors.card, borderColor: colors.icon + '18' }
|
||||||
<BorderBottomItem
|
]}>
|
||||||
key={index}
|
<Pressable
|
||||||
borderType="bottom"
|
onPress={() => router.push(`/division/${id}/task/create/task`)}
|
||||||
icon={
|
style={[Styles.sectionActionRow, { marginBottom: taskCreate.length > 0 ? 12 : 0 }]}
|
||||||
<ImageUser
|
>
|
||||||
src={`${ConstEnv.url_storage}/files/${item.img}`}
|
<View style={[Styles.sectionIconBox, { backgroundColor: colors.tabActive + '18' }]}>
|
||||||
size="sm"
|
<MaterialCommunityIcons name="calendar-check-outline" size={18} color={colors.tabActive} />
|
||||||
/>
|
</View>
|
||||||
}
|
<View style={Styles.flex1}>
|
||||||
title={item.name}
|
<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>
|
||||||
</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>
|
</View>
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ export default function DetailProject() {
|
|||||||
const { id } = useLocalSearchParams<{ id: string }>();
|
const { id } = useLocalSearchParams<{ id: string }>();
|
||||||
const [data, setData] = useState<Props>()
|
const [data, setData] = useState<Props>()
|
||||||
const [progress, setProgress] = useState(0)
|
const [progress, setProgress] = useState(0)
|
||||||
|
const [taskStats, setTaskStats] = useState<{ done: number, total: number } | undefined>()
|
||||||
const [loading, setLoading] = useState(true)
|
const [loading, setLoading] = useState(true)
|
||||||
const update = useSelector((state: any) => state.projectUpdate)
|
const update = useSelector((state: any) => state.projectUpdate)
|
||||||
const [isMember, setIsMember] = useState(false)
|
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() {
|
async function checkMember() {
|
||||||
try {
|
try {
|
||||||
const hasil = await decryptToken(String(token?.current))
|
const hasil = await decryptToken(String(token?.current))
|
||||||
@@ -79,6 +91,10 @@ export default function DetailProject() {
|
|||||||
handleLoad('progress')
|
handleLoad('progress')
|
||||||
}, [update.progress])
|
}, [update.progress])
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
handleLoadTaskStats()
|
||||||
|
}, [update.task])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
checkMember()
|
checkMember()
|
||||||
}, [])
|
}, [])
|
||||||
@@ -88,6 +104,7 @@ export default function DetailProject() {
|
|||||||
setRefreshing(true)
|
setRefreshing(true)
|
||||||
await handleLoad('data')
|
await handleLoad('data')
|
||||||
await handleLoad('progress')
|
await handleLoad('progress')
|
||||||
|
await handleLoadTaskStats()
|
||||||
await new Promise(resolve => setTimeout(resolve, 2000));
|
await new Promise(resolve => setTimeout(resolve, 2000));
|
||||||
setRefreshing(false)
|
setRefreshing(false)
|
||||||
};
|
};
|
||||||
@@ -126,7 +143,7 @@ export default function DetailProject() {
|
|||||||
{
|
{
|
||||||
data?.reason != null && data?.reason != "" && <SectionCancel text={data?.reason} />
|
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} />
|
<SectionReportProject refreshing={refreshing} />
|
||||||
<SectionTanggalTugasProject status={data?.status} member={isMember} refreshing={refreshing} />
|
<SectionTanggalTugasProject status={data?.status} member={isMember} refreshing={refreshing} />
|
||||||
<SectionFile status={data?.status} member={isMember} refreshing={refreshing} />
|
<SectionFile status={data?.status} member={isMember} refreshing={refreshing} />
|
||||||
|
|||||||
377
app/(application)/project/[id]/tugas-file/[taskId].tsx
Normal file
377
app/(application)/project/[id]/tugas-file/[taskId].tsx
Normal 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>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,7 +1,5 @@
|
|||||||
import AppHeader from "@/components/AppHeader";
|
import AppHeader from "@/components/AppHeader";
|
||||||
import BorderBottomItem from "@/components/borderBottomItem";
|
|
||||||
import ButtonSaveHeader from "@/components/buttonSaveHeader";
|
import ButtonSaveHeader from "@/components/buttonSaveHeader";
|
||||||
import ButtonSelect from "@/components/buttonSelect";
|
|
||||||
import DrawerBottom from "@/components/drawerBottom";
|
import DrawerBottom from "@/components/drawerBottom";
|
||||||
import ImageUser from "@/components/imageNew";
|
import ImageUser from "@/components/imageNew";
|
||||||
import { InputForm } from "@/components/inputForm";
|
import { InputForm } from "@/components/inputForm";
|
||||||
@@ -25,6 +23,7 @@ import * as DocumentPicker from "expo-document-picker";
|
|||||||
import { router, Stack } from "expo-router";
|
import { router, Stack } from "expo-router";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import {
|
import {
|
||||||
|
Pressable,
|
||||||
SafeAreaView,
|
SafeAreaView,
|
||||||
ScrollView,
|
ScrollView,
|
||||||
View
|
View
|
||||||
@@ -32,6 +31,26 @@ import {
|
|||||||
import Toast from "react-native-toast-message";
|
import Toast from "react-native-toast-message";
|
||||||
import { useDispatch, useSelector } from "react-redux";
|
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() {
|
export default function CreateProject() {
|
||||||
const { colors } = useTheme();
|
const { colors } = useTheme();
|
||||||
const [loading, setLoading] = useState(false)
|
const [loading, setLoading] = useState(false)
|
||||||
@@ -241,26 +260,23 @@ export default function CreateProject() {
|
|||||||
style={[Styles.h100, { backgroundColor: colors.background }]}
|
style={[Styles.h100, { backgroundColor: colors.background }]}
|
||||||
>
|
>
|
||||||
<View style={[Styles.p15]}>
|
<View style={[Styles.p15]}>
|
||||||
{
|
{(entityUser.role == "supadmin" || entityUser.role == "developer") && (
|
||||||
(entityUser.role == "supadmin" || entityUser.role == "developer")
|
<SelectForm
|
||||||
&&
|
label="Lembaga Desa"
|
||||||
(
|
placeholder="Pilih Lembaga Desa"
|
||||||
<SelectForm
|
value={chooseGroup.label}
|
||||||
label="Lembaga Desa"
|
required
|
||||||
placeholder="Pilih Lembaga Desa"
|
bg={colors.card}
|
||||||
value={chooseGroup.label}
|
onPress={() => {
|
||||||
required
|
setValChoose(chooseGroup.val);
|
||||||
bg={colors.card}
|
setValSelect("group");
|
||||||
onPress={() => {
|
setSelect(true);
|
||||||
setValChoose(chooseGroup.val);
|
}}
|
||||||
setValSelect("group");
|
error={error.group}
|
||||||
setSelect(true);
|
errorText="Lembaga Desa tidak boleh kosong"
|
||||||
}}
|
/>
|
||||||
error={error.group}
|
)}
|
||||||
errorText="Lembaga Desa tidak boleh kosong"
|
|
||||||
/>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
<InputForm
|
<InputForm
|
||||||
label="Kegiatan"
|
label="Kegiatan"
|
||||||
type="default"
|
type="default"
|
||||||
@@ -270,85 +286,154 @@ export default function CreateProject() {
|
|||||||
value={dataForm.title}
|
value={dataForm.title}
|
||||||
error={error.title}
|
error={error.title}
|
||||||
errorText="Nama kegiatan tidak boleh kosong"
|
errorText="Nama kegiatan tidak boleh kosong"
|
||||||
onChange={(val) => {
|
onChange={(val) => validationForm("title", 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 }]}>
|
{/* Tanggal & Tugas */}
|
||||||
{entitiesMember.map(
|
<View style={[
|
||||||
(item: { img: any; name: any }, index: any) => {
|
Styles.wrapPaper, Styles.mb15, Styles.sectionCard,
|
||||||
return (
|
{ backgroundColor: colors.card, borderColor: error.task ? colors.error + '50' : colors.icon + '18' }
|
||||||
<BorderBottomItem
|
]}>
|
||||||
key={index}
|
<Pressable
|
||||||
borderType="bottom"
|
onPress={() => router.push(`/project/create/task`)}
|
||||||
icon={
|
style={[Styles.sectionActionRow, { marginBottom: taskCreate.length > 0 ? 12 : 0 }]}
|
||||||
<ImageUser
|
>
|
||||||
src={`${ConstEnv.url_storage}/files/${item.img}`}
|
<View style={[Styles.sectionIconBox, { backgroundColor: colors.tabActive + '18' }]}>
|
||||||
size="sm"
|
<MaterialCommunityIcons name="calendar-check-outline" size={18} color={colors.tabActive} />
|
||||||
/>
|
</View>
|
||||||
}
|
<View style={Styles.flex1}>
|
||||||
title={item.name}
|
<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>
|
||||||
</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>
|
</View>
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
<DrawerBottom animation="slide" isVisible={isModal} setVisible={setModal} title="Menu">
|
<DrawerBottom animation="slide" isVisible={isModal} setVisible={setModal} title="Menu">
|
||||||
|
|||||||
@@ -1,62 +1,184 @@
|
|||||||
import Styles from "@/constants/Styles";
|
import Styles from "@/constants/Styles";
|
||||||
import { useTheme } from "@/providers/ThemeProvider";
|
import { useTheme } from "@/providers/ThemeProvider";
|
||||||
import { MaterialCommunityIcons } from "@expo/vector-icons";
|
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";
|
import Text from "./Text";
|
||||||
|
|
||||||
|
type FileItem = {
|
||||||
|
name: string
|
||||||
|
extension: string
|
||||||
|
}
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
done?: boolean
|
done?: boolean
|
||||||
title: string
|
title: string
|
||||||
dateStart: string
|
dateStart: string
|
||||||
dateEnd: string
|
dateEnd: string
|
||||||
|
files?: FileItem[]
|
||||||
onPress?: () => void
|
onPress?: () => void
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function ItemSectionTanggalTugas({ done, title, dateStart, dateEnd, onPress }: Props) {
|
const CHAR_W = 6.5
|
||||||
const { colors } = useTheme();
|
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'
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function ItemSectionTanggalTugas({ done, 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 accentColor = done === true ? successColor : dimmed + '80'
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Pressable style={[Styles.mb15, { borderBottomColor: colors.icon + '20', borderBottomWidth: 1 }]} onPress={onPress}>
|
<Pressable
|
||||||
<View style={[Styles.rowItemsCenter]}>
|
onPress={onPress}
|
||||||
{
|
style={{
|
||||||
done != undefined ?
|
flexDirection: 'row',
|
||||||
done ?
|
borderRadius: 10,
|
||||||
<>
|
overflow: 'hidden',
|
||||||
<MaterialCommunityIcons name="checkbox-marked-circle-outline" size={22} color={colors.text} style={[Styles.mr10]} />
|
borderWidth: 1,
|
||||||
<Text>Selesai</Text>
|
borderColor: colors.icon + '18',
|
||||||
</>
|
backgroundColor: colors.card,
|
||||||
:
|
marginBottom: 10,
|
||||||
<>
|
}}
|
||||||
<MaterialCommunityIcons name="checkbox-blank-circle-outline" size={22} color={colors.text} style={[Styles.mr10]} />
|
>
|
||||||
<Text>Belum Selesai</Text>
|
{/* Accent bar kiri */}
|
||||||
</>
|
{done !== undefined && (
|
||||||
:
|
<View style={{ width: 4, backgroundColor: accentColor }} />
|
||||||
<></>
|
)}
|
||||||
}
|
|
||||||
|
|
||||||
</View>
|
{/* Konten */}
|
||||||
<View style={[Styles.wrapPaper, Styles.noShadow, Styles.borderAll, Styles.mv10, Styles.p10, { backgroundColor: colors.card, borderColor: colors.icon + '20' }]}>
|
<View style={{ flex: 1, padding: 12 }}>
|
||||||
<View style={[Styles.rowItemsCenter, { alignItems: 'flex-start' }]}>
|
|
||||||
<MaterialCommunityIcons name="file-table-outline" size={25} color={colors.text} style={[Styles.mr10]} />
|
{/* Judul + badge status */}
|
||||||
<View style={[Styles.w90]}>
|
<View style={{ flexDirection: 'row', justifyContent: 'space-between', alignItems: 'flex-start', marginBottom: 8 }}>
|
||||||
<Text style={[Styles.textDefault]}>{title}</Text>
|
<Text style={[Styles.textDefault, { flex: 1, marginRight: 8 }]}>{title}</Text>
|
||||||
</View>
|
{done !== undefined && (
|
||||||
|
<View style={{
|
||||||
|
backgroundColor: done ? successColor + '25' : dimmed + '18',
|
||||||
|
borderRadius: 20,
|
||||||
|
paddingHorizontal: 8,
|
||||||
|
paddingVertical: 3,
|
||||||
|
alignSelf: 'flex-start',
|
||||||
|
}}>
|
||||||
|
<Text style={[Styles.textSmallSemiBold, { color: done ? successColor : colors.dimmed }]}>
|
||||||
|
{done ? 'Selesai' : 'Belum Selesai'}
|
||||||
|
</Text>
|
||||||
|
</View>
|
||||||
|
)}
|
||||||
</View>
|
</View>
|
||||||
</View>
|
|
||||||
<View style={[Styles.rowSpaceBetween, Styles.mb15]}>
|
{/* Tanggal */}
|
||||||
<View style={[{ width: '48%' }]}>
|
<View style={{ flexDirection: 'row', alignItems: 'center', marginBottom: files.length > 0 ? 8 : 0 }}>
|
||||||
<Text style={[Styles.mb05]}>Tanggal Mulai</Text>
|
<MaterialCommunityIcons name="calendar-outline" size={13} color={colors.dimmed} style={{ marginRight: 4 }} />
|
||||||
<View style={[Styles.wrapPaper, Styles.noShadow, Styles.borderAll, Styles.p10, { backgroundColor: colors.card, borderColor: colors.icon + '20' }]}>
|
<Text style={[Styles.textSmallSemiBold, { color: colors.dimmed }]}>{dateStart}</Text>
|
||||||
<Text style={{ textAlign: 'center' }}>{dateStart}</Text>
|
<MaterialCommunityIcons name="arrow-right" size={13} color={colors.dimmed} style={{ marginHorizontal: 4 }} />
|
||||||
</View>
|
<Text style={[Styles.textSmallSemiBold, { color: colors.dimmed }]}>{dateEnd}</Text>
|
||||||
</View>
|
</View>
|
||||||
<View style={[{ width: '48%' }]}>
|
|
||||||
<Text style={[Styles.mb05]}>Tanggal Berakhir</Text>
|
{/* Chips lampiran */}
|
||||||
<View style={[Styles.wrapPaper, Styles.noShadow, Styles.borderAll, Styles.p10, { backgroundColor: colors.card, borderColor: colors.icon + '20' }]}>
|
{files.length > 0 && (
|
||||||
<Text style={{ textAlign: 'center' }}>{dateEnd}</Text>
|
<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>
|
)}
|
||||||
</View>
|
</View>
|
||||||
</Pressable>
|
</Pressable>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -108,12 +108,12 @@ export default function ModalSelect({ open, close, title, category, idParent, on
|
|||||||
setChooseValue({ ...chooseValue, val: valChoose })
|
setChooseValue({ ...chooseValue, val: valChoose })
|
||||||
}, [dispatch, open, search]);
|
}, [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 (category == "member") {
|
||||||
if (selectMember.some((i: any) => i.idUser == val)) {
|
if (selectMember.some((i: any) => i.idUser == val)) {
|
||||||
setSelectMember(selectMember.filter((i: any) => i.idUser != val))
|
setSelectMember(selectMember.filter((i: any) => i.idUser != val))
|
||||||
} else {
|
} else {
|
||||||
setSelectMember([...selectMember, { idUser: val, name: label, img }])
|
setSelectMember([...selectMember, { idUser: val, name: label, img, position }])
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
setChooseValue({ val, label })
|
setChooseValue({ val, label })
|
||||||
@@ -144,7 +144,7 @@ export default function ModalSelect({ open, close, title, category, idParent, on
|
|||||||
key={index}
|
key={index}
|
||||||
label={item.name}
|
label={item.name}
|
||||||
src={`${ConstEnv.url_storage}/files/${item.img}`}
|
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' ?
|
category != 'status-task' ?
|
||||||
data.length > 0 ?
|
data.length > 0 ?
|
||||||
data.map((item: any, index: any) => (
|
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'
|
category == 'member'
|
||||||
?
|
?
|
||||||
|
|||||||
100
components/project/itemSectionLink.tsx
Normal file
100
components/project/itemSectionLink.tsx
Normal 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>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -10,19 +10,17 @@ import { startActivityAsync } from 'expo-intent-launcher';
|
|||||||
import { useLocalSearchParams } from "expo-router";
|
import { useLocalSearchParams } from "expo-router";
|
||||||
import * as Sharing from 'expo-sharing';
|
import * as Sharing from 'expo-sharing';
|
||||||
import { useEffect, useState } from "react";
|
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 * as mime from 'react-native-mime-types';
|
||||||
import Toast from "react-native-toast-message";
|
import Toast from "react-native-toast-message";
|
||||||
import { useDispatch, useSelector } from "react-redux";
|
import { useDispatch, useSelector } from "react-redux";
|
||||||
import ModalConfirmation from "../ModalConfirmation";
|
|
||||||
import BorderBottomItem from "../borderBottomItem";
|
|
||||||
import DrawerBottom from "../drawerBottom";
|
import DrawerBottom from "../drawerBottom";
|
||||||
import MenuItemRow from "../menuItemRow";
|
import MenuItemRow from "../menuItemRow";
|
||||||
|
import ModalConfirmation from "../ModalConfirmation";
|
||||||
import ModalLoading from "../modalLoading";
|
import ModalLoading from "../modalLoading";
|
||||||
import Skeleton from "../skeleton";
|
import Skeleton from "../skeleton";
|
||||||
import Text from "../Text";
|
import Text from "../Text";
|
||||||
|
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
id: string
|
id: string
|
||||||
name: string
|
name: string
|
||||||
@@ -30,6 +28,28 @@ type Props = {
|
|||||||
idStorage: string
|
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 }) {
|
export default function SectionFile({ status, member, refreshing }: { status: number | undefined, member: boolean, refreshing?: boolean }) {
|
||||||
const { colors } = useTheme();
|
const { colors } = useTheme();
|
||||||
const entityUser = useSelector((state: any) => state.user)
|
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 update = useSelector((state: any) => state.projectUpdate)
|
||||||
const dispatch = useDispatch()
|
const dispatch = useDispatch()
|
||||||
const [loading, setLoading] = useState(true)
|
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 [selectFile, setSelectFile] = useState<Props | null>(null)
|
||||||
const [showDeleteModal, setShowDeleteModal] = useState(false)
|
const [showDeleteModal, setShowDeleteModal] = useState(false)
|
||||||
const [loadingOpen, setLoadingOpen] = useState(false)
|
const [loadingOpen, setLoadingOpen] = useState(false)
|
||||||
@@ -49,11 +69,7 @@ export default function SectionFile({ status, member, refreshing }: { status: nu
|
|||||||
try {
|
try {
|
||||||
setLoading(loading)
|
setLoading(loading)
|
||||||
const hasil = await decryptToken(String(token?.current));
|
const hasil = await decryptToken(String(token?.current));
|
||||||
const response = await apiGetProjectOne({
|
const response = await apiGetProjectOne({ user: hasil, cat: "file", id });
|
||||||
user: hasil,
|
|
||||||
cat: "file",
|
|
||||||
id: id,
|
|
||||||
});
|
|
||||||
setData(response.data);
|
setData(response.data);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
@@ -62,110 +78,90 @@ export default function SectionFile({ status, member, refreshing }: { status: nu
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => { handleLoad(false) }, [update.file]);
|
||||||
handleLoad(false);
|
useEffect(() => { if (refreshing) handleLoad(false) }, [refreshing]);
|
||||||
}, [update.file]);
|
useEffect(() => { handleLoad(true) }, []);
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (refreshing)
|
|
||||||
handleLoad(false);
|
|
||||||
}, [refreshing]);
|
|
||||||
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
handleLoad(true);
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
async function handleDelete() {
|
async function handleDelete() {
|
||||||
try {
|
try {
|
||||||
const hasil = await decryptToken(String(token?.current));
|
const hasil = await decryptToken(String(token?.current));
|
||||||
const response = await apiDeleteFileProject({ user: hasil }, String(selectFile?.id));
|
const response = await apiDeleteFileProject({ user: hasil }, String(selectFile?.id));
|
||||||
if (response.success) {
|
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 }))
|
dispatch(setUpdateProject({ ...update, file: !update.file }))
|
||||||
} else {
|
} else {
|
||||||
Toast.show({ type: 'small', text1: response.message, })
|
Toast.show({ type: 'small', text1: response.message })
|
||||||
}
|
}
|
||||||
} catch (error : any ) {
|
} catch (error: any) {
|
||||||
console.error(error);
|
Toast.show({ type: 'small', text1: error?.response?.data?.message || "Gagal menghapus file" })
|
||||||
const message = error?.response?.data?.message || "Gagal menghapus file"
|
|
||||||
|
|
||||||
Toast.show({ type: 'small', text1: message })
|
|
||||||
} finally {
|
} finally {
|
||||||
setModal(false)
|
setModal(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const openFile = () => {
|
const openFile = () => {
|
||||||
setModal(false)
|
setModal(false)
|
||||||
setLoadingOpen(true)
|
setLoadingOpen(true)
|
||||||
let remoteUrl = ConstEnv.url_storage + '/files/' + selectFile?.idStorage;
|
const remoteUrl = ConstEnv.url_storage + '/files/' + selectFile?.idStorage
|
||||||
const fileName = selectFile?.name + '.' + selectFile?.extension;
|
const fileName = selectFile?.name + '.' + selectFile?.extension
|
||||||
let localPath = `${FileSystem.documentDirectory}/${fileName}`;
|
const localPath = `${FileSystem.documentDirectory}/${fileName}`
|
||||||
const mimeType = mime.lookup(fileName)
|
const mimeType = mime.lookup(fileName)
|
||||||
|
|
||||||
FileSystem.downloadAsync(remoteUrl, localPath).then(async ({ uri }) => {
|
FileSystem.downloadAsync(remoteUrl, localPath).then(async ({ uri }) => {
|
||||||
const contentURL = await FileSystem.getContentUriAsync(uri);
|
const contentURL = await FileSystem.getContentUriAsync(uri)
|
||||||
try {
|
try {
|
||||||
|
if (Platform.OS === 'android') {
|
||||||
if (Platform.OS == 'android') {
|
await startActivityAsync('android.intent.action.VIEW', { data: contentURL, flags: 1, type: mimeType as string })
|
||||||
// open with android intent
|
} else {
|
||||||
await startActivityAsync(
|
Sharing.shareAsync(localPath)
|
||||||
'android.intent.action.VIEW',
|
|
||||||
{
|
|
||||||
data: contentURL,
|
|
||||||
flags: 1,
|
|
||||||
type: mimeType as string,
|
|
||||||
}
|
|
||||||
);
|
|
||||||
// or
|
|
||||||
// Sharing.shareAsync(localPath);
|
|
||||||
|
|
||||||
} else if (Platform.OS == 'ios') {
|
|
||||||
Sharing.shareAsync(localPath);
|
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch {
|
||||||
Alert.alert('INFO', 'Gagal membuka file, tidak ada aplikasi yang dapat membuka file ini');
|
Alert.alert('INFO', 'Gagal membuka file, tidak ada aplikasi yang dapat membuka file ini')
|
||||||
} finally {
|
} finally {
|
||||||
setLoadingOpen(false)
|
setLoadingOpen(false)
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<ModalLoading isVisible={loadingOpen} setVisible={setLoadingOpen} />
|
<ModalLoading isVisible={loadingOpen} setVisible={setLoadingOpen} />
|
||||||
<View style={[Styles.mb15]}>
|
<View style={[Styles.mb15]}>
|
||||||
<Text style={[Styles.textDefaultSemiBold, Styles.mv05]}>File</Text>
|
<Text style={[Styles.textDefaultSemiBold, Styles.mv05]}>File</Text>
|
||||||
<View style={[Styles.wrapPaper, { backgroundColor: colors.card, borderColor: colors.background }]}>
|
|
||||||
{
|
{loading ? (
|
||||||
loading ?
|
<View style={Styles.fileGrid}>
|
||||||
arrSkeleton.map((item, index) => {
|
{arrSkeleton.map((_, index) => (
|
||||||
return (
|
<Skeleton key={index} width={48} height={68} widthType="percent" borderRadius={10} />
|
||||||
<Skeleton key={index} width={100} height={40} widthType="percent" borderRadius={10} />
|
))}
|
||||||
)
|
</View>
|
||||||
})
|
) : data.length > 0 ? (
|
||||||
:
|
<View style={Styles.fileGrid}>
|
||||||
data.length > 0 ?
|
{data.map((item, index) => {
|
||||||
data.map((item, index) => {
|
const iconName = getFileIcon(item.extension)
|
||||||
return (
|
const iconColor = getFileColor(item.extension)
|
||||||
<BorderBottomItem
|
return (
|
||||||
key={index}
|
<Pressable
|
||||||
borderType="all"
|
key={index}
|
||||||
icon={<MaterialCommunityIcons name="file-outline" size={25} color={colors.text} />}
|
onPress={() => { setSelectFile(item); setModal(true) }}
|
||||||
title={item.name + '.' + item.extension}
|
style={[Styles.fileCard, { backgroundColor: colors.card, borderColor: colors.icon + '18' }]}
|
||||||
titleWeight="normal"
|
>
|
||||||
onPress={() => { setSelectFile(item); setModal(true) }}
|
<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.textDefault, { textAlign: 'center', color: colors.dimmed }]}>Tidak ada file</Text>
|
<Text style={[Styles.textSmallSemiBold, { color: colors.dimmed }]}>
|
||||||
}
|
{item.extension.toUpperCase()}
|
||||||
</View>
|
</Text>
|
||||||
|
</View>
|
||||||
|
</Pressable>
|
||||||
|
)
|
||||||
|
})}
|
||||||
|
</View>
|
||||||
|
) : (
|
||||||
|
<Text style={[Styles.textDefault, { textAlign: 'center', color: colors.dimmed }]}>Tidak ada file</Text>
|
||||||
|
)}
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
<DrawerBottom animation="slide" isVisible={isModal} setVisible={setModal} title="Menu">
|
<DrawerBottom animation="slide" isVisible={isModal} setVisible={setModal} title="Menu">
|
||||||
@@ -173,26 +169,20 @@ export default function SectionFile({ status, member, refreshing }: { status: nu
|
|||||||
<MenuItemRow
|
<MenuItemRow
|
||||||
icon={<MaterialCommunityIcons name="file-eye" color={colors.text} size={25} />}
|
icon={<MaterialCommunityIcons name="file-eye" color={colors.text} size={25} />}
|
||||||
title="Lihat / Share"
|
title="Lihat / Share"
|
||||||
onPress={() => {
|
onPress={openFile}
|
||||||
openFile()
|
|
||||||
}}
|
|
||||||
/>
|
/>
|
||||||
{
|
{(!member && (entityUser.role === "user" || entityUser.role === "coadmin")) ? null : (
|
||||||
!member && (entityUser.role == "user" || entityUser.role == "coadmin") ? <></>
|
<MenuItemRow
|
||||||
:
|
icon={<Ionicons name="trash-outline" color={colors.text} size={25} />}
|
||||||
<MenuItemRow
|
title="Hapus"
|
||||||
icon={<Ionicons name="trash-outline" color={colors.text} size={25} />}
|
disabled={status === 3}
|
||||||
title="Hapus"
|
onPress={() => {
|
||||||
disabled={status == 3}
|
if (status === 3) return
|
||||||
onPress={() => {
|
setModal(false)
|
||||||
if (status == 3) return
|
setTimeout(() => setShowDeleteModal(true), 600)
|
||||||
setModal(false)
|
}}
|
||||||
setTimeout(() => {
|
/>
|
||||||
setShowDeleteModal(true)
|
)}
|
||||||
}, 600)
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
</View>
|
</View>
|
||||||
</DrawerBottom>
|
</DrawerBottom>
|
||||||
|
|
||||||
@@ -200,14 +190,11 @@ export default function SectionFile({ status, member, refreshing }: { status: nu
|
|||||||
visible={showDeleteModal}
|
visible={showDeleteModal}
|
||||||
title="Konfirmasi"
|
title="Konfirmasi"
|
||||||
message="Apakah Anda yakin ingin menghapus file ini? File yang dihapus tidak dapat dikembalikan"
|
message="Apakah Anda yakin ingin menghapus file ini? File yang dihapus tidak dapat dikembalikan"
|
||||||
onConfirm={() => {
|
onConfirm={() => { setShowDeleteModal(false); handleDelete() }}
|
||||||
setShowDeleteModal(false)
|
|
||||||
handleDelete()
|
|
||||||
}}
|
|
||||||
onCancel={() => setShowDeleteModal(false)}
|
onCancel={() => setShowDeleteModal(false)}
|
||||||
confirmText="Hapus"
|
confirmText="Hapus"
|
||||||
cancelText="Batal"
|
cancelText="Batal"
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,20 +1,19 @@
|
|||||||
import Styles from "@/constants/Styles";
|
import Styles from "@/constants/Styles";
|
||||||
import { apiDeleteLinkProject, apiGetProjectOne } from "@/lib/api";
|
import { apiDeleteLinkProject, apiGetProjectOne } from "@/lib/api";
|
||||||
import { urlCompleted } from "@/lib/fun_urlCompleted";
|
|
||||||
import { setUpdateProject } from "@/lib/projectUpdate";
|
import { setUpdateProject } from "@/lib/projectUpdate";
|
||||||
import { useAuthSession } from "@/providers/AuthProvider";
|
import { useAuthSession } from "@/providers/AuthProvider";
|
||||||
import { useTheme } from "@/providers/ThemeProvider";
|
import { useTheme } from "@/providers/ThemeProvider";
|
||||||
import { Feather, Ionicons } from "@expo/vector-icons";
|
import { Ionicons } from "@expo/vector-icons";
|
||||||
import { useLocalSearchParams } from "expo-router";
|
import { useLocalSearchParams } from "expo-router";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { Linking, View } from "react-native";
|
import { View } from "react-native";
|
||||||
import Toast from "react-native-toast-message";
|
import Toast from "react-native-toast-message";
|
||||||
import { useDispatch, useSelector } from "react-redux";
|
import { useDispatch, useSelector } from "react-redux";
|
||||||
import ModalConfirmation from "../ModalConfirmation";
|
import ModalConfirmation from "../ModalConfirmation";
|
||||||
import BorderBottomItem from "../borderBottomItem";
|
|
||||||
import DrawerBottom from "../drawerBottom";
|
import DrawerBottom from "../drawerBottom";
|
||||||
import MenuItemRow from "../menuItemRow";
|
import MenuItemRow from "../menuItemRow";
|
||||||
import Text from "../Text";
|
import Text from "../Text";
|
||||||
|
import ItemSectionLink from "./itemSectionLink";
|
||||||
|
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
@@ -87,17 +86,16 @@ export default function SectionLink({ status, member, refreshing }: { status: nu
|
|||||||
<>
|
<>
|
||||||
<View style={[Styles.mb15]}>
|
<View style={[Styles.mb15]}>
|
||||||
<Text style={[Styles.textDefaultSemiBold, Styles.mv05]}>Link</Text>
|
<Text style={[Styles.textDefaultSemiBold, Styles.mv05]}>Link</Text>
|
||||||
<View style={[Styles.wrapPaper, { backgroundColor: colors.card, borderColor: colors.background }]}>
|
<View>
|
||||||
{
|
{
|
||||||
data.map((item, index) => {
|
data.map((item, index) => {
|
||||||
|
const canDelete = member || (entityUser.role !== "user" && entityUser.role !== "coadmin")
|
||||||
return (
|
return (
|
||||||
<BorderBottomItem
|
<ItemSectionLink
|
||||||
key={index}
|
key={index}
|
||||||
borderType="all"
|
link={item.link}
|
||||||
icon={<Feather name="link" size={25} color={colors.text} />}
|
canDelete={canDelete && status !== 3}
|
||||||
title={item.link}
|
onLongPress={() => { setSelectLink(item); setModal(true) }}
|
||||||
titleWeight="normal"
|
|
||||||
onPress={() => { 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">
|
<DrawerBottom animation="slide" isVisible={isModal} setVisible={setModal} title="Menu">
|
||||||
<View style={Styles.rowItemsCenter}>
|
<View style={Styles.rowItemsCenter}>
|
||||||
<MenuItemRow
|
<MenuItemRow
|
||||||
icon={<Feather name="external-link" color={colors.text} size={25} />}
|
icon={<Ionicons name="trash-outline" color={colors.text} size={25} />}
|
||||||
title="Buka Link"
|
title="Hapus Link"
|
||||||
onPress={() => {
|
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>
|
</View>
|
||||||
</DrawerBottom>
|
</DrawerBottom>
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import ItemSectionTanggalTugas from "../itemSectionTanggalTugas";
|
|||||||
import MenuItemRow from "../menuItemRow";
|
import MenuItemRow from "../menuItemRow";
|
||||||
import Text from "../Text";
|
import Text from "../Text";
|
||||||
|
|
||||||
export default function SectionListAddTask() {
|
export default function SectionListAddTask({ showTitle = true }: { showTitle?: boolean }) {
|
||||||
const { colors } = useTheme();
|
const { colors } = useTheme();
|
||||||
const taskCreate = useSelector((state: any) => state.taskCreate)
|
const taskCreate = useSelector((state: any) => state.taskCreate)
|
||||||
const [select, setSelect] = useState<any>(null)
|
const [select, setSelect] = useState<any>(null)
|
||||||
@@ -22,42 +22,32 @@ export default function SectionListAddTask() {
|
|||||||
setModal(false)
|
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 (
|
return (
|
||||||
<>
|
<>
|
||||||
{
|
{taskCreate.length > 0 && (
|
||||||
taskCreate.length > 0
|
|
||||||
&&
|
|
||||||
<>
|
<>
|
||||||
<View style={[Styles.mb15, Styles.mt10]}>
|
{showTitle ? (
|
||||||
<Text style={[Styles.textDefaultSemiBold, Styles.mv05]}>
|
<View style={[Styles.mb15, Styles.mt10]}>
|
||||||
Tanggal & Tugas
|
<Text style={[Styles.textDefaultSemiBold, Styles.mv05]}>Tanggal & Tugas</Text>
|
||||||
</Text>
|
{items}
|
||||||
<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)
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
</View>
|
</View>
|
||||||
</View>
|
) : (
|
||||||
<DrawerBottom
|
<View>{items}</View>
|
||||||
animation="slide"
|
)}
|
||||||
isVisible={isModal}
|
<DrawerBottom animation="slide" isVisible={isModal} setVisible={setModal} title="Menu">
|
||||||
setVisible={setModal}
|
|
||||||
title="Menu"
|
|
||||||
>
|
|
||||||
<View style={Styles.rowItemsCenter}>
|
<View style={Styles.rowItemsCenter}>
|
||||||
<MenuItemRow
|
<MenuItemRow
|
||||||
icon={<Ionicons name="trash-outline" color={colors.text} size={25} />}
|
icon={<Ionicons name="trash-outline" color={colors.text} size={25} />}
|
||||||
@@ -67,7 +57,7 @@ export default function SectionListAddTask() {
|
|||||||
</View>
|
</View>
|
||||||
</DrawerBottom>
|
</DrawerBottom>
|
||||||
</>
|
</>
|
||||||
}
|
)}
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -7,15 +7,14 @@ import { useTheme } from "@/providers/ThemeProvider";
|
|||||||
import { MaterialCommunityIcons } from "@expo/vector-icons";
|
import { MaterialCommunityIcons } from "@expo/vector-icons";
|
||||||
import { router, useLocalSearchParams } from "expo-router";
|
import { router, useLocalSearchParams } from "expo-router";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { View } from "react-native";
|
import { Pressable, View } from "react-native";
|
||||||
import Toast from "react-native-toast-message";
|
import Toast from "react-native-toast-message";
|
||||||
import { useDispatch, useSelector } from "react-redux";
|
import { useDispatch, useSelector } from "react-redux";
|
||||||
import ModalConfirmation from "../ModalConfirmation";
|
|
||||||
import BorderBottomItem from "../borderBottomItem";
|
|
||||||
import DrawerBottom from "../drawerBottom";
|
import DrawerBottom from "../drawerBottom";
|
||||||
import ImageUser from "../imageNew";
|
import ImageUser from "../imageNew";
|
||||||
import MenuItemRow from "../menuItemRow";
|
import MenuItemRow from "../menuItemRow";
|
||||||
import SkeletonTwoItem from "../skeletonTwoItem";
|
import ModalConfirmation from "../ModalConfirmation";
|
||||||
|
import Skeleton from "../skeleton";
|
||||||
import Text from "../Text";
|
import Text from "../Text";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
@@ -35,26 +34,17 @@ export default function SectionMember({ status, refreshing }: { status: number |
|
|||||||
const [isModal, setModal] = useState(false);
|
const [isModal, setModal] = useState(false);
|
||||||
const { token, decryptToken } = useAuthSession();
|
const { token, decryptToken } = useAuthSession();
|
||||||
const { id } = useLocalSearchParams<{ id: string }>();
|
const { id } = useLocalSearchParams<{ id: string }>();
|
||||||
const [selectLink, setSelectLink] = useState<Props | null>(null);
|
|
||||||
const [showDeleteModal, setShowDeleteModal] = useState(false);
|
const [showDeleteModal, setShowDeleteModal] = useState(false);
|
||||||
const [data, setData] = useState<Props[]>([]);
|
const [data, setData] = useState<Props[]>([]);
|
||||||
const [loading, setLoading] = useState(true)
|
const [loading, setLoading] = useState(true)
|
||||||
const arrSkeleton = Array.from({ length: 3 })
|
const arrSkeleton = Array.from({ length: 4 })
|
||||||
const [memberChoose, setMemberChoose] = useState({
|
const [memberChoose, setMemberChoose] = useState({ id: '', name: '' })
|
||||||
id: '',
|
|
||||||
name: '',
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
async function handleLoad(loading: boolean) {
|
async function handleLoad(loading: boolean) {
|
||||||
try {
|
try {
|
||||||
setLoading(loading)
|
setLoading(loading)
|
||||||
const hasil = await decryptToken(String(token?.current));
|
const hasil = await decryptToken(String(token?.current));
|
||||||
const response = await apiGetProjectOne({
|
const response = await apiGetProjectOne({ user: hasil, cat: "member", id });
|
||||||
user: hasil,
|
|
||||||
cat: "member",
|
|
||||||
id: id,
|
|
||||||
});
|
|
||||||
setData(response.data);
|
setData(response.data);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
@@ -63,36 +53,21 @@ export default function SectionMember({ status, refreshing }: { status: number |
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => { handleLoad(false) }, [update.member]);
|
||||||
handleLoad(false);
|
useEffect(() => { if (refreshing) handleLoad(false) }, [refreshing]);
|
||||||
}, [update.member]);
|
useEffect(() => { handleLoad(true) }, []);
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (refreshing)
|
|
||||||
handleLoad(false);
|
|
||||||
}, [refreshing]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
handleLoad(true);
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
async function handleDeleteMember() {
|
async function handleDeleteMember() {
|
||||||
try {
|
try {
|
||||||
const hasil = await decryptToken(String(token?.current));
|
const hasil = await decryptToken(String(token?.current));
|
||||||
const response = await apiDeleteProjectMember({
|
const response = await apiDeleteProjectMember({ user: hasil, idUser: memberChoose.id }, id)
|
||||||
user: hasil,
|
|
||||||
idUser: memberChoose.id,
|
|
||||||
}, id)
|
|
||||||
if (response.success) {
|
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 }))
|
dispatch(setUpdateProject({ ...update, member: !update.member }))
|
||||||
setModal(false);
|
setModal(false);
|
||||||
}
|
}
|
||||||
} catch (error : any ) {
|
} catch (error: any) {
|
||||||
console.error(error);
|
Toast.show({ type: 'small', text1: error?.response?.data?.message || "Gagal menghapus anggota" })
|
||||||
const message = error?.response?.data?.message || "Gagal menghapus anggota"
|
|
||||||
|
|
||||||
Toast.show({ type: 'small', text1: message })
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -101,84 +76,85 @@ export default function SectionMember({ status, refreshing }: { status: number |
|
|||||||
<View style={[Styles.mb15]}>
|
<View style={[Styles.mb15]}>
|
||||||
<View style={[Styles.rowSpaceBetween, Styles.mv05]}>
|
<View style={[Styles.rowSpaceBetween, Styles.mv05]}>
|
||||||
<Text style={[Styles.textDefaultSemiBold]}>Anggota</Text>
|
<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>
|
||||||
|
|
||||||
<View style={[Styles.wrapPaper, { backgroundColor: colors.card, borderColor: colors.background }]}>
|
<View style={{ gap: 6 }}>
|
||||||
{
|
{loading ? (
|
||||||
loading ?
|
arrSkeleton.map((_, index) => (
|
||||||
arrSkeleton.map((item, index) => {
|
<View key={index} style={{ flexDirection: 'row', alignItems: 'center', gap: 10 }}>
|
||||||
return (
|
<Skeleton width={40} height={40} borderRadius={20} />
|
||||||
<SkeletonTwoItem key={index} />
|
<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>
|
||||||
data.length > 0
|
</View>
|
||||||
?
|
))
|
||||||
data.map((item, index) => {
|
) : data.length > 0 ? (
|
||||||
return (
|
data.map((item, index) => (
|
||||||
<BorderBottomItem
|
<Pressable
|
||||||
key={index}
|
key={index}
|
||||||
borderType="bottom"
|
onPress={() => {
|
||||||
icon={<ImageUser src={`${ConstEnv.url_storage}/files/${item.img}`} />}
|
if (status === 3) return
|
||||||
title={item.name}
|
setMemberChoose({ id: item.idUser, name: item.name })
|
||||||
onPress={() => {
|
setModal(true)
|
||||||
if (status == 3) return
|
}}
|
||||||
setMemberChoose({
|
style={{
|
||||||
id: item.idUser,
|
flexDirection: 'row',
|
||||||
name: item.name,
|
alignItems: 'center',
|
||||||
})
|
backgroundColor: colors.card,
|
||||||
setModal(true);
|
borderRadius: 10,
|
||||||
}}
|
borderWidth: 1,
|
||||||
/>
|
borderColor: colors.icon + '18',
|
||||||
);
|
paddingHorizontal: 12,
|
||||||
})
|
paddingVertical: 10,
|
||||||
:
|
gap: 12,
|
||||||
<Text style={[Styles.textDefault, { textAlign: 'center', color: colors.dimmed }]}>Tidak ada anggota</Text>
|
}}
|
||||||
}
|
>
|
||||||
|
<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>
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
<DrawerBottom
|
<DrawerBottom animation="slide" isVisible={isModal} setVisible={setModal} title={memberChoose.name}>
|
||||||
animation="slide"
|
|
||||||
isVisible={isModal}
|
|
||||||
setVisible={setModal}
|
|
||||||
title={memberChoose.name}
|
|
||||||
>
|
|
||||||
<View style={Styles.rowItemsCenter}>
|
<View style={Styles.rowItemsCenter}>
|
||||||
<MenuItemRow
|
<MenuItemRow
|
||||||
icon={
|
icon={<MaterialCommunityIcons name="account-eye" color={colors.text} size={25} />}
|
||||||
<MaterialCommunityIcons
|
|
||||||
name="account-eye"
|
|
||||||
color={colors.text}
|
|
||||||
size={25}
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
title="Lihat Profil"
|
title="Lihat Profil"
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
setModal(false);
|
setModal(false)
|
||||||
router.push(`/member/${memberChoose.id}`);
|
router.push(`/member/${memberChoose.id}`)
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
{
|
{entityUser.role !== "user" && entityUser.role !== "coadmin" && (
|
||||||
entityUser.role != "user" && entityUser.role != "coadmin" &&
|
|
||||||
<MenuItemRow
|
<MenuItemRow
|
||||||
icon={
|
icon={<MaterialCommunityIcons name="account-remove" color={colors.text} size={25} />}
|
||||||
<MaterialCommunityIcons
|
|
||||||
name="account-remove"
|
|
||||||
color={colors.text}
|
|
||||||
size={25}
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
title="Keluarkan"
|
title="Keluarkan"
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
setModal(false)
|
setModal(false)
|
||||||
setTimeout(() => {
|
setTimeout(() => setShowDeleteModal(true), 600)
|
||||||
setShowDeleteModal(true)
|
|
||||||
}, 600)
|
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
}
|
)}
|
||||||
</View>
|
</View>
|
||||||
</DrawerBottom>
|
</DrawerBottom>
|
||||||
|
|
||||||
@@ -186,10 +162,7 @@ export default function SectionMember({ status, refreshing }: { status: number |
|
|||||||
visible={showDeleteModal}
|
visible={showDeleteModal}
|
||||||
title="Konfirmasi"
|
title="Konfirmasi"
|
||||||
message="Apakah Anda yakin ingin mengeluarkan anggota?"
|
message="Apakah Anda yakin ingin mengeluarkan anggota?"
|
||||||
onConfirm={() => {
|
onConfirm={() => { setShowDeleteModal(false); handleDeleteMember() }}
|
||||||
setShowDeleteModal(false)
|
|
||||||
handleDeleteMember()
|
|
||||||
}}
|
|
||||||
onCancel={() => setShowDeleteModal(false)}
|
onCancel={() => setShowDeleteModal(false)}
|
||||||
confirmText="Keluarkan"
|
confirmText="Keluarkan"
|
||||||
cancelText="Batal"
|
cancelText="Batal"
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import Styles from "@/constants/Styles";
|
|||||||
import { apiGetProjectOne } from "@/lib/api";
|
import { apiGetProjectOne } from "@/lib/api";
|
||||||
import { useAuthSession } from "@/providers/AuthProvider";
|
import { useAuthSession } from "@/providers/AuthProvider";
|
||||||
import { useTheme } from "@/providers/ThemeProvider";
|
import { useTheme } from "@/providers/ThemeProvider";
|
||||||
|
import { MaterialCommunityIcons } from "@expo/vector-icons";
|
||||||
import { useLocalSearchParams } from "expo-router";
|
import { useLocalSearchParams } from "expo-router";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { View } from "react-native";
|
import { View } from "react-native";
|
||||||
@@ -19,39 +20,37 @@ export default function SectionReportProject({ refreshing }: { refreshing?: bool
|
|||||||
async function handleLoad() {
|
async function handleLoad() {
|
||||||
try {
|
try {
|
||||||
const hasil = await decryptToken(String(token?.current));
|
const hasil = await decryptToken(String(token?.current));
|
||||||
const response = await apiGetProjectOne({
|
const response = await apiGetProjectOne({ user: hasil, cat: "data", id: id });
|
||||||
user: hasil,
|
|
||||||
cat: "data",
|
|
||||||
id: id,
|
|
||||||
});
|
|
||||||
setData(response.data.report);
|
setData(response.data.report);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => { handleLoad() }, [update.report]);
|
||||||
handleLoad();
|
useEffect(() => { if (refreshing) handleLoad() }, [refreshing]);
|
||||||
}, [update.report]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
if (!data || data === "") return null;
|
||||||
if (refreshing)
|
|
||||||
handleLoad();
|
|
||||||
}, [refreshing]);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<View style={[
|
||||||
{
|
Styles.wrapPaper,
|
||||||
data != "" && data != null &&
|
Styles.mb15,
|
||||||
<View style={[Styles.mb15, Styles.mt10]}>
|
Styles.sectionCard,
|
||||||
<Text style={[Styles.textDefaultSemiBold, Styles.mv05]}>
|
{ backgroundColor: colors.card, borderColor: colors.icon + '18' },
|
||||||
Laporan Kegiatan
|
]}>
|
||||||
</Text>
|
<View style={Styles.sectionHeader}>
|
||||||
<View style={[Styles.wrapPaper, { backgroundColor: colors.card, borderColor: colors.background }]}>
|
<View style={[Styles.sectionIconBox, Styles.mr10, { backgroundColor: colors.tabActive + '18' }]}>
|
||||||
<TextExpandable content={data} maxLines={2} />
|
<MaterialCommunityIcons name="text-box-outline" size={18} color={colors.tabActive} />
|
||||||
</View>
|
|
||||||
</View>
|
</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>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,10 +9,10 @@ import { useEffect, useState } from "react";
|
|||||||
import { View } from "react-native";
|
import { View } from "react-native";
|
||||||
import Toast from "react-native-toast-message";
|
import Toast from "react-native-toast-message";
|
||||||
import { useDispatch, useSelector } from "react-redux";
|
import { useDispatch, useSelector } from "react-redux";
|
||||||
import ModalConfirmation from "../ModalConfirmation";
|
|
||||||
import DrawerBottom from "../drawerBottom";
|
import DrawerBottom from "../drawerBottom";
|
||||||
import ItemSectionTanggalTugas from "../itemSectionTanggalTugas";
|
import ItemSectionTanggalTugas from "../itemSectionTanggalTugas";
|
||||||
import MenuItemRow from "../menuItemRow";
|
import MenuItemRow from "../menuItemRow";
|
||||||
|
import ModalConfirmation from "../ModalConfirmation";
|
||||||
import ModalSelect from "../modalSelect";
|
import ModalSelect from "../modalSelect";
|
||||||
import SkeletonTask from "../skeletonTask";
|
import SkeletonTask from "../skeletonTask";
|
||||||
import Text from "../Text";
|
import Text from "../Text";
|
||||||
@@ -26,6 +26,7 @@ type Props = {
|
|||||||
dateStart: string;
|
dateStart: string;
|
||||||
dateEnd: string;
|
dateEnd: string;
|
||||||
createdAt: string;
|
createdAt: string;
|
||||||
|
files?: { name: string; extension: string }[];
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function SectionTanggalTugasProject({ status, member, refreshing }: { status: number | undefined, member: boolean, refreshing?: boolean }) {
|
export default function SectionTanggalTugasProject({ status, member, refreshing }: { status: number | undefined, member: boolean, refreshing?: boolean }) {
|
||||||
@@ -91,7 +92,7 @@ export default function SectionTanggalTugasProject({ status, member, refreshing
|
|||||||
setSelect(false);
|
setSelect(false);
|
||||||
Toast.show({ type: 'small', text1: 'Berhasil mengubah data', })
|
Toast.show({ type: 'small', text1: 'Berhasil mengubah data', })
|
||||||
}
|
}
|
||||||
} catch (error : any ) {
|
} catch (error: any) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
const message = error?.response?.data?.message || "Gagal mengubah data"
|
const message = error?.response?.data?.message || "Gagal mengubah data"
|
||||||
|
|
||||||
@@ -111,7 +112,7 @@ export default function SectionTanggalTugasProject({ status, member, refreshing
|
|||||||
setModal(false);
|
setModal(false);
|
||||||
Toast.show({ type: 'small', text1: 'Berhasil menghapus data', })
|
Toast.show({ type: 'small', text1: 'Berhasil menghapus data', })
|
||||||
}
|
}
|
||||||
} catch (error : any ) {
|
} catch (error: any) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
const message = error?.response?.data?.message || "Gagal menghapus data"
|
const message = error?.response?.data?.message || "Gagal menghapus data"
|
||||||
|
|
||||||
@@ -125,7 +126,7 @@ export default function SectionTanggalTugasProject({ status, member, refreshing
|
|||||||
<Text style={[Styles.textDefaultSemiBold, Styles.mv05]}>
|
<Text style={[Styles.textDefaultSemiBold, Styles.mv05]}>
|
||||||
Tanggal & Tugas
|
Tanggal & Tugas
|
||||||
</Text>
|
</Text>
|
||||||
<View style={[Styles.wrapPaper, { backgroundColor: colors.card, borderColor: colors.background }]}>
|
<View>
|
||||||
{
|
{
|
||||||
loading ?
|
loading ?
|
||||||
arrSkeleton.map((item, index) => {
|
arrSkeleton.map((item, index) => {
|
||||||
@@ -144,12 +145,9 @@ export default function SectionTanggalTugasProject({ status, member, refreshing
|
|||||||
title={item.title}
|
title={item.title}
|
||||||
dateStart={item.dateStart}
|
dateStart={item.dateStart}
|
||||||
dateEnd={item.dateEnd}
|
dateEnd={item.dateEnd}
|
||||||
|
files={item.files ?? []}
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
if (status == 3 || (!member && (entityUser.role == "user" || entityUser.role == "coadmin"))) return
|
setTugas({ id: item.id, status: item.status })
|
||||||
setTugas({
|
|
||||||
id: item.id,
|
|
||||||
status: item.status
|
|
||||||
})
|
|
||||||
setModal(true)
|
setModal(true)
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
@@ -168,66 +166,53 @@ export default function SectionTanggalTugasProject({ status, member, refreshing
|
|||||||
title="Menu"
|
title="Menu"
|
||||||
>
|
>
|
||||||
<View style={Styles.rowItemsCenter}>
|
<View style={Styles.rowItemsCenter}>
|
||||||
|
{(member || (entityUser.role != "user" && entityUser.role != "coadmin")) && status != 3 && (
|
||||||
|
<MenuItemRow
|
||||||
|
icon={<MaterialCommunityIcons name="list-status" color={colors.text} size={25} />}
|
||||||
|
title="Update Status"
|
||||||
|
onPress={() => {
|
||||||
|
setModal(false);
|
||||||
|
setTimeout(() => setSelect(true), 600)
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
<MenuItemRow
|
<MenuItemRow
|
||||||
icon={
|
icon={<MaterialCommunityIcons name="file-multiple-outline" color={colors.text} size={25} />}
|
||||||
<MaterialCommunityIcons
|
title="File Tugas"
|
||||||
name="list-status"
|
|
||||||
color={colors.text}
|
|
||||||
size={25}
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
title="Update Status"
|
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
setModal(false);
|
setModal(false);
|
||||||
setTimeout(() => {
|
router.push(`/project/${id}/tugas-file/${tugas.id}?member=${member}`);
|
||||||
setSelect(true);
|
|
||||||
}, 600)
|
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<MenuItemRow
|
<MenuItemRow
|
||||||
icon={
|
icon={<MaterialCommunityIcons name="clock-time-three-outline" color={colors.text} size={25} />}
|
||||||
<MaterialCommunityIcons
|
|
||||||
name="pencil-outline"
|
|
||||||
color={colors.text}
|
|
||||||
size={25}
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
title="Edit Tugas"
|
|
||||||
onPress={() => {
|
|
||||||
setModal(false);
|
|
||||||
router.push(`/project/update/${tugas.id}`);
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<MenuItemRow
|
|
||||||
icon={
|
|
||||||
<MaterialCommunityIcons
|
|
||||||
name="clock-time-three-outline"
|
|
||||||
color={colors.text}
|
|
||||||
size={25}
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
title="Detail Waktu"
|
title="Detail Waktu"
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
setModal(false);
|
setModal(false);
|
||||||
setTimeout(() => {
|
setTimeout(() => setModalDetail(true), 600)
|
||||||
setModalDetail(true)
|
|
||||||
}, 600)
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</View>
|
|
||||||
<View style={[Styles.rowItemsCenter, Styles.mt15]}>
|
|
||||||
<MenuItemRow
|
|
||||||
icon={<Ionicons name="trash-outline" color={colors.text} size={25} />}
|
|
||||||
title="Hapus Tugas"
|
|
||||||
onPress={() => {
|
|
||||||
setModal(false)
|
|
||||||
setTimeout(() => {
|
|
||||||
setShowDeleteModal(true)
|
|
||||||
}, 600)
|
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
|
{(member || (entityUser.role != "user" && entityUser.role != "coadmin")) && status != 3 && (
|
||||||
|
<View style={[Styles.rowItemsCenter, Styles.mt15]}>
|
||||||
|
<MenuItemRow
|
||||||
|
icon={<MaterialCommunityIcons name="pencil-outline" color={colors.text} size={25} />}
|
||||||
|
title="Edit Tugas"
|
||||||
|
onPress={() => {
|
||||||
|
setModal(false);
|
||||||
|
router.push(`/project/update/${tugas.id}`);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<MenuItemRow
|
||||||
|
icon={<Ionicons name="trash-outline" color={colors.text} size={25} />}
|
||||||
|
title="Hapus Tugas"
|
||||||
|
onPress={() => {
|
||||||
|
setModal(false)
|
||||||
|
setTimeout(() => setShowDeleteModal(true), 600)
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
|
)}
|
||||||
</DrawerBottom>
|
</DrawerBottom>
|
||||||
|
|
||||||
<ModalConfirmation
|
<ModalConfirmation
|
||||||
|
|||||||
@@ -1,12 +1,11 @@
|
|||||||
import { ColorsStatus } from "@/constants/ColorsStatus";
|
|
||||||
import Styles from "@/constants/Styles";
|
import Styles from "@/constants/Styles";
|
||||||
import { useTheme } from "@/providers/ThemeProvider";
|
import { useTheme } from "@/providers/ThemeProvider";
|
||||||
import { AntDesign } from "@expo/vector-icons";
|
import { MaterialCommunityIcons } from "@expo/vector-icons";
|
||||||
import Text from "./Text";
|
|
||||||
import { View } from "react-native";
|
import { View } from "react-native";
|
||||||
|
import Text from "./Text";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
text?: string,
|
text?: string
|
||||||
title?: string
|
title?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -14,18 +13,26 @@ export default function SectionCancel({ text, title }: Props) {
|
|||||||
const { colors } = useTheme();
|
const { colors } = useTheme();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View style={[Styles.p10, Styles.round05, Styles.mb15, { backgroundColor: colors.error + '70' }]}>
|
<View style={[
|
||||||
<View style={[Styles.rowItemsCenter]}>
|
Styles.wrapPaper,
|
||||||
<AntDesign name="warning" size={22} style={[Styles.mr10]} color={colors.text} />
|
Styles.mb15,
|
||||||
<Text style={[Styles.textDefaultSemiBold]}>{title ? title : 'Kegiatan Dibatalkan'}</Text>
|
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>
|
</View>
|
||||||
{
|
|
||||||
text && (
|
{text && (
|
||||||
<View>
|
<View style={[Styles.reportContent, { borderLeftColor: colors.error + '50' }]}>
|
||||||
<Text style={[Styles.mt05]}>{text}</Text>
|
<Text style={[Styles.textDefault, { color: colors.text }]}>{text}</Text>
|
||||||
</View>
|
</View>
|
||||||
)
|
)}
|
||||||
}
|
|
||||||
</View>
|
</View>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,27 +1,87 @@
|
|||||||
import Styles from "@/constants/Styles";
|
import Styles from "@/constants/Styles";
|
||||||
import { useTheme } from "@/providers/ThemeProvider";
|
import { useTheme } from "@/providers/ThemeProvider";
|
||||||
import { AntDesign } from "@expo/vector-icons";
|
import { MaterialCommunityIcons } from "@expo/vector-icons";
|
||||||
import { View } from "react-native";
|
import { useEffect, useRef } from "react";
|
||||||
import ProgressBar from "./progressBar";
|
import { Animated, View } from "react-native";
|
||||||
import Text from "./Text";
|
import Text from "./Text";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
text: string,
|
|
||||||
progress: number
|
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 { colors } = useTheme();
|
||||||
|
const animatedWidth = useRef(new Animated.Value(0)).current;
|
||||||
|
|
||||||
|
const progressColor = colors.tabActive;
|
||||||
|
|
||||||
|
const statusLabel = progress === 100
|
||||||
|
? 'Selesai'
|
||||||
|
: progress > 0
|
||||||
|
? 'Sedang berlangsung'
|
||||||
|
: 'Belum dimulai';
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
animatedWidth.setValue(0);
|
||||||
|
Animated.timing(animatedWidth, {
|
||||||
|
toValue: progress,
|
||||||
|
duration: 900,
|
||||||
|
useNativeDriver: false,
|
||||||
|
}).start();
|
||||||
|
}, [progress]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View style={[Styles.wrapPaper, Styles.rowItemsCenter, { backgroundColor: colors.card }]}>
|
<View style={[
|
||||||
<View style={[Styles.iconContent]}>
|
Styles.wrapPaper,
|
||||||
<AntDesign name="areachart" size={30} color={'black'} />
|
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>
|
||||||
<View style={[Styles.ml10, { flex: 1 }]}>
|
|
||||||
<Text style={[Styles.mb05]}>{text}</Text>
|
<View style={[Styles.progressTrack, { backgroundColor: colors.icon + '20' }]}>
|
||||||
<ProgressBar margin={0} category="page" value={progress} />
|
<Animated.View style={[
|
||||||
|
Styles.progressFill,
|
||||||
|
{
|
||||||
|
backgroundColor: progressColor,
|
||||||
|
width: animatedWidth.interpolate({
|
||||||
|
inputRange: [0, 100],
|
||||||
|
outputRange: ['0%', '100%'],
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
]} />
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,15 +10,13 @@ import { startActivityAsync } from 'expo-intent-launcher';
|
|||||||
import { useLocalSearchParams } from "expo-router";
|
import { useLocalSearchParams } from "expo-router";
|
||||||
import * as Sharing from 'expo-sharing';
|
import * as Sharing from 'expo-sharing';
|
||||||
import { useEffect, useState } from "react";
|
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 * as mime from 'react-native-mime-types';
|
||||||
import Toast from "react-native-toast-message";
|
import Toast from "react-native-toast-message";
|
||||||
import { useDispatch, useSelector } from "react-redux";
|
import { useDispatch, useSelector } from "react-redux";
|
||||||
import ModalConfirmation from "../ModalConfirmation";
|
|
||||||
import ButtonMenuHeader from "../buttonMenuHeader";
|
|
||||||
import BorderBottomItem from "../borderBottomItem";
|
|
||||||
import DrawerBottom from "../drawerBottom";
|
import DrawerBottom from "../drawerBottom";
|
||||||
import MenuItemRow from "../menuItemRow";
|
import MenuItemRow from "../menuItemRow";
|
||||||
|
import ModalConfirmation from "../ModalConfirmation";
|
||||||
import ModalLoading from "../modalLoading";
|
import ModalLoading from "../modalLoading";
|
||||||
import Skeleton from "../skeleton";
|
import Skeleton from "../skeleton";
|
||||||
import Text from "../Text";
|
import Text from "../Text";
|
||||||
@@ -30,6 +28,28 @@ type Props = {
|
|||||||
idStorage: string
|
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 }) {
|
export default function SectionFileTask({ refreshing, isMemberDivision }: { refreshing: boolean, isMemberDivision: boolean }) {
|
||||||
const { colors } = useTheme()
|
const { colors } = useTheme()
|
||||||
const [isModal, setModal] = useState(false)
|
const [isModal, setModal] = useState(false)
|
||||||
@@ -119,7 +139,7 @@ export default function SectionFileTask({ refreshing, isMemberDivision }: { refr
|
|||||||
} else {
|
} else {
|
||||||
Toast.show({ type: 'small', text1: response.message, })
|
Toast.show({ type: 'small', text1: response.message, })
|
||||||
}
|
}
|
||||||
} catch (error : any ) {
|
} catch (error: any) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
const message = error?.response?.data?.message || "Gagal menghapus file"
|
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} />
|
<ModalLoading isVisible={loadingOpen} setVisible={setLoadingOpen} />
|
||||||
<View style={[Styles.mb15]}>
|
<View style={[Styles.mb15]}>
|
||||||
<Text style={[Styles.textDefaultSemiBold, Styles.mv05]}>File</Text>
|
<Text style={[Styles.textDefaultSemiBold, Styles.mv05]}>File</Text>
|
||||||
<View style={[Styles.wrapPaper, { backgroundColor: colors.card, borderColor: colors.background }]}>
|
{loading ? (
|
||||||
{
|
<View style={Styles.fileGrid}>
|
||||||
loading ?
|
{arrSkeleton.map((_, index) => (
|
||||||
arrSkeleton.map((item, index) => {
|
<Skeleton key={index} width={48} height={68} widthType="percent" borderRadius={10} />
|
||||||
return (
|
))}
|
||||||
<Skeleton key={index} width={100} height={40} widthType="percent" borderRadius={10} />
|
</View>
|
||||||
)
|
) : data.length > 0 ? (
|
||||||
})
|
<View style={Styles.fileGrid}>
|
||||||
:
|
{data.map((item, index) => {
|
||||||
data.length > 0 ?
|
const iconName = getFileIcon(item.extension)
|
||||||
data.map((item, index) => {
|
const iconColor = getFileColor(item.extension)
|
||||||
return (
|
return (
|
||||||
<BorderBottomItem
|
<Pressable
|
||||||
key={index}
|
key={index}
|
||||||
borderType="all"
|
onPress={() => { setSelectFile(item); setModal(true) }}
|
||||||
icon={<MaterialCommunityIcons name="file-outline" size={25} color={colors.text} />}
|
style={[Styles.fileCard, { backgroundColor: colors.card, borderColor: colors.icon + '18' }]}
|
||||||
title={item.name + '.' + item.extension}
|
>
|
||||||
titleWeight="normal"
|
<View style={[Styles.sectionIconBox, { backgroundColor: iconColor + '20' }]}>
|
||||||
onPress={() => { setSelectFile(item); setModal(true) }}
|
<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 }]}>
|
||||||
<Text style={[Styles.textDefault, { textAlign: 'center', color: colors.dimmed }]}>Tidak ada file</Text>
|
{item.extension.toUpperCase()}
|
||||||
}
|
</Text>
|
||||||
</View>
|
</View>
|
||||||
|
</Pressable>
|
||||||
|
)
|
||||||
|
})}
|
||||||
|
</View>
|
||||||
|
) : (
|
||||||
|
<Text style={[Styles.textDefault, { textAlign: 'center', color: colors.dimmed }]}>Tidak ada file</Text>
|
||||||
|
)}
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
<DrawerBottom animation="slide" isVisible={isModal} setVisible={setModal} title="Menu">
|
<DrawerBottom animation="slide" isVisible={isModal} setVisible={setModal} title="Menu">
|
||||||
|
|||||||
@@ -1,20 +1,19 @@
|
|||||||
import Styles from "@/constants/Styles";
|
import Styles from "@/constants/Styles";
|
||||||
import { apiDeleteLinkTask, apiGetTaskOne } from "@/lib/api";
|
import { apiDeleteLinkTask, apiGetTaskOne } from "@/lib/api";
|
||||||
import { urlCompleted } from "@/lib/fun_urlCompleted";
|
|
||||||
import { setUpdateTask } from "@/lib/taskUpdate";
|
import { setUpdateTask } from "@/lib/taskUpdate";
|
||||||
import { useAuthSession } from "@/providers/AuthProvider";
|
import { useAuthSession } from "@/providers/AuthProvider";
|
||||||
import { useTheme } from "@/providers/ThemeProvider";
|
import { useTheme } from "@/providers/ThemeProvider";
|
||||||
import { Feather, Ionicons } from "@expo/vector-icons";
|
import { Ionicons } from "@expo/vector-icons";
|
||||||
import { useLocalSearchParams } from "expo-router";
|
import { useLocalSearchParams } from "expo-router";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { Linking, View } from "react-native";
|
import { View } from "react-native";
|
||||||
import Toast from "react-native-toast-message";
|
import Toast from "react-native-toast-message";
|
||||||
import { useDispatch, useSelector } from "react-redux";
|
import { useDispatch, useSelector } from "react-redux";
|
||||||
import ModalConfirmation from "../ModalConfirmation";
|
import ModalConfirmation from "../ModalConfirmation";
|
||||||
import BorderBottomItem from "../borderBottomItem";
|
|
||||||
import DrawerBottom from "../drawerBottom";
|
import DrawerBottom from "../drawerBottom";
|
||||||
import MenuItemRow from "../menuItemRow";
|
import MenuItemRow from "../menuItemRow";
|
||||||
import Text from "../Text";
|
import Text from "../Text";
|
||||||
|
import ItemSectionLink from "../project/itemSectionLink";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
id: string
|
id: string
|
||||||
@@ -62,84 +61,60 @@ export default function SectionLinkTask({ refreshing, isMemberDivision }: { refr
|
|||||||
} else {
|
} else {
|
||||||
Toast.show({ type: 'small', text1: response.message, })
|
Toast.show({ type: 'small', text1: response.message, })
|
||||||
}
|
}
|
||||||
} catch (error : any ) {
|
} catch (error: any) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
const message = error?.response?.data?.message || "Gagal menghapus link"
|
const message = error?.response?.data?.message || "Gagal menghapus link"
|
||||||
|
|
||||||
Toast.show({ type: 'small', text1: message })
|
Toast.show({ type: 'small', text1: message })
|
||||||
} finally {
|
} finally {
|
||||||
setModal(false)
|
setModal(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (data.length === 0) return null;
|
||||||
|
|
||||||
|
const canDelete = (entityUser.role !== "user" && entityUser.role !== "coadmin") || isMemberDivision;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{
|
<View style={[Styles.mb15]}>
|
||||||
data.length > 0 &&
|
<Text style={[Styles.textDefaultSemiBold, Styles.mv05]}>Link</Text>
|
||||||
<>
|
<View>
|
||||||
<View style={[Styles.mb15]}>
|
{data.map((item, index) => (
|
||||||
<Text style={[Styles.textDefaultSemiBold, Styles.mv05]}>Link</Text>
|
<ItemSectionLink
|
||||||
<View style={[Styles.wrapPaper, { backgroundColor: colors.card, borderColor: colors.background }]}>
|
key={index}
|
||||||
{
|
link={item.link}
|
||||||
data.map((item, index) => {
|
canDelete={canDelete}
|
||||||
return (
|
onLongPress={() => { setSelectLink(item); setModal(true) }}
|
||||||
<BorderBottomItem
|
/>
|
||||||
key={index}
|
))}
|
||||||
borderType="all"
|
</View>
|
||||||
icon={<Feather name="link" size={25} color={colors.text} />}
|
</View>
|
||||||
title={item.link}
|
|
||||||
titleWeight="normal"
|
|
||||||
onPress={() => { setSelectLink(item); setModal(true) }}
|
|
||||||
/>
|
|
||||||
)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
</View>
|
|
||||||
</View>
|
|
||||||
|
|
||||||
<DrawerBottom animation="slide" isVisible={isModal} setVisible={setModal} title="Menu">
|
<DrawerBottom animation="slide" isVisible={isModal} setVisible={setModal} title="Menu">
|
||||||
<View style={Styles.rowItemsCenter}>
|
<View style={Styles.rowItemsCenter}>
|
||||||
<MenuItemRow
|
<MenuItemRow
|
||||||
icon={<Feather name="external-link" color={colors.text} size={25} />}
|
icon={<Ionicons name="trash-outline" color={colors.text} size={25} />}
|
||||||
title="Buka Link"
|
title="Hapus Link"
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
Linking.openURL(urlCompleted(String(selectLink?.link)))
|
setModal(false)
|
||||||
}}
|
setTimeout(() => setShowDeleteModal(true), 600)
|
||||||
/>
|
|
||||||
{
|
|
||||||
(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()
|
|
||||||
}}
|
}}
|
||||||
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"
|
||||||
|
/>
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,15 +7,14 @@ import { useTheme } from "@/providers/ThemeProvider";
|
|||||||
import { MaterialCommunityIcons } from "@expo/vector-icons";
|
import { MaterialCommunityIcons } from "@expo/vector-icons";
|
||||||
import { router, useLocalSearchParams } from "expo-router";
|
import { router, useLocalSearchParams } from "expo-router";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { View } from "react-native";
|
import { Pressable, View } from "react-native";
|
||||||
import Toast from "react-native-toast-message";
|
import Toast from "react-native-toast-message";
|
||||||
import { useDispatch, useSelector } from "react-redux";
|
import { useDispatch, useSelector } from "react-redux";
|
||||||
import ModalConfirmation from "../ModalConfirmation";
|
|
||||||
import BorderBottomItem from "../borderBottomItem";
|
|
||||||
import DrawerBottom from "../drawerBottom";
|
import DrawerBottom from "../drawerBottom";
|
||||||
import ImageUser from "../imageNew";
|
import ImageUser from "../imageNew";
|
||||||
import MenuItemRow from "../menuItemRow";
|
import MenuItemRow from "../menuItemRow";
|
||||||
import SkeletonTwoItem from "../skeletonTwoItem";
|
import ModalConfirmation from "../ModalConfirmation";
|
||||||
|
import Skeleton from "../skeleton";
|
||||||
import Text from "../Text";
|
import Text from "../Text";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
@@ -88,7 +87,7 @@ export default function SectionMemberTask({ refreshing, isAdminDivision }: { ref
|
|||||||
} else {
|
} else {
|
||||||
Toast.show({ type: 'small', text1: response.message, })
|
Toast.show({ type: 'small', text1: response.message, })
|
||||||
}
|
}
|
||||||
} catch (error : any ) {
|
} catch (error: any) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
const message = error?.response?.data?.message || "Gagal menghapus anggota"
|
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.mb15]}>
|
||||||
<View style={[Styles.rowSpaceBetween, Styles.mv05]}>
|
<View style={[Styles.rowSpaceBetween, Styles.mv05]}>
|
||||||
<Text style={[Styles.textDefaultSemiBold]}>Anggota</Text>
|
<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>
|
||||||
|
|
||||||
<View style={[Styles.wrapPaper, { backgroundColor: colors.card, borderColor: colors.background }]}>
|
<View style={{ gap: 6 }}>
|
||||||
{
|
{
|
||||||
loading ?
|
loading ?
|
||||||
arrSkeleton.map((item, index) => {
|
arrSkeleton.map((item, index) => {
|
||||||
return (
|
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.length > 0 ? (
|
||||||
data.map((item, index) => {
|
data.map((item, index) => {
|
||||||
return (
|
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}
|
key={index}
|
||||||
borderType="bottom"
|
|
||||||
icon={
|
|
||||||
<ImageUser src={`${ConstEnv.url_storage}/files/${item.img}`} />
|
|
||||||
}
|
|
||||||
title={item.name}
|
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
setMemberChoose({
|
setMemberChoose({
|
||||||
id: item.idUser,
|
id: item.idUser,
|
||||||
@@ -132,7 +149,33 @@ export default function SectionMemberTask({ refreshing, isAdminDivision }: { ref
|
|||||||
});
|
});
|
||||||
setModal(true);
|
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>
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
) : (
|
) : (
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import Styles from "@/constants/Styles";
|
|||||||
import { apiGetTaskOne } from "@/lib/api";
|
import { apiGetTaskOne } from "@/lib/api";
|
||||||
import { useAuthSession } from "@/providers/AuthProvider";
|
import { useAuthSession } from "@/providers/AuthProvider";
|
||||||
import { useTheme } from "@/providers/ThemeProvider";
|
import { useTheme } from "@/providers/ThemeProvider";
|
||||||
|
import { MaterialCommunityIcons } from "@expo/vector-icons";
|
||||||
import { useLocalSearchParams } from "expo-router";
|
import { useLocalSearchParams } from "expo-router";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { View } from "react-native";
|
import { View } from "react-native";
|
||||||
@@ -9,7 +10,6 @@ import { useSelector } from "react-redux";
|
|||||||
import Text from "../Text";
|
import Text from "../Text";
|
||||||
import TextExpandable from "../textExpandable";
|
import TextExpandable from "../textExpandable";
|
||||||
|
|
||||||
|
|
||||||
export default function SectionReportTask({ refreshing }: { refreshing: boolean }) {
|
export default function SectionReportTask({ refreshing }: { refreshing: boolean }) {
|
||||||
const { colors } = useTheme()
|
const { colors } = useTheme()
|
||||||
const update = useSelector((state: any) => state.taskUpdate)
|
const update = useSelector((state: any) => state.taskUpdate)
|
||||||
@@ -27,29 +27,30 @@ export default function SectionReportTask({ refreshing }: { refreshing: boolean
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => { handleLoad() }, [update.report])
|
||||||
handleLoad()
|
useEffect(() => { if (refreshing) handleLoad() }, [refreshing])
|
||||||
}, [update.report])
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (refreshing)
|
|
||||||
handleLoad();
|
|
||||||
}, [refreshing]);
|
|
||||||
|
|
||||||
|
if (!data || data === "") return null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<View style={[
|
||||||
{
|
Styles.wrapPaper,
|
||||||
data != "" && data != null &&
|
Styles.mb15,
|
||||||
<View style={[Styles.mb15, Styles.mt10]}>
|
Styles.sectionCard,
|
||||||
<Text style={[Styles.textDefaultSemiBold, Styles.mv05]}>
|
{ backgroundColor: colors.card, borderColor: colors.icon + '18' },
|
||||||
Laporan Kegiatan
|
]}>
|
||||||
</Text>
|
<View style={Styles.sectionHeader}>
|
||||||
<View style={[Styles.wrapPaper, { backgroundColor: colors.card, borderColor: colors.background }]}>
|
<View style={[Styles.sectionIconBox, Styles.mr10, { backgroundColor: colors.tabActive + '18' }]}>
|
||||||
<TextExpandable content={data} maxLines={2} />
|
<MaterialCommunityIcons name="text-box-outline" size={18} color={colors.tabActive} />
|
||||||
</View>
|
|
||||||
</View>
|
</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>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,10 +9,10 @@ import { useEffect, useState } from "react";
|
|||||||
import { View } from "react-native";
|
import { View } from "react-native";
|
||||||
import Toast from "react-native-toast-message";
|
import Toast from "react-native-toast-message";
|
||||||
import { useDispatch, useSelector } from "react-redux";
|
import { useDispatch, useSelector } from "react-redux";
|
||||||
import ModalConfirmation from "../ModalConfirmation";
|
|
||||||
import DrawerBottom from "../drawerBottom";
|
import DrawerBottom from "../drawerBottom";
|
||||||
import ItemSectionTanggalTugas from "../itemSectionTanggalTugas";
|
import ItemSectionTanggalTugas from "../itemSectionTanggalTugas";
|
||||||
import MenuItemRow from "../menuItemRow";
|
import MenuItemRow from "../menuItemRow";
|
||||||
|
import ModalConfirmation from "../ModalConfirmation";
|
||||||
import ModalSelect from "../modalSelect";
|
import ModalSelect from "../modalSelect";
|
||||||
import SkeletonTask from "../skeletonTask";
|
import SkeletonTask from "../skeletonTask";
|
||||||
import Text from "../Text";
|
import Text from "../Text";
|
||||||
@@ -25,6 +25,7 @@ type Props = {
|
|||||||
status: number;
|
status: number;
|
||||||
dateStart: string;
|
dateStart: string;
|
||||||
dateEnd: string;
|
dateEnd: string;
|
||||||
|
files?: { name: string; extension: string }[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function SectionTanggalTugasTask({ refreshing, isMemberDivision }: { refreshing: boolean, isMemberDivision: boolean }) {
|
export default function SectionTanggalTugasTask({ refreshing, isMemberDivision }: { refreshing: boolean, isMemberDivision: boolean }) {
|
||||||
@@ -73,7 +74,7 @@ export default function SectionTanggalTugasTask({ refreshing, isMemberDivision }
|
|||||||
} else {
|
} else {
|
||||||
Toast.show({ type: 'small', text1: response.message, })
|
Toast.show({ type: 'small', text1: response.message, })
|
||||||
}
|
}
|
||||||
} catch (error : any ) {
|
} catch (error: any) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
const message = error?.response?.data?.message || "Gagal mengubah data"
|
const message = error?.response?.data?.message || "Gagal mengubah data"
|
||||||
|
|
||||||
@@ -111,7 +112,7 @@ export default function SectionTanggalTugasTask({ refreshing, isMemberDivision }
|
|||||||
} else {
|
} else {
|
||||||
Toast.show({ type: 'small', text1: response.message, })
|
Toast.show({ type: 'small', text1: response.message, })
|
||||||
}
|
}
|
||||||
} catch (error : any ) {
|
} catch (error: any) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
const message = error?.response?.data?.message || "Gagal menghapus data"
|
const message = error?.response?.data?.message || "Gagal menghapus data"
|
||||||
|
|
||||||
@@ -126,7 +127,7 @@ export default function SectionTanggalTugasTask({ refreshing, isMemberDivision }
|
|||||||
<>
|
<>
|
||||||
<View style={[Styles.mb15, Styles.mt10]}>
|
<View style={[Styles.mb15, Styles.mt10]}>
|
||||||
<Text style={[Styles.textDefaultSemiBold, Styles.mv05]}>Tanggal & Tugas</Text>
|
<Text style={[Styles.textDefaultSemiBold, Styles.mv05]}>Tanggal & Tugas</Text>
|
||||||
<View style={[Styles.wrapPaper, { backgroundColor: colors.card, borderColor: colors.background }]}>
|
<View>
|
||||||
{
|
{
|
||||||
loading ?
|
loading ?
|
||||||
arrSkeleton.map((item, index) => {
|
arrSkeleton.map((item, index) => {
|
||||||
@@ -145,6 +146,7 @@ export default function SectionTanggalTugasTask({ refreshing, isMemberDivision }
|
|||||||
title={item.title}
|
title={item.title}
|
||||||
dateStart={item.dateStart}
|
dateStart={item.dateStart}
|
||||||
dateEnd={item.dateEnd}
|
dateEnd={item.dateEnd}
|
||||||
|
files={item.files ?? []}
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
setTugas({
|
setTugas({
|
||||||
id: item.id,
|
id: item.id,
|
||||||
@@ -163,68 +165,53 @@ export default function SectionTanggalTugasTask({ refreshing, isMemberDivision }
|
|||||||
|
|
||||||
<DrawerBottom animation="slide" isVisible={isModal} setVisible={setModal} title="Menu">
|
<DrawerBottom animation="slide" isVisible={isModal} setVisible={setModal} title="Menu">
|
||||||
<View style={Styles.rowItemsCenter}>
|
<View style={Styles.rowItemsCenter}>
|
||||||
|
{((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
|
<MenuItemRow
|
||||||
icon={
|
icon={<MaterialCommunityIcons name="file-multiple-outline" color={colors.text} size={25} />}
|
||||||
<MaterialCommunityIcons
|
title="File Tugas"
|
||||||
name="clock-time-three-outline"
|
onPress={() => {
|
||||||
color={colors.text}
|
setModal(false);
|
||||||
size={25}
|
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"
|
title="Detail Waktu"
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
setModal(false);
|
setModal(false);
|
||||||
setTimeout(() => {
|
setTimeout(() => setModalDetail(true), 600)
|
||||||
setModalDetail(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>
|
</View>
|
||||||
{
|
{((entityUser.role != "user" && entityUser.role != "coadmin") || isMemberDivision) && (
|
||||||
(entityUser.role != "user" && entityUser.role != "coadmin") || isMemberDivision
|
<View style={[Styles.rowItemsCenter, Styles.mt15]}>
|
||||||
?
|
<MenuItemRow
|
||||||
<View style={[Styles.rowItemsCenter, Styles.mt15]}>
|
icon={<MaterialCommunityIcons name="pencil-outline" color={colors.text} size={25} />}
|
||||||
<MenuItemRow
|
title="Edit Tugas"
|
||||||
icon={<Ionicons name="trash-outline" color={colors.text} size={25} />}
|
onPress={() => {
|
||||||
title="Hapus Tugas"
|
setModal(false)
|
||||||
onPress={() => {
|
router.push(`./update/${tugas.id}`)
|
||||||
setModal(false)
|
}}
|
||||||
setTimeout(() => {
|
/>
|
||||||
setShowDeleteModal(true)
|
<MenuItemRow
|
||||||
}, 600)
|
icon={<Ionicons name="trash-outline" color={colors.text} size={25} />}
|
||||||
}}
|
title="Hapus Tugas"
|
||||||
/>
|
onPress={() => {
|
||||||
</View>
|
setModal(false)
|
||||||
:
|
setTimeout(() => setShowDeleteModal(true), 600)
|
||||||
<></>
|
}}
|
||||||
}
|
/>
|
||||||
|
</View>
|
||||||
|
)}
|
||||||
</DrawerBottom>
|
</DrawerBottom>
|
||||||
|
|
||||||
<ModalConfirmation
|
<ModalConfirmation
|
||||||
|
|||||||
@@ -1,32 +1,38 @@
|
|||||||
import Styles from "@/constants/Styles";
|
import Styles from "@/constants/Styles";
|
||||||
|
import { useTheme } from "@/providers/ThemeProvider";
|
||||||
|
import { MaterialCommunityIcons } from "@expo/vector-icons";
|
||||||
import { useRef, useState, useEffect } from "react";
|
import { useRef, useState, useEffect } from "react";
|
||||||
import { Animated, Pressable, View } from "react-native";
|
import { Animated, Pressable, View } from "react-native";
|
||||||
import Text from "./Text";
|
import Text from "./Text";
|
||||||
|
|
||||||
export default function TextExpandable({ content, maxLines }: { content: string, maxLines: number }) {
|
export default function TextExpandable({ content, maxLines }: { content: string, maxLines: number }) {
|
||||||
|
const { colors } = useTheme();
|
||||||
const [isExpanded, setIsExpanded] = useState(false);
|
const [isExpanded, setIsExpanded] = useState(false);
|
||||||
const [shouldShowMore, setShouldShowMore] = useState(false);
|
const [shouldShowMore, setShouldShowMore] = useState(false);
|
||||||
const [collapsedHeight, setCollapsedHeight] = useState(0);
|
const [collapsedHeight, setCollapsedHeight] = useState(0);
|
||||||
const [fullHeight, setFullHeight] = useState(0);
|
const [fullHeight, setFullHeight] = useState(0);
|
||||||
const animatedHeight = useRef(new Animated.Value(0)).current;
|
const animatedHeight = useRef(new Animated.Value(0)).current;
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setCollapsedHeight(0);
|
||||||
|
setFullHeight(0);
|
||||||
|
setShouldShowMore(false);
|
||||||
|
setIsExpanded(false);
|
||||||
|
}, [content]);
|
||||||
|
|
||||||
const measureCollapsed = (e: any) => {
|
const measureCollapsed = (e: any) => {
|
||||||
if (collapsedHeight === 0) {
|
const h = e.nativeEvent.layout.height;
|
||||||
setCollapsedHeight(e.nativeEvent.layout.height);
|
setCollapsedHeight(h);
|
||||||
animatedHeight.setValue(e.nativeEvent.layout.height);
|
animatedHeight.setValue(h);
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const measureFull = (e: any) => {
|
const measureFull = (e: any) => {
|
||||||
if (fullHeight === 0) {
|
setFullHeight(e.nativeEvent.layout.height);
|
||||||
setFullHeight(e.nativeEvent.layout.height);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Cek apakah memang perlu "View More"
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (collapsedHeight > 0 && fullHeight > 0) {
|
if (collapsedHeight > 0 && fullHeight > 0) {
|
||||||
setShouldShowMore(fullHeight > collapsedHeight + 1); // +1 untuk toleransi float
|
setShouldShowMore(fullHeight > collapsedHeight + 1);
|
||||||
}
|
}
|
||||||
}, [collapsedHeight, fullHeight]);
|
}, [collapsedHeight, fullHeight]);
|
||||||
|
|
||||||
@@ -41,41 +47,34 @@ export default function TextExpandable({ content, maxLines }: { content: string,
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<View>
|
<View>
|
||||||
{/* Hidden full text for measurement */}
|
|
||||||
<View style={Styles.hidden}>
|
<View style={Styles.hidden}>
|
||||||
<Text style={Styles.textDefault} onLayout={measureFull}>
|
<Text style={Styles.textDefault} onLayout={measureFull}>
|
||||||
{content}
|
{content}
|
||||||
</Text>
|
</Text>
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
{/* Collapsed text for measurement */}
|
|
||||||
<View style={Styles.hidden}>
|
<View style={Styles.hidden}>
|
||||||
<Text
|
<Text numberOfLines={maxLines} style={Styles.textDefault} onLayout={measureCollapsed} ellipsizeMode="tail">
|
||||||
numberOfLines={maxLines}
|
|
||||||
style={Styles.textDefault}
|
|
||||||
onLayout={measureCollapsed}
|
|
||||||
ellipsizeMode="tail"
|
|
||||||
>
|
|
||||||
{content}
|
{content}
|
||||||
</Text>
|
</Text>
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
{/* Animated visible text */}
|
|
||||||
<Animated.View style={{ height: animatedHeight, overflow: 'hidden' }}>
|
<Animated.View style={{ height: animatedHeight, overflow: 'hidden' }}>
|
||||||
<Text
|
<Text style={Styles.textDefault} numberOfLines={isExpanded ? undefined : maxLines} ellipsizeMode="tail">
|
||||||
style={Styles.textDefault}
|
|
||||||
numberOfLines={isExpanded ? undefined : maxLines}
|
|
||||||
ellipsizeMode="tail"
|
|
||||||
>
|
|
||||||
{content}
|
{content}
|
||||||
</Text>
|
</Text>
|
||||||
</Animated.View>
|
</Animated.View>
|
||||||
|
|
||||||
{shouldShowMore && (
|
{shouldShowMore && (
|
||||||
<Pressable onPress={toggleExpand}>
|
<Pressable onPress={toggleExpand} style={Styles.expandBtn}>
|
||||||
<Text style={Styles.textLink}>
|
<Text style={[Styles.textMediumSemiBold, { color: colors.tabActive }]}>
|
||||||
{isExpanded ? 'View Less' : 'View More'}
|
{isExpanded ? 'Sembunyikan' : 'Lihat selengkapnya'}
|
||||||
</Text>
|
</Text>
|
||||||
|
<MaterialCommunityIcons
|
||||||
|
name={isExpanded ? 'chevron-up' : 'chevron-down'}
|
||||||
|
size={16}
|
||||||
|
color={colors.tabActive}
|
||||||
|
/>
|
||||||
</Pressable>
|
</Pressable>
|
||||||
)}
|
)}
|
||||||
</View>
|
</View>
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ export const Colors = {
|
|||||||
tabActive: '#2563EB',
|
tabActive: '#2563EB',
|
||||||
header: '#234881',
|
header: '#234881',
|
||||||
homeGradient: '#346CC4',
|
homeGradient: '#346CC4',
|
||||||
dimmed: '#707887ff',
|
dimmed: '#707887',
|
||||||
success: '#40C057',
|
success: '#40C057',
|
||||||
warning: '#FBBF24',
|
warning: '#FBBF24',
|
||||||
error: '#F87171',
|
error: '#F87171',
|
||||||
|
|||||||
@@ -813,6 +813,109 @@ const Styles = StyleSheet.create({
|
|||||||
width: '48.5%',
|
width: '48.5%',
|
||||||
marginBottom: 10,
|
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: {
|
flex1: {
|
||||||
flex: 1
|
flex: 1
|
||||||
},
|
},
|
||||||
|
|||||||
44
lib/api.ts
44
lib/api.ts
@@ -357,6 +357,28 @@ export const apiDeleteProjectMember = async (data: { user: string, idUser: strin
|
|||||||
return response.data
|
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 apiAddMemberProject = async ({ data, id }: { data: { user: string, member: any[] }, id: string }) => {
|
export const apiAddMemberProject = async ({ data, id }: { data: { user: string, member: any[] }, id: string }) => {
|
||||||
const response = await api.post(`/mobile/project/${id}/member`, data)
|
const response = await api.post(`/mobile/project/${id}/member`, data)
|
||||||
@@ -664,6 +686,28 @@ export const apiAddFileTask = async ({ data, id }: { data: FormData, id: string
|
|||||||
return response.data;
|
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) => {
|
export const apiEditTask = async (data: { title: string, user: string }, id: string) => {
|
||||||
const response = await api.put(`/mobile/task/${id}`, data)
|
const response = await api.put(`/mobile/task/${id}`, data)
|
||||||
return response.data;
|
return response.data;
|
||||||
|
|||||||
Reference in New Issue
Block a user