Compare commits
37 Commits
amalia/09-
...
amalia/27-
| Author | SHA1 | Date | |
|---|---|---|---|
| c230e0b18b | |||
| 013589b9f7 | |||
| b99476a593 | |||
| e1b2cd3790 | |||
| 03d0836111 | |||
| 588df062f1 | |||
| e61fb83bfd | |||
| e68f8957ad | |||
| eee3691aca | |||
| d9508ba978 | |||
| 6f3514c80c | |||
| bd31a2f993 | |||
| 3fbb230302 | |||
| 57a24b699a | |||
| 1a4ccc4f66 | |||
| 2ba3675b3a | |||
| ca3d0d9d19 | |||
| 42f245f37c | |||
| 6acfcf9a54 | |||
| 2b7022ee3d | |||
| ec24cb70cb | |||
| 5451dc092f | |||
| 74ba2641ca | |||
| fb8a140a31 | |||
| f341bd01c6 | |||
| c458504da2 | |||
| a0d1b90662 | |||
| bd9fe8676d | |||
| 56856a96fd | |||
| 049f6c63cc | |||
| 2ea92d3e9a | |||
| 04f7bda40f | |||
| 863871aae5 | |||
| 0ce1f270ef | |||
| 6ffda375a4 | |||
| 2347b322cf | |||
| 13a1d0e858 |
@@ -4,7 +4,7 @@ export default {
|
||||
expo: {
|
||||
name: "Desa+",
|
||||
slug: "mobile-darmasaba",
|
||||
version: "2.0.2", // Versi aplikasi (App Store)
|
||||
version: "2.0.5", // Versi aplikasi (App Store)
|
||||
jsEngine: "jsc",
|
||||
orientation: "portrait",
|
||||
icon: "./assets/images/logo-icon-small.png",
|
||||
@@ -14,7 +14,7 @@ export default {
|
||||
ios: {
|
||||
supportsTablet: true,
|
||||
bundleIdentifier: "mobiledarmasaba.app",
|
||||
buildNumber: "4",
|
||||
buildNumber: "7",
|
||||
infoPlist: {
|
||||
ITSAppUsesNonExemptEncryption: false,
|
||||
CFBundleDisplayName: "Desa+"
|
||||
@@ -23,7 +23,7 @@ export default {
|
||||
},
|
||||
android: {
|
||||
package: "mobiledarmasaba.app",
|
||||
versionCode: 11,
|
||||
versionCode: 15,
|
||||
adaptiveIcon: {
|
||||
foregroundImage: "./assets/images/logo-icon-small.png",
|
||||
backgroundColor: "#ffffff"
|
||||
@@ -77,7 +77,8 @@ export default {
|
||||
URL_OTP: process.env.URL_OTP,
|
||||
URL_STORAGE: process.env.URL_STORAGE,
|
||||
URL_FIREBASE_DB: process.env.URL_FIREBASE_DB,
|
||||
PASS_ENC: process.env.PASS_ENC
|
||||
PASS_ENC: process.env.PASS_ENC,
|
||||
WA_SERVER_TOKEN: process.env.WA_SERVER_TOKEN,
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import HeaderRightAnnouncementList from "@/components/announcement/headerAnnouncementList";
|
||||
import ButtonBackHeader from "@/components/buttonBackHeader";
|
||||
import AppHeader from "@/components/AppHeader";
|
||||
import HeaderDiscussionGeneral from "@/components/discussion_general/headerDiscussionGeneral";
|
||||
import HeaderRightDivisionList from "@/components/division/headerDivisionList";
|
||||
import HeaderRightGroupList from "@/components/group/headerGroupList";
|
||||
@@ -19,7 +19,6 @@ import { getMessaging, onMessage } from "@react-native-firebase/messaging";
|
||||
import { Redirect, router, Stack, usePathname } from "expo-router";
|
||||
import { StatusBar } from 'expo-status-bar';
|
||||
import { useEffect } from "react";
|
||||
import { Platform } from "react-native";
|
||||
import { Easing, Notifier } from 'react-native-notifier';
|
||||
import { Provider } from "react-redux";
|
||||
|
||||
@@ -98,54 +97,100 @@ export default function RootLayout() {
|
||||
<Stack.Screen name="search" options={{ title: 'Pencarian' }} />
|
||||
<Stack.Screen name="notification" options={{
|
||||
title: 'Notifikasi',
|
||||
headerLeft: () => <ButtonBackHeader onPress={() => { router.back() }} />,
|
||||
// headerLeft: () => <ButtonBackHeader onPress={() => { router.back() }} />,
|
||||
headerTitle: 'Notifikasi',
|
||||
headerTitleAlign: 'center'
|
||||
headerTitleAlign: 'center',
|
||||
header: () => (
|
||||
<AppHeader title="Notifikasi" showBack={true} onPressLeft={() => router.back()} />
|
||||
)
|
||||
}} />
|
||||
<Stack.Screen name="profile" options={{ title: 'Profile' }} />
|
||||
<Stack.Screen name="member/index" options={{
|
||||
headerLeft: () => <ButtonBackHeader onPress={() => { router.back() }} />,
|
||||
// headerLeft: () => <ButtonBackHeader onPress={() => { router.back() }} />,
|
||||
title: 'Anggota',
|
||||
headerTitleAlign: 'center',
|
||||
headerRight: () => <HeaderMemberList />
|
||||
// headerRight: () => <HeaderMemberList />
|
||||
header: () => (
|
||||
<AppHeader title="Anggota"
|
||||
showBack={true}
|
||||
onPressLeft={() => router.back()}
|
||||
right={<HeaderMemberList />}
|
||||
/>
|
||||
)
|
||||
}} />
|
||||
<Stack.Screen name="discussion/index" options={{
|
||||
headerLeft: () => <ButtonBackHeader onPress={() => { router.back() }} />,
|
||||
// headerLeft: () => <ButtonBackHeader onPress={() => { router.back() }} />,
|
||||
title: 'Diskusi Umum',
|
||||
headerTitleAlign: 'center',
|
||||
headerRight: () => <HeaderDiscussionGeneral />
|
||||
// headerRight: () => <HeaderDiscussionGeneral />
|
||||
header: () => (
|
||||
<AppHeader
|
||||
title="Diskusi Umum"
|
||||
showBack={true}
|
||||
onPressLeft={() => router.back()}
|
||||
right={<HeaderDiscussionGeneral />}
|
||||
/>
|
||||
)
|
||||
}} />
|
||||
<Stack.Screen name="project/index" options={{
|
||||
headerLeft: () => <ButtonBackHeader onPress={() => { router.back() }} />,
|
||||
// headerLeft: () => <ButtonBackHeader onPress={() => { router.back() }} />,
|
||||
title: 'Kegiatan',
|
||||
headerTitleAlign: 'center',
|
||||
headerRight: () => <HeaderRightProjectList />
|
||||
// headerRight: () => <HeaderRightProjectList />
|
||||
header: () => (
|
||||
<AppHeader title="Kegiatan"
|
||||
showBack={true}
|
||||
onPressLeft={() => router.back()}
|
||||
right={<HeaderRightProjectList />}
|
||||
/>
|
||||
)
|
||||
}} />
|
||||
<Stack.Screen name="division/index" options={{
|
||||
headerLeft: () => <ButtonBackHeader onPress={() => { router.back() }} />,
|
||||
// headerLeft: () => <ButtonBackHeader onPress={() => { router.back() }} />,
|
||||
title: 'Divisi',
|
||||
headerTitleAlign: 'center',
|
||||
headerRight: () => <HeaderRightDivisionList />
|
||||
}} />
|
||||
<Stack.Screen name="division/[id]/(fitur-division)" options={{ headerShown: false }} />
|
||||
<Stack.Screen name="group/index" options={{
|
||||
headerLeft: () => <ButtonBackHeader onPress={() => { router.back() }} />,
|
||||
// headerLeft: () => <ButtonBackHeader onPress={() => { router.back() }} />,
|
||||
headerTitle: 'Lembaga Desa',
|
||||
headerTitleAlign: 'center',
|
||||
headerRight: () => <HeaderRightGroupList />
|
||||
// headerRight: () => <HeaderRightGroupList />
|
||||
header: () => (
|
||||
<AppHeader title="Lembaga Desa"
|
||||
showBack={true}
|
||||
onPressLeft={() => router.back()}
|
||||
right={<HeaderRightGroupList />}
|
||||
/>
|
||||
)
|
||||
}} />
|
||||
<Stack.Screen name="position/index" options={{
|
||||
headerLeft: () => <ButtonBackHeader onPress={() => { router.back() }} />,
|
||||
// headerLeft: () => <ButtonBackHeader onPress={() => { router.back() }} />,
|
||||
headerTitle: 'Jabatan',
|
||||
headerTitleAlign: 'center',
|
||||
headerRight: () => <HeaderRightPositionList />
|
||||
// headerRight: () => <HeaderRightPositionList />
|
||||
header: () => (
|
||||
<AppHeader title="Jabatan"
|
||||
showBack={true}
|
||||
onPressLeft={() => router.back()}
|
||||
right={<HeaderRightPositionList />}
|
||||
/>
|
||||
)
|
||||
}} />
|
||||
<Stack.Screen name="announcement/index"
|
||||
options={{
|
||||
headerLeft: () => <ButtonBackHeader onPress={() => { router.back() }} />,
|
||||
// headerLeft: () => <ButtonBackHeader onPress={() => { router.back() }} />,
|
||||
headerTitle: 'Pengumuman',
|
||||
headerTitleAlign: 'center',
|
||||
headerRight: () => <HeaderRightAnnouncementList />
|
||||
// headerRight: () => <HeaderRightAnnouncementList />
|
||||
header: () => (
|
||||
<AppHeader title="Pengumuman"
|
||||
showBack={true}
|
||||
onPressLeft={() => router.back()}
|
||||
right={<HeaderRightAnnouncementList />}
|
||||
/>
|
||||
)
|
||||
}}
|
||||
/>
|
||||
</Stack>
|
||||
|
||||
@@ -1,15 +1,23 @@
|
||||
import HeaderRightAnnouncementDetail from "@/components/announcement/headerAnnouncementDetail";
|
||||
import AppHeader from "@/components/AppHeader";
|
||||
import BorderBottomItem from "@/components/borderBottomItem";
|
||||
import ButtonBackHeader from "@/components/buttonBackHeader";
|
||||
import Skeleton from "@/components/skeleton";
|
||||
import Text from '@/components/Text';
|
||||
import { ConstEnv } from "@/constants/ConstEnv";
|
||||
import Styles from "@/constants/Styles";
|
||||
import { apiGetAnnouncementOne } from "@/lib/api";
|
||||
import { useAuthSession } from "@/providers/AuthProvider";
|
||||
import { Entypo, MaterialIcons } from "@expo/vector-icons";
|
||||
import { Entypo, MaterialCommunityIcons, MaterialIcons } from "@expo/vector-icons";
|
||||
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 React, { useEffect, useState } from "react";
|
||||
import { Dimensions, RefreshControl, SafeAreaView, ScrollView, View } from "react-native";
|
||||
import { Alert, Dimensions, Platform, RefreshControl, SafeAreaView, ScrollView, View } from "react-native";
|
||||
import * as mime from 'react-native-mime-types';
|
||||
import RenderHTML from 'react-native-render-html';
|
||||
import Toast from "react-native-toast-message";
|
||||
import { useSelector } from "react-redux";
|
||||
|
||||
type Props = {
|
||||
@@ -23,22 +31,31 @@ export default function DetailAnnouncement() {
|
||||
const { token, decryptToken } = useAuthSession()
|
||||
const [data, setData] = useState<Props>({ id: '', title: '', desc: '' })
|
||||
const [dataMember, setDataMember] = useState<any>({})
|
||||
const [dataFile, setDataFile] = useState<{ id: string; idStorage: string; name: string; extension: string }[]>([])
|
||||
const update = useSelector((state: any) => state.announcementUpdate)
|
||||
const entityUser = useSelector((state: any) => state.user)
|
||||
const contentWidth = Dimensions.get('window').width
|
||||
const [loading, setLoading] = useState(true)
|
||||
const arrSkeleton = Array.from({ length: 2 }, (_, index) => index)
|
||||
const [refreshing, setRefreshing] = useState(false)
|
||||
const [loadingOpen, setLoadingOpen] = useState(false)
|
||||
|
||||
|
||||
async function handleLoad(loading: boolean) {
|
||||
try {
|
||||
setLoading(loading)
|
||||
const hasil = await decryptToken(String(token?.current))
|
||||
const response = await apiGetAnnouncementOne({ id: id, user: hasil })
|
||||
setData(response.data)
|
||||
setDataMember(response.member)
|
||||
if (response.success) {
|
||||
setData(response.data)
|
||||
setDataMember(response.member)
|
||||
setDataFile(response.file)
|
||||
} else {
|
||||
Toast.show({ type: 'small', text1: response.message })
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
Toast.show({ type: 'small', text1: 'Gagal mengambil data' })
|
||||
} finally {
|
||||
setLoading(false)
|
||||
}
|
||||
@@ -64,14 +81,52 @@ export default function DetailAnnouncement() {
|
||||
setRefreshing(false)
|
||||
};
|
||||
|
||||
const openFile = (item: { idStorage: string; name: string; extension: string }) => {
|
||||
if (Platform.OS == 'android') setLoadingOpen(true)
|
||||
let remoteUrl = ConstEnv.url_storage + '/files/' + item.idStorage;
|
||||
const fileName = item.name + '.' + item.extension;
|
||||
let localPath = `${FileSystem.documentDirectory}/${fileName}`;
|
||||
const mimeType = mime.lookup(fileName)
|
||||
|
||||
FileSystem.downloadAsync(remoteUrl, localPath).then(async ({ uri }) => {
|
||||
const contentURL = await FileSystem.getContentUriAsync(uri);
|
||||
setLoadingOpen(false)
|
||||
try {
|
||||
if (Platform.OS == 'android') {
|
||||
await startActivityAsync(
|
||||
'android.intent.action.VIEW',
|
||||
{
|
||||
data: contentURL,
|
||||
flags: 1,
|
||||
type: mimeType as string,
|
||||
}
|
||||
);
|
||||
} else if (Platform.OS == 'ios') {
|
||||
Sharing.shareAsync(localPath);
|
||||
}
|
||||
} catch (error) {
|
||||
Alert.alert('INFO', 'Gagal membuka file, tidak ada aplikasi yang dapat membuka file ini');
|
||||
} finally {
|
||||
if (Platform.OS == 'android') setLoadingOpen(false)
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<SafeAreaView>
|
||||
<Stack.Screen
|
||||
options={{
|
||||
headerLeft: () => <ButtonBackHeader onPress={() => { router.back() }} />,
|
||||
// headerLeft: () => <ButtonBackHeader onPress={() => { router.back() }} />,
|
||||
headerTitle: 'Pengumuman',
|
||||
headerTitleAlign: 'center',
|
||||
headerRight: () => entityUser.role != 'user' && entityUser.role != 'coadmin' ? <HeaderRightAnnouncementDetail id={id} /> : <></>,
|
||||
// headerRight: () => entityUser.role != 'user' && entityUser.role != 'coadmin' ? <HeaderRightAnnouncementDetail id={id} /> : <></>,
|
||||
header: () => (
|
||||
<AppHeader title="Pengumuman"
|
||||
showBack={true}
|
||||
onPressLeft={() => router.back()}
|
||||
right={entityUser.role != 'user' && entityUser.role != 'coadmin' ? <HeaderRightAnnouncementDetail id={id} /> : <></>}
|
||||
/>
|
||||
)
|
||||
}}
|
||||
/>
|
||||
<ScrollView
|
||||
@@ -102,8 +157,8 @@ export default function DetailAnnouncement() {
|
||||
:
|
||||
<>
|
||||
<View style={[Styles.rowItemsCenter, { alignItems: 'flex-start' }]}>
|
||||
<MaterialIcons name="campaign" size={30} color="black" style={Styles.mr05} />
|
||||
<Text style={[Styles.textDefaultSemiBold, Styles.w90]}>{data?.title}</Text>
|
||||
<MaterialIcons name="campaign" size={25} color="black" style={[Styles.mr05]} />
|
||||
<Text style={[Styles.textDefaultSemiBold, Styles.w90, Styles.mt02]}>{data?.title}</Text>
|
||||
</View>
|
||||
<View style={[Styles.mt10]}>
|
||||
{
|
||||
@@ -111,6 +166,7 @@ export default function DetailAnnouncement() {
|
||||
<RenderHTML
|
||||
contentWidth={contentWidth}
|
||||
source={{ html: data?.desc }}
|
||||
baseStyle={{ color: 'black' }}
|
||||
/>
|
||||
:
|
||||
<Text>{data?.desc}</Text>
|
||||
@@ -120,7 +176,26 @@ export default function DetailAnnouncement() {
|
||||
}
|
||||
|
||||
</View>
|
||||
<View style={[Styles.wrapPaper, Styles.mv15]}>
|
||||
{
|
||||
dataFile.length > 0 && (
|
||||
<View style={[Styles.wrapPaper, Styles.mt10]}>
|
||||
<View style={[Styles.mb05]}>
|
||||
<Text style={[Styles.textDefaultSemiBold]}>File</Text>
|
||||
</View>
|
||||
{dataFile.map((item, index) => (
|
||||
<BorderBottomItem
|
||||
key={index}
|
||||
borderType="bottom"
|
||||
icon={<MaterialCommunityIcons name="file-outline" size={25} color="black" />}
|
||||
title={item.name}
|
||||
titleWeight="normal"
|
||||
onPress={() => { openFile({ idStorage: item.idStorage, name: item.name, extension: item.extension }) }}
|
||||
/>
|
||||
))}
|
||||
</View>
|
||||
)
|
||||
}
|
||||
<View style={[Styles.wrapPaper, Styles.mt10]}>
|
||||
{
|
||||
loading ?
|
||||
arrSkeleton.map((item, index) => {
|
||||
|
||||
@@ -1,16 +1,21 @@
|
||||
import ButtonBackHeader from "@/components/buttonBackHeader";
|
||||
import AppHeader from "@/components/AppHeader";
|
||||
import BorderBottomItem from "@/components/borderBottomItem";
|
||||
import ButtonSaveHeader from "@/components/buttonSaveHeader";
|
||||
import ButtonSelect from "@/components/buttonSelect";
|
||||
import DrawerBottom from "@/components/drawerBottom";
|
||||
import { InputForm } from "@/components/inputForm";
|
||||
import LoadingOverlay from "@/components/loadingOverlay";
|
||||
import MenuItemRow from "@/components/menuItemRow";
|
||||
import ModalSelectMultiple from "@/components/modalSelectMultiple";
|
||||
import Text from "@/components/Text";
|
||||
import Styles from "@/constants/Styles";
|
||||
import { setUpdateAnnouncement } from "@/lib/announcementUpdate";
|
||||
import { apiCreateAnnouncement } from "@/lib/api";
|
||||
import { useAuthSession } from "@/providers/AuthProvider";
|
||||
import { Entypo } from "@expo/vector-icons";
|
||||
import { Entypo, Ionicons, MaterialCommunityIcons } from "@expo/vector-icons";
|
||||
import * as DocumentPicker from "expo-document-picker";
|
||||
import { router, Stack } from "expo-router";
|
||||
import { useEffect, useState } from "react";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { SafeAreaView, ScrollView, StyleSheet, View } from "react-native";
|
||||
import Toast from "react-native-toast-message";
|
||||
import { useDispatch, useSelector } from "react-redux";
|
||||
@@ -23,6 +28,9 @@ export default function CreateAnnouncement() {
|
||||
const [modalDivisi, setModalDivisi] = useState(false);
|
||||
const [divisionMember, setDivisionMember] = useState<any>([])
|
||||
const [loading, setLoading] = useState(false)
|
||||
const [fileForm, setFileForm] = useState<any[]>([])
|
||||
const [isModalFile, setModalFile] = useState(false)
|
||||
const [indexDelFile, setIndexDelFile] = useState<number>(0)
|
||||
const [dataForm, setDataForm] = useState({
|
||||
title: "",
|
||||
desc: "",
|
||||
@@ -69,9 +77,26 @@ export default function CreateAnnouncement() {
|
||||
try {
|
||||
setLoading(true)
|
||||
const hasil = await decryptToken(String(token?.current))
|
||||
const response = await apiCreateAnnouncement({
|
||||
data: { ...dataForm, user: hasil, groups: divisionMember },
|
||||
});
|
||||
const fd = new FormData()
|
||||
|
||||
for (let i = 0; i < fileForm.length; i++) {
|
||||
fd.append(`file${i}`, {
|
||||
uri: fileForm[i].uri,
|
||||
type: 'application/octet-stream',
|
||||
name: fileForm[i].name,
|
||||
} as any);
|
||||
}
|
||||
|
||||
fd.append("data", JSON.stringify(
|
||||
{ user: hasil, groups: divisionMember, ...dataForm }
|
||||
))
|
||||
|
||||
const response = await apiCreateAnnouncement(fd)
|
||||
|
||||
// const response = await apiCreateAnnouncement({
|
||||
// data: { ...dataForm, user: hasil, groups: divisionMember },
|
||||
// });
|
||||
|
||||
if (response.success) {
|
||||
dispatch(setUpdateAnnouncement(!update))
|
||||
Toast.show({ type: 'small', text1: 'Berhasil menambahkan data', })
|
||||
@@ -84,32 +109,70 @@ export default function CreateAnnouncement() {
|
||||
}
|
||||
}
|
||||
|
||||
const pickDocumentAsync = async () => {
|
||||
let result = await DocumentPicker.getDocumentAsync({
|
||||
type: ["*/*"],
|
||||
multiple: true
|
||||
});
|
||||
if (!result.canceled) {
|
||||
for (let i = 0; i < result.assets?.length; i++) {
|
||||
if (result.assets[i].uri) {
|
||||
setFileForm((prev) => [...prev, result.assets[i]])
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function deleteFile(index: number) {
|
||||
setFileForm([...fileForm.filter((val, i) => i !== index)])
|
||||
setModalFile(false)
|
||||
}
|
||||
|
||||
return (
|
||||
<SafeAreaView>
|
||||
<Stack.Screen
|
||||
options={{
|
||||
headerLeft: () => (
|
||||
<ButtonBackHeader
|
||||
onPress={() => {
|
||||
router.back();
|
||||
}}
|
||||
/>
|
||||
),
|
||||
// headerLeft: () => (
|
||||
// <ButtonBackHeader
|
||||
// onPress={() => {
|
||||
// router.back();
|
||||
// }}
|
||||
// />
|
||||
// ),
|
||||
headerTitle: "Tambah Pengumuman",
|
||||
headerTitleAlign: "center",
|
||||
headerRight: () => (
|
||||
<ButtonSaveHeader
|
||||
disable={disableBtn || divisionMember.length == 0 || loading ? true : false}
|
||||
category="create"
|
||||
onPress={() => {
|
||||
divisionMember.length == 0
|
||||
? Toast.show({ type: 'small', text1: "Anda belum memilih divisi", })
|
||||
: handleCreate();
|
||||
}}
|
||||
// headerRight: () => (
|
||||
// <ButtonSaveHeader
|
||||
// disable={disableBtn || divisionMember.length == 0 || loading ? true : false}
|
||||
// category="create"
|
||||
// onPress={() => {
|
||||
// divisionMember.length == 0
|
||||
// ? Toast.show({ type: 'small', text1: "Anda belum memilih divisi", })
|
||||
// : handleCreate();
|
||||
// }}
|
||||
// />
|
||||
// ),
|
||||
header: () => (
|
||||
<AppHeader
|
||||
title="Tambah Pengumuman"
|
||||
showBack={true}
|
||||
onPressLeft={() => router.back()}
|
||||
right={
|
||||
<ButtonSaveHeader
|
||||
disable={disableBtn || divisionMember.length == 0 || loading ? true : false}
|
||||
category="create"
|
||||
onPress={() => {
|
||||
divisionMember.length == 0
|
||||
? Toast.show({ type: 'small', text1: "Anda belum memilih divisi", })
|
||||
: handleCreate();
|
||||
}}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
),
|
||||
)
|
||||
}}
|
||||
/>
|
||||
<LoadingOverlay visible={loading} />
|
||||
<ScrollView
|
||||
showsVerticalScrollIndicator={false}
|
||||
style={[Styles.h100]}
|
||||
@@ -134,6 +197,27 @@ export default function CreateAnnouncement() {
|
||||
onChange={(val) => validationForm("desc", val)}
|
||||
multiline
|
||||
/>
|
||||
<ButtonSelect value="Upload File" onPress={pickDocumentAsync} />
|
||||
{
|
||||
fileForm.length > 0
|
||||
&&
|
||||
<View style={[Styles.borderAll, Styles.round10, Styles.p10, Styles.mb10]}>
|
||||
<Text style={[Styles.textDefaultSemiBold]}>File</Text>
|
||||
{
|
||||
fileForm.map((item, index) => (
|
||||
<BorderBottomItem
|
||||
key={index}
|
||||
borderType={fileForm.length > 1 ? "bottom" : "none"}
|
||||
icon={<MaterialCommunityIcons name="file-outline" size={25} color="black" />}
|
||||
title={item.name}
|
||||
titleWeight="normal"
|
||||
onPress={() => { setIndexDelFile(index); setModalFile(true) }}
|
||||
/>
|
||||
))
|
||||
}
|
||||
</View>
|
||||
}
|
||||
|
||||
<ButtonSelect
|
||||
value="Pilih divisi penerima pengumuman"
|
||||
onPress={() => {
|
||||
@@ -178,6 +262,16 @@ export default function CreateAnnouncement() {
|
||||
setModalDivisi(false)
|
||||
}}
|
||||
/>
|
||||
|
||||
<DrawerBottom animation="slide" isVisible={isModalFile} setVisible={setModalFile} title="Menu">
|
||||
<View style={Styles.rowItemsCenter}>
|
||||
<MenuItemRow
|
||||
icon={<Ionicons name="trash" color="black" size={25} />}
|
||||
title="Hapus"
|
||||
onPress={() => { deleteFile(indexDelFile) }}
|
||||
/>
|
||||
</View>
|
||||
</DrawerBottom>
|
||||
</SafeAreaView>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,14 +1,19 @@
|
||||
import ButtonBackHeader from "@/components/buttonBackHeader";
|
||||
import AppHeader from "@/components/AppHeader";
|
||||
import BorderBottomItem from "@/components/borderBottomItem";
|
||||
import ButtonSaveHeader from "@/components/buttonSaveHeader";
|
||||
import ButtonSelect from "@/components/buttonSelect";
|
||||
import DrawerBottom from "@/components/drawerBottom";
|
||||
import { InputForm } from "@/components/inputForm";
|
||||
import LoadingOverlay from "@/components/loadingOverlay";
|
||||
import MenuItemRow from "@/components/menuItemRow";
|
||||
import ModalSelectMultiple from "@/components/modalSelectMultiple";
|
||||
import Text from '@/components/Text';
|
||||
import Styles from "@/constants/Styles";
|
||||
import { setUpdateAnnouncement } from "@/lib/announcementUpdate";
|
||||
import { apiEditAnnouncement, apiGetAnnouncementOne } from "@/lib/api";
|
||||
import { useAuthSession } from "@/providers/AuthProvider";
|
||||
import { Entypo } from "@expo/vector-icons";
|
||||
import { Entypo, Ionicons, MaterialCommunityIcons } from "@expo/vector-icons";
|
||||
import * as DocumentPicker from "expo-document-picker";
|
||||
import { router, Stack, useLocalSearchParams } from "expo-router";
|
||||
import { useEffect, useState } from "react";
|
||||
import { SafeAreaView, ScrollView, View } from "react-native";
|
||||
@@ -33,6 +38,10 @@ export default function EditAnnouncement() {
|
||||
const [modalDivisi, setModalDivisi] = useState(false);
|
||||
const [disableBtn, setDisableBtn] = useState(true);
|
||||
const [dataMember, setDataMember] = useState<any>([]);
|
||||
const [fileForm, setFileForm] = useState<any[]>([])
|
||||
const [dataFile, setDataFile] = useState<{ id: string; idStorage: string; name: string; extension: string; delete?: boolean }[]>([])
|
||||
const [indexDelFile, setIndexDelFile] = useState<{ id: string | number; cat: "newFile" | "oldFile" }>({ id: "", cat: "newFile" })
|
||||
const [isModalFile, setModalFile] = useState(false)
|
||||
const [loading, setLoading] = useState(false)
|
||||
const [dataForm, setDataForm] = useState({
|
||||
title: "",
|
||||
@@ -66,6 +75,7 @@ export default function EditAnnouncement() {
|
||||
arrNew.push(newObject)
|
||||
})
|
||||
setDataMember(arrNew);
|
||||
setDataFile(response.file);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
@@ -112,9 +122,22 @@ export default function EditAnnouncement() {
|
||||
try {
|
||||
setLoading(true)
|
||||
const hasil = await decryptToken(String(token?.current))
|
||||
const response = await apiEditAnnouncement({
|
||||
...dataForm, user: hasil, groups: dataMember,
|
||||
}, id);
|
||||
const fd = new FormData()
|
||||
for (let i = 0; i < fileForm.length; i++) {
|
||||
fd.append(`file${i}`, {
|
||||
uri: fileForm[i].uri,
|
||||
type: 'application/octet-stream',
|
||||
name: fileForm[i].name,
|
||||
} as any);
|
||||
}
|
||||
|
||||
fd.append("data", JSON.stringify(
|
||||
{
|
||||
...dataForm, user: hasil, groups: dataMember, oldFile: dataFile
|
||||
}
|
||||
))
|
||||
|
||||
const response = await apiEditAnnouncement(fd, id);
|
||||
if (response.success) {
|
||||
dispatch(setUpdateAnnouncement(!update))
|
||||
Toast.show({ type: 'small', text1: 'Berhasil mengubah data', })
|
||||
@@ -127,32 +150,80 @@ export default function EditAnnouncement() {
|
||||
}
|
||||
}
|
||||
|
||||
const pickDocumentAsync = async () => {
|
||||
let result = await DocumentPicker.getDocumentAsync({
|
||||
type: ["*/*"],
|
||||
multiple: true
|
||||
});
|
||||
if (!result.canceled) {
|
||||
for (let i = 0; i < result.assets?.length; i++) {
|
||||
if (result.assets[i].uri) {
|
||||
setFileForm((prev) => [...prev, result.assets[i]])
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function deleteFile(index: number | string, cat: "newFile" | "oldFile" | null) {
|
||||
if (cat == "newFile") {
|
||||
setFileForm([...fileForm.filter((val, i) => i !== index)])
|
||||
} else {
|
||||
setDataFile(prev =>
|
||||
prev.map(item =>
|
||||
item.id === index
|
||||
? { ...item, delete: true }
|
||||
: item
|
||||
)
|
||||
);
|
||||
}
|
||||
setModalFile(false)
|
||||
}
|
||||
|
||||
return (
|
||||
<SafeAreaView>
|
||||
<Stack.Screen
|
||||
options={{
|
||||
headerLeft: () => (
|
||||
<ButtonBackHeader
|
||||
onPress={() => {
|
||||
router.back();
|
||||
}}
|
||||
/>
|
||||
),
|
||||
// headerLeft: () => (
|
||||
// <ButtonBackHeader
|
||||
// onPress={() => {
|
||||
// router.back();
|
||||
// }}
|
||||
// />
|
||||
// ),
|
||||
headerTitle: "Edit Pengumuman",
|
||||
headerTitleAlign: "center",
|
||||
headerRight: () => (
|
||||
<ButtonSaveHeader
|
||||
disable={disableBtn || loading ? true : false}
|
||||
category="update"
|
||||
onPress={() => {
|
||||
dataMember.length == 0
|
||||
? Toast.show({ type: 'small', text1: "Anda belum memilih divisi", })
|
||||
: handleEdit();
|
||||
}}
|
||||
// headerRight: () => (
|
||||
// <ButtonSaveHeader
|
||||
// disable={disableBtn || loading ? true : false}
|
||||
// category="update"
|
||||
// onPress={() => {
|
||||
// dataMember.length == 0
|
||||
// ? Toast.show({ type: 'small', text1: "Anda belum memilih divisi", })
|
||||
// : handleEdit();
|
||||
// }}
|
||||
// />
|
||||
// ),
|
||||
header: () => (
|
||||
<AppHeader
|
||||
title="Edit Pengumuman"
|
||||
showBack={true}
|
||||
onPressLeft={() => router.back()}
|
||||
right={
|
||||
<ButtonSaveHeader
|
||||
disable={disableBtn || loading ? true : false}
|
||||
category="update"
|
||||
onPress={() => {
|
||||
dataMember.length == 0
|
||||
? Toast.show({ type: 'small', text1: "Anda belum memilih divisi", })
|
||||
: handleEdit();
|
||||
}}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
),
|
||||
)
|
||||
}}
|
||||
/>
|
||||
<LoadingOverlay visible={loading} />
|
||||
<ScrollView
|
||||
showsVerticalScrollIndicator={false}
|
||||
style={[Styles.h100]}
|
||||
@@ -179,6 +250,38 @@ export default function EditAnnouncement() {
|
||||
value={dataForm.desc}
|
||||
multiline
|
||||
/>
|
||||
<ButtonSelect value="Upload File" onPress={pickDocumentAsync} />
|
||||
{
|
||||
(fileForm.length > 0 || dataFile.filter((val) => !val.delete).length > 0)
|
||||
&&
|
||||
<View style={[Styles.borderAll, Styles.round10, Styles.p10, Styles.mb10]}>
|
||||
<Text style={[Styles.textDefaultSemiBold]}>File</Text>
|
||||
{
|
||||
dataFile.filter((val) => !val.delete).map((item, index) => (
|
||||
<BorderBottomItem
|
||||
key={index}
|
||||
borderType={(fileForm.length + dataFile.length) > 1 ? "bottom" : "none"}
|
||||
icon={<MaterialCommunityIcons name="file-outline" size={25} color="black" />}
|
||||
title={item.name + '.' + item.extension}
|
||||
titleWeight="normal"
|
||||
onPress={() => { setIndexDelFile({ id: item.id, cat: "oldFile" }); setModalFile(true) }}
|
||||
/>
|
||||
))
|
||||
}
|
||||
{
|
||||
fileForm.map((item, index) => (
|
||||
<BorderBottomItem
|
||||
key={index}
|
||||
borderType={(fileForm.length + dataFile.length) > 1 ? "bottom" : "none"}
|
||||
icon={<MaterialCommunityIcons name="file-outline" size={25} color="black" />}
|
||||
title={item.name}
|
||||
titleWeight="normal"
|
||||
onPress={() => { setIndexDelFile({ id: index, cat: "newFile" }); setModalFile(true) }}
|
||||
/>
|
||||
))
|
||||
}
|
||||
</View>
|
||||
}
|
||||
<ButtonSelect
|
||||
value="Pilih divisi penerima pengumuman"
|
||||
onPress={() => {
|
||||
@@ -223,6 +326,16 @@ export default function EditAnnouncement() {
|
||||
}}
|
||||
value={dataMember}
|
||||
/>
|
||||
|
||||
<DrawerBottom animation="slide" isVisible={isModalFile} setVisible={setModalFile} title="Menu">
|
||||
<View style={Styles.rowItemsCenter}>
|
||||
<MenuItemRow
|
||||
icon={<Ionicons name="trash" color="black" size={25} />}
|
||||
title="Hapus"
|
||||
onPress={() => { deleteFile(indexDelFile.id, indexDelFile.cat) }}
|
||||
/>
|
||||
</View>
|
||||
</DrawerBottom>
|
||||
</SafeAreaView>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import ButtonBackHeader from "@/components/buttonBackHeader";
|
||||
import AppHeader from "@/components/AppHeader";
|
||||
import ButtonSaveHeader from "@/components/buttonSaveHeader";
|
||||
import { InputForm } from "@/components/inputForm";
|
||||
import Text from "@/components/Text";
|
||||
@@ -115,19 +115,32 @@ export default function EditBanner() {
|
||||
<SafeAreaView>
|
||||
<Stack.Screen
|
||||
options={{
|
||||
headerLeft: () => (
|
||||
<ButtonBackHeader
|
||||
onPress={() => {
|
||||
router.back();
|
||||
}}
|
||||
/>
|
||||
),
|
||||
// headerLeft: () => (
|
||||
// <ButtonBackHeader
|
||||
// onPress={() => {
|
||||
// router.back();
|
||||
// }}
|
||||
// />
|
||||
// ),
|
||||
headerTitle: "Edit Banner",
|
||||
headerTitleAlign: "center",
|
||||
headerRight: () => <ButtonSaveHeader
|
||||
disable={title == "" || error || loading ? true : false}
|
||||
onPress={() => { handleUpdateEntity() }}
|
||||
category="update" />,
|
||||
// headerRight: () => <ButtonSaveHeader
|
||||
// disable={title == "" || error || loading ? true : false}
|
||||
// onPress={() => { handleUpdateEntity() }}
|
||||
// category="update" />,
|
||||
header: () => (
|
||||
<AppHeader
|
||||
title="Edit Banner"
|
||||
showBack={true}
|
||||
onPressLeft={() => router.back()}
|
||||
right={
|
||||
<ButtonSaveHeader
|
||||
disable={title == "" || error || loading ? true : false}
|
||||
onPress={() => { handleUpdateEntity() }}
|
||||
category="update" />
|
||||
}
|
||||
/>
|
||||
)
|
||||
}}
|
||||
/>
|
||||
<ScrollView showsVerticalScrollIndicator={false} style={[Styles.h100]}>
|
||||
@@ -154,7 +167,7 @@ export default function EditBanner() {
|
||||
>
|
||||
<Entypo name="image" size={50} color={"#aeaeae"} />
|
||||
<Text style={[Styles.textInformation, Styles.mt05]}>
|
||||
Mohon unggah gambar dalam resolusi 1535 x 450 piksel untuk
|
||||
Mohon unggah gambar dalam resolusi 1650 x 720 pixel untuk
|
||||
memastikan
|
||||
</Text>
|
||||
</View>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import ButtonBackHeader from "@/components/buttonBackHeader";
|
||||
import AppHeader from "@/components/AppHeader";
|
||||
import ButtonSaveHeader from "@/components/buttonSaveHeader";
|
||||
import { InputForm } from "@/components/inputForm";
|
||||
import Text from "@/components/Text";
|
||||
@@ -97,24 +97,40 @@ export default function CreateBanner() {
|
||||
<SafeAreaView>
|
||||
<Stack.Screen
|
||||
options={{
|
||||
headerLeft: () => (
|
||||
<ButtonBackHeader
|
||||
onPress={() => {
|
||||
router.back();
|
||||
}}
|
||||
/>
|
||||
),
|
||||
// headerLeft: () => (
|
||||
// <ButtonBackHeader
|
||||
// onPress={() => {
|
||||
// router.back();
|
||||
// }}
|
||||
// />
|
||||
// ),
|
||||
headerTitle: "Tambah Banner",
|
||||
headerTitleAlign: "center",
|
||||
headerRight: () => (
|
||||
<ButtonSaveHeader
|
||||
disable={title == "" || selectedImage == undefined || error || loading ? true : false}
|
||||
category="create"
|
||||
onPress={() => {
|
||||
handleCreateEntity();
|
||||
}}
|
||||
// headerRight: () => (
|
||||
// <ButtonSaveHeader
|
||||
// disable={title == "" || selectedImage == undefined || error || loading ? true : false}
|
||||
// category="create"
|
||||
// onPress={() => {
|
||||
// handleCreateEntity();
|
||||
// }}
|
||||
// />
|
||||
// ),
|
||||
header: () => (
|
||||
<AppHeader
|
||||
title="Fitur"
|
||||
showBack={true}
|
||||
onPressLeft={() => router.back()}
|
||||
right={
|
||||
<ButtonSaveHeader
|
||||
disable={title == "" || selectedImage == undefined || error || loading ? true : false}
|
||||
category="create"
|
||||
onPress={() => {
|
||||
handleCreateEntity();
|
||||
}}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
),
|
||||
)
|
||||
}}
|
||||
/>
|
||||
<ScrollView showsVerticalScrollIndicator={false} style={[Styles.h100]}>
|
||||
@@ -137,7 +153,7 @@ export default function CreateBanner() {
|
||||
>
|
||||
<Entypo name="image" size={50} color={"#aeaeae"} />
|
||||
<Text style={[Styles.textInformation, Styles.mt05]}>
|
||||
Mohon unggah gambar dalam resolusi 1535 x 450 pixel untuk
|
||||
Mohon unggah gambar dalam resolusi 1650 x 720 pixel untuk
|
||||
memastikan
|
||||
</Text>
|
||||
</View>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import AlertKonfirmasi from "@/components/alertKonfirmasi"
|
||||
import AppHeader from "@/components/AppHeader"
|
||||
import HeaderRightBannerList from "@/components/banner/headerBannerList"
|
||||
import BorderBottomItem from "@/components/borderBottomItem"
|
||||
import ButtonBackHeader from "@/components/buttonBackHeader"
|
||||
import DrawerBottom from "@/components/drawerBottom"
|
||||
import MenuItemRow from "@/components/menuItemRow"
|
||||
import ModalLoading from "@/components/modalLoading"
|
||||
@@ -18,6 +18,7 @@ import { router, Stack } from "expo-router"
|
||||
import * as Sharing from 'expo-sharing'
|
||||
import { useState } from "react"
|
||||
import { Alert, Image, Platform, RefreshControl, SafeAreaView, ScrollView, View } from "react-native"
|
||||
import ImageViewing from 'react-native-image-viewing'
|
||||
import * as mime from 'react-native-mime-types'
|
||||
import Toast from "react-native-toast-message"
|
||||
import { useDispatch, useSelector } from "react-redux"
|
||||
@@ -38,6 +39,7 @@ export default function BannerList() {
|
||||
const dispatch = useDispatch()
|
||||
const [refreshing, setRefreshing] = useState(false)
|
||||
const [loadingOpen, setLoadingOpen] = useState(false)
|
||||
const [viewImg, setViewImg] = useState(false)
|
||||
|
||||
const handleDeleteEntity = async () => {
|
||||
try {
|
||||
@@ -106,10 +108,20 @@ export default function BannerList() {
|
||||
<SafeAreaView>
|
||||
<Stack.Screen
|
||||
options={{
|
||||
headerLeft: () => <ButtonBackHeader onPress={() => { router.back() }} />,
|
||||
// headerLeft: () => <ButtonBackHeader onPress={() => { router.back() }} />,
|
||||
headerTitle: 'Banner',
|
||||
headerTitleAlign: 'center',
|
||||
headerRight: () => <HeaderRightBannerList />
|
||||
// headerRight: () => <HeaderRightBannerList />
|
||||
header: () => (
|
||||
<AppHeader
|
||||
title="Banner"
|
||||
showBack={true}
|
||||
onPressLeft={() => router.back()}
|
||||
right={
|
||||
<HeaderRightBannerList />
|
||||
}
|
||||
/>
|
||||
)
|
||||
}}
|
||||
/>
|
||||
<ModalLoading isVisible={loadingOpen} setVisible={setLoadingOpen} />
|
||||
@@ -167,8 +179,14 @@ export default function BannerList() {
|
||||
/>
|
||||
<MenuItemRow
|
||||
icon={<MaterialCommunityIcons name="file-eye" color="black" size={25} />}
|
||||
title="Lihat / Share"
|
||||
onPress={() => { openFile() }}
|
||||
title="Lihat"
|
||||
onPress={() => {
|
||||
setModal(false)
|
||||
setTimeout(() => {
|
||||
setViewImg(true);
|
||||
}, 1000);
|
||||
// openFile()
|
||||
}}
|
||||
/>
|
||||
<MenuItemRow
|
||||
icon={<Ionicons name="trash" color="black" size={25} />}
|
||||
@@ -184,6 +202,14 @@ export default function BannerList() {
|
||||
/>
|
||||
</View>
|
||||
</DrawerBottom>
|
||||
|
||||
<ImageViewing
|
||||
images={[{ uri: `${ConstEnv.url_storage}/files/${selectFile?.image}` }]}
|
||||
imageIndex={0}
|
||||
visible={viewImg}
|
||||
onRequestClose={() => setViewImg(false)}
|
||||
doubleTapToZoomEnabled
|
||||
/>
|
||||
</SafeAreaView>
|
||||
)
|
||||
}
|
||||
@@ -1,9 +1,13 @@
|
||||
import AlertKonfirmasi from "@/components/alertKonfirmasi";
|
||||
import AppHeader from "@/components/AppHeader";
|
||||
import BorderBottomItem from "@/components/borderBottomItem";
|
||||
import ButtonBackHeader from "@/components/buttonBackHeader";
|
||||
import BorderBottomItem2 from "@/components/borderBottomItem2";
|
||||
import HeaderRightDiscussionGeneralDetail from "@/components/discussion_general/headerDiscussionDetail";
|
||||
import DrawerBottom from "@/components/drawerBottom";
|
||||
import ImageUser from "@/components/imageNew";
|
||||
import { InputForm } from "@/components/inputForm";
|
||||
import LabelStatus from "@/components/labelStatus";
|
||||
import MenuItemRow from "@/components/menuItemRow";
|
||||
import Skeleton from "@/components/skeleton";
|
||||
import SkeletonContent from "@/components/skeletonContent";
|
||||
import Text from '@/components/Text';
|
||||
@@ -11,15 +15,15 @@ import { ColorsStatus } from "@/constants/ColorsStatus";
|
||||
import { ConstEnv } from "@/constants/ConstEnv";
|
||||
import { regexOnlySpacesOrEnter } from "@/constants/OnlySpaceOrEnter";
|
||||
import Styles from "@/constants/Styles";
|
||||
import { apiGetDiscussionGeneralOne, apiSendDiscussionGeneralCommentar } from "@/lib/api";
|
||||
import { apiDeleteDiscussionGeneralCommentar, apiGetDiscussionGeneralOne, apiSendDiscussionGeneralCommentar, apiUpdateDiscussionGeneralCommentar } from "@/lib/api";
|
||||
import { getDB } from "@/lib/firebaseDatabase";
|
||||
import { useAuthSession } from "@/providers/AuthProvider";
|
||||
import { Ionicons, MaterialIcons } from "@expo/vector-icons";
|
||||
import { Feather, Ionicons, MaterialCommunityIcons, MaterialIcons } from "@expo/vector-icons";
|
||||
import { ref } from '@react-native-firebase/database';
|
||||
import { useHeaderHeight } from '@react-navigation/elements';
|
||||
import { router, Stack, useLocalSearchParams } from "expo-router";
|
||||
import { useEffect, useState } from "react";
|
||||
import { KeyboardAvoidingView, Platform, Pressable, ScrollView, View } from "react-native";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { KeyboardAvoidingView, Platform, Pressable, RefreshControl, ScrollView, View } from "react-native";
|
||||
import Toast from "react-native-toast-message";
|
||||
import { useSelector } from "react-redux";
|
||||
|
||||
@@ -39,15 +43,26 @@ type PropsKomentar = {
|
||||
idUser: string
|
||||
img: string
|
||||
username: string
|
||||
isEdited: boolean
|
||||
updatedAt: string
|
||||
}
|
||||
|
||||
type PropsFile = {
|
||||
id: string;
|
||||
idStorage: string;
|
||||
name: string;
|
||||
extension: string
|
||||
}
|
||||
|
||||
export default function DetailDiscussionGeneral() {
|
||||
const { token, decryptToken } = useAuthSession()
|
||||
const entityUser = useSelector((state: any) => state.user)
|
||||
const entities = useSelector((state: any) => state.entities)
|
||||
const { id } = useLocalSearchParams<{ id: string }>();
|
||||
const [data, setData] = useState<Props>()
|
||||
const [dataKomentar, setDataKomentar] = useState<PropsKomentar[]>([])
|
||||
const [memberDiscussion, setMemberDiscussion] = useState(false)
|
||||
const [fileDiscussion, setFileDiscussion] = useState<PropsFile[]>([])
|
||||
const [komentar, setKomentar] = useState('')
|
||||
const update = useSelector((state: any) => state.discussionGeneralDetailUpdate)
|
||||
const [loading, setLoading] = useState(true)
|
||||
@@ -57,6 +72,14 @@ export default function DetailDiscussionGeneral() {
|
||||
const headerHeight = useHeaderHeight();
|
||||
const [detailMore, setDetailMore] = useState<any>([])
|
||||
const [loadingSendKomentar, setLoadingSendKomentar] = useState(false)
|
||||
const [isVisible, setVisible] = useState(false)
|
||||
const [refreshing, setRefreshing] = useState(false)
|
||||
const [selectKomentar, setSelectKomentar] = useState({
|
||||
id: '',
|
||||
comment: ''
|
||||
})
|
||||
const [viewEdit, setViewEdit] = useState(false)
|
||||
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
@@ -79,7 +102,7 @@ export default function DetailDiscussionGeneral() {
|
||||
}
|
||||
|
||||
|
||||
async function handleLoad(cat: 'detail' | 'komentar' | 'cek-anggota', loading: boolean) {
|
||||
async function handleLoad(cat: 'detail' | 'komentar' | 'cek-anggota' | 'file', loading: boolean) {
|
||||
try {
|
||||
if (cat == "detail") {
|
||||
setLoading(loading)
|
||||
@@ -96,6 +119,8 @@ export default function DetailDiscussionGeneral() {
|
||||
setDataKomentar(response.data)
|
||||
} else if (cat == 'cek-anggota') {
|
||||
setMemberDiscussion(response.data)
|
||||
} else if (cat == 'file') {
|
||||
setFileDiscussion(response.data)
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
@@ -110,12 +135,14 @@ export default function DetailDiscussionGeneral() {
|
||||
handleLoad('detail', false)
|
||||
handleLoad('komentar', false)
|
||||
handleLoad('cek-anggota', false)
|
||||
handleLoad('file', false)
|
||||
}, [update]);
|
||||
|
||||
useEffect(() => {
|
||||
handleLoad('detail', true)
|
||||
handleLoad('komentar', true)
|
||||
handleLoad('cek-anggota', true)
|
||||
handleLoad('file', true)
|
||||
}, []);
|
||||
|
||||
async function handleKomentar() {
|
||||
@@ -128,7 +155,7 @@ export default function DetailDiscussionGeneral() {
|
||||
setKomentar('')
|
||||
updateTrigger()
|
||||
} else {
|
||||
Toast.show({ type: 'small', text1: 'Gagal menambahkan komentar' })
|
||||
Toast.show({ type: 'small', text1: response.message })
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
@@ -138,24 +165,98 @@ export default function DetailDiscussionGeneral() {
|
||||
}
|
||||
}
|
||||
|
||||
async function handleEditKomentar() {
|
||||
try {
|
||||
setLoadingSendKomentar(true)
|
||||
const hasil = await decryptToken(String(token?.current))
|
||||
const response = await apiUpdateDiscussionGeneralCommentar({ id: selectKomentar.id, data: { desc: selectKomentar.comment, user: hasil } })
|
||||
if (response.success) {
|
||||
updateTrigger()
|
||||
} else {
|
||||
Toast.show({ type: 'small', text1: response.message })
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
} finally {
|
||||
setLoadingSendKomentar(false)
|
||||
handleViewEditKomentar()
|
||||
}
|
||||
}
|
||||
|
||||
async function handleDeleteKomentar() {
|
||||
try {
|
||||
setLoadingSendKomentar(true)
|
||||
const hasil = await decryptToken(String(token?.current))
|
||||
const response = await apiDeleteDiscussionGeneralCommentar({ id: selectKomentar.id, data: { user: hasil } })
|
||||
if (response.success) {
|
||||
updateTrigger()
|
||||
} else {
|
||||
Toast.show({ type: 'small', text1: response.message })
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
} finally {
|
||||
setLoadingSendKomentar(false)
|
||||
setVisible(false)
|
||||
}
|
||||
}
|
||||
|
||||
function handleMenuKomentar(id: string, comment: string) {
|
||||
setSelectKomentar({ id, comment })
|
||||
setVisible(true)
|
||||
}
|
||||
|
||||
function handleViewEditKomentar() {
|
||||
setVisible(false)
|
||||
setViewEdit(!viewEdit)
|
||||
}
|
||||
|
||||
const handleRefresh = async () => {
|
||||
setRefreshing(true)
|
||||
handleLoad('detail', false)
|
||||
handleLoad('komentar', false)
|
||||
handleLoad('cek-anggota', false)
|
||||
handleLoad('file', false)
|
||||
await new Promise(resolve => setTimeout(resolve, 2000));
|
||||
setRefreshing(false)
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<Stack.Screen
|
||||
options={{
|
||||
headerLeft: () => <ButtonBackHeader onPress={() => { router.back() }} />,
|
||||
// headerLeft: () => <ButtonBackHeader onPress={() => { router.back() }} />,
|
||||
headerTitle: 'Diskusi',
|
||||
headerTitleAlign: 'center',
|
||||
headerRight: () => <HeaderRightDiscussionGeneralDetail id={id} active={data?.isActive !== undefined ? data.isActive : false} status={data?.status !== undefined ? data.status : 0} />,
|
||||
// headerRight: () => <HeaderRightDiscussionGeneralDetail id={id} active={data?.isActive !== undefined ? data.isActive : false} status={data?.status !== undefined ? data.status : 0} />,
|
||||
header: () => (
|
||||
<AppHeader
|
||||
title="Diskusi"
|
||||
showBack={true}
|
||||
onPressLeft={() => router.back()}
|
||||
right={<HeaderRightDiscussionGeneralDetail id={id} active={data?.isActive !== undefined ? data.isActive : false} status={data?.status !== undefined ? data.status : 0} />}
|
||||
/>
|
||||
)
|
||||
}}
|
||||
/>
|
||||
<View style={{ flex: 1 }}>
|
||||
<ScrollView showsVerticalScrollIndicator={false}>
|
||||
<View style={[Styles.p15, Styles.mb100]}>
|
||||
<ScrollView
|
||||
showsVerticalScrollIndicator={false}
|
||||
style={[Styles.h100]}
|
||||
refreshControl={
|
||||
<RefreshControl
|
||||
refreshing={refreshing}
|
||||
onRefresh={() => handleRefresh()}
|
||||
/>
|
||||
}
|
||||
>
|
||||
<View style={[Styles.p15]}>
|
||||
{
|
||||
loading ?
|
||||
<SkeletonContent />
|
||||
:
|
||||
<BorderBottomItem
|
||||
<BorderBottomItem2
|
||||
dataFile={fileDiscussion}
|
||||
descEllipsize={false}
|
||||
borderType="bottom"
|
||||
icon={
|
||||
@@ -163,7 +264,8 @@ export default function DetailDiscussionGeneral() {
|
||||
<MaterialIcons name="chat" size={25} color={'#384288'} />
|
||||
</View>
|
||||
}
|
||||
title={data?.title + " " + data?.createdAt}
|
||||
title={data?.title}
|
||||
titleShowAll={true}
|
||||
subtitle={
|
||||
!data?.isActive ?
|
||||
<LabelStatus category='warning' text='ARSIP' size="small" />
|
||||
@@ -198,12 +300,14 @@ export default function DetailDiscussionGeneral() {
|
||||
<BorderBottomItem
|
||||
key={i}
|
||||
borderType="bottom"
|
||||
colorPress
|
||||
icon={
|
||||
<ImageUser src={`${ConstEnv.url_storage}/files/${item.img}`} size="xs" />
|
||||
}
|
||||
title={item.username}
|
||||
rightTopInfo={item.createdAt}
|
||||
desc={item.comment}
|
||||
rightBottomInfo={item.isEdited ? "Edited" : ""}
|
||||
descEllipsize={detailMore.includes(item.id) ? false : true}
|
||||
onPress={() => {
|
||||
setDetailMore((prev: any) => {
|
||||
@@ -214,6 +318,9 @@ export default function DetailDiscussionGeneral() {
|
||||
}
|
||||
})
|
||||
}}
|
||||
onLongPress={() => {
|
||||
item.idUser == entities.id && data?.status != 2 && data?.isActive && handleMenuKomentar(item.id, item.comment)
|
||||
}}
|
||||
/>
|
||||
)
|
||||
})
|
||||
@@ -229,45 +336,106 @@ export default function DetailDiscussionGeneral() {
|
||||
Styles.contentItemCenter,
|
||||
Styles.w100,
|
||||
{ backgroundColor: "#f4f4f4" },
|
||||
viewEdit && Styles.borderTop
|
||||
]}>
|
||||
{
|
||||
data?.status != 2 && data?.isActive && ((entityUser.role != "user" && entityUser.role != "coadmin") || memberDiscussion)
|
||||
?
|
||||
<InputForm
|
||||
disable={(data?.status === 2 || !data?.isActive || (!memberDiscussion && (entityUser.role == "user" || entityUser.role == "coadmin")))}
|
||||
type="default"
|
||||
round
|
||||
placeholder="Kirim Komentar"
|
||||
bg="white"
|
||||
onChange={setKomentar}
|
||||
value={komentar}
|
||||
multiline
|
||||
itemRight={
|
||||
<Pressable onPress={() => {
|
||||
(!loadingSendKomentar && komentar != '' && !regexOnlySpacesOrEnter.test(komentar) && data?.status === 1 && data?.isActive && (memberDiscussion || (entityUser.role != "user" && entityUser.role != "coadmin")))
|
||||
&& handleKomentar()
|
||||
}}
|
||||
style={[
|
||||
Platform.OS == 'android' && Styles.mb12,
|
||||
]}
|
||||
>
|
||||
<MaterialIcons name="send" size={25} style={(loadingSendKomentar || komentar == '' || regexOnlySpacesOrEnter.test(komentar) || data?.status === 2 || !data?.isActive || (!memberDiscussion && (entityUser.role == "user" || entityUser.role == "coadmin"))) ? Styles.cGray : Styles.cDefault} />
|
||||
viewEdit ?
|
||||
<>
|
||||
<View style={[Styles.w90, Styles.rowSpaceBetween, Styles.pv05]}>
|
||||
<View style={[Styles.rowItemsCenter]}>
|
||||
<Feather name="edit-3" color="black" size={22} style={[Styles.mh05]} />
|
||||
<Text style={[Styles.textMediumSemiBold]}>Edit Komentar</Text>
|
||||
</View>
|
||||
<Pressable onPress={() => handleViewEditKomentar()}>
|
||||
<MaterialIcons name="close" color="black" size={22} />
|
||||
</Pressable>
|
||||
}
|
||||
/>
|
||||
:
|
||||
<View style={[Styles.pv20, { alignItems: 'center' }]}>
|
||||
<Text style={[Styles.textInformation, Styles.cGray]}>
|
||||
{
|
||||
data?.status == 2 ? "Diskusi telah ditutup" : data?.isActive == false ? "Diskusi telah diarsipkan" : "Hanya anggota diskusi yang dapat memberikan komentar"
|
||||
</View>
|
||||
<InputForm
|
||||
disable={(data?.status === 2 || !data?.isActive || (!memberDiscussion && (entityUser.role == "user" || entityUser.role == "coadmin")))}
|
||||
type="default"
|
||||
round
|
||||
placeholder="Kirim Komentar"
|
||||
bg="white"
|
||||
onChange={(val: string) => setSelectKomentar({ ...selectKomentar, comment: val })}
|
||||
value={selectKomentar.comment}
|
||||
multiline
|
||||
focus={viewEdit}
|
||||
itemRight={
|
||||
<Pressable onPress={() => {
|
||||
(!loadingSendKomentar && selectKomentar.comment != '' && !regexOnlySpacesOrEnter.test(selectKomentar.comment) && data?.status === 1 && data?.isActive && (memberDiscussion || (entityUser.role != "user" && entityUser.role != "coadmin")))
|
||||
&& handleEditKomentar()
|
||||
}}
|
||||
style={[
|
||||
Platform.OS == 'android' && Styles.mb12,
|
||||
]}
|
||||
>
|
||||
<MaterialIcons name="send" size={25} style={(loadingSendKomentar || selectKomentar.comment == '' || regexOnlySpacesOrEnter.test(selectKomentar.comment) || data?.status === 2 || !data?.isActive || (!memberDiscussion && (entityUser.role == "user" || entityUser.role == "coadmin"))) ? Styles.cGray : Styles.cDefault} />
|
||||
</Pressable>
|
||||
}
|
||||
</Text>
|
||||
</View>
|
||||
/>
|
||||
</>
|
||||
:
|
||||
data?.status != 2 && data?.isActive && ((entityUser.role != "user" && entityUser.role != "coadmin") || memberDiscussion)
|
||||
?
|
||||
<InputForm
|
||||
disable={(data?.status === 2 || !data?.isActive || (!memberDiscussion && (entityUser.role == "user" || entityUser.role == "coadmin")))}
|
||||
type="default"
|
||||
round
|
||||
placeholder="Kirim Komentar"
|
||||
bg="white"
|
||||
onChange={setKomentar}
|
||||
value={komentar}
|
||||
multiline
|
||||
focus={viewEdit}
|
||||
itemRight={
|
||||
<Pressable onPress={() => {
|
||||
(!loadingSendKomentar && komentar != '' && !regexOnlySpacesOrEnter.test(komentar) && data?.status === 1 && data?.isActive && (memberDiscussion || (entityUser.role != "user" && entityUser.role != "coadmin")))
|
||||
&& handleKomentar()
|
||||
}}
|
||||
style={[
|
||||
Platform.OS == 'android' && Styles.mb12,
|
||||
]}
|
||||
>
|
||||
<MaterialIcons name="send" size={25} style={(loadingSendKomentar || komentar == '' || regexOnlySpacesOrEnter.test(komentar) || data?.status === 2 || !data?.isActive || (!memberDiscussion && (entityUser.role == "user" || entityUser.role == "coadmin"))) ? Styles.cGray : Styles.cDefault} />
|
||||
</Pressable>
|
||||
}
|
||||
/>
|
||||
:
|
||||
<View style={[Styles.pv20, { alignItems: 'center' }]}>
|
||||
<Text style={[Styles.textInformation, Styles.cGray]}>
|
||||
{
|
||||
data?.status == 2 ? "Diskusi telah ditutup" : data?.isActive == false ? "Diskusi telah diarsipkan" : "Hanya anggota diskusi yang dapat memberikan komentar"
|
||||
}
|
||||
</Text>
|
||||
</View>
|
||||
}
|
||||
|
||||
</View>
|
||||
</KeyboardAvoidingView>
|
||||
</View >
|
||||
|
||||
<DrawerBottom animation="slide" isVisible={isVisible} setVisible={setVisible} title="Komentar">
|
||||
<View style={Styles.rowItemsCenter}>
|
||||
<MenuItemRow
|
||||
icon={<MaterialCommunityIcons name="pencil-outline" color="black" size={25} />}
|
||||
title="Edit"
|
||||
onPress={() => { handleViewEditKomentar() }}
|
||||
/>
|
||||
<MenuItemRow
|
||||
icon={<MaterialIcons name="delete" color="black" size={25} />}
|
||||
title="Hapus"
|
||||
onPress={() => {
|
||||
AlertKonfirmasi({
|
||||
title: 'Konfirmasi',
|
||||
desc: 'Apakah anda yakin ingin menghapus komentar?',
|
||||
onPress: () => {
|
||||
handleDeleteKomentar()
|
||||
}
|
||||
})
|
||||
}}
|
||||
/>
|
||||
</View>
|
||||
</DrawerBottom>
|
||||
</>
|
||||
)
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import ButtonBackHeader from "@/components/buttonBackHeader";
|
||||
import AppHeader from "@/components/AppHeader";
|
||||
import ButtonSaveHeader from "@/components/buttonSaveHeader";
|
||||
import ImageUser from "@/components/imageNew";
|
||||
import ImageWithLabel from "@/components/imageWithLabel";
|
||||
@@ -95,16 +95,32 @@ export default function AddMemberDiscussionDetail() {
|
||||
<SafeAreaView>
|
||||
<Stack.Screen
|
||||
options={{
|
||||
headerLeft: () => <ButtonBackHeader onPress={() => { router.back() }} />,
|
||||
// headerLeft: () => <ButtonBackHeader onPress={() => { router.back() }} />,
|
||||
headerTitle: 'Tambah Anggota Diskusi',
|
||||
headerTitleAlign: 'center',
|
||||
headerRight: () => (
|
||||
<ButtonSaveHeader
|
||||
category="update"
|
||||
disable={selectMember.length == 0 || loading ? true : false}
|
||||
onPress={() => {
|
||||
handleAddMember()
|
||||
}}
|
||||
// headerRight: () => (
|
||||
// <ButtonSaveHeader
|
||||
// category="update"
|
||||
// disable={selectMember.length == 0 || loading ? true : false}
|
||||
// onPress={() => {
|
||||
// handleAddMember()
|
||||
// }}
|
||||
// />
|
||||
// )
|
||||
header: () => (
|
||||
<AppHeader
|
||||
title="Tambah Anggota Diskusi"
|
||||
showBack={true}
|
||||
onPressLeft={() => router.back()}
|
||||
right={
|
||||
<ButtonSaveHeader
|
||||
category="update"
|
||||
disable={selectMember.length == 0 || loading ? true : false}
|
||||
onPress={() => {
|
||||
handleAddMember()
|
||||
}}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
)
|
||||
}}
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
import AppHeader from "@/components/AppHeader";
|
||||
import BorderBottomItem from "@/components/borderBottomItem";
|
||||
import ButtonBackHeader from "@/components/buttonBackHeader";
|
||||
import ButtonSaveHeader from "@/components/buttonSaveHeader";
|
||||
import ButtonSelect from "@/components/buttonSelect";
|
||||
import DrawerBottom from "@/components/drawerBottom";
|
||||
import ImageUser from "@/components/imageNew";
|
||||
import { InputForm } from "@/components/inputForm";
|
||||
import LoadingOverlay from "@/components/loadingOverlay";
|
||||
import MenuItemRow from "@/components/menuItemRow";
|
||||
import ModalSelect from "@/components/modalSelect";
|
||||
import SelectForm from "@/components/selectForm";
|
||||
import Text from '@/components/Text';
|
||||
@@ -13,6 +16,8 @@ import { apiCreateDiscussionGeneral } from "@/lib/api";
|
||||
import { setUpdateDiscussionGeneralDetail } from "@/lib/discussionGeneralDetail";
|
||||
import { setMemberChoose } from "@/lib/memberChoose";
|
||||
import { useAuthSession } from "@/providers/AuthProvider";
|
||||
import { Ionicons, MaterialCommunityIcons } from "@expo/vector-icons";
|
||||
import * as DocumentPicker from "expo-document-picker";
|
||||
import { router, Stack } from "expo-router";
|
||||
import { useEffect, useState } from "react";
|
||||
import { SafeAreaView, ScrollView, View } from "react-native";
|
||||
@@ -33,6 +38,9 @@ export default function CreateDiscussionGeneral() {
|
||||
const entitiesMember = useSelector((state: any) => state.memberChoose)
|
||||
const update = useSelector((state: any) => state.discussionGeneralDetailUpdate)
|
||||
const [loading, setLoading] = useState(false)
|
||||
const [fileForm, setFileForm] = useState<any[]>([])
|
||||
const [isModalFile, setModalFile] = useState(false)
|
||||
const [indexDelFile, setIndexDelFile] = useState<number>(0)
|
||||
const [dataForm, setDataForm] = useState({
|
||||
idGroup: "",
|
||||
title: "",
|
||||
@@ -95,13 +103,49 @@ export default function CreateDiscussionGeneral() {
|
||||
router.back()
|
||||
}
|
||||
|
||||
const pickDocumentAsync = async () => {
|
||||
let result = await DocumentPicker.getDocumentAsync({
|
||||
type: ["*/*"],
|
||||
multiple: true
|
||||
});
|
||||
if (!result.canceled) {
|
||||
for (let i = 0; i < result.assets?.length; i++) {
|
||||
if (result.assets[i].uri) {
|
||||
setFileForm((prev) => [...prev, result.assets[i]])
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function deleteFile(index: number) {
|
||||
setFileForm([...fileForm.filter((val, i) => i !== index)])
|
||||
setModalFile(false)
|
||||
}
|
||||
|
||||
async function handleCreate() {
|
||||
try {
|
||||
setLoading(true)
|
||||
const hasil = await decryptToken(String(token?.current))
|
||||
const response = await apiCreateDiscussionGeneral({
|
||||
data: { ...dataForm, user: hasil, member: entitiesMember },
|
||||
})
|
||||
const fd = new FormData()
|
||||
|
||||
for (let i = 0; i < fileForm.length; i++) {
|
||||
fd.append(`file${i}`, {
|
||||
uri: fileForm[i].uri,
|
||||
type: 'application/octet-stream',
|
||||
name: fileForm[i].name,
|
||||
} as any);
|
||||
}
|
||||
|
||||
fd.append("data", JSON.stringify(
|
||||
{ ...dataForm, user: hasil, member: entitiesMember }
|
||||
))
|
||||
|
||||
const response = await apiCreateDiscussionGeneral(fd)
|
||||
|
||||
// const response = await apiCreateDiscussionGeneral({
|
||||
// data: { ...dataForm, user: hasil, member: entitiesMember },
|
||||
// })
|
||||
|
||||
if (response.success) {
|
||||
dispatch(setMemberChoose([]))
|
||||
dispatch(setUpdateDiscussionGeneralDetail(!update))
|
||||
@@ -122,26 +166,45 @@ export default function CreateDiscussionGeneral() {
|
||||
<SafeAreaView>
|
||||
<Stack.Screen
|
||||
options={{
|
||||
headerLeft: () => (
|
||||
<ButtonBackHeader
|
||||
onPress={() => { handleBack() }}
|
||||
/>
|
||||
),
|
||||
// headerLeft: () => (
|
||||
// <ButtonBackHeader
|
||||
// onPress={() => { handleBack() }}
|
||||
// />
|
||||
// ),
|
||||
headerTitle: "Tambah Diskusi",
|
||||
headerTitleAlign: "center",
|
||||
headerRight: () => (
|
||||
<ButtonSaveHeader
|
||||
category="create"
|
||||
disable={disableBtn || loading ? true : false}
|
||||
onPress={() => {
|
||||
entitiesMember.length == 0
|
||||
? Toast.show({ type: 'small', text1: 'Anda belum memilih anggota', })
|
||||
: handleCreate()
|
||||
}}
|
||||
// headerRight: () => (
|
||||
// <ButtonSaveHeader
|
||||
// category="create"
|
||||
// disable={disableBtn || loading ? true : false}
|
||||
// onPress={() => {
|
||||
// entitiesMember.length == 0
|
||||
// ? Toast.show({ type: 'small', text1: 'Anda belum memilih anggota', })
|
||||
// : handleCreate()
|
||||
// }}
|
||||
// />
|
||||
// ),
|
||||
header: () => (
|
||||
<AppHeader
|
||||
title="Tambah Diskusi"
|
||||
showBack={true}
|
||||
onPressLeft={() => router.back()}
|
||||
right={
|
||||
<ButtonSaveHeader
|
||||
category="create"
|
||||
disable={disableBtn || loading ? true : false}
|
||||
onPress={() => {
|
||||
entitiesMember.length == 0
|
||||
? Toast.show({ type: 'small', text1: 'Anda belum memilih anggota', })
|
||||
: handleCreate()
|
||||
}}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
),
|
||||
)
|
||||
}}
|
||||
/>
|
||||
<LoadingOverlay visible={loading} />
|
||||
<ScrollView showsVerticalScrollIndicator={false} style={[Styles.h100]}>
|
||||
<View style={[Styles.p15, Styles.mb100]}>
|
||||
{
|
||||
@@ -181,6 +244,26 @@ export default function CreateDiscussionGeneral() {
|
||||
onChange={(val) => { validationForm("desc", val) }}
|
||||
multiline
|
||||
/>
|
||||
<ButtonSelect value="Upload File" onPress={pickDocumentAsync} />
|
||||
{
|
||||
fileForm.length > 0
|
||||
&&
|
||||
<View style={[Styles.borderAll, Styles.round10, Styles.p10, Styles.mb10]}>
|
||||
<Text style={[Styles.textDefaultSemiBold]}>File</Text>
|
||||
{
|
||||
fileForm.map((item, index) => (
|
||||
<BorderBottomItem
|
||||
key={index}
|
||||
borderType={fileForm.length > 1 ? "bottom" : "none"}
|
||||
icon={<MaterialCommunityIcons name="file-outline" size={25} color="black" />}
|
||||
title={item.name}
|
||||
titleWeight="normal"
|
||||
onPress={() => { setIndexDelFile(index); setModalFile(true) }}
|
||||
/>
|
||||
))
|
||||
}
|
||||
</View>
|
||||
}
|
||||
<ButtonSelect
|
||||
value="Pilih Anggota"
|
||||
onPress={() => {
|
||||
@@ -240,6 +323,16 @@ export default function CreateDiscussionGeneral() {
|
||||
idParent={valSelect == "member" ? chooseGroup.val : ""}
|
||||
valChoose={valChoose}
|
||||
/>
|
||||
|
||||
<DrawerBottom animation="slide" isVisible={isModalFile} setVisible={setModalFile} title="Menu">
|
||||
<View style={Styles.rowItemsCenter}>
|
||||
<MenuItemRow
|
||||
icon={<Ionicons name="trash" color="black" size={25} />}
|
||||
title="Hapus"
|
||||
onPress={() => { deleteFile(indexDelFile) }}
|
||||
/>
|
||||
</View>
|
||||
</DrawerBottom>
|
||||
</SafeAreaView>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,10 +1,18 @@
|
||||
import ButtonBackHeader from "@/components/buttonBackHeader";
|
||||
import AppHeader from "@/components/AppHeader";
|
||||
import Text from "@/components/Text";
|
||||
import BorderBottomItem from "@/components/borderBottomItem";
|
||||
import ButtonSaveHeader from "@/components/buttonSaveHeader";
|
||||
import ButtonSelect from "@/components/buttonSelect";
|
||||
import DrawerBottom from "@/components/drawerBottom";
|
||||
import { InputForm } from "@/components/inputForm";
|
||||
import LoadingOverlay from "@/components/loadingOverlay";
|
||||
import MenuItemRow from "@/components/menuItemRow";
|
||||
import Styles from "@/constants/Styles";
|
||||
import { apiEditDiscussionGeneral, apiGetDiscussionGeneralOne } from "@/lib/api";
|
||||
import { setUpdateDiscussionGeneralDetail } from "@/lib/discussionGeneralDetail";
|
||||
import { useAuthSession } from "@/providers/AuthProvider";
|
||||
import { Ionicons, MaterialCommunityIcons } from "@expo/vector-icons";
|
||||
import * as DocumentPicker from "expo-document-picker";
|
||||
import { router, Stack, useLocalSearchParams } from "expo-router";
|
||||
import { useEffect, useState } from "react";
|
||||
import { SafeAreaView, ScrollView, View } from "react-native";
|
||||
@@ -17,6 +25,10 @@ export default function EditDiscussionGeneral() {
|
||||
const [disableBtn, setDisableBtn] = useState(false)
|
||||
const dispatch = useDispatch()
|
||||
const [loading, setLoading] = useState(false)
|
||||
const [fileForm, setFileForm] = useState<any[]>([])
|
||||
const [isModalFile, setModalFile] = useState(false)
|
||||
const [indexDelFile, setIndexDelFile] = useState<{ id: string | number; cat: "newFile" | "oldFile" }>({ id: "", cat: "newFile" })
|
||||
const [dataFile, setDataFile] = useState<{ id: string; idStorage: string; name: string; extension: string; delete?: boolean }[]>([])
|
||||
const update = useSelector((state: any) => state.discussionGeneralDetailUpdate)
|
||||
const [dataForm, setDataForm] = useState({
|
||||
title: "",
|
||||
@@ -35,9 +47,17 @@ export default function EditDiscussionGeneral() {
|
||||
user: hasil,
|
||||
cat: "detail",
|
||||
});
|
||||
const responseFile = await apiGetDiscussionGeneralOne({
|
||||
id: id,
|
||||
user: hasil,
|
||||
cat: "file",
|
||||
});
|
||||
if (response.success) {
|
||||
setDataForm(response.data);
|
||||
}
|
||||
if (responseFile.success) {
|
||||
setDataFile(responseFile.data);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
@@ -78,12 +98,56 @@ export default function EditDiscussionGeneral() {
|
||||
checkForm()
|
||||
}, [error, dataForm])
|
||||
|
||||
const pickDocumentAsync = async () => {
|
||||
let result = await DocumentPicker.getDocumentAsync({
|
||||
type: ["*/*"],
|
||||
multiple: true
|
||||
});
|
||||
if (!result.canceled) {
|
||||
for (let i = 0; i < result.assets?.length; i++) {
|
||||
if (result.assets[i].uri) {
|
||||
setFileForm((prev) => [...prev, result.assets[i]])
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function deleteFile(index: number | string, cat: "newFile" | "oldFile" | null) {
|
||||
if (cat == "newFile") {
|
||||
setFileForm([...fileForm.filter((val, i) => i !== index)])
|
||||
} else {
|
||||
setDataFile(prev =>
|
||||
prev.map(item =>
|
||||
item.id === index
|
||||
? { ...item, delete: true }
|
||||
: item
|
||||
)
|
||||
);
|
||||
}
|
||||
setModalFile(false)
|
||||
}
|
||||
|
||||
|
||||
async function handleEdit() {
|
||||
try {
|
||||
setLoading(true)
|
||||
const hasil = await decryptToken(String(token?.current));
|
||||
const response = await apiEditDiscussionGeneral({ user: hasil, title: dataForm.title, desc: dataForm.desc }, id);
|
||||
const fd = new FormData()
|
||||
for (let i = 0; i < fileForm.length; i++) {
|
||||
fd.append(`file${i}`, {
|
||||
uri: fileForm[i].uri,
|
||||
type: 'application/octet-stream',
|
||||
name: fileForm[i].name,
|
||||
} as any);
|
||||
}
|
||||
|
||||
fd.append("data", JSON.stringify(
|
||||
{
|
||||
user: hasil, title: dataForm.title, desc: dataForm.desc, oldFile: dataFile
|
||||
}
|
||||
))
|
||||
|
||||
const response = await apiEditDiscussionGeneral(fd, id);
|
||||
if (response.success) {
|
||||
dispatch(setUpdateDiscussionGeneralDetail(!update))
|
||||
Toast.show({ type: 'small', text1: 'Berhasil mengubah data', })
|
||||
@@ -101,24 +165,39 @@ export default function EditDiscussionGeneral() {
|
||||
<SafeAreaView>
|
||||
<Stack.Screen
|
||||
options={{
|
||||
headerLeft: () => (
|
||||
<ButtonBackHeader
|
||||
onPress={() => {
|
||||
router.back();
|
||||
}}
|
||||
/>
|
||||
),
|
||||
// headerLeft: () => (
|
||||
// <ButtonBackHeader
|
||||
// onPress={() => {
|
||||
// router.back();
|
||||
// }}
|
||||
// />
|
||||
// ),
|
||||
headerTitle: "Edit Diskusi",
|
||||
headerTitleAlign: "center",
|
||||
headerRight: () => (
|
||||
<ButtonSaveHeader
|
||||
disable={disableBtn || loading ? true : false}
|
||||
category="update"
|
||||
onPress={() => { handleEdit() }}
|
||||
// headerRight: () => (
|
||||
// <ButtonSaveHeader
|
||||
// disable={disableBtn || loading ? true : false}
|
||||
// category="update"
|
||||
// onPress={() => { handleEdit() }}
|
||||
// />
|
||||
// ),
|
||||
header: () => (
|
||||
<AppHeader
|
||||
title="Edit Diskusi"
|
||||
showBack={true}
|
||||
onPressLeft={() => router.back()}
|
||||
right={
|
||||
<ButtonSaveHeader
|
||||
disable={disableBtn || loading ? true : false}
|
||||
category="update"
|
||||
onPress={() => { handleEdit() }}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
),
|
||||
)
|
||||
}}
|
||||
/>
|
||||
<LoadingOverlay visible={loading} />
|
||||
<ScrollView showsVerticalScrollIndicator={false} style={[Styles.h100]}>
|
||||
<View style={[Styles.p15]}>
|
||||
<InputForm
|
||||
@@ -142,8 +221,50 @@ export default function EditDiscussionGeneral() {
|
||||
onChange={(val) => validationForm("desc", val)}
|
||||
multiline
|
||||
/>
|
||||
<ButtonSelect value="Upload File" onPress={pickDocumentAsync} />
|
||||
{
|
||||
(fileForm.length > 0 || dataFile.filter((val) => !val.delete).length > 0)
|
||||
&&
|
||||
<View style={[Styles.borderAll, Styles.round10, Styles.p10, Styles.mb10]}>
|
||||
<Text style={[Styles.textDefaultSemiBold]}>File</Text>
|
||||
{
|
||||
dataFile.filter((val) => !val.delete).map((item, index) => (
|
||||
<BorderBottomItem
|
||||
key={index}
|
||||
borderType={(fileForm.length + dataFile.length) > 1 ? "bottom" : "none"}
|
||||
icon={<MaterialCommunityIcons name="file-outline" size={25} color="black" />}
|
||||
title={item.name + '.' + item.extension}
|
||||
titleWeight="normal"
|
||||
onPress={() => { setIndexDelFile({ id: item.id, cat: "oldFile" }); setModalFile(true) }}
|
||||
/>
|
||||
))
|
||||
}
|
||||
{
|
||||
fileForm.map((item, index) => (
|
||||
<BorderBottomItem
|
||||
key={index}
|
||||
borderType={(fileForm.length + dataFile.length) > 1 ? "bottom" : "none"}
|
||||
icon={<MaterialCommunityIcons name="file-outline" size={25} color="black" />}
|
||||
title={item.name}
|
||||
titleWeight="normal"
|
||||
onPress={() => { setIndexDelFile({ id: index, cat: "newFile" }); setModalFile(true) }}
|
||||
/>
|
||||
))
|
||||
}
|
||||
</View>
|
||||
}
|
||||
</View>
|
||||
</ScrollView>
|
||||
|
||||
<DrawerBottom animation="slide" isVisible={isModalFile} setVisible={setModalFile} title="Menu">
|
||||
<View style={Styles.rowItemsCenter}>
|
||||
<MenuItemRow
|
||||
icon={<Ionicons name="trash" color="black" size={25} />}
|
||||
title="Hapus"
|
||||
onPress={() => { deleteFile(indexDelFile.id, indexDelFile.cat) }}
|
||||
/>
|
||||
</View>
|
||||
</DrawerBottom>
|
||||
</SafeAreaView>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import AlertKonfirmasi from "@/components/alertKonfirmasi";
|
||||
import AppHeader from "@/components/AppHeader";
|
||||
import BorderBottomItem from "@/components/borderBottomItem";
|
||||
import ButtonBackHeader from "@/components/buttonBackHeader";
|
||||
import DrawerBottom from "@/components/drawerBottom";
|
||||
import ImageUser from "@/components/imageNew";
|
||||
import MenuItemRow from "@/components/menuItemRow";
|
||||
@@ -74,9 +74,16 @@ export default function MemberDiscussionDetail() {
|
||||
<SafeAreaView>
|
||||
<Stack.Screen
|
||||
options={{
|
||||
headerLeft: () => <ButtonBackHeader onPress={() => { router.back() }} />,
|
||||
// headerLeft: () => <ButtonBackHeader onPress={() => { router.back() }} />,
|
||||
headerTitle: 'Anggota Diskusi',
|
||||
headerTitleAlign: 'center',
|
||||
header: () => (
|
||||
<AppHeader
|
||||
title="Anggota Diskusi"
|
||||
showBack={true}
|
||||
onPressLeft={() => router.back()}
|
||||
/>
|
||||
)
|
||||
}}
|
||||
/>
|
||||
<ScrollView>
|
||||
|
||||
@@ -1,10 +1,18 @@
|
||||
import BorderBottomItem from "@/components/borderBottomItem";
|
||||
import ButtonBackHeader from "@/components/buttonBackHeader";
|
||||
import ButtonSaveHeader from "@/components/buttonSaveHeader";
|
||||
import ButtonSelect from "@/components/buttonSelect";
|
||||
import DrawerBottom from "@/components/drawerBottom";
|
||||
import { InputForm } from "@/components/inputForm";
|
||||
import LoadingOverlay from "@/components/loadingOverlay";
|
||||
import MenuItemRow from "@/components/menuItemRow";
|
||||
import Text from "@/components/Text";
|
||||
import Styles from "@/constants/Styles";
|
||||
import { apiEditDiscussion, apiGetDiscussionOne } from "@/lib/api";
|
||||
import { setUpdateDiscussion } from "@/lib/discussionUpdate";
|
||||
import { useAuthSession } from "@/providers/AuthProvider";
|
||||
import { Ionicons, MaterialCommunityIcons } from "@expo/vector-icons";
|
||||
import * as DocumentPicker from "expo-document-picker";
|
||||
import { router, Stack, useLocalSearchParams } from "expo-router";
|
||||
import { useEffect, useState } from "react";
|
||||
import { SafeAreaView, ScrollView, View } from "react-native";
|
||||
@@ -18,6 +26,11 @@ export default function DiscussionDivisionEdit() {
|
||||
const update = useSelector((state: any) => state.discussionUpdate);
|
||||
const dispatch = useDispatch();
|
||||
const [loading, setLoading] = useState(false)
|
||||
const [fileForm, setFileForm] = useState<any[]>([])
|
||||
const [isModalFile, setModalFile] = useState(false)
|
||||
const [indexDelFile, setIndexDelFile] = useState<{ id: string | number; cat: "newFile" | "oldFile" }>({ id: "", cat: "newFile" })
|
||||
const [dataFile, setDataFile] = useState<{ id: string; idStorage: string; name: string; extension: string; delete?: boolean }[]>([])
|
||||
|
||||
|
||||
async function handleLoad() {
|
||||
try {
|
||||
@@ -27,6 +40,12 @@ export default function DiscussionDivisionEdit() {
|
||||
user: hasil,
|
||||
cat: "data",
|
||||
});
|
||||
const response2 = await apiGetDiscussionOne({
|
||||
id: detail,
|
||||
user: hasil,
|
||||
cat: "file",
|
||||
});
|
||||
setDataFile(response2.data);
|
||||
setData(response.data.desc);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
@@ -41,15 +60,31 @@ export default function DiscussionDivisionEdit() {
|
||||
try {
|
||||
setLoading(true)
|
||||
const hasil = await decryptToken(String(token?.current));
|
||||
const response = await apiEditDiscussion({
|
||||
data: { user: hasil, desc: data },
|
||||
id: detail,
|
||||
});
|
||||
const fd = new FormData()
|
||||
for (let i = 0; i < fileForm.length; i++) {
|
||||
fd.append(`file${i}`, {
|
||||
uri: fileForm[i].uri,
|
||||
type: 'application/octet-stream',
|
||||
name: fileForm[i].name,
|
||||
} as any);
|
||||
}
|
||||
|
||||
fd.append("data", JSON.stringify(
|
||||
{
|
||||
user: hasil, desc: data, oldFile: dataFile
|
||||
}
|
||||
))
|
||||
const response = await apiEditDiscussion(fd, detail);
|
||||
|
||||
// const response = await apiEditDiscussion({
|
||||
// data: { user: hasil, desc: data },
|
||||
// id: detail,
|
||||
// });
|
||||
if (response.success) {
|
||||
Toast.show({ type: 'small', text1: 'Berhasil mengubah data', })
|
||||
dispatch(setUpdateDiscussion({ ...update, data: !update.data }));
|
||||
router.back();
|
||||
}else{
|
||||
} else {
|
||||
Toast.show({ type: 'small', text1: response.message, })
|
||||
}
|
||||
} catch (error) {
|
||||
@@ -60,6 +95,37 @@ export default function DiscussionDivisionEdit() {
|
||||
}
|
||||
}
|
||||
|
||||
const pickDocumentAsync = async () => {
|
||||
let result = await DocumentPicker.getDocumentAsync({
|
||||
type: ["*/*"],
|
||||
multiple: true
|
||||
});
|
||||
if (!result.canceled) {
|
||||
for (let i = 0; i < result.assets?.length; i++) {
|
||||
if (result.assets[i].uri) {
|
||||
setFileForm((prev) => [...prev, result.assets[i]])
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
function deleteFile(index: number | string, cat: "newFile" | "oldFile" | null) {
|
||||
if (cat == "newFile") {
|
||||
setFileForm([...fileForm.filter((val, i) => i !== index)])
|
||||
} else {
|
||||
setDataFile(prev =>
|
||||
prev.map(item =>
|
||||
item.id === index
|
||||
? { ...item, delete: true }
|
||||
: item
|
||||
)
|
||||
);
|
||||
}
|
||||
setModalFile(false)
|
||||
}
|
||||
|
||||
return (
|
||||
<SafeAreaView>
|
||||
<Stack.Screen
|
||||
@@ -84,7 +150,8 @@ export default function DiscussionDivisionEdit() {
|
||||
),
|
||||
}}
|
||||
/>
|
||||
<ScrollView>
|
||||
<LoadingOverlay visible={loading} />
|
||||
<ScrollView showsVerticalScrollIndicator={false} style={[Styles.h100]}>
|
||||
<View style={[Styles.p15]}>
|
||||
<InputForm
|
||||
label="Diskusi"
|
||||
@@ -95,8 +162,53 @@ export default function DiscussionDivisionEdit() {
|
||||
onChange={setData}
|
||||
multiline
|
||||
/>
|
||||
|
||||
<ButtonSelect value="Upload File" onPress={pickDocumentAsync} />
|
||||
{
|
||||
(fileForm.length > 0 || dataFile.filter((val) => !val.delete).length > 0)
|
||||
&&
|
||||
<View style={[Styles.borderAll, Styles.round10, Styles.p10, Styles.mb10]}>
|
||||
<Text style={[Styles.textDefaultSemiBold]}>File</Text>
|
||||
{
|
||||
dataFile.filter((val) => !val.delete).map((item, index) => (
|
||||
<BorderBottomItem
|
||||
key={index}
|
||||
borderType={(fileForm.length + dataFile.length) > 1 ? "bottom" : "none"}
|
||||
icon={<MaterialCommunityIcons name="file-outline" size={25} color="black" />}
|
||||
title={item.name + '.' + item.extension}
|
||||
titleWeight="normal"
|
||||
onPress={() => { setIndexDelFile({ id: item.id, cat: "oldFile" }); setModalFile(true) }}
|
||||
/>
|
||||
))
|
||||
}
|
||||
{
|
||||
fileForm.map((item, index) => (
|
||||
<BorderBottomItem
|
||||
key={index}
|
||||
borderType={fileForm.length > 1 ? "bottom" : "none"}
|
||||
icon={<MaterialCommunityIcons name="file-outline" size={25} color="black" />}
|
||||
title={item.name}
|
||||
titleWeight="normal"
|
||||
onPress={() => { setIndexDelFile({ id: index, cat: "newFile" }); setModalFile(true) }}
|
||||
/>
|
||||
))
|
||||
}
|
||||
</View>
|
||||
}
|
||||
</View>
|
||||
</ScrollView>
|
||||
|
||||
|
||||
<DrawerBottom animation="slide" isVisible={isModalFile} setVisible={setModalFile} title="Menu">
|
||||
<View style={Styles.rowItemsCenter}>
|
||||
<MenuItemRow
|
||||
icon={<Ionicons name="trash" color="black" size={25} />}
|
||||
title="Hapus"
|
||||
onPress={() => { deleteFile(indexDelFile.id, indexDelFile.cat) }}
|
||||
/>
|
||||
</View>
|
||||
</DrawerBottom>
|
||||
|
||||
</SafeAreaView>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
import AlertKonfirmasi from "@/components/alertKonfirmasi";
|
||||
import BorderBottomItem from "@/components/borderBottomItem";
|
||||
import BorderBottomItem2 from "@/components/borderBottomItem2";
|
||||
import ButtonBackHeader from "@/components/buttonBackHeader";
|
||||
import HeaderRightDiscussionDetail from "@/components/discussion/headerDiscussionDetail";
|
||||
import DrawerBottom from "@/components/drawerBottom";
|
||||
import ImageUser from "@/components/imageNew";
|
||||
import { InputForm } from "@/components/inputForm";
|
||||
import LabelStatus from "@/components/labelStatus";
|
||||
import MenuItemRow from "@/components/menuItemRow";
|
||||
import Skeleton from "@/components/skeleton";
|
||||
import SkeletonContent from "@/components/skeletonContent";
|
||||
import Text from "@/components/Text";
|
||||
@@ -11,18 +15,21 @@ import { ConstEnv } from "@/constants/ConstEnv";
|
||||
import { regexOnlySpacesOrEnter } from "@/constants/OnlySpaceOrEnter";
|
||||
import Styles from "@/constants/Styles";
|
||||
import {
|
||||
apiDeleteDiscussionCommentar,
|
||||
apiEditDiscussionCommentar,
|
||||
apiGetDiscussionOne,
|
||||
apiGetDivisionOneFeature,
|
||||
apiSendDiscussionCommentar,
|
||||
} from "@/lib/api";
|
||||
import { getDB } from "@/lib/firebaseDatabase";
|
||||
import { useAuthSession } from "@/providers/AuthProvider";
|
||||
import { Ionicons, MaterialIcons } from "@expo/vector-icons";
|
||||
import { Feather, Ionicons, MaterialCommunityIcons, MaterialIcons } from "@expo/vector-icons";
|
||||
import { ref } from "@react-native-firebase/database";
|
||||
import { useHeaderHeight } from '@react-navigation/elements';
|
||||
import { router, Stack, useLocalSearchParams } from "expo-router";
|
||||
import { useEffect, useState } from "react";
|
||||
import { KeyboardAvoidingView, Platform, Pressable, RefreshControl, ScrollView, View } from "react-native";
|
||||
import Toast from "react-native-toast-message";
|
||||
import { useSelector } from "react-redux";
|
||||
|
||||
type Props = {
|
||||
@@ -44,12 +51,23 @@ type PropsComment = {
|
||||
createdAt: string;
|
||||
username: string;
|
||||
img: string;
|
||||
idUser: string;
|
||||
isEdited: boolean;
|
||||
updatedAt: string;
|
||||
};
|
||||
|
||||
type PropsFile = {
|
||||
id: string;
|
||||
idStorage: string;
|
||||
name: string;
|
||||
extension: string
|
||||
}
|
||||
|
||||
export default function DiscussionDetail() {
|
||||
const { id, detail } = useLocalSearchParams<{ id: string; detail: string }>();
|
||||
const [data, setData] = useState<Props>();
|
||||
const [dataComment, setDataComment] = useState<PropsComment[]>([]);
|
||||
const [fileDiscussion, setFileDiscussion] = useState<PropsFile[]>([])
|
||||
const { token, decryptToken } = useAuthSession();
|
||||
const [komentar, setKomentar] = useState("");
|
||||
const [loadingSend, setLoadingSend] = useState(false);
|
||||
@@ -65,6 +83,14 @@ export default function DiscussionDetail() {
|
||||
const [refreshing, setRefreshing] = useState(false)
|
||||
const headerHeight = useHeaderHeight();
|
||||
const [detailMore, setDetailMore] = useState<any>([])
|
||||
const entities = useSelector((state: any) => state.entities)
|
||||
const [isVisible, setVisible] = useState(false)
|
||||
const [selectKomentar, setSelectKomentar] = useState({
|
||||
id: '',
|
||||
comment: ''
|
||||
})
|
||||
const [viewEdit, setViewEdit] = useState(false)
|
||||
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
@@ -96,7 +122,15 @@ export default function DiscussionDetail() {
|
||||
user: hasil,
|
||||
cat: "data",
|
||||
});
|
||||
|
||||
const responseFile = await apiGetDiscussionOne({
|
||||
id: detail,
|
||||
user: hasil,
|
||||
cat: "file",
|
||||
});
|
||||
|
||||
setData(response.data);
|
||||
setFileDiscussion(responseFile.data)
|
||||
setIsCreator(response.data.createdBy == hasil);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
@@ -172,6 +206,59 @@ export default function DiscussionDetail() {
|
||||
}
|
||||
}
|
||||
|
||||
async function handleEditKomentar() {
|
||||
try {
|
||||
setLoadingSend(true);
|
||||
const hasil = await decryptToken(String(token?.current));
|
||||
const response = await apiEditDiscussionCommentar({
|
||||
id: selectKomentar.id,
|
||||
data: { comment: selectKomentar.comment, user: hasil },
|
||||
});
|
||||
if (response.success) {
|
||||
updateTrigger()
|
||||
} else {
|
||||
Toast.show({ type: 'small', text1: response.message })
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
} finally {
|
||||
setLoadingSend(false);
|
||||
handleViewEditKomentar()
|
||||
}
|
||||
}
|
||||
|
||||
async function handleDeleteKomentar() {
|
||||
try {
|
||||
setLoadingSend(true);
|
||||
const hasil = await decryptToken(String(token?.current));
|
||||
const response = await apiDeleteDiscussionCommentar({
|
||||
id: selectKomentar.id,
|
||||
data: { user: hasil },
|
||||
});
|
||||
if (response.success) {
|
||||
updateTrigger()
|
||||
} else {
|
||||
Toast.show({ type: 'small', text1: response.message })
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
} finally {
|
||||
setLoadingSend(false)
|
||||
setVisible(false)
|
||||
}
|
||||
}
|
||||
|
||||
function handleMenuKomentar(id: string, comment: string) {
|
||||
setSelectKomentar({ id, comment })
|
||||
setVisible(true)
|
||||
}
|
||||
|
||||
|
||||
function handleViewEditKomentar() {
|
||||
setVisible(false)
|
||||
setViewEdit(!viewEdit)
|
||||
}
|
||||
|
||||
|
||||
const handleRefresh = async () => {
|
||||
setRefreshing(true)
|
||||
@@ -218,7 +305,8 @@ export default function DiscussionDetail() {
|
||||
loading ?
|
||||
<SkeletonContent />
|
||||
:
|
||||
<BorderBottomItem
|
||||
<BorderBottomItem2
|
||||
dataFile={fileDiscussion}
|
||||
descEllipsize={false}
|
||||
borderType="bottom"
|
||||
icon={
|
||||
@@ -268,6 +356,7 @@ export default function DiscussionDetail() {
|
||||
<BorderBottomItem
|
||||
key={index}
|
||||
borderType="bottom"
|
||||
colorPress
|
||||
icon={
|
||||
<ImageUser
|
||||
src={`${ConstEnv.url_storage}/files/${item.img}`}
|
||||
@@ -277,6 +366,7 @@ export default function DiscussionDetail() {
|
||||
title={item.username}
|
||||
rightTopInfo={item.createdAt}
|
||||
desc={item.comment}
|
||||
rightBottomInfo={item.isEdited ? "Edited" : ""}
|
||||
descEllipsize={detailMore.includes(item.id) ? false : true}
|
||||
onPress={() => {
|
||||
setDetailMore((prev: any) => {
|
||||
@@ -287,6 +377,9 @@ export default function DiscussionDetail() {
|
||||
}
|
||||
})
|
||||
}}
|
||||
onLongPress={() => {
|
||||
item.idUser == entities.id && data?.status != 2 && data?.isActive && handleMenuKomentar(item.id, item.comment)
|
||||
}}
|
||||
/>
|
||||
))
|
||||
}
|
||||
@@ -303,73 +396,145 @@ export default function DiscussionDetail() {
|
||||
Styles.contentItemCenter,
|
||||
Styles.w100,
|
||||
{ backgroundColor: "#f4f4f4" },
|
||||
viewEdit && Styles.borderTop
|
||||
]}
|
||||
>
|
||||
{
|
||||
data?.status != 2 && data?.isActive && ((entityUser.role != "user" && entityUser.role != "coadmin") ||
|
||||
isMemberDivision)
|
||||
?
|
||||
<InputForm
|
||||
// disable={
|
||||
// data?.status == 2 ||
|
||||
// data?.isActive == false ||
|
||||
// ((entityUser.role == "user" || entityUser.role == "coadmin") && !isMemberDivision)
|
||||
// }
|
||||
bg="white"
|
||||
type="default"
|
||||
round
|
||||
multiline
|
||||
placeholder="Kirim Komentar"
|
||||
onChange={setKomentar}
|
||||
value={komentar}
|
||||
itemRight={
|
||||
<Pressable
|
||||
onPress={() => {
|
||||
komentar != "" &&
|
||||
!regexOnlySpacesOrEnter.test(komentar) &&
|
||||
!loadingSend &&
|
||||
data?.status != 2 &&
|
||||
data?.isActive &&
|
||||
(((entityUser.role == "user" ||
|
||||
entityUser.role == "coadmin") &&
|
||||
isMemberDivision) ||
|
||||
entityUser.role == "admin" ||
|
||||
entityUser.role == "supadmin" ||
|
||||
entityUser.role == "developer" ||
|
||||
entityUser.role == "cosupadmin") &&
|
||||
handleKomentar();
|
||||
}}
|
||||
style={[
|
||||
Platform.OS == 'android' && Styles.mb12,
|
||||
]}
|
||||
>
|
||||
<MaterialIcons
|
||||
name="send"
|
||||
size={25}
|
||||
style={
|
||||
[komentar == "" || regexOnlySpacesOrEnter.test(komentar) || loadingSend || ((entityUser.role == "user" || entityUser.role == "coadmin") && !isMemberDivision)
|
||||
? Styles.cGray
|
||||
: Styles.cDefault,
|
||||
]
|
||||
}
|
||||
/>
|
||||
viewEdit ?
|
||||
<>
|
||||
<View style={[Styles.w90, Styles.rowSpaceBetween, Styles.pv05]}>
|
||||
<View style={[Styles.rowItemsCenter]}>
|
||||
<Feather name="edit-3" color="black" size={22} style={[Styles.mh05]} />
|
||||
<Text style={[Styles.textMediumSemiBold]}>Edit Komentar</Text>
|
||||
</View>
|
||||
<Pressable onPress={() => handleViewEditKomentar()}>
|
||||
<MaterialIcons name="close" color="black" size={22} />
|
||||
</Pressable>
|
||||
}
|
||||
/>
|
||||
:
|
||||
<View style={[Styles.pv20, { alignItems: 'center' }]}>
|
||||
<Text style={[Styles.textInformation, Styles.cGray]}>
|
||||
{
|
||||
data?.status == 2 ? "Diskusi telah ditutup" : data?.isActive == false ? "Diskusi telah diarsipkan" : "Hanya anggota divisi yang dapat memberikan komentar"
|
||||
</View>
|
||||
<InputForm
|
||||
bg="white"
|
||||
type="default"
|
||||
round
|
||||
multiline
|
||||
placeholder="Kirim Komentar"
|
||||
onChange={(val: string) => setSelectKomentar({ ...selectKomentar, comment: val })}
|
||||
value={selectKomentar.comment}
|
||||
itemRight={
|
||||
<Pressable
|
||||
onPress={() => {
|
||||
selectKomentar.comment != "" &&
|
||||
!regexOnlySpacesOrEnter.test(selectKomentar.comment) &&
|
||||
!loadingSend &&
|
||||
data?.status != 2 &&
|
||||
data?.isActive &&
|
||||
(((entityUser.role == "user" ||
|
||||
entityUser.role == "coadmin") &&
|
||||
isMemberDivision) ||
|
||||
entityUser.role == "admin" ||
|
||||
entityUser.role == "supadmin" ||
|
||||
entityUser.role == "developer" ||
|
||||
entityUser.role == "cosupadmin") &&
|
||||
handleEditKomentar();
|
||||
}}
|
||||
style={[
|
||||
Platform.OS == 'android' && Styles.mb12,
|
||||
]}
|
||||
>
|
||||
<MaterialIcons
|
||||
name="send"
|
||||
size={25}
|
||||
style={
|
||||
[selectKomentar.comment == "" || regexOnlySpacesOrEnter.test(selectKomentar.comment) || loadingSend || ((entityUser.role == "user" || entityUser.role == "coadmin") && !isMemberDivision)
|
||||
? Styles.cGray
|
||||
: Styles.cDefault,
|
||||
]
|
||||
}
|
||||
/>
|
||||
</Pressable>
|
||||
}
|
||||
</Text>
|
||||
</View>
|
||||
/>
|
||||
</>
|
||||
:
|
||||
data?.status != 2 && data?.isActive && ((entityUser.role != "user" && entityUser.role != "coadmin") ||
|
||||
isMemberDivision)
|
||||
?
|
||||
<InputForm
|
||||
bg="white"
|
||||
type="default"
|
||||
round
|
||||
multiline
|
||||
placeholder="Kirim Komentar"
|
||||
onChange={setKomentar}
|
||||
value={komentar}
|
||||
itemRight={
|
||||
<Pressable
|
||||
onPress={() => {
|
||||
komentar != "" &&
|
||||
!regexOnlySpacesOrEnter.test(komentar) &&
|
||||
!loadingSend &&
|
||||
data?.status != 2 &&
|
||||
data?.isActive &&
|
||||
(((entityUser.role == "user" ||
|
||||
entityUser.role == "coadmin") &&
|
||||
isMemberDivision) ||
|
||||
entityUser.role == "admin" ||
|
||||
entityUser.role == "supadmin" ||
|
||||
entityUser.role == "developer" ||
|
||||
entityUser.role == "cosupadmin") &&
|
||||
handleKomentar();
|
||||
}}
|
||||
style={[
|
||||
Platform.OS == 'android' && Styles.mb12,
|
||||
]}
|
||||
>
|
||||
<MaterialIcons
|
||||
name="send"
|
||||
size={25}
|
||||
style={
|
||||
[komentar == "" || regexOnlySpacesOrEnter.test(komentar) || loadingSend || ((entityUser.role == "user" || entityUser.role == "coadmin") && !isMemberDivision)
|
||||
? Styles.cGray
|
||||
: Styles.cDefault,
|
||||
]
|
||||
}
|
||||
/>
|
||||
</Pressable>
|
||||
}
|
||||
/>
|
||||
:
|
||||
<View style={[Styles.pv20, { alignItems: 'center' }]}>
|
||||
<Text style={[Styles.textInformation, Styles.cGray]}>
|
||||
{
|
||||
data?.status == 2 ? "Diskusi telah ditutup" : data?.isActive == false ? "Diskusi telah diarsipkan" : "Hanya anggota divisi yang dapat memberikan komentar"
|
||||
}
|
||||
</Text>
|
||||
</View>
|
||||
}
|
||||
|
||||
</View>
|
||||
</KeyboardAvoidingView>
|
||||
|
||||
</View>
|
||||
<DrawerBottom animation="slide" isVisible={isVisible} setVisible={setVisible} title="Komentar">
|
||||
<View style={Styles.rowItemsCenter}>
|
||||
<MenuItemRow
|
||||
icon={<MaterialCommunityIcons name="pencil-outline" color="black" size={25} />}
|
||||
title="Edit"
|
||||
onPress={() => { handleViewEditKomentar() }}
|
||||
/>
|
||||
<MenuItemRow
|
||||
icon={<MaterialIcons name="delete" color="black" size={25} />}
|
||||
title="Hapus"
|
||||
onPress={() => {
|
||||
AlertKonfirmasi({
|
||||
title: 'Konfirmasi',
|
||||
desc: 'Apakah anda yakin ingin menghapus komentar?',
|
||||
onPress: () => {
|
||||
handleDeleteKomentar()
|
||||
}
|
||||
})
|
||||
}}
|
||||
/>
|
||||
</View>
|
||||
</DrawerBottom>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,16 +1,25 @@
|
||||
import BorderBottomItem from "@/components/borderBottomItem"
|
||||
import ButtonBackHeader from "@/components/buttonBackHeader"
|
||||
import ButtonSaveHeader from "@/components/buttonSaveHeader"
|
||||
import ButtonSelect from "@/components/buttonSelect"
|
||||
import DrawerBottom from "@/components/drawerBottom"
|
||||
import { InputForm } from "@/components/inputForm"
|
||||
import LoadingOverlay from "@/components/loadingOverlay"
|
||||
import MenuItemRow from "@/components/menuItemRow"
|
||||
import Text from "@/components/Text"
|
||||
import Styles from "@/constants/Styles"
|
||||
import { apiCreateDiscussion } from "@/lib/api"
|
||||
import { setUpdateDiscussion } from "@/lib/discussionUpdate"
|
||||
import { useAuthSession } from "@/providers/AuthProvider"
|
||||
import { Ionicons, MaterialCommunityIcons } from "@expo/vector-icons"
|
||||
import * as DocumentPicker from "expo-document-picker"
|
||||
import { router, Stack, useLocalSearchParams } from "expo-router"
|
||||
import { useState } from "react"
|
||||
import { SafeAreaView, ScrollView, View } from "react-native"
|
||||
import Toast from "react-native-toast-message"
|
||||
import { useDispatch, useSelector } from "react-redux"
|
||||
|
||||
|
||||
export default function CreateDiscussionDivision() {
|
||||
const { id } = useLocalSearchParams<{ id: string }>()
|
||||
const [desc, setDesc] = useState('')
|
||||
@@ -18,12 +27,51 @@ export default function CreateDiscussionDivision() {
|
||||
const update = useSelector((state: any) => state.discussionUpdate)
|
||||
const dispatch = useDispatch();
|
||||
const [loading, setLoading] = useState(false)
|
||||
const [fileForm, setFileForm] = useState<any[]>([])
|
||||
const [isModalFile, setModalFile] = useState(false)
|
||||
const [indexDelFile, setIndexDelFile] = useState<number>(0)
|
||||
|
||||
const pickDocumentAsync = async () => {
|
||||
let result = await DocumentPicker.getDocumentAsync({
|
||||
type: ["*/*"],
|
||||
multiple: true
|
||||
});
|
||||
if (!result.canceled) {
|
||||
for (let i = 0; i < result.assets?.length; i++) {
|
||||
if (result.assets[i].uri) {
|
||||
setFileForm((prev) => [...prev, result.assets[i]])
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function deleteFile(index: number) {
|
||||
setFileForm([...fileForm.filter((val, i) => i !== index)])
|
||||
setModalFile(false)
|
||||
}
|
||||
|
||||
|
||||
async function handleCreate() {
|
||||
try {
|
||||
setLoading(true)
|
||||
const hasil = await decryptToken(String(token?.current))
|
||||
const response = await apiCreateDiscussion({ data: { user: hasil, desc, idDivision: id } })
|
||||
const fd = new FormData()
|
||||
|
||||
for (let i = 0; i < fileForm.length; i++) {
|
||||
fd.append(`file${i}`, {
|
||||
uri: fileForm[i].uri,
|
||||
type: 'application/octet-stream',
|
||||
name: fileForm[i].name,
|
||||
} as any);
|
||||
}
|
||||
|
||||
fd.append("data", JSON.stringify(
|
||||
{ user: hasil, desc, idDivision: id }
|
||||
))
|
||||
|
||||
const response = await apiCreateDiscussion(fd)
|
||||
|
||||
// const response = await apiCreateDiscussion({ data: { user: hasil, desc, idDivision: id } })
|
||||
if (response.success) {
|
||||
Toast.show({ type: 'small', text1: 'Berhasil menambahkan data', })
|
||||
dispatch(setUpdateDiscussion({ ...update, data: !update.data }));
|
||||
@@ -54,7 +102,8 @@ export default function CreateDiscussionDivision() {
|
||||
}} />
|
||||
}}
|
||||
/>
|
||||
<ScrollView>
|
||||
<LoadingOverlay visible={loading} />
|
||||
<ScrollView showsVerticalScrollIndicator={false} style={[Styles.h100]}>
|
||||
<View style={[Styles.p15, Styles.mb100]}>
|
||||
<InputForm
|
||||
label="Diskusi"
|
||||
@@ -64,8 +113,38 @@ export default function CreateDiscussionDivision() {
|
||||
onChange={setDesc}
|
||||
multiline
|
||||
/>
|
||||
<ButtonSelect value="Upload File" onPress={pickDocumentAsync} />
|
||||
{
|
||||
fileForm.length > 0
|
||||
&&
|
||||
<View style={[Styles.borderAll, Styles.round10, Styles.p10, Styles.mb10]}>
|
||||
<Text style={[Styles.textDefaultSemiBold]}>File</Text>
|
||||
{
|
||||
fileForm.map((item, index) => (
|
||||
<BorderBottomItem
|
||||
key={index}
|
||||
borderType={fileForm.length > 1 ? "bottom" : "none"}
|
||||
icon={<MaterialCommunityIcons name="file-outline" size={25} color="black" />}
|
||||
title={item.name}
|
||||
titleWeight="normal"
|
||||
onPress={() => { setIndexDelFile(index); setModalFile(true) }}
|
||||
/>
|
||||
))
|
||||
}
|
||||
</View>
|
||||
}
|
||||
</View>
|
||||
</ScrollView>
|
||||
|
||||
<DrawerBottom animation="slide" isVisible={isModalFile} setVisible={setModalFile} title="Menu">
|
||||
<View style={Styles.rowItemsCenter}>
|
||||
<MenuItemRow
|
||||
icon={<Ionicons name="trash" color="black" size={25} />}
|
||||
title="Hapus"
|
||||
onPress={() => { deleteFile(indexDelFile) }}
|
||||
/>
|
||||
</View>
|
||||
</DrawerBottom>
|
||||
</SafeAreaView>
|
||||
)
|
||||
}
|
||||
@@ -69,10 +69,9 @@ export default function CreateDivision() {
|
||||
if (!response.available) {
|
||||
AlertKonfirmasi({
|
||||
title: 'Peringatan',
|
||||
desc: 'Nama divisi sudah ada. Apakah anda yakin ingin membuat divisi dengan nama yang sama?',
|
||||
onPress: () => {
|
||||
handleSetData()
|
||||
}
|
||||
category: 'warning',
|
||||
desc: 'Nama divisi sudah ada. Tidak dapat membuat divisi dengan nama yang sama',
|
||||
onPress: () => { }
|
||||
})
|
||||
} else {
|
||||
handleSetData()
|
||||
|
||||
@@ -328,7 +328,7 @@ export default function EditProfile() {
|
||||
type="numeric"
|
||||
placeholder="8XX-XXX-XXX"
|
||||
required
|
||||
itemLeft={<Text>+62</Text>}
|
||||
itemLeft={<Text style={[Platform.OS === 'ios' && Styles.mt02]}>+62</Text>}
|
||||
value={data?.phone}
|
||||
error={error.phone}
|
||||
errorText="Nomor Telepon tidak valid"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import ButtonBackHeader from "@/components/buttonBackHeader";
|
||||
import AppHeader from "@/components/AppHeader";
|
||||
import { ButtonFiturMenu } from "@/components/buttonFiturMenu";
|
||||
import Styles from "@/constants/Styles";
|
||||
import { AntDesign, Entypo, Ionicons, MaterialCommunityIcons, MaterialIcons } from "@expo/vector-icons";
|
||||
@@ -13,9 +13,11 @@ export default function Feature() {
|
||||
<SafeAreaView>
|
||||
<Stack.Screen
|
||||
options={{
|
||||
headerLeft: () => <ButtonBackHeader onPress={() => { router.back() }} />,
|
||||
headerTitle: 'Fitur',
|
||||
headerTitleAlign: 'center'
|
||||
headerTitleAlign: 'center',
|
||||
header: () => (
|
||||
<AppHeader title="Fitur" showBack={true} onPressLeft={() => router.back()} />
|
||||
)
|
||||
}}
|
||||
/>
|
||||
<View style={[Styles.p15]}>
|
||||
|
||||
@@ -1,17 +1,20 @@
|
||||
import ButtonBackHeader from "@/components/buttonBackHeader";
|
||||
import AppHeader from "@/components/AppHeader";
|
||||
import ImageUser from "@/components/imageNew";
|
||||
import ItemDetailMember from "@/components/itemDetailMember";
|
||||
import LabelStatus from "@/components/labelStatus";
|
||||
import HeaderRightMemberDetail from "@/components/member/headerMemberDetail";
|
||||
import Skeleton from "@/components/skeleton";
|
||||
import Text from "@/components/Text";
|
||||
import { assetUserImage } from "@/constants/AssetsError";
|
||||
import { ConstEnv } from "@/constants/ConstEnv";
|
||||
import { valueRoleUser } from "@/constants/RoleUser";
|
||||
import Styles from "@/constants/Styles";
|
||||
import { apiGetProfile } from "@/lib/api";
|
||||
import { router, Stack, useLocalSearchParams } from "expo-router";
|
||||
import { useEffect, useState } from "react";
|
||||
import { RefreshControl, SafeAreaView, ScrollView, View } from "react-native";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { Pressable, RefreshControl, SafeAreaView, ScrollView, View } from "react-native";
|
||||
import ImageViewing from 'react-native-image-viewing';
|
||||
import Toast from "react-native-toast-message";
|
||||
import { useSelector } from "react-redux";
|
||||
|
||||
type Props = {
|
||||
@@ -31,21 +34,27 @@ type Props = {
|
||||
export default function MemberDetail() {
|
||||
const { id } = useLocalSearchParams<{ id: string }>();
|
||||
const [data, setData] = useState<Props>()
|
||||
const [error, setError] = useState(false)
|
||||
const [errorImg, setErrorImg] = useState(false)
|
||||
const entityUser = useSelector((state: any) => state.user)
|
||||
const [isEdit, setEdit] = useState(true)
|
||||
const arrSkeleton = Array.from({ length: 5 }, (_, index) => index)
|
||||
const [loading, setLoading] = useState(true)
|
||||
const [refreshing, setRefreshing] = useState(false)
|
||||
const [preview, setPreview] = useState(false)
|
||||
|
||||
async function handleLoad(loading: boolean) {
|
||||
try {
|
||||
setLoading(loading)
|
||||
const response = await apiGetProfile({ id: id })
|
||||
setData(response.data)
|
||||
setEdit(valueRoleUser.filter((v) => v.login == entityUser.role)[0]?.data.some((i: any) => i.id == response.data.idUserRole))
|
||||
if (response.success) {
|
||||
setData(response.data)
|
||||
setEdit(valueRoleUser.filter((v) => v.login == entityUser.role)[0]?.data.some((i: any) => i.id == response.data.idUserRole))
|
||||
} else {
|
||||
Toast.show({ type: 'small', text1: response.message })
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
Toast.show({ type: 'small', text1: 'Gagal mengambil data' })
|
||||
} finally {
|
||||
setLoading(false)
|
||||
}
|
||||
@@ -68,11 +77,19 @@ export default function MemberDetail() {
|
||||
<SafeAreaView>
|
||||
<Stack.Screen
|
||||
options={{
|
||||
headerLeft: () => <ButtonBackHeader onPress={() => { router.back() }} />,
|
||||
// headerLeft: () => <ButtonBackHeader onPress={() => { router.back() }} />,
|
||||
headerTitle: 'Anggota',
|
||||
headerTitleAlign: 'center',
|
||||
headerRight: () => (entityUser.role != "user") && isEdit ? <HeaderRightMemberDetail active={data?.isActive} id={id} /> : <></>,
|
||||
headerShadowVisible: false
|
||||
// headerRight: () => (entityUser.role != "user") && isEdit ? <HeaderRightMemberDetail active={data?.isActive} id={id} /> : <></>,
|
||||
header: () => (
|
||||
<AppHeader title="Anggota"
|
||||
showBack={true}
|
||||
onPressLeft={() => router.back()}
|
||||
right={
|
||||
(entityUser.role != "user") && isEdit ? <HeaderRightMemberDetail active={data?.isActive} id={id} /> : <></>
|
||||
}
|
||||
/>
|
||||
)
|
||||
}}
|
||||
/>
|
||||
<ScrollView
|
||||
@@ -84,7 +101,7 @@ export default function MemberDetail() {
|
||||
/>
|
||||
}
|
||||
>
|
||||
<View style={[Styles.wrapHeadViewMember,]}>
|
||||
<View style={[Styles.wrapHeadViewMember]}>
|
||||
{
|
||||
loading ?
|
||||
<>
|
||||
@@ -94,7 +111,9 @@ export default function MemberDetail() {
|
||||
</>
|
||||
:
|
||||
<>
|
||||
<ImageUser src={`${ConstEnv.url_storage}/files/${data?.img}`} size="lg" />
|
||||
<Pressable onPress={() => setPreview(true)}>
|
||||
<ImageUser src={`${ConstEnv.url_storage}/files/${data?.img}`} size="lg" onError={setErrorImg} />
|
||||
</Pressable>
|
||||
<Text style={[Styles.textSubtitle, Styles.cWhite, Styles.mt10, { textAlign: 'center' }]}>{data?.name}</Text>
|
||||
<Text style={[Styles.textMediumNormal, Styles.cWhite]}>{data?.role}</Text>
|
||||
</>
|
||||
@@ -130,6 +149,14 @@ export default function MemberDetail() {
|
||||
|
||||
</View>
|
||||
</ScrollView>
|
||||
|
||||
<ImageViewing
|
||||
images={[{ uri: errorImg ? assetUserImage.uri : `${ConstEnv.url_storage}/files/${data?.img}` }]}
|
||||
imageIndex={0}
|
||||
visible={preview}
|
||||
onRequestClose={() => setPreview(false)}
|
||||
doubleTapToZoomEnabled
|
||||
/>
|
||||
</SafeAreaView>
|
||||
)
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import ButtonBackHeader from "@/components/buttonBackHeader";
|
||||
import AppHeader from "@/components/AppHeader";
|
||||
import ButtonSaveHeader from "@/components/buttonSaveHeader";
|
||||
import { InputForm } from "@/components/inputForm";
|
||||
import ModalSelect from "@/components/modalSelect";
|
||||
@@ -209,22 +209,35 @@ export default function CreateMember() {
|
||||
<SafeAreaView>
|
||||
<Stack.Screen
|
||||
options={{
|
||||
headerLeft: () => (
|
||||
<ButtonBackHeader
|
||||
onPress={() => {
|
||||
router.back();
|
||||
}}
|
||||
/>
|
||||
),
|
||||
// headerLeft: () => (
|
||||
// <ButtonBackHeader
|
||||
// onPress={() => {
|
||||
// router.back();
|
||||
// }}
|
||||
// />
|
||||
// ),
|
||||
headerTitle: "Tambah Anggota",
|
||||
headerTitleAlign: "center",
|
||||
headerRight: () => (
|
||||
<ButtonSaveHeader
|
||||
disable={disableBtn || loading}
|
||||
category="create"
|
||||
onPress={() => { handleCreate() }}
|
||||
// headerRight: () => (
|
||||
// <ButtonSaveHeader
|
||||
// disable={disableBtn || loading}
|
||||
// category="create"
|
||||
// onPress={() => { handleCreate() }}
|
||||
// />
|
||||
// ),
|
||||
header: () => (
|
||||
<AppHeader title="Anggota"
|
||||
showBack={true}
|
||||
onPressLeft={() => router.back()}
|
||||
right={
|
||||
<ButtonSaveHeader
|
||||
disable={disableBtn || loading}
|
||||
category="create"
|
||||
onPress={() => { handleCreate() }}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
),
|
||||
)
|
||||
}}
|
||||
/>
|
||||
<KeyboardAvoidingView
|
||||
@@ -331,7 +344,7 @@ export default function CreateMember() {
|
||||
type="numeric"
|
||||
placeholder="8XX-XXX-XXX"
|
||||
required
|
||||
itemLeft={<Text>+62</Text>}
|
||||
itemLeft={<Text style={[Platform.OS === 'ios' && Styles.mt02]}>+62</Text>}
|
||||
error={error.phone}
|
||||
errorText="Nomor Telepon tidak valid"
|
||||
onChange={val => {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import ButtonBackHeader from "@/components/buttonBackHeader";
|
||||
import AppHeader from "@/components/AppHeader";
|
||||
import ButtonSaveHeader from "@/components/buttonSaveHeader";
|
||||
import { InputForm } from "@/components/inputForm";
|
||||
import ModalSelect from "@/components/modalSelect";
|
||||
@@ -239,24 +239,40 @@ export default function EditMember() {
|
||||
<SafeAreaView>
|
||||
<Stack.Screen
|
||||
options={{
|
||||
headerLeft: () => (
|
||||
<ButtonBackHeader
|
||||
onPress={() => {
|
||||
router.back();
|
||||
}}
|
||||
/>
|
||||
),
|
||||
// headerLeft: () => (
|
||||
// <ButtonBackHeader
|
||||
// onPress={() => {
|
||||
// router.back();
|
||||
// }}
|
||||
// />
|
||||
// ),
|
||||
headerTitle: "Edit Anggota",
|
||||
headerTitleAlign: "center",
|
||||
headerRight: () => (
|
||||
<ButtonSaveHeader
|
||||
disable={disableBtn || loading}
|
||||
category="update"
|
||||
onPress={() => {
|
||||
handleEdit()
|
||||
}}
|
||||
// headerRight: () => (
|
||||
// <ButtonSaveHeader
|
||||
// disable={disableBtn || loading}
|
||||
// category="update"
|
||||
// onPress={() => {
|
||||
// handleEdit()
|
||||
// }}
|
||||
// />
|
||||
// ),
|
||||
header: () => (
|
||||
<AppHeader
|
||||
title="Edit Anggota"
|
||||
showBack={true}
|
||||
onPressLeft={() => router.back()}
|
||||
right={
|
||||
<ButtonSaveHeader
|
||||
disable={disableBtn || loading}
|
||||
category="update"
|
||||
onPress={() => {
|
||||
handleEdit()
|
||||
}}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
),
|
||||
)
|
||||
}}
|
||||
/>
|
||||
|
||||
@@ -371,7 +387,7 @@ export default function EditMember() {
|
||||
type="numeric"
|
||||
placeholder="8XX-XXX-XXX"
|
||||
required
|
||||
itemLeft={<Text>+62</Text>}
|
||||
itemLeft={<Text style={[Platform.OS === 'ios' && Styles.mt02]}>+62</Text>}
|
||||
value={data?.phone}
|
||||
error={error.phone}
|
||||
errorText="Nomor Telepon tidak valid"
|
||||
|
||||
@@ -1,51 +1,73 @@
|
||||
import AlertKonfirmasi from "@/components/alertKonfirmasi";
|
||||
import ButtonBackHeader from "@/components/buttonBackHeader";
|
||||
import AppHeader from "@/components/AppHeader";
|
||||
import { ButtonHeader } from "@/components/buttonHeader";
|
||||
import ItemDetailMember from "@/components/itemDetailMember";
|
||||
import Text from "@/components/Text";
|
||||
import { assetUserImage } from "@/constants/AssetsError";
|
||||
import { ConstEnv } from "@/constants/ConstEnv";
|
||||
import Styles from "@/constants/Styles";
|
||||
import { useAuthSession } from "@/providers/AuthProvider";
|
||||
import { AntDesign } from "@expo/vector-icons";
|
||||
import { router, Stack } from "expo-router";
|
||||
import { useState } from "react";
|
||||
import { Image, SafeAreaView, ScrollView, View } from "react-native";
|
||||
import { Image, Pressable, SafeAreaView, ScrollView, View } from "react-native";
|
||||
import ImageViewing from 'react-native-image-viewing';
|
||||
import { useSelector } from 'react-redux';
|
||||
|
||||
export default function Profile() {
|
||||
const { signOut } = useAuthSession()
|
||||
const entities = useSelector((state: any) => state.entities)
|
||||
const [error, setError] = useState(false)
|
||||
const [preview, setPreview] = useState(false)
|
||||
|
||||
|
||||
return (
|
||||
<SafeAreaView>
|
||||
<Stack.Screen
|
||||
options={{
|
||||
headerLeft: () => <ButtonBackHeader onPress={() => { router.back() }} />,
|
||||
headerTitle: 'Profile',
|
||||
headerTitleAlign: 'center',
|
||||
headerShadowVisible: false,
|
||||
headerRight: () => <ButtonHeader
|
||||
item={<AntDesign name="logout" size={20} color="white" />}
|
||||
onPress={() => {
|
||||
AlertKonfirmasi({
|
||||
title: 'Keluar',
|
||||
desc: 'Apakah anda yakin ingin keluar?',
|
||||
onPress: () => { signOut() }
|
||||
})
|
||||
}}
|
||||
/>
|
||||
header: () => (
|
||||
<AppHeader
|
||||
title="Profile"
|
||||
showBack={true}
|
||||
onPressLeft={() => router.back()}
|
||||
right={
|
||||
<ButtonHeader
|
||||
item={<AntDesign name="logout" size={20} color="white" />}
|
||||
onPress={() => {
|
||||
AlertKonfirmasi({
|
||||
title: 'Keluar',
|
||||
desc: 'Apakah anda yakin ingin keluar?',
|
||||
onPress: () => { signOut() }
|
||||
})
|
||||
}}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
)
|
||||
// headerRight: () => <ButtonHeader
|
||||
// item={<AntDesign name="logout" size={20} color="white" />}
|
||||
// onPress={() => {
|
||||
// AlertKonfirmasi({
|
||||
// title: 'Keluar',
|
||||
// desc: 'Apakah anda yakin ingin keluar?',
|
||||
// onPress: () => { signOut() }
|
||||
// })
|
||||
// }}
|
||||
// />
|
||||
}}
|
||||
/>
|
||||
<ScrollView style={[Styles.h100]}>
|
||||
<View style={{ flexDirection: 'column' }}>
|
||||
<View style={[Styles.wrapHeadViewMember]}>
|
||||
<Image
|
||||
source={error ? require("../../assets/images/user.jpg") : { uri: `${ConstEnv.url_storage}/files/${entities.img}` }}
|
||||
onError={() => { setError(true) }}
|
||||
style={[Styles.userProfileBig]}
|
||||
/>
|
||||
<Pressable onPress={() => setPreview(true)}>
|
||||
<Image
|
||||
source={error ? require("../../assets/images/user.jpg") : { uri: `${ConstEnv.url_storage}/files/${entities.img}` }}
|
||||
onError={() => { setError(true) }}
|
||||
style={[Styles.userProfileBig]}
|
||||
/>
|
||||
</Pressable>
|
||||
<Text style={[Styles.textSubtitle, Styles.cWhite, Styles.mt10]}>{entities.name}</Text>
|
||||
<Text style={[Styles.textMediumNormal, Styles.cWhite]}>{entities.role}</Text>
|
||||
</View>
|
||||
@@ -65,6 +87,13 @@ export default function Profile() {
|
||||
</View>
|
||||
</View>
|
||||
</ScrollView>
|
||||
<ImageViewing
|
||||
images={[{ uri: error ? assetUserImage.uri : `${ConstEnv.url_storage}/files/${entities.img}` }]}
|
||||
imageIndex={0}
|
||||
visible={preview}
|
||||
onRequestClose={() => setPreview(false)}
|
||||
doubleTapToZoomEnabled
|
||||
/>
|
||||
</SafeAreaView>
|
||||
)
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
import AppHeader from "@/components/AppHeader"
|
||||
import BorderBottomItem from "@/components/borderBottomItem"
|
||||
import ButtonBackHeader from "@/components/buttonBackHeader"
|
||||
import ButtonSaveHeader from "@/components/buttonSaveHeader"
|
||||
import ButtonSelect from "@/components/buttonSelect"
|
||||
import DrawerBottom from "@/components/drawerBottom"
|
||||
@@ -130,13 +130,27 @@ export default function ProjectAddFile() {
|
||||
<SafeAreaView>
|
||||
<Stack.Screen
|
||||
options={{
|
||||
headerLeft: () => <ButtonBackHeader onPress={() => { router.back() }} />,
|
||||
// headerLeft: () => <ButtonBackHeader onPress={() => { router.back() }} />,
|
||||
headerTitle: 'Tambah File',
|
||||
headerTitleAlign: 'center',
|
||||
headerRight: () => <ButtonSaveHeader
|
||||
disable={fileForm.length == 0 || loading ? true : false}
|
||||
category="create"
|
||||
onPress={() => { handleAddFile() }} />
|
||||
// headerRight: () => <ButtonSaveHeader
|
||||
// disable={fileForm.length == 0 || loading ? true : false}
|
||||
// category="create"
|
||||
// onPress={() => { handleAddFile() }} />
|
||||
header: () => (
|
||||
<AppHeader
|
||||
title="Tambah File"
|
||||
showBack={true}
|
||||
onPressLeft={() => router.back()}
|
||||
right={
|
||||
<ButtonSaveHeader
|
||||
disable={fileForm.length == 0 || loading ? true : false}
|
||||
category="create"
|
||||
onPress={() => { handleAddFile() }}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
)
|
||||
}}
|
||||
/>
|
||||
<ScrollView>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import ButtonBackHeader from "@/components/buttonBackHeader";
|
||||
import AppHeader from "@/components/AppHeader";
|
||||
import ButtonSaveHeader from "@/components/buttonSaveHeader";
|
||||
import ImageUser from "@/components/imageNew";
|
||||
import ImageWithLabel from "@/components/imageWithLabel";
|
||||
@@ -97,16 +97,32 @@ export default function AddMemberProject() {
|
||||
<>
|
||||
<Stack.Screen
|
||||
options={{
|
||||
headerLeft: () => <ButtonBackHeader onPress={() => { router.back() }} />,
|
||||
// headerLeft: () => <ButtonBackHeader onPress={() => { router.back() }} />,
|
||||
headerTitle: 'Tambah Anggota Kegiatan',
|
||||
headerTitleAlign: 'center',
|
||||
headerRight: () => (
|
||||
<ButtonSaveHeader
|
||||
category="update"
|
||||
disable={selectMember.length == 0 || loading ? true : false}
|
||||
onPress={() => {
|
||||
handleAddMember()
|
||||
}}
|
||||
// headerRight: () => (
|
||||
// <ButtonSaveHeader
|
||||
// category="update"
|
||||
// disable={selectMember.length == 0 || loading ? true : false}
|
||||
// onPress={() => {
|
||||
// handleAddMember()
|
||||
// }}
|
||||
// />
|
||||
// )
|
||||
header: () => (
|
||||
<AppHeader
|
||||
title="Tambah Anggota Kegiatan"
|
||||
showBack={true}
|
||||
onPressLeft={() => router.back()}
|
||||
right={
|
||||
<ButtonSaveHeader
|
||||
category="update"
|
||||
disable={selectMember.length == 0 || loading ? true : false}
|
||||
onPress={() => {
|
||||
handleAddMember()
|
||||
}}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
)
|
||||
}}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import ButtonBackHeader from "@/components/buttonBackHeader";
|
||||
import AppHeader from "@/components/AppHeader";
|
||||
import ButtonSaveHeader from "@/components/buttonSaveHeader";
|
||||
import { InputForm } from "@/components/inputForm";
|
||||
import ModalAddDetailTugasProject from "@/components/project/modalAddDetailTugasProject";
|
||||
@@ -136,22 +136,36 @@ export default function ProjectAddTask() {
|
||||
<SafeAreaView>
|
||||
<Stack.Screen
|
||||
options={{
|
||||
headerLeft: () => (
|
||||
<ButtonBackHeader
|
||||
onPress={() => {
|
||||
router.back();
|
||||
}}
|
||||
/>
|
||||
),
|
||||
// headerLeft: () => (
|
||||
// <ButtonBackHeader
|
||||
// onPress={() => {
|
||||
// router.back();
|
||||
// }}
|
||||
// />
|
||||
// ),
|
||||
headerTitle: "Tambah Tugas",
|
||||
headerTitleAlign: "center",
|
||||
headerRight: () => (
|
||||
<ButtonSaveHeader
|
||||
disable={disable || loading}
|
||||
category="create"
|
||||
onPress={() => { handleCreate() }}
|
||||
// headerRight: () => (
|
||||
// <ButtonSaveHeader
|
||||
// disable={disable || loading}
|
||||
// category="create"
|
||||
// onPress={() => { handleCreate() }}
|
||||
// />
|
||||
// ),
|
||||
header: () => (
|
||||
<AppHeader
|
||||
title="Tambah Tugas"
|
||||
showBack={true}
|
||||
onPressLeft={() => router.back()}
|
||||
right={
|
||||
<ButtonSaveHeader
|
||||
disable={disable || loading}
|
||||
category="create"
|
||||
onPress={() => { handleCreate() }}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
),
|
||||
)
|
||||
}}
|
||||
/>
|
||||
<KeyboardAvoidingView
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import ButtonBackHeader from "@/components/buttonBackHeader";
|
||||
import AppHeader from "@/components/AppHeader";
|
||||
import ButtonSaveHeader from "@/components/buttonSaveHeader";
|
||||
import { InputForm } from "@/components/inputForm";
|
||||
import Styles from "@/constants/Styles";
|
||||
@@ -6,7 +6,7 @@ import { apiCancelProject } from "@/lib/api";
|
||||
import { setUpdateProject } from "@/lib/projectUpdate";
|
||||
import { useAuthSession } from "@/providers/AuthProvider";
|
||||
import { router, Stack, useLocalSearchParams } from "expo-router";
|
||||
import { useEffect, useState } from "react";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { SafeAreaView, ScrollView, View } from "react-native";
|
||||
import Toast from "react-native-toast-message";
|
||||
import { useDispatch, useSelector } from "react-redux";
|
||||
@@ -68,24 +68,40 @@ export default function ProjectCancel() {
|
||||
<SafeAreaView>
|
||||
<Stack.Screen
|
||||
options={{
|
||||
headerLeft: () => (
|
||||
<ButtonBackHeader
|
||||
onPress={() => {
|
||||
router.back();
|
||||
}}
|
||||
/>
|
||||
),
|
||||
// headerLeft: () => (
|
||||
// <ButtonBackHeader
|
||||
// onPress={() => {
|
||||
// router.back();
|
||||
// }}
|
||||
// />
|
||||
// ),
|
||||
headerTitle: "Pembatalan Kegiatan",
|
||||
headerTitleAlign: "center",
|
||||
headerRight: () => (
|
||||
<ButtonSaveHeader
|
||||
disable={disable || loading}
|
||||
category="cancel"
|
||||
onPress={() => {
|
||||
handleCancel();
|
||||
}}
|
||||
// headerRight: () => (
|
||||
// <ButtonSaveHeader
|
||||
// disable={disable || loading}
|
||||
// category="cancel"
|
||||
// onPress={() => {
|
||||
// handleCancel();
|
||||
// }}
|
||||
// />
|
||||
// ),
|
||||
header: () => (
|
||||
<AppHeader
|
||||
title="Pembatalan Kegiatan"
|
||||
showBack={true}
|
||||
onPressLeft={() => router.back()}
|
||||
right={
|
||||
<ButtonSaveHeader
|
||||
disable={disable || loading}
|
||||
category="cancel"
|
||||
onPress={() => {
|
||||
handleCancel();
|
||||
}}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
),
|
||||
)
|
||||
}}
|
||||
/>
|
||||
<ScrollView
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import ButtonBackHeader from "@/components/buttonBackHeader";
|
||||
import AppHeader from "@/components/AppHeader";
|
||||
import ButtonSaveHeader from "@/components/buttonSaveHeader";
|
||||
import { InputForm } from "@/components/inputForm";
|
||||
import Styles from "@/constants/Styles";
|
||||
@@ -43,7 +43,7 @@ export default function EditProject() {
|
||||
setJudul(val)
|
||||
if (val == "" || val == "null") {
|
||||
setError(true)
|
||||
}else{
|
||||
} else {
|
||||
setError(false)
|
||||
}
|
||||
}
|
||||
@@ -89,22 +89,36 @@ export default function EditProject() {
|
||||
<SafeAreaView>
|
||||
<Stack.Screen
|
||||
options={{
|
||||
headerLeft: () => (
|
||||
<ButtonBackHeader
|
||||
onPress={() => {
|
||||
router.back();
|
||||
}}
|
||||
/>
|
||||
),
|
||||
// headerLeft: () => (
|
||||
// <ButtonBackHeader
|
||||
// onPress={() => {
|
||||
// router.back();
|
||||
// }}
|
||||
// />
|
||||
// ),
|
||||
headerTitle: "Edit Judul Kegiatan",
|
||||
headerTitleAlign: "center",
|
||||
headerRight: () => (
|
||||
<ButtonSaveHeader
|
||||
disable={disable || loading}
|
||||
category="update"
|
||||
onPress={() => { handleUpdate() }}
|
||||
// headerRight: () => (
|
||||
// <ButtonSaveHeader
|
||||
// disable={disable || loading}
|
||||
// category="update"
|
||||
// onPress={() => { handleUpdate() }}
|
||||
// />
|
||||
// ),
|
||||
header: () => (
|
||||
<AppHeader
|
||||
title="Edit Judul Kegiatan"
|
||||
showBack={true}
|
||||
onPressLeft={() => router.back()}
|
||||
right={
|
||||
<ButtonSaveHeader
|
||||
disable={disable || loading}
|
||||
category="update"
|
||||
onPress={() => { handleUpdate() }}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
),
|
||||
)
|
||||
}}
|
||||
/>
|
||||
<ScrollView>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import ButtonBackHeader from "@/components/buttonBackHeader";
|
||||
import AppHeader from "@/components/AppHeader";
|
||||
import HeaderRightProjectDetail from "@/components/project/headerProjectDetail";
|
||||
import SectionFile from "@/components/project/sectionFile";
|
||||
import SectionLink from "@/components/project/sectionLink";
|
||||
@@ -11,7 +11,7 @@ import Styles from "@/constants/Styles";
|
||||
import { apiGetProjectOne } from "@/lib/api";
|
||||
import { useAuthSession } from "@/providers/AuthProvider";
|
||||
import { router, Stack, useLocalSearchParams } from "expo-router";
|
||||
import { useEffect, useState } from "react";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { RefreshControl, SafeAreaView, ScrollView, View } from "react-native";
|
||||
import { useSelector } from "react-redux";
|
||||
|
||||
@@ -94,10 +94,20 @@ export default function DetailProject() {
|
||||
<SafeAreaView>
|
||||
<Stack.Screen
|
||||
options={{
|
||||
headerLeft: () => <ButtonBackHeader onPress={() => { router.back() }} />,
|
||||
// headerLeft: () => <ButtonBackHeader onPress={() => { router.back() }} />,
|
||||
headerTitle: loading ? 'Loading... ' : data?.title,
|
||||
headerTitleAlign: 'center',
|
||||
headerRight: () => (entityUser.role == "user" || entityUser.role == "coadmin") && !isMember ? null : <HeaderRightProjectDetail id={id} status={data?.status} />,
|
||||
// headerRight: () => (entityUser.role == "user" || entityUser.role == "coadmin") && !isMember ? null : <HeaderRightProjectDetail id={id} status={data?.status} />,
|
||||
header: () => (
|
||||
<AppHeader
|
||||
title={loading ? 'Loading...' : data && data?.title || ''}
|
||||
showBack={true}
|
||||
onPressLeft={() => router.back()}
|
||||
right={
|
||||
(entityUser.role == "user" || entityUser.role == "coadmin") && !isMember ? null : <HeaderRightProjectDetail id={id} status={data?.status} />
|
||||
}
|
||||
/>
|
||||
)
|
||||
}}
|
||||
/>
|
||||
<ScrollView
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import ButtonBackHeader from "@/components/buttonBackHeader";
|
||||
import AppHeader from "@/components/AppHeader";
|
||||
import ButtonSaveHeader from "@/components/buttonSaveHeader";
|
||||
import { InputForm } from "@/components/inputForm";
|
||||
import Styles from "@/constants/Styles";
|
||||
@@ -89,22 +89,36 @@ export default function ReportProject() {
|
||||
<SafeAreaView>
|
||||
<Stack.Screen
|
||||
options={{
|
||||
headerLeft: () => (
|
||||
<ButtonBackHeader
|
||||
onPress={() => {
|
||||
router.back();
|
||||
}}
|
||||
/>
|
||||
),
|
||||
// headerLeft: () => (
|
||||
// <ButtonBackHeader
|
||||
// onPress={() => {
|
||||
// router.back();
|
||||
// }}
|
||||
// />
|
||||
// ),
|
||||
headerTitle: "Laporan Kegiatan",
|
||||
headerTitleAlign: "center",
|
||||
headerRight: () => (
|
||||
<ButtonSaveHeader
|
||||
disable={disable || loading}
|
||||
category="update"
|
||||
onPress={() => { handleUpdate() }}
|
||||
// headerRight: () => (
|
||||
// <ButtonSaveHeader
|
||||
// disable={disable || loading}
|
||||
// category="update"
|
||||
// onPress={() => { handleUpdate() }}
|
||||
// />
|
||||
// ),
|
||||
header: () => (
|
||||
<AppHeader
|
||||
title="Laporan Kegiatan"
|
||||
showBack={true}
|
||||
onPressLeft={() => router.back()}
|
||||
right={
|
||||
<ButtonSaveHeader
|
||||
disable={disable || loading}
|
||||
category="update"
|
||||
onPress={() => { handleUpdate() }}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
),
|
||||
)
|
||||
}}
|
||||
/>
|
||||
<ScrollView
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import AppHeader from "@/components/AppHeader";
|
||||
import BorderBottomItem from "@/components/borderBottomItem";
|
||||
import ButtonBackHeader from "@/components/buttonBackHeader";
|
||||
import ButtonSaveHeader from "@/components/buttonSaveHeader";
|
||||
import ButtonSelect from "@/components/buttonSelect";
|
||||
import DrawerBottom from "@/components/drawerBottom";
|
||||
@@ -193,24 +193,39 @@ export default function CreateProject() {
|
||||
<SafeAreaView>
|
||||
<Stack.Screen
|
||||
options={{
|
||||
headerLeft: () => (
|
||||
<ButtonBackHeader
|
||||
onPress={() => {
|
||||
handleBack();
|
||||
}}
|
||||
/>
|
||||
),
|
||||
// headerLeft: () => (
|
||||
// <ButtonBackHeader
|
||||
// onPress={() => {
|
||||
// handleBack();
|
||||
// }}
|
||||
// />
|
||||
// ),
|
||||
headerTitle: "Tambah Kegiatan",
|
||||
headerTitleAlign: "center",
|
||||
headerRight: () => (
|
||||
<ButtonSaveHeader
|
||||
disable={disableBtn || loading}
|
||||
category="create"
|
||||
onPress={() => {
|
||||
handleCreate()
|
||||
}}
|
||||
// headerRight: () => (
|
||||
// <ButtonSaveHeader
|
||||
// disable={disableBtn || loading}
|
||||
// category="create"
|
||||
// onPress={() => {
|
||||
// handleCreate()
|
||||
// }}
|
||||
// />
|
||||
// ),
|
||||
header: () => (
|
||||
<AppHeader title="Tambah Kegiatan"
|
||||
showBack={true}
|
||||
onPressLeft={() => router.back()}
|
||||
right={
|
||||
<ButtonSaveHeader
|
||||
disable={disableBtn || loading}
|
||||
category="create"
|
||||
onPress={() => {
|
||||
handleCreate()
|
||||
}}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
),
|
||||
)
|
||||
}}
|
||||
/>
|
||||
<ScrollView
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import ButtonBackHeader from "@/components/buttonBackHeader";
|
||||
import AppHeader from "@/components/AppHeader";
|
||||
import ButtonSaveHeader from "@/components/buttonSaveHeader";
|
||||
import ImageUser from "@/components/imageNew";
|
||||
import ImageWithLabel from "@/components/imageWithLabel";
|
||||
@@ -11,8 +11,8 @@ import { setMemberChoose } from "@/lib/memberChoose";
|
||||
import { useAuthSession } from "@/providers/AuthProvider";
|
||||
import { AntDesign } from "@expo/vector-icons";
|
||||
import { router, Stack } from "expo-router";
|
||||
import { useEffect, useState } from "react";
|
||||
import { Pressable, SafeAreaView, ScrollView, View } from "react-native";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { Pressable, ScrollView, View } from "react-native";
|
||||
import Toast from "react-native-toast-message";
|
||||
import { useDispatch, useSelector } from "react-redux";
|
||||
|
||||
@@ -74,16 +74,31 @@ export default function AddMemberCreateProject() {
|
||||
<>
|
||||
<Stack.Screen
|
||||
options={{
|
||||
headerLeft: () => <ButtonBackHeader onPress={() => { router.back() }} />,
|
||||
// headerLeft: () => <ButtonBackHeader onPress={() => { router.back() }} />,
|
||||
headerTitle: 'Pilih Anggota',
|
||||
headerTitleAlign: 'center',
|
||||
headerRight: () => (
|
||||
<ButtonSaveHeader
|
||||
category="create"
|
||||
disable={selectMember.length > 0 ? false : true}
|
||||
onPress={() => {
|
||||
handleAddMember()
|
||||
}}
|
||||
// headerRight: () => (
|
||||
// <ButtonSaveHeader
|
||||
// category="create"
|
||||
// disable={selectMember.length > 0 ? false : true}
|
||||
// onPress={() => {
|
||||
// handleAddMember()
|
||||
// }}
|
||||
// />
|
||||
// )
|
||||
header: () => (
|
||||
<AppHeader title="Pilih Anggota"
|
||||
showBack={true}
|
||||
onPressLeft={() => router.back()}
|
||||
right={
|
||||
<ButtonSaveHeader
|
||||
category="create"
|
||||
disable={selectMember.length > 0 ? false : true}
|
||||
onPress={() => {
|
||||
handleAddMember()
|
||||
}}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
)
|
||||
}}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import ButtonBackHeader from "@/components/buttonBackHeader";
|
||||
import AppHeader from "@/components/AppHeader";
|
||||
import ButtonSaveHeader from "@/components/buttonSaveHeader";
|
||||
import { InputForm } from "@/components/inputForm";
|
||||
import ModalAddDetailTugasProject from "@/components/project/modalAddDetailTugasProject";
|
||||
@@ -12,7 +12,7 @@ import { router, Stack } from "expo-router";
|
||||
import 'intl';
|
||||
import 'intl/locale-data/jsonp/id';
|
||||
import moment from "moment";
|
||||
import { useEffect, useState } from "react";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import {
|
||||
KeyboardAvoidingView,
|
||||
Platform,
|
||||
@@ -122,22 +122,36 @@ export default function CreateProjectAddTask() {
|
||||
<SafeAreaView>
|
||||
<Stack.Screen
|
||||
options={{
|
||||
headerLeft: () => (
|
||||
<ButtonBackHeader
|
||||
onPress={() => {
|
||||
router.back();
|
||||
}}
|
||||
/>
|
||||
),
|
||||
// headerLeft: () => (
|
||||
// <ButtonBackHeader
|
||||
// onPress={() => {
|
||||
// router.back();
|
||||
// }}
|
||||
// />
|
||||
// ),
|
||||
headerTitle: "Tambah Tugas",
|
||||
headerTitleAlign: "center",
|
||||
headerRight: () => (
|
||||
<ButtonSaveHeader
|
||||
disable={disable}
|
||||
category="create"
|
||||
onPress={() => { handleCreate() }}
|
||||
// headerRight: () => (
|
||||
// <ButtonSaveHeader
|
||||
// disable={disable}
|
||||
// category="create"
|
||||
// onPress={() => { handleCreate() }}
|
||||
// />
|
||||
// ),
|
||||
header: () => (
|
||||
<AppHeader
|
||||
title="Tambah Tugas"
|
||||
showBack={true}
|
||||
onPressLeft={() => router.back()}
|
||||
right={
|
||||
<ButtonSaveHeader
|
||||
disable={disable}
|
||||
category="create"
|
||||
onPress={() => { handleCreate() }}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
),
|
||||
)
|
||||
}}
|
||||
/>
|
||||
<KeyboardAvoidingView
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import ButtonBackHeader from "@/components/buttonBackHeader";
|
||||
import AppHeader from "@/components/AppHeader";
|
||||
import ButtonSaveHeader from "@/components/buttonSaveHeader";
|
||||
import { InputForm } from "@/components/inputForm";
|
||||
import ModalAddDetailTugasProject from "@/components/project/modalAddDetailTugasProject";
|
||||
@@ -14,7 +14,7 @@ import { router, Stack, useLocalSearchParams } from "expo-router";
|
||||
import 'intl';
|
||||
import 'intl/locale-data/jsonp/id';
|
||||
import moment from "moment";
|
||||
import { useEffect, useState } from "react";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { KeyboardAvoidingView, Platform, Pressable, SafeAreaView, ScrollView, View } from "react-native";
|
||||
import Toast from "react-native-toast-message";
|
||||
import DateTimePicker, { DateType } from "react-native-ui-datepicker";
|
||||
@@ -172,14 +172,28 @@ export default function UpdateProjectTask() {
|
||||
<SafeAreaView>
|
||||
<Stack.Screen
|
||||
options={{
|
||||
headerLeft: () => <ButtonBackHeader onPress={() => { router.back() }} />,
|
||||
// headerLeft: () => <ButtonBackHeader onPress={() => { router.back() }} />,
|
||||
headerTitle: 'Edit Tanggal dan Tugas',
|
||||
headerTitleAlign: 'center',
|
||||
headerRight: () => <ButtonSaveHeader
|
||||
disable={disableBtn || loadingSubmit}
|
||||
category="update"
|
||||
onPress={() => { handleEdit() }}
|
||||
/>
|
||||
// headerRight: () => <ButtonSaveHeader
|
||||
// disable={disableBtn || loadingSubmit}
|
||||
// category="update"
|
||||
// onPress={() => { handleEdit() }}
|
||||
// />
|
||||
header: () => (
|
||||
<AppHeader
|
||||
title="Edit Tanggal dan Tugas"
|
||||
showBack={true}
|
||||
onPressLeft={() => router.back()}
|
||||
right={
|
||||
<ButtonSaveHeader
|
||||
disable={disableBtn || loadingSubmit}
|
||||
category="update"
|
||||
onPress={() => { handleEdit() }}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
)
|
||||
}}
|
||||
/>
|
||||
<KeyboardAvoidingView
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import AppHeader from "@/components/AppHeader";
|
||||
import BorderBottomItem from "@/components/borderBottomItem";
|
||||
import ButtonBackHeader from "@/components/buttonBackHeader";
|
||||
import ImageUser from "@/components/imageNew";
|
||||
import InputSearch from "@/components/inputSearch";
|
||||
import Text from '@/components/Text';
|
||||
@@ -82,9 +82,11 @@ export default function Search() {
|
||||
<SafeAreaView>
|
||||
<Stack.Screen
|
||||
options={{
|
||||
headerLeft: () => <ButtonBackHeader onPress={() => { router.back() }} />,
|
||||
headerTitle: 'Pencarian',
|
||||
headerTitleAlign: 'center'
|
||||
headerTitleAlign: 'center',
|
||||
header: () => (
|
||||
<AppHeader title="Pencarian" showBack={true} onPressLeft={() => router.back()} />
|
||||
)
|
||||
}}
|
||||
/>
|
||||
<View style={[Styles.p15]}>
|
||||
|
||||
33
components/AppHeader.tsx
Normal file
33
components/AppHeader.tsx
Normal file
@@ -0,0 +1,33 @@
|
||||
import { useRouter } from 'expo-router';
|
||||
import { StyleSheet, Text, View } from 'react-native';
|
||||
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
||||
import ButtonBackHeader from './buttonBackHeader';
|
||||
import Styles from '@/constants/Styles';
|
||||
|
||||
type Props = {
|
||||
title: string;
|
||||
right?: React.ReactNode;
|
||||
showBack?: boolean;
|
||||
onPressLeft?: () => void
|
||||
};
|
||||
|
||||
export default function AppHeader({ title, right, showBack = true, onPressLeft }: Props) {
|
||||
const insets = useSafeAreaInsets();
|
||||
const router = useRouter();
|
||||
|
||||
return (
|
||||
<View style={[Styles.headerContainer, { paddingTop: insets.top }]}>
|
||||
<View style={Styles.headerApp}>
|
||||
{showBack ? (
|
||||
<ButtonBackHeader onPress={onPressLeft} />
|
||||
) : (
|
||||
<View style={Styles.headerSide} />
|
||||
)}
|
||||
|
||||
<Text style={Styles.headerTitle}>{title}</Text>
|
||||
|
||||
<View style={Styles.headerSide}>{right}</View>
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
@@ -5,17 +5,27 @@ type Props = {
|
||||
title: string,
|
||||
desc: string
|
||||
onPress: () => void
|
||||
category?: string
|
||||
}
|
||||
|
||||
export default function AlertKonfirmasi({ title, desc, onPress }: Props) {
|
||||
Alert.alert(title, desc, [
|
||||
{
|
||||
text: 'Tidak',
|
||||
style: 'cancel',
|
||||
},
|
||||
{
|
||||
text: 'Ya',
|
||||
onPress: () => { onPress() }
|
||||
},
|
||||
]);
|
||||
export default function AlertKonfirmasi({ title, desc, onPress, category }: Props) {
|
||||
if (category == "warning") {
|
||||
Alert.alert(title, desc, [
|
||||
{
|
||||
text: 'Oke',
|
||||
style: 'cancel',
|
||||
},
|
||||
]);
|
||||
} else {
|
||||
Alert.alert(title, desc, [
|
||||
{
|
||||
text: 'Tidak',
|
||||
style: 'cancel',
|
||||
},
|
||||
{
|
||||
text: 'Ya',
|
||||
onPress: () => { onPress() }
|
||||
},
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -39,10 +39,10 @@ export default function ViewLogin({ onValidate }: Props) {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return Toast.show({ type: 'small', text1: response.message, position: 'top' })
|
||||
return Toast.show({ type: 'small', text1: response.message, position: 'bottom' })
|
||||
}
|
||||
} catch (error) {
|
||||
return Toast.show({ type: 'small', text1: `Terjadi kesalahan, coba lagi`, position: 'top' })
|
||||
return Toast.show({ type: 'small', text1: `Terjadi kesalahan, coba lagi`, position: 'bottom' })
|
||||
} finally {
|
||||
setLoadingLogin(false)
|
||||
}
|
||||
@@ -70,7 +70,7 @@ export default function ViewLogin({ onValidate }: Props) {
|
||||
type="numeric"
|
||||
placeholder="XXX-XXX-XXXX"
|
||||
round
|
||||
itemLeft={<Text>+62</Text>}
|
||||
itemLeft={<Text style={[Platform.OS === 'ios' && Styles.mt02]}>+62</Text>}
|
||||
info="Kami akan mengirim kode verifikasi melalui WhatsApp, guna mengonfirmasikan nomor Anda." />
|
||||
<ButtonForm
|
||||
text="MASUK"
|
||||
|
||||
@@ -28,7 +28,7 @@ export default function ViewVerification({ phone, otp }: Props) {
|
||||
const encrypted = await encryptToken(valueUser);
|
||||
signIn(encrypted);
|
||||
} else {
|
||||
return Toast.show({ type: 'small', text1: 'Terjadi kesalahan', position: 'top' })
|
||||
return Toast.show({ type: 'small', text1: 'Terjadi kesalahan', position: 'bottom' })
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ export default function ViewVerification({ phone, otp }: Props) {
|
||||
if (value === otpFix.toString()) {
|
||||
login()
|
||||
} else {
|
||||
return Toast.show({ type: 'small', text1: 'Kode OTP tidak sesuai', position: 'top' });
|
||||
return Toast.show({ type: 'small', text1: 'Kode OTP tidak sesuai', position: 'bottom' });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { ColorsStatus } from "@/constants/ColorsStatus";
|
||||
import Styles from "@/constants/Styles";
|
||||
import React from "react";
|
||||
import React, { useState } from "react";
|
||||
import { Dimensions, Pressable, View } from "react-native";
|
||||
import Text from "./Text";
|
||||
|
||||
@@ -11,6 +11,7 @@ type Props = {
|
||||
desc?: string
|
||||
rightTopInfo?: string
|
||||
onPress?: () => void
|
||||
onLongPress?: () => void
|
||||
borderType: 'all' | 'bottom' | 'none'
|
||||
leftBottomInfo?: React.ReactNode | string
|
||||
rightBottomInfo?: React.ReactNode | string
|
||||
@@ -18,21 +19,38 @@ type Props = {
|
||||
bgColor?: 'white' | 'transparent'
|
||||
width?: number
|
||||
descEllipsize?: boolean
|
||||
textColor?: string
|
||||
textColor?: string,
|
||||
colorPress?: boolean
|
||||
titleShowAll?: boolean
|
||||
}
|
||||
|
||||
export default function BorderBottomItem({ title, subtitle, icon, desc, onPress, rightTopInfo, borderType, leftBottomInfo, rightBottomInfo, titleWeight, bgColor, width, descEllipsize, textColor }: Props) {
|
||||
export default function BorderBottomItem({ title, subtitle, icon, desc, onPress, onLongPress, rightTopInfo, borderType, leftBottomInfo, rightBottomInfo, titleWeight, bgColor, width, descEllipsize, textColor, colorPress, titleShowAll }: Props) {
|
||||
const lebarDim = Dimensions.get("window").width;
|
||||
const lebar = width ? lebarDim * width / 100 : 'auto';
|
||||
const textColorFix = textColor ? textColor : 'black';
|
||||
const [isTap, setIsTap] = useState(false);
|
||||
|
||||
|
||||
return (
|
||||
<Pressable style={[borderType == 'bottom' ? Styles.wrapItemBorderBottom : borderType == 'all' ? Styles.wrapItemBorderAll : Styles.wrapItemBorderNone, bgColor && bgColor == 'white' && ColorsStatus.white]} onPress={onPress}>
|
||||
<Pressable onLongPress={onLongPress} onPress={onPress}
|
||||
onPressIn={() => setIsTap(true)}
|
||||
onPressOut={() => setIsTap(false)}
|
||||
style={({ pressed }) => [
|
||||
borderType == 'bottom'
|
||||
? Styles.wrapItemBorderBottom
|
||||
: borderType == 'all'
|
||||
? Styles.wrapItemBorderAll
|
||||
: Styles.wrapItemBorderNone,
|
||||
bgColor && bgColor == 'white' && ColorsStatus.white,
|
||||
// efek warna saat ditekan (sementara)
|
||||
isTap && colorPress && ColorsStatus.pressedGray,
|
||||
]}
|
||||
>
|
||||
<View style={[Styles.rowItemsCenter]}>
|
||||
{icon}
|
||||
<View style={[Styles.rowSpaceBetween, width ? { width: lebar } : { width: '88%' }]}>
|
||||
<View style={[Styles.ml10, rightTopInfo ? { width: '70%' } : { width: '90%' }]}>
|
||||
<Text style={[titleWeight == 'normal' ? Styles.textDefault : Styles.textDefaultSemiBold, { color: textColorFix }]} numberOfLines={1} ellipsizeMode='tail'>{title}</Text>
|
||||
<Text style={[titleWeight == 'normal' ? Styles.textDefault : Styles.textDefaultSemiBold, { color: textColorFix }]} numberOfLines={titleShowAll ? 0 : 1} ellipsizeMode='tail'>{title}</Text>
|
||||
{
|
||||
subtitle &&
|
||||
typeof subtitle == "string"
|
||||
@@ -52,16 +70,16 @@ export default function BorderBottomItem({ title, subtitle, icon, desc, onPress,
|
||||
{
|
||||
(leftBottomInfo || rightBottomInfo) &&
|
||||
(
|
||||
<View style={[Styles.rowSpaceBetween, Styles.mt10]}>
|
||||
<View style={[rightBottomInfo && !leftBottomInfo ? Styles.rowSpaceBetweenReverse : Styles.rowSpaceBetween, Styles.mt05]}>
|
||||
{
|
||||
typeof leftBottomInfo == 'string' ?
|
||||
<Text style={[Styles.textInformation, Styles.cGray, { textAlign: 'left' }]}>{leftBottomInfo}</Text>
|
||||
<Text style={[Styles.textInformation, Styles.cGray]}>{leftBottomInfo}</Text>
|
||||
:
|
||||
leftBottomInfo
|
||||
}
|
||||
{
|
||||
typeof rightBottomInfo == 'string' ?
|
||||
<Text style={[Styles.textInformation, Styles.mt05, Styles.cGray, { textAlign: 'right' }]}>{rightBottomInfo}</Text>
|
||||
<Text style={[Styles.textInformation, Styles.cGray]}>{rightBottomInfo}</Text>
|
||||
:
|
||||
rightBottomInfo
|
||||
}
|
||||
|
||||
149
components/borderBottomItem2.tsx
Normal file
149
components/borderBottomItem2.tsx
Normal file
@@ -0,0 +1,149 @@
|
||||
import { ColorsStatus } from "@/constants/ColorsStatus";
|
||||
import { ConstEnv } from "@/constants/ConstEnv";
|
||||
import Styles from "@/constants/Styles";
|
||||
import { Ionicons } from "@expo/vector-icons";
|
||||
import * as FileSystem from 'expo-file-system';
|
||||
import { startActivityAsync } from 'expo-intent-launcher';
|
||||
import * as Sharing from 'expo-sharing';
|
||||
import React, { useState } from "react";
|
||||
import { Alert, Dimensions, Platform, Pressable, View } from "react-native";
|
||||
import { ScrollView } from "react-native-gesture-handler";
|
||||
import * as mime from 'react-native-mime-types';
|
||||
import Text from "./Text";
|
||||
|
||||
|
||||
type Props = {
|
||||
title?: string
|
||||
subtitle?: string | React.ReactNode
|
||||
icon: React.ReactNode
|
||||
desc?: string
|
||||
rightTopInfo?: string
|
||||
onPress?: () => void
|
||||
onLongPress?: () => void
|
||||
borderType: 'all' | 'bottom' | 'none'
|
||||
leftBottomInfo?: React.ReactNode | string
|
||||
rightBottomInfo?: React.ReactNode | string
|
||||
titleWeight?: 'normal' | 'bold'
|
||||
bgColor?: 'white' | 'transparent'
|
||||
width?: number
|
||||
descEllipsize?: boolean
|
||||
textColor?: string,
|
||||
colorPress?: boolean
|
||||
titleShowAll?: boolean
|
||||
dataFile: { id: string; idStorage: string; name: string; extension: string }[]
|
||||
}
|
||||
|
||||
export default function BorderBottomItem2({ title, subtitle, icon, desc, onPress, onLongPress, rightTopInfo, borderType, leftBottomInfo, rightBottomInfo, titleWeight, bgColor, width, descEllipsize, textColor, colorPress, titleShowAll, dataFile }: Props) {
|
||||
const lebarDim = Dimensions.get("window").width;
|
||||
const lebar = width ? lebarDim * width / 100 : 'auto';
|
||||
const textColorFix = textColor ? textColor : 'black';
|
||||
const [isTap, setIsTap] = useState(false);
|
||||
const [loadingOpen, setLoadingOpen] = useState(false)
|
||||
|
||||
|
||||
const openFile = (item: { idStorage: string; name: string; extension: string }) => {
|
||||
if (Platform.OS == 'android') setLoadingOpen(true)
|
||||
let remoteUrl = ConstEnv.url_storage + '/files/' + item.idStorage;
|
||||
const fileName = item.name + '.' + item.extension;
|
||||
let localPath = `${FileSystem.documentDirectory}/${fileName}`;
|
||||
const mimeType = mime.lookup(fileName)
|
||||
|
||||
FileSystem.downloadAsync(remoteUrl, localPath).then(async ({ uri }) => {
|
||||
const contentURL = await FileSystem.getContentUriAsync(uri);
|
||||
setLoadingOpen(false)
|
||||
try {
|
||||
if (Platform.OS == 'android') {
|
||||
await startActivityAsync(
|
||||
'android.intent.action.VIEW',
|
||||
{
|
||||
data: contentURL,
|
||||
flags: 1,
|
||||
type: mimeType as string,
|
||||
}
|
||||
);
|
||||
} else if (Platform.OS == 'ios') {
|
||||
Sharing.shareAsync(localPath);
|
||||
}
|
||||
} catch (error) {
|
||||
Alert.alert('INFO', 'Gagal membuka file, tidak ada aplikasi yang dapat membuka file ini');
|
||||
} finally {
|
||||
if (Platform.OS == 'android') setLoadingOpen(false)
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
return (
|
||||
<Pressable onLongPress={onLongPress} onPress={onPress}
|
||||
onPressIn={() => setIsTap(true)}
|
||||
onPressOut={() => setIsTap(false)}
|
||||
style={({ pressed }) => [
|
||||
borderType == 'bottom'
|
||||
? Styles.wrapItemBorderBottom
|
||||
: borderType == 'all'
|
||||
? Styles.wrapItemBorderAll
|
||||
: Styles.wrapItemBorderNone,
|
||||
bgColor && bgColor == 'white' && ColorsStatus.white,
|
||||
// efek warna saat ditekan (sementara)
|
||||
isTap && colorPress && ColorsStatus.pressedGray,
|
||||
]}
|
||||
>
|
||||
<View style={[Styles.rowItemsCenter]}>
|
||||
{icon}
|
||||
<View style={[Styles.rowSpaceBetween, width ? { width: lebar } : { width: '88%' }]}>
|
||||
<View style={[Styles.ml10, rightTopInfo ? { width: '70%' } : { width: '90%' }]}>
|
||||
<Text style={[titleWeight == 'normal' ? Styles.textDefault : Styles.textDefaultSemiBold, { color: textColorFix }]} numberOfLines={titleShowAll ? 0 : 1} ellipsizeMode='tail'>{title}</Text>
|
||||
{
|
||||
subtitle &&
|
||||
typeof subtitle == "string"
|
||||
? <Text style={[Styles.textMediumNormal, { lineHeight: 15, color: textColorFix }]}>{subtitle}</Text>
|
||||
: <View style={{ alignItems: 'flex-start' }}>
|
||||
{subtitle}
|
||||
</View>
|
||||
}
|
||||
</View>
|
||||
{
|
||||
rightTopInfo && <Text style={[Styles.textInformation, Styles.mt05, { color: textColorFix }]}>{rightTopInfo}</Text>
|
||||
}
|
||||
</View>
|
||||
|
||||
</View>
|
||||
{desc && <Text style={[Styles.textDefault, Styles.mt05, { textAlign: 'left', color: textColorFix }]} numberOfLines={descEllipsize == false ? 0 : 2} ellipsizeMode='tail'>{desc}</Text>}
|
||||
{
|
||||
dataFile.length > 0 && (
|
||||
<ScrollView horizontal style={[Styles.mv05]} showsHorizontalScrollIndicator={false}>
|
||||
{dataFile.map((item, index) => (
|
||||
<Pressable
|
||||
key={index}
|
||||
style={[Styles.rowItemsCenter, Styles.borderAll, Styles.round10, Styles.ph05, Styles.pv03, Styles.mr05]}
|
||||
onPress={() => { openFile({ idStorage: item.idStorage, name: item.name, extension: item.extension }) }}
|
||||
>
|
||||
<Ionicons name="document-text" size={18} color="grey" style={Styles.mr05} />
|
||||
<Text style={[Styles.textInformation, Styles.cGray, Styles.mb05]}>{item.name}.{item.extension}</Text>
|
||||
</Pressable>
|
||||
))}
|
||||
</ScrollView>
|
||||
)
|
||||
}
|
||||
{
|
||||
(leftBottomInfo || rightBottomInfo) &&
|
||||
(
|
||||
<View style={[rightBottomInfo && !leftBottomInfo ? Styles.rowSpaceBetweenReverse : Styles.rowSpaceBetween, Styles.mt05]}>
|
||||
{
|
||||
typeof leftBottomInfo == 'string' ?
|
||||
<Text style={[Styles.textInformation, Styles.cGray]}>{leftBottomInfo}</Text>
|
||||
:
|
||||
leftBottomInfo
|
||||
}
|
||||
{
|
||||
typeof rightBottomInfo == 'string' ?
|
||||
<Text style={[Styles.textInformation, Styles.cGray]}>{rightBottomInfo}</Text>
|
||||
:
|
||||
rightBottomInfo
|
||||
}
|
||||
</View>
|
||||
)
|
||||
}
|
||||
</Pressable>
|
||||
)
|
||||
}
|
||||
@@ -15,16 +15,16 @@ export default function DiscussionItem({ title, user, date, onPress }: Props) {
|
||||
<Pressable style={[Styles.wrapItemDiscussion]} onPress={onPress}>
|
||||
<View style={[Styles.rowItemsCenter, Styles.mb10]}>
|
||||
<Ionicons name="chatbox-ellipses-outline" size={22} color="black" style={Styles.mr10} />
|
||||
<View style={[{flex:1}]}>
|
||||
<View style={[{ flex: 1 }]}>
|
||||
<Text style={{ fontWeight: 'bold' }} numberOfLines={1} ellipsizeMode="tail">{title}</Text>
|
||||
</View>
|
||||
</View>
|
||||
<View style={Styles.rowSpaceBetween}>
|
||||
<View style={Styles.rowItemsCenter}>
|
||||
<View style={[Styles.rowSpaceBetween]}>
|
||||
<View style={[Styles.rowItemsCenter, { flex: 1 }]}>
|
||||
<Feather name="user" size={18} color="grey" style={Styles.mr05} />
|
||||
<Text style={[Styles.textInformation]}>{user}</Text>
|
||||
<Text style={[Styles.textInformation]} numberOfLines={1} ellipsizeMode="tail">{user}</Text>
|
||||
</View>
|
||||
<View style={Styles.rowItemsCenter}>
|
||||
<View style={[Styles.rowItemsCenter, { flex: 1, justifyContent: 'flex-end' }]}>
|
||||
<Feather name="clock" size={18} color="grey" style={Styles.mr05} />
|
||||
<Text style={[Styles.textInformation]}>{date}</Text>
|
||||
</View>
|
||||
|
||||
@@ -57,7 +57,7 @@ export default function TaskDivisionDetail({ refreshing }: { refreshing: boolean
|
||||
:
|
||||
data.length > 0 ?
|
||||
data.map((item, index) => (
|
||||
<Pressable key={index} style={[Styles.wrapPaper]} onPress={() => { router.push(`/division/${id}/task/${item.idProject}`) }}>
|
||||
<Pressable key={index} style={[Styles.wrapPaper, Styles.mb05]} onPress={() => { router.push(`/division/${id}/task/${item.idProject}`) }}>
|
||||
<Text style={[Styles.textDefaultSemiBold]} numberOfLines={1} ellipsizeMode="tail">{item.title} - {item.projectTitle}</Text>
|
||||
<View style={[Styles.rowItemsCenter, Styles.mt10]}>
|
||||
<Feather name="clock" size={18} color="grey" style={Styles.mr05} />
|
||||
|
||||
@@ -6,17 +6,19 @@ type Props = {
|
||||
src: string,
|
||||
size?: 'sm' | 'xs' | 'lg'
|
||||
border?: boolean
|
||||
onError?: (val:boolean) => void
|
||||
}
|
||||
|
||||
export default function ImageUser({ src, size }: Props) {
|
||||
export default function ImageUser({ src, size, onError }: Props) {
|
||||
const [error, setError] = useState(false)
|
||||
return (
|
||||
<Image
|
||||
source={error ? require('../assets/images/user.jpg') : { uri: src }}
|
||||
style={[size == 'xs' ? Styles.userProfileExtraSmall : size == 'lg' ? Styles.userProfileBig : Styles.userProfileSmall, Styles.borderAll]}
|
||||
onError={() =>
|
||||
onError={() => {
|
||||
setError(true)
|
||||
}
|
||||
onError?.(true)
|
||||
}}
|
||||
/>
|
||||
)
|
||||
}
|
||||
@@ -20,10 +20,11 @@ type Props = {
|
||||
disable?: boolean
|
||||
multiline?: boolean
|
||||
mb?: boolean
|
||||
focus?: boolean
|
||||
};
|
||||
|
||||
|
||||
export function InputForm({ label, value, placeholder, onChange, info, disable, error, errorText, required, itemLeft, itemRight, type, round, width, bg, multiline, mb = true }: Props) {
|
||||
export function InputForm({ label, value, placeholder, onChange, info, disable, error, errorText, required, itemLeft, itemRight, type, round, width, bg, multiline, mb = true, focus }: Props) {
|
||||
const lebar = Dimensions.get("window").width;
|
||||
|
||||
if (itemLeft != undefined || itemRight != undefined) {
|
||||
|
||||
50
components/loadingOverlay.tsx
Normal file
50
components/loadingOverlay.tsx
Normal file
@@ -0,0 +1,50 @@
|
||||
import React from "react";
|
||||
import { View, ActivityIndicator, StyleSheet, Text } from "react-native";
|
||||
|
||||
type Props = {
|
||||
visible: boolean;
|
||||
text?: string;
|
||||
};
|
||||
|
||||
export default function LoadingOverlay({
|
||||
visible,
|
||||
text = "Loading...",
|
||||
}: Props) {
|
||||
if (!visible) return null;
|
||||
|
||||
return (
|
||||
<View style={styles.overlay}>
|
||||
<View style={styles.box}>
|
||||
<ActivityIndicator size="small" color="#2c3e50" />
|
||||
<Text style={styles.text}>{text}</Text>
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
overlay: {
|
||||
...StyleSheet.absoluteFillObject,
|
||||
backgroundColor: "rgba(0,0,0,0.35)",
|
||||
justifyContent: "center",
|
||||
alignItems: "center",
|
||||
zIndex: 9999,
|
||||
},
|
||||
box: {
|
||||
paddingVertical: 5,
|
||||
paddingHorizontal: 15,
|
||||
backgroundColor: "#fff",
|
||||
borderRadius: 8,
|
||||
alignItems: "center",
|
||||
elevation: 6, // Android
|
||||
shadowColor: "#000", // iOS
|
||||
shadowOpacity: 0.25,
|
||||
shadowRadius: 5,
|
||||
shadowOffset: { width: 0, height: 4 },
|
||||
},
|
||||
text: {
|
||||
marginTop: 5,
|
||||
fontSize: 14,
|
||||
color: "#2c3e50",
|
||||
},
|
||||
});
|
||||
@@ -67,7 +67,7 @@ export default function HeaderRightProjectDetail({ id, status }: Props) {
|
||||
return (
|
||||
<>
|
||||
<ButtonMenuHeader onPress={() => { setVisible(true) }} />
|
||||
<DrawerBottom animation="slide" isVisible={isVisible} setVisible={setVisible} title="Menu" height={30}>
|
||||
<DrawerBottom animation="slide" isVisible={isVisible} setVisible={setVisible} title="Menu" height={35}>
|
||||
<View style={Styles.rowItemsCenter}>
|
||||
<MenuItemRow
|
||||
icon={<AntDesign name="pluscircle" color="black" size={25} />}
|
||||
|
||||
@@ -69,7 +69,7 @@ export default function HeaderRightTaskDetail({ id, division, status, isAdminDiv
|
||||
return (
|
||||
<>
|
||||
<ButtonMenuHeader onPress={() => { setVisible(true) }} />
|
||||
<DrawerBottom animation="slide" isVisible={isVisible} setVisible={setVisible} title="Menu" height={30}>
|
||||
<DrawerBottom animation="slide" isVisible={isVisible} setVisible={setVisible} title="Menu" height={35}>
|
||||
<View style={Styles.rowItemsCenter}>
|
||||
<MenuItemRow
|
||||
icon={<AntDesign name="pluscircle" color="black" size={25} />}
|
||||
|
||||
5
constants/AssetsError.ts
Normal file
5
constants/AssetsError.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
import { Image } from "react-native";
|
||||
|
||||
export const assetUserImage = Image.resolveAssetSource(
|
||||
require('@/assets/images/user.jpg')
|
||||
);
|
||||
@@ -31,5 +31,8 @@ export const ColorsStatus = {
|
||||
},
|
||||
lightRed: {
|
||||
backgroundColor: '#ffcdcd'
|
||||
},
|
||||
pressedGray: {
|
||||
backgroundColor: '#e4e4e4'
|
||||
}
|
||||
}
|
||||
@@ -178,6 +178,9 @@ const Styles = StyleSheet.create({
|
||||
ph20: {
|
||||
paddingHorizontal: 20,
|
||||
},
|
||||
pv03: {
|
||||
paddingVertical: 3
|
||||
},
|
||||
pv05: {
|
||||
paddingVertical: 5
|
||||
},
|
||||
@@ -250,6 +253,10 @@ const Styles = StyleSheet.create({
|
||||
justifyContent: 'space-between',
|
||||
flexDirection: 'row'
|
||||
},
|
||||
rowSpaceBetweenReverse: {
|
||||
justifyContent: 'space-between',
|
||||
flexDirection: 'row-reverse'
|
||||
},
|
||||
rowItemsCenter: {
|
||||
flexDirection: 'row',
|
||||
alignItems: 'center'
|
||||
@@ -339,7 +346,9 @@ const Styles = StyleSheet.create({
|
||||
borderRadius: 15,
|
||||
backgroundColor: '#19345E',
|
||||
display: 'flex',
|
||||
width: '92%'
|
||||
width: '92%',
|
||||
resizeMode: 'stretch',
|
||||
overflow: 'hidden',
|
||||
},
|
||||
wrapGridContent: {
|
||||
shadowColor: '#171717',
|
||||
@@ -469,6 +478,7 @@ const Styles = StyleSheet.create({
|
||||
wrapHeadViewMember: {
|
||||
backgroundColor: '#19345E',
|
||||
paddingVertical: 30,
|
||||
paddingHorizontal: 15,
|
||||
alignItems: 'center',
|
||||
borderBottomLeftRadius: 25,
|
||||
borderBottomRightRadius: 25
|
||||
@@ -621,7 +631,27 @@ const Styles = StyleSheet.create({
|
||||
position: 'absolute',
|
||||
opacity: 0,
|
||||
zIndex: -1,
|
||||
}
|
||||
},
|
||||
headerContainer: {
|
||||
backgroundColor: '#19345E',
|
||||
},
|
||||
headerApp: {
|
||||
// height: 40,
|
||||
flexDirection: 'row',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'space-between',
|
||||
paddingHorizontal: 16,
|
||||
paddingVertical: 3
|
||||
},
|
||||
headerTitle: {
|
||||
color: '#fff',
|
||||
fontSize: 16,
|
||||
fontWeight: '600',
|
||||
},
|
||||
headerSide: {
|
||||
width: 40,
|
||||
alignItems: 'center',
|
||||
},
|
||||
})
|
||||
|
||||
export default Styles;
|
||||
@@ -394,7 +394,7 @@
|
||||
);
|
||||
OTHER_SWIFT_FLAGS = "$(inherited) -D EXPO_CONFIGURATION_DEBUG";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = mobiledarmasaba.app;
|
||||
PRODUCT_NAME = "Desa";
|
||||
PRODUCT_NAME = Desa;
|
||||
PROVISIONING_PROFILE_SPECIFIER = "";
|
||||
SWIFT_OBJC_BRIDGING_HEADER = "Desa/Desa-Bridging-Header.h";
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||
@@ -429,7 +429,7 @@
|
||||
);
|
||||
OTHER_SWIFT_FLAGS = "$(inherited) -D EXPO_CONFIGURATION_RELEASE";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = mobiledarmasaba.app;
|
||||
PRODUCT_NAME = "Desa";
|
||||
PRODUCT_NAME = Desa;
|
||||
PROVISIONING_PROFILE_SPECIFIER = "";
|
||||
SWIFT_OBJC_BRIDGING_HEADER = "Desa/Desa-Bridging-Header.h";
|
||||
SWIFT_VERSION = 5.0;
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>2.0.2</string>
|
||||
<string>2.0.5</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleURLTypes</key>
|
||||
@@ -39,7 +39,7 @@
|
||||
</dict>
|
||||
</array>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>4</string>
|
||||
<string>7</string>
|
||||
<key>ITSAppUsesNonExemptEncryption</key>
|
||||
<false/>
|
||||
<key>LSMinimumSystemVersion</key>
|
||||
|
||||
118
lib/api.ts
118
lib/api.ts
@@ -11,7 +11,20 @@ export const apiCheckPhoneLogin = async (body: { phone: string }) => {
|
||||
}
|
||||
|
||||
export const apiSendOtp = async (body: { phone: string, otp: number }) => {
|
||||
const res = await axios.get(`${Constants.expoConfig?.extra?.URL_OTP}/code?nom=${body.phone}&text=*Desa%2B*%0AMasukkan%20kode%20ini%20*${encodeURIComponent(body.otp)}*%20pada%20aplikasi%20Desa%2B%20anda.%20Jangan%20berikan%20pada%20siapapun.`)
|
||||
const message = "Desa+\nMasukkan kode ini " + body.otp + " pada aplikasi Desa+ anda. Jangan berikan pada siapapun."
|
||||
const textFix = encodeURIComponent(message)
|
||||
// const res = await axios.get(`${Constants.expoConfig?.extra?.URL_OTP}/code?nom=${body.phone}&text=*Desa%2B*%0AMasukkan%20kode%20ini%20*${encodeURIComponent(body.otp)}*%20pada%20aplikasi%20Desa%2B%20anda.%20Jangan%20berikan%20pada%20siapapun.`)
|
||||
const res = await fetch(
|
||||
`${Constants.expoConfig?.extra?.URL_OTP}/code?nom=${body.phone}&text=${textFix}`,
|
||||
{
|
||||
cache: "no-cache",
|
||||
headers: {
|
||||
Authorization: `Bearer ${Constants.expoConfig?.extra?.WA_SERVER_TOKEN}`,
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
return res.status
|
||||
}
|
||||
|
||||
@@ -182,6 +195,16 @@ export const apiSendDiscussionGeneralCommentar = async ({ id, data }: { id: stri
|
||||
return response.data;
|
||||
};
|
||||
|
||||
export const apiDeleteDiscussionGeneralCommentar = async ({ id, data }: { id: string, data: { user: string } }) => {
|
||||
const response = await api.delete(`/mobile/discussion-general/${id}/comment`, { data })
|
||||
return response.data;
|
||||
};
|
||||
|
||||
export const apiUpdateDiscussionGeneralCommentar = async ({ id, data }: { id: string, data: { desc: string, user: string } }) => {
|
||||
const response = await api.put(`/mobile/discussion-general/${id}/comment`, data)
|
||||
return response.data;
|
||||
};
|
||||
|
||||
|
||||
export const apiDeleteMemberDiscussionGeneral = async (data: { user: string, idUser: string }, id: string) => {
|
||||
await api.delete(`mobile/discussion-general/${id}/member`, { data }).then(response => {
|
||||
@@ -207,13 +230,32 @@ export const apiDeleteDiscussionGeneral = async (data: { user: string, active: b
|
||||
});
|
||||
};
|
||||
|
||||
export const apiEditDiscussionGeneral = async (data: { user: string, title: string, desc: string }, id: string) => {
|
||||
const response = await api.put(`/mobile/discussion-general/${id}`, data)
|
||||
// export const apiEditDiscussionGeneral = async (data: { user: string, title: string, desc: string }, id: string) => {
|
||||
// const response = await api.put(`/mobile/discussion-general/${id}`, data)
|
||||
// return response.data;
|
||||
// };
|
||||
|
||||
export const apiEditDiscussionGeneral = async (data: FormData, id: string) => {
|
||||
const response = await api.put(`/mobile/discussion-general/${id}`, data, {
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data',
|
||||
},
|
||||
})
|
||||
return response.data;
|
||||
};
|
||||
|
||||
export const apiCreateDiscussionGeneral = async ({ data }: { data: { idGroup: string, title: string, desc: string, user: string, member: [] } }) => {
|
||||
const response = await api.post(`/mobile/discussion-general`, data)
|
||||
// export const apiCreateDiscussionGeneral = async ({ data }: { data: { idGroup: string, title: string, desc: string, user: string, member: [] } }) => {
|
||||
// const response = await api.post(`/mobile/discussion-general`, data)
|
||||
// return response.data;
|
||||
// };
|
||||
|
||||
export const apiCreateDiscussionGeneral = async (data: FormData) => {
|
||||
// const response = await api.post(`/mobile/discussion-general`, data)
|
||||
const response = await api.post(`/mobile/discussion-general`, data, {
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data',
|
||||
},
|
||||
})
|
||||
return response.data;
|
||||
};
|
||||
|
||||
@@ -233,21 +275,41 @@ export const apiGetDivisionGroup = async ({ user }: { user: string }) => {
|
||||
return response.data;
|
||||
};
|
||||
|
||||
export const apiCreateAnnouncement = async ({ data }: { data: { title: string, desc: string, user: string, groups: any[] } }) => {
|
||||
const response = await api.post(`/mobile/announcement`, data)
|
||||
// export const apiCreateAnnouncement = async ({ data }: { data: { title: string, desc: string, user: string, groups: any[] } }) => {
|
||||
// const response = await api.post(`/mobile/announcement`, data)
|
||||
// return response.data;
|
||||
// };
|
||||
|
||||
export const apiCreateAnnouncement = async (data: FormData) => {
|
||||
const response = await api.post(`/mobile/announcement`, data, {
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data',
|
||||
},
|
||||
})
|
||||
return response.data;
|
||||
};
|
||||
|
||||
|
||||
export const apiGetAnnouncementOne = async ({ user, id }: { user: string, id: string }) => {
|
||||
const response = await api.get(`mobile/announcement/${id}?user=${user}`);
|
||||
return response.data;
|
||||
};
|
||||
|
||||
export const apiEditAnnouncement = async (data: { title: string, desc: string, user: string, groups: any[] }, id: string) => {
|
||||
const response = await api.put(`/mobile/announcement/${id}`, data)
|
||||
// export const apiEditAnnouncement = async (data: { title: string, desc: string, user: string, groups: any[], oldFile: any[] }, id: string) => {
|
||||
// const response = await api.put(`/mobile/announcement/${id}`, data)
|
||||
// return response.data;
|
||||
// };
|
||||
|
||||
export const apiEditAnnouncement = async (data: FormData, id: string) => {
|
||||
const response = await api.put(`/mobile/announcement/${id}`, data, {
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data',
|
||||
},
|
||||
})
|
||||
return response.data;
|
||||
};
|
||||
|
||||
|
||||
export const apiDeleteAnnouncement = async (data: { user: string }, id: string) => {
|
||||
const response = await api.delete(`mobile/announcement/${id}`, { data })
|
||||
return response.data
|
||||
@@ -435,7 +497,7 @@ export const apiGetDiscussion = async ({ user, search, division, active, page }:
|
||||
return response.data;
|
||||
};
|
||||
|
||||
export const apiGetDiscussionOne = async ({ id, user, cat }: { id: string, user: string, cat: 'data' | 'comment' }) => {
|
||||
export const apiGetDiscussionOne = async ({ id, user, cat }: { id: string, user: string, cat: 'data' | 'comment' | 'file' }) => {
|
||||
const response = await api.get(`mobile/discussion/${id}?user=${user}&cat=${cat}`);
|
||||
return response.data;
|
||||
};
|
||||
@@ -445,8 +507,27 @@ export const apiSendDiscussionCommentar = async ({ data, id }: { data: { user: s
|
||||
return response.data;
|
||||
};
|
||||
|
||||
export const apiEditDiscussion = async ({ data, id }: { data: { user: string, desc: string }, id: string }) => {
|
||||
const response = await api.post(`/mobile/discussion/${id}`, data)
|
||||
export const apiEditDiscussionCommentar = async ({ data, id }: { data: { user: string, comment: string }, id: string }) => {
|
||||
const response = await api.put(`/mobile/discussion/${id}/comment`, data)
|
||||
return response.data;
|
||||
};
|
||||
|
||||
export const apiDeleteDiscussionCommentar = async ({ data, id }: { data: { user: string }, id: string }) => {
|
||||
const response = await api.delete(`/mobile/discussion/${id}/comment`, { data })
|
||||
return response.data;
|
||||
};
|
||||
|
||||
// export const apiEditDiscussion = async ({ data, id }: { data: { user: string, desc: string }, id: string }) => {
|
||||
// const response = await api.post(`/mobile/discussion/${id}`, data)
|
||||
// return response.data;
|
||||
// };
|
||||
|
||||
export const apiEditDiscussion = async (data: FormData, id: string) => {
|
||||
const response = await api.post(`/mobile/discussion/${id}`, data, {
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data',
|
||||
},
|
||||
})
|
||||
return response.data;
|
||||
};
|
||||
|
||||
@@ -460,8 +541,17 @@ export const apiOpenCloseDiscussion = async (data: { user: string, status: numbe
|
||||
return response.data
|
||||
};
|
||||
|
||||
export const apiCreateDiscussion = async ({ data }: { data: { user: string, desc: string, idDivision: string } }) => {
|
||||
const response = await api.post(`/mobile/discussion`, data)
|
||||
// export const apiCreateDiscussion = async ({ data }: { data: { user: string, desc: string, idDivision: string } }) => {
|
||||
// const response = await api.post(`/mobile/discussion`, data)
|
||||
// return response.data;
|
||||
// };
|
||||
|
||||
export const apiCreateDiscussion = async (data: FormData) => {
|
||||
const response = await api.post(`/mobile/discussion`, data, {
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data',
|
||||
},
|
||||
})
|
||||
return response.data;
|
||||
};
|
||||
|
||||
|
||||
@@ -75,6 +75,7 @@
|
||||
"react-native-gesture-handler": "~2.24.0",
|
||||
"react-native-gifted-charts": "^1.4.57",
|
||||
"react-native-image-picker": "^8.2.1",
|
||||
"react-native-image-viewing": "^0.2.2",
|
||||
"react-native-mime-types": "^2.5.0",
|
||||
"react-native-modal": "^14.0.0-rc.1",
|
||||
"react-native-modal-datetime-picker": "^18.0.0",
|
||||
|
||||
Reference in New Issue
Block a user