Compare commits
42 Commits
amalia/03-
...
amalia/15-
| Author | SHA1 | Date | |
|---|---|---|---|
| 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 | |||
| f6ea4f65bb | |||
| 6069756d6f | |||
| 5de8962a0a | |||
| 67ac6d920c | |||
| f9c8c92d3b | |||
| 9b18322f38 | |||
| af24a8af23 | |||
| 95121d0442 | |||
| 5e1ed12ca8 | |||
| 9dde198d5e | |||
| 5fcabc5d77 | |||
| 9fa19af68b | |||
| d2cb7d7738 | |||
| a27c6181dd | |||
| c4e48726e0 |
@@ -4,7 +4,7 @@ export default {
|
||||
expo: {
|
||||
name: "Desa+",
|
||||
slug: "mobile-darmasaba",
|
||||
version: "2.0.1", // 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: "3",
|
||||
buildNumber: "7",
|
||||
infoPlist: {
|
||||
ITSAppUsesNonExemptEncryption: false,
|
||||
CFBundleDisplayName: "Desa+"
|
||||
@@ -23,7 +23,7 @@ export default {
|
||||
},
|
||||
android: {
|
||||
package: "mobiledarmasaba.app",
|
||||
versionCode: 10,
|
||||
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,
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -148,7 +148,7 @@ export default function RootLayout() {
|
||||
}}
|
||||
/>
|
||||
</Stack>
|
||||
<StatusBar style="inverted" translucent={false} backgroundColor="black" />
|
||||
<StatusBar style={'light'} translucent={false} backgroundColor="black" />
|
||||
<ToastCustom />
|
||||
</Provider>
|
||||
)
|
||||
|
||||
@@ -1,15 +1,22 @@
|
||||
import HeaderRightAnnouncementDetail from "@/components/announcement/headerAnnouncementDetail";
|
||||
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 +30,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,6 +80,37 @@ 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
|
||||
@@ -111,6 +158,7 @@ export default function DetailAnnouncement() {
|
||||
<RenderHTML
|
||||
contentWidth={contentWidth}
|
||||
source={{ html: data?.desc }}
|
||||
baseStyle={{ color: 'black' }}
|
||||
/>
|
||||
:
|
||||
<Text>{data?.desc}</Text>
|
||||
@@ -120,7 +168,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,14 +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 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 { SafeAreaView, ScrollView, StyleSheet, View } from "react-native";
|
||||
@@ -23,6 +27,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 +76,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,6 +108,25 @@ 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
|
||||
@@ -134,6 +177,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 +242,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,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 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 +37,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 +74,7 @@ export default function EditAnnouncement() {
|
||||
arrNew.push(newObject)
|
||||
})
|
||||
setDataMember(arrNew);
|
||||
setDataFile(response.file);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
@@ -112,9 +121,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,6 +149,35 @@ 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
|
||||
@@ -179,6 +230,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 +306,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>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -154,7 +154,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>
|
||||
|
||||
@@ -137,7 +137,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>
|
||||
|
||||
@@ -43,7 +43,7 @@ export default function BannerList() {
|
||||
try {
|
||||
const hasil = await decryptToken(String(token?.current));
|
||||
const deletedEntity = await apiDeleteBanner({ user: hasil }, dataId);
|
||||
if (deletedEntity.success) {
|
||||
if (deletedEntity.success ) {
|
||||
Toast.show({ type: 'small', text1: 'Berhasil menghapus data', })
|
||||
apiGetBanner({ user: hasil }).then((data) =>
|
||||
dispatch(setEntities(data.data))
|
||||
|
||||
@@ -1,24 +1,30 @@
|
||||
import AlertKonfirmasi from "@/components/alertKonfirmasi";
|
||||
import BorderBottomItem from "@/components/borderBottomItem";
|
||||
import BorderBottomItem2 from "@/components/borderBottomItem2";
|
||||
import ButtonBackHeader from "@/components/buttonBackHeader";
|
||||
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';
|
||||
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 Toast from "react-native-toast-message";
|
||||
import { useSelector } from "react-redux";
|
||||
|
||||
type Props = {
|
||||
@@ -37,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)
|
||||
@@ -53,6 +70,16 @@ export default function DetailDiscussionGeneral() {
|
||||
const arrSkeleton = Array.from({ length: 3 }, (_, index) => index)
|
||||
const reference = ref(getDB(), `/discussion-general/${id}`);
|
||||
const headerHeight = useHeaderHeight();
|
||||
const [detailMore, setDetailMore] = useState<any>([])
|
||||
const [loadingSendKomentar, setLoadingSendKomentar] = useState(false)
|
||||
const [isVisible, setVisible] = useState(false)
|
||||
const [selectKomentar, setSelectKomentar] = useState({
|
||||
id: '',
|
||||
comment: ''
|
||||
})
|
||||
const [viewEdit, setViewEdit] = useState(false)
|
||||
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
const onValueChange = reference.on('value', snapshot => {
|
||||
@@ -74,7 +101,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)
|
||||
@@ -91,6 +118,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) {
|
||||
@@ -111,23 +140,75 @@ export default function DetailDiscussionGeneral() {
|
||||
handleLoad('detail', true)
|
||||
handleLoad('komentar', true)
|
||||
handleLoad('cek-anggota', true)
|
||||
handleLoad('file', true)
|
||||
}, []);
|
||||
|
||||
async function handleKomentar() {
|
||||
try {
|
||||
setLoadingSendKomentar(true)
|
||||
if (komentar != '') {
|
||||
const hasil = await decryptToken(String(token?.current))
|
||||
const response = await apiSendDiscussionGeneralCommentar({ id: id, data: { desc: komentar, user: hasil } })
|
||||
if (response.success) {
|
||||
setKomentar('')
|
||||
updateTrigger()
|
||||
} else {
|
||||
Toast.show({ type: 'small', text1: response.message })
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
} finally {
|
||||
setLoadingSendKomentar(false)
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<Stack.Screen
|
||||
@@ -145,7 +226,8 @@ export default function DetailDiscussionGeneral() {
|
||||
loading ?
|
||||
<SkeletonContent />
|
||||
:
|
||||
<BorderBottomItem
|
||||
<BorderBottomItem2
|
||||
dataFile={fileDiscussion}
|
||||
descEllipsize={false}
|
||||
borderType="bottom"
|
||||
icon={
|
||||
@@ -153,7 +235,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" />
|
||||
@@ -188,12 +271,27 @@ 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) => {
|
||||
if (prev.includes(item.id)) {
|
||||
return prev.filter((id: string) => id !== item.id)
|
||||
} else {
|
||||
return [...prev, item.id]
|
||||
}
|
||||
})
|
||||
}}
|
||||
onLongPress={() => {
|
||||
item.idUser == entities.id && data?.status != 2 && data?.isActive && handleMenuKomentar(item.id, item.comment)
|
||||
}}
|
||||
/>
|
||||
)
|
||||
})
|
||||
@@ -209,32 +307,106 @@ export default function DetailDiscussionGeneral() {
|
||||
Styles.contentItemCenter,
|
||||
Styles.w100,
|
||||
{ backgroundColor: "#f4f4f4" },
|
||||
viewEdit && Styles.borderTop
|
||||
]}>
|
||||
<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={() => {
|
||||
(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={(komentar == '' || data?.status === 2 || !data?.isActive || (!memberDiscussion && (entityUser.role == "user" || entityUser.role == "coadmin"))) ? Styles.cGray : Styles.cDefault} />
|
||||
</Pressable>
|
||||
}
|
||||
/>
|
||||
{
|
||||
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>
|
||||
<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>
|
||||
}
|
||||
/>
|
||||
</>
|
||||
:
|
||||
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>
|
||||
</>
|
||||
)
|
||||
}
|
||||
@@ -2,8 +2,10 @@ 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 MenuItemRow from "@/components/menuItemRow";
|
||||
import ModalSelect from "@/components/modalSelect";
|
||||
import SelectForm from "@/components/selectForm";
|
||||
import Text from '@/components/Text';
|
||||
@@ -13,6 +15,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 +37,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 +102,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))
|
||||
@@ -181,6 +224,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 +303,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,17 @@
|
||||
import Text from "@/components/Text";
|
||||
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 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 +24,9 @@ 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<number>(0)
|
||||
const update = useSelector((state: any) => state.discussionGeneralDetailUpdate)
|
||||
const [dataForm, setDataForm] = useState({
|
||||
title: "",
|
||||
@@ -78,6 +88,25 @@ 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) {
|
||||
setFileForm([...fileForm.filter((val, i) => i !== index)])
|
||||
setModalFile(false)
|
||||
}
|
||||
|
||||
|
||||
async function handleEdit() {
|
||||
try {
|
||||
@@ -142,8 +171,38 @@ export default function EditDiscussionGeneral() {
|
||||
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>
|
||||
}
|
||||
</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>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,10 +1,17 @@
|
||||
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 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 +25,9 @@ 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<number>(0)
|
||||
|
||||
async function handleLoad() {
|
||||
try {
|
||||
@@ -49,7 +59,7 @@ export default function DiscussionDivisionEdit() {
|
||||
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 +70,27 @@ 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) {
|
||||
setFileForm([...fileForm.filter((val, i) => i !== index)])
|
||||
setModalFile(false)
|
||||
}
|
||||
|
||||
return (
|
||||
<SafeAreaView>
|
||||
<Stack.Screen
|
||||
@@ -95,8 +126,41 @@ export default function DiscussionDivisionEdit() {
|
||||
onChange={setData}
|
||||
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>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,27 +1,35 @@
|
||||
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";
|
||||
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 = {
|
||||
@@ -43,6 +51,9 @@ type PropsComment = {
|
||||
createdAt: string;
|
||||
username: string;
|
||||
img: string;
|
||||
idUser: string;
|
||||
isEdited: boolean;
|
||||
updatedAt: string;
|
||||
};
|
||||
|
||||
export default function DiscussionDetail() {
|
||||
@@ -63,6 +74,15 @@ export default function DiscussionDetail() {
|
||||
const reference = ref(getDB(), `/discussion-division/${detail}`);
|
||||
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(() => {
|
||||
@@ -170,6 +190,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)
|
||||
@@ -216,7 +289,7 @@ export default function DiscussionDetail() {
|
||||
loading ?
|
||||
<SkeletonContent />
|
||||
:
|
||||
<BorderBottomItem
|
||||
<BorderBottomItem2
|
||||
descEllipsize={false}
|
||||
borderType="bottom"
|
||||
icon={
|
||||
@@ -266,6 +339,7 @@ export default function DiscussionDetail() {
|
||||
<BorderBottomItem
|
||||
key={index}
|
||||
borderType="bottom"
|
||||
colorPress
|
||||
icon={
|
||||
<ImageUser
|
||||
src={`${ConstEnv.url_storage}/files/${item.img}`}
|
||||
@@ -275,7 +349,20 @@ export default function DiscussionDetail() {
|
||||
title={item.username}
|
||||
rightTopInfo={item.createdAt}
|
||||
desc={item.comment}
|
||||
descEllipsize={false}
|
||||
rightBottomInfo={item.isEdited ? "Edited" : ""}
|
||||
descEllipsize={detailMore.includes(item.id) ? false : true}
|
||||
onPress={() => {
|
||||
setDetailMore((prev: any) => {
|
||||
if (prev.includes(item.id)) {
|
||||
return prev.filter((id: string) => id !== item.id)
|
||||
} else {
|
||||
return [...prev, item.id]
|
||||
}
|
||||
})
|
||||
}}
|
||||
onLongPress={() => {
|
||||
item.idUser == entities.id && data?.status != 2 && data?.isActive && handleMenuKomentar(item.id, item.comment)
|
||||
}}
|
||||
/>
|
||||
))
|
||||
}
|
||||
@@ -292,65 +379,145 @@ export default function DiscussionDetail() {
|
||||
Styles.contentItemCenter,
|
||||
Styles.w100,
|
||||
{ backgroundColor: "#f4f4f4" },
|
||||
viewEdit && Styles.borderTop
|
||||
]}
|
||||
>
|
||||
<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 != "" &&
|
||||
!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 == "" ||
|
||||
loadingSend ||
|
||||
data?.status == 2 ||
|
||||
data?.isActive == false ||
|
||||
((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>
|
||||
<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>
|
||||
}
|
||||
/>
|
||||
</Pressable>
|
||||
}
|
||||
/>
|
||||
</>
|
||||
:
|
||||
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,24 @@
|
||||
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 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,6 +26,29 @@ 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 {
|
||||
@@ -64,8 +95,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>
|
||||
)
|
||||
}
|
||||
@@ -12,7 +12,7 @@ import { useAuthSession } from "@/providers/AuthProvider";
|
||||
import { AntDesign } from "@expo/vector-icons";
|
||||
import { router, Stack, useLocalSearchParams } from "expo-router";
|
||||
import { useEffect, useState } from "react";
|
||||
import { Pressable, SafeAreaView, ScrollView, View } from "react-native";
|
||||
import { Pressable, ScrollView, View } from "react-native";
|
||||
import Toast from "react-native-toast-message";
|
||||
import { useDispatch, useSelector } from "react-redux";
|
||||
|
||||
@@ -94,7 +94,7 @@ export default function AddMemberTask() {
|
||||
|
||||
|
||||
return (
|
||||
<SafeAreaView>
|
||||
<>
|
||||
<Stack.Screen
|
||||
options={{
|
||||
headerLeft: () => <ButtonBackHeader onPress={() => { router.back() }} />,
|
||||
@@ -111,7 +111,7 @@ export default function AddMemberTask() {
|
||||
)
|
||||
}}
|
||||
/>
|
||||
<View style={[Styles.p15, Styles.mb100]}>
|
||||
<View style={[Styles.p15, { flex: 1 }]}>
|
||||
<InputSearch onChange={(val) => setSearch(val)} value={search} />
|
||||
|
||||
{
|
||||
@@ -172,6 +172,6 @@ export default function AddMemberTask() {
|
||||
}
|
||||
</ScrollView>
|
||||
</View>
|
||||
</SafeAreaView>
|
||||
</>
|
||||
)
|
||||
}
|
||||
@@ -12,7 +12,7 @@ import { useAuthSession } from "@/providers/AuthProvider";
|
||||
import { AntDesign } from "@expo/vector-icons";
|
||||
import { router, Stack, useLocalSearchParams } from "expo-router";
|
||||
import { useEffect, useState } from "react";
|
||||
import { Pressable, SafeAreaView, ScrollView, View } from "react-native";
|
||||
import { Pressable, ScrollView, View } from "react-native";
|
||||
import Toast from "react-native-toast-message";
|
||||
import { useDispatch, useSelector } from "react-redux";
|
||||
|
||||
@@ -64,7 +64,7 @@ export default function AddMemberCreateTask() {
|
||||
|
||||
|
||||
return (
|
||||
<SafeAreaView>
|
||||
<>
|
||||
<Stack.Screen
|
||||
options={{
|
||||
headerLeft: () => <ButtonBackHeader onPress={() => { router.back() }} />,
|
||||
@@ -81,7 +81,7 @@ export default function AddMemberCreateTask() {
|
||||
)
|
||||
}}
|
||||
/>
|
||||
<View style={[Styles.p15]}>
|
||||
<View style={[Styles.p15, { flex: 1 }]}>
|
||||
<InputSearch onChange={(val) => setSearch(val)} value={search} />
|
||||
|
||||
{
|
||||
@@ -138,6 +138,6 @@ export default function AddMemberCreateTask() {
|
||||
}
|
||||
</ScrollView>
|
||||
</View>
|
||||
</SafeAreaView>
|
||||
</>
|
||||
)
|
||||
}
|
||||
@@ -99,14 +99,18 @@ export default function CreateTaskAddTugas() {
|
||||
timeStart: item.timeStart,
|
||||
timeEnd: item.timeEnd,
|
||||
}))
|
||||
dispatch(setTaskCreate([...taskCreate, {
|
||||
const hasilOrder = [...taskCreate, {
|
||||
title: title,
|
||||
dateStart: from,
|
||||
dateEnd: to,
|
||||
dateStartFix: formatDateOnly(range.startDate, "YYYY-MM-DD"),
|
||||
dateEndFix: formatDateOnly(range.endDate, "YYYY-MM-DD"),
|
||||
dataDetail: dataDetailFix
|
||||
}]))
|
||||
}].sort((a, b) => {
|
||||
return new Date(a.dateStartFix).getTime() - new Date(b.dateStartFix).getTime();
|
||||
});
|
||||
|
||||
dispatch(setTaskCreate(hasilOrder))
|
||||
router.back();
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
|
||||
@@ -97,7 +97,7 @@ export default function AddMemberDivision() {
|
||||
|
||||
|
||||
return (
|
||||
<SafeAreaView>
|
||||
<>
|
||||
<Stack.Screen
|
||||
options={{
|
||||
headerLeft: () => <ButtonBackHeader onPress={() => { router.back() }} />,
|
||||
@@ -114,7 +114,7 @@ export default function AddMemberDivision() {
|
||||
)
|
||||
}}
|
||||
/>
|
||||
<View style={[Styles.p15]}>
|
||||
<View style={[Styles.p15, { flex: 1 }]}>
|
||||
<InputSearch onChange={(val) => handleSearch(val)} value={search} />
|
||||
|
||||
{
|
||||
@@ -175,6 +175,6 @@ export default function AddMemberDivision() {
|
||||
}
|
||||
</ScrollView>
|
||||
</View>
|
||||
</SafeAreaView>
|
||||
</>
|
||||
)
|
||||
}
|
||||
@@ -1,22 +1,28 @@
|
||||
import AlertKonfirmasi from "@/components/alertKonfirmasi";
|
||||
import ButtonBackHeader from "@/components/buttonBackHeader";
|
||||
import ButtonNextHeader from "@/components/buttonNextHeader";
|
||||
import { InputForm } from "@/components/inputForm";
|
||||
import ModalSelect from "@/components/modalSelect";
|
||||
import SelectForm from "@/components/selectForm";
|
||||
import Styles from "@/constants/Styles";
|
||||
import { apiCheckDivisionName } from "@/lib/api";
|
||||
import { setFormCreateDivision } from "@/lib/divisionCreate";
|
||||
import { useAuthSession } from "@/providers/AuthProvider";
|
||||
import { router, Stack } from "expo-router";
|
||||
import { useEffect, 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 CreateDivision() {
|
||||
const [isSelect, setSelect] = useState(false);
|
||||
const [chooseGroup, setChooseGroup] = useState({ val: "", label: "" });
|
||||
const dispatch = useDispatch();
|
||||
const update = useSelector((state: any) => state.divisionCreate);
|
||||
const { token, decryptToken } = useAuthSession()
|
||||
const [isSelect, setSelect] = useState(false)
|
||||
const [chooseGroup, setChooseGroup] = useState({ val: "", label: "" })
|
||||
const dispatch = useDispatch()
|
||||
const update = useSelector((state: any) => state.divisionCreate)
|
||||
const entityUser = useSelector((state: any) => state.user)
|
||||
const userLogin = useSelector((state: any) => state.entities)
|
||||
const [loadingBtn, setLoadingBtn] = useState(false)
|
||||
const [error, setError] = useState({
|
||||
idGroup: false,
|
||||
name: false,
|
||||
@@ -54,7 +60,34 @@ export default function CreateDivision() {
|
||||
}
|
||||
}
|
||||
|
||||
function handleSetData() {
|
||||
async function handleCheckName() {
|
||||
try {
|
||||
setLoadingBtn(true)
|
||||
const hasil = await decryptToken(String(token?.current))
|
||||
const response = await apiCheckDivisionName({ data: { ...dataForm }, user: hasil })
|
||||
if (response.success) {
|
||||
if (!response.available) {
|
||||
AlertKonfirmasi({
|
||||
title: 'Peringatan',
|
||||
category: 'warning',
|
||||
desc: 'Nama divisi sudah ada. Tidak dapat membuat divisi dengan nama yang sama',
|
||||
onPress: () => { }
|
||||
})
|
||||
} else {
|
||||
handleSetData()
|
||||
}
|
||||
} else {
|
||||
Toast.show({ type: 'small', text1: response.message, })
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
Toast.show({ type: 'small', text1: 'Terjadi kesalahan', })
|
||||
} finally {
|
||||
setLoadingBtn(false)
|
||||
}
|
||||
}
|
||||
|
||||
async function handleSetData() {
|
||||
dispatch(setFormCreateDivision({ ...update, data: dataForm }))
|
||||
router.push(`./create/add-member`)
|
||||
}
|
||||
@@ -80,8 +113,8 @@ export default function CreateDivision() {
|
||||
headerTitleAlign: "center",
|
||||
headerRight: () => (
|
||||
<ButtonNextHeader
|
||||
onPress={() => { handleSetData() }}
|
||||
disable={error.idGroup || error.name || chooseGroup.val == "" || chooseGroup.val == "null" || dataForm.name == "" || dataForm.name == "null"}
|
||||
onPress={() => { handleCheckName() }}
|
||||
disable={loadingBtn || error.idGroup || error.name || chooseGroup.val == "" || chooseGroup.val == "null" || dataForm.name == "" || dataForm.name == "null"}
|
||||
/>
|
||||
),
|
||||
}}
|
||||
|
||||
@@ -74,7 +74,7 @@ export default function CreateDivisionAddAdmin() {
|
||||
|
||||
|
||||
return (
|
||||
<SafeAreaView>
|
||||
<>
|
||||
<Stack.Screen
|
||||
options={{
|
||||
headerLeft: () => <ButtonBackHeader onPress={() => { router.back() }} />,
|
||||
@@ -91,7 +91,7 @@ export default function CreateDivisionAddAdmin() {
|
||||
)
|
||||
}}
|
||||
/>
|
||||
<View style={[Styles.p15]}>
|
||||
<View style={[Styles.p15, { flex: 1 }]}>
|
||||
<ScrollView>
|
||||
{
|
||||
data.length > 0 ?
|
||||
@@ -126,6 +126,6 @@ export default function CreateDivisionAddAdmin() {
|
||||
}
|
||||
</ScrollView>
|
||||
</View>
|
||||
</SafeAreaView>
|
||||
</>
|
||||
)
|
||||
}
|
||||
@@ -12,7 +12,7 @@ import { useAuthSession } from "@/providers/AuthProvider";
|
||||
import { AntDesign } from "@expo/vector-icons";
|
||||
import { router, Stack, useLocalSearchParams } from "expo-router";
|
||||
import { useEffect, useState } from "react";
|
||||
import { Pressable, SafeAreaView, ScrollView, View } from "react-native";
|
||||
import { Pressable, ScrollView, View } from "react-native";
|
||||
import { useDispatch, useSelector } from "react-redux";
|
||||
|
||||
type Props = {
|
||||
@@ -60,7 +60,7 @@ export default function CreateDivisionAddMember() {
|
||||
|
||||
|
||||
return (
|
||||
<SafeAreaView>
|
||||
<>
|
||||
<Stack.Screen
|
||||
options={{
|
||||
headerLeft: () => <ButtonBackHeader onPress={() => { router.back() }} />,
|
||||
@@ -74,7 +74,7 @@ export default function CreateDivisionAddMember() {
|
||||
)
|
||||
}}
|
||||
/>
|
||||
<View style={[Styles.p15]}>
|
||||
<View style={[Styles.p15, { flex: 1 }]}>
|
||||
<InputSearch onChange={(val) => setSearch(val)} value={search} />
|
||||
|
||||
{
|
||||
@@ -135,6 +135,6 @@ export default function CreateDivisionAddMember() {
|
||||
}
|
||||
</ScrollView>
|
||||
</View>
|
||||
</SafeAreaView>
|
||||
</>
|
||||
)
|
||||
}
|
||||
@@ -12,6 +12,7 @@ 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 Toast from "react-native-toast-message";
|
||||
import { useSelector } from "react-redux";
|
||||
|
||||
type Props = {
|
||||
@@ -42,10 +43,15 @@ export default function MemberDetail() {
|
||||
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)
|
||||
}
|
||||
@@ -84,7 +90,7 @@ export default function MemberDetail() {
|
||||
/>
|
||||
}
|
||||
>
|
||||
<View style={[Styles.wrapHeadViewMember,]}>
|
||||
<View style={[Styles.wrapHeadViewMember]}>
|
||||
{
|
||||
loading ?
|
||||
<>
|
||||
|
||||
@@ -12,7 +12,7 @@ import { useAuthSession } from "@/providers/AuthProvider";
|
||||
import { AntDesign } from "@expo/vector-icons";
|
||||
import { router, Stack, useLocalSearchParams } from "expo-router";
|
||||
import { useEffect, useState } from "react";
|
||||
import { Pressable, SafeAreaView, ScrollView, View } from "react-native";
|
||||
import { Pressable, ScrollView, View } from "react-native";
|
||||
import Toast from "react-native-toast-message";
|
||||
import { useDispatch, useSelector } from "react-redux";
|
||||
|
||||
@@ -94,7 +94,7 @@ export default function AddMemberProject() {
|
||||
|
||||
|
||||
return (
|
||||
<SafeAreaView>
|
||||
<>
|
||||
<Stack.Screen
|
||||
options={{
|
||||
headerLeft: () => <ButtonBackHeader onPress={() => { router.back() }} />,
|
||||
@@ -111,7 +111,7 @@ export default function AddMemberProject() {
|
||||
)
|
||||
}}
|
||||
/>
|
||||
<View style={[Styles.p15, Styles.mb100]}>
|
||||
<View style={[Styles.p15, { flex: 1 }]}>
|
||||
<InputSearch onChange={(val) => handleSearch(val)} value={search} />
|
||||
{
|
||||
selectMember.length > 0
|
||||
@@ -176,6 +176,6 @@ export default function AddMemberProject() {
|
||||
}
|
||||
</ScrollView>
|
||||
</View>
|
||||
</SafeAreaView>
|
||||
</>
|
||||
)
|
||||
}
|
||||
@@ -71,7 +71,7 @@ export default function AddMemberCreateProject() {
|
||||
|
||||
|
||||
return (
|
||||
<SafeAreaView>
|
||||
<>
|
||||
<Stack.Screen
|
||||
options={{
|
||||
headerLeft: () => <ButtonBackHeader onPress={() => { router.back() }} />,
|
||||
@@ -88,7 +88,7 @@ export default function AddMemberCreateProject() {
|
||||
)
|
||||
}}
|
||||
/>
|
||||
<View style={[Styles.p15]}>
|
||||
<View style={[Styles.p15, { flex: 1 }]}>
|
||||
<InputSearch onChange={(val) => setSearch(val)} value={search} />
|
||||
|
||||
{
|
||||
@@ -145,6 +145,6 @@ export default function AddMemberCreateProject() {
|
||||
}
|
||||
</ScrollView>
|
||||
</View>
|
||||
</SafeAreaView>
|
||||
</>
|
||||
)
|
||||
}
|
||||
@@ -99,14 +99,19 @@ export default function CreateProjectAddTask() {
|
||||
timeStart: item.timeStart,
|
||||
timeEnd: item.timeEnd,
|
||||
}))
|
||||
dispatch(setTaskCreate([...taskCreate, {
|
||||
|
||||
const hasilOrder = [...taskCreate, {
|
||||
title: title,
|
||||
dateStart: from,
|
||||
dateEnd: to,
|
||||
dateStartFix: formatDateOnly(range.startDate, "YYYY-MM-DD"),
|
||||
dateEndFix: formatDateOnly(range.endDate, "YYYY-MM-DD"),
|
||||
dataDetail: dataDetailFix
|
||||
}]))
|
||||
}].sort((a, b) => {
|
||||
return new Date(a.dateStartFix).getTime() - new Date(b.dateStartFix).getTime();
|
||||
});
|
||||
|
||||
dispatch(setTaskCreate(hasilOrder))
|
||||
router.back();
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
|
||||
@@ -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() }
|
||||
},
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -50,7 +50,7 @@ export default function ViewLogin({ onValidate }: Props) {
|
||||
|
||||
return (
|
||||
<SafeAreaView>
|
||||
<StatusBar style={Platform.OS === 'ios' ? 'auto' : 'light'} translucent={false} backgroundColor="black" />
|
||||
<StatusBar style={Platform.OS === 'ios' ? 'dark' : 'light'} translucent={false} backgroundColor="black" />
|
||||
<ToastCustom />
|
||||
<View style={[Styles.p20, Styles.h100]}>
|
||||
<View style={{ alignItems: "center", marginTop: 70, marginBottom: 50 }}>
|
||||
|
||||
@@ -57,7 +57,7 @@ export default function ViewVerification({ phone, otp }: Props) {
|
||||
|
||||
return (
|
||||
<>
|
||||
<StatusBar style={Platform.OS === 'ios' ? 'auto' : 'light'} translucent={false} backgroundColor="black" />
|
||||
<StatusBar style={Platform.OS === 'ios' ? 'dark' : 'light'} translucent={false} backgroundColor="black" />
|
||||
<ToastCustom />
|
||||
<View style={Styles.wrapLogin} >
|
||||
<View style={{ alignItems: "center", marginTop: 70, marginBottom: 50 }}>
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
106
components/borderBottomItem2.tsx
Normal file
106
components/borderBottomItem2.tsx
Normal file
@@ -0,0 +1,106 @@
|
||||
import { ColorsStatus } from "@/constants/ColorsStatus";
|
||||
import Styles from "@/constants/Styles";
|
||||
import { Ionicons, Entypo, EvilIcons } from "@expo/vector-icons";
|
||||
import React, { useState } from "react";
|
||||
import { Dimensions, Pressable, View } from "react-native";
|
||||
import { ScrollView } from "react-native-gesture-handler";
|
||||
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);
|
||||
|
||||
|
||||
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) => (
|
||||
<View key={index} style={[Styles.rowItemsCenter, Styles.borderAll, Styles.round10, Styles.ph05, Styles.pv03, Styles.mr05]}>
|
||||
<Ionicons name="document-text" size={18} color="grey" style={Styles.mr05} />
|
||||
<Text style={[Styles.textInformation, Styles.cGray, Styles.mb05]}>{item.name}.{item.extension}</Text>
|
||||
</View>
|
||||
))}
|
||||
</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} />
|
||||
|
||||
@@ -15,7 +15,7 @@ export default function EventItem({ category, title, user, jamAwal, jamAkhir, on
|
||||
return (
|
||||
<Pressable style={[Styles.itemEvent, { backgroundColor: category == 'orange' ? '#FED6C5' : '#D8D8F1' }]} onPress={onPress}>
|
||||
<View style={[Styles.dividerEvent, { backgroundColor: category == 'orange' ? '#FB804C' : '#535FCA' }]} />
|
||||
<View>
|
||||
<View style={[Styles.w90]}>
|
||||
<Text>{jamAwal} - {jamAkhir}</Text>
|
||||
<Text numberOfLines={1} ellipsizeMode="tail" style={[Styles.textDefaultSemiBold, Styles.mv05]}>{title}</Text>
|
||||
<Text numberOfLines={1} ellipsizeMode="tail">Dibuat oleh : {user}</Text>
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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} />}
|
||||
|
||||
@@ -31,5 +31,8 @@ export const ColorsStatus = {
|
||||
},
|
||||
lightRed: {
|
||||
backgroundColor: '#ffcdcd'
|
||||
},
|
||||
pressedGray: {
|
||||
backgroundColor: '#e4e4e4'
|
||||
}
|
||||
}
|
||||
1
constants/OnlySpaceOrEnter.ts
Normal file
1
constants/OnlySpaceOrEnter.ts
Normal file
@@ -0,0 +1 @@
|
||||
export const regexOnlySpacesOrEnter = /^[\s\r\n]+$/;
|
||||
@@ -178,6 +178,9 @@ const Styles = StyleSheet.create({
|
||||
ph20: {
|
||||
paddingHorizontal: 20,
|
||||
},
|
||||
pv03: {
|
||||
paddingVertical: 3
|
||||
},
|
||||
pv05: {
|
||||
paddingVertical: 5
|
||||
},
|
||||
@@ -187,6 +190,9 @@ const Styles = StyleSheet.create({
|
||||
pv15: {
|
||||
paddingVertical: 15
|
||||
},
|
||||
pv20: {
|
||||
paddingVertical: 20
|
||||
},
|
||||
p15: {
|
||||
padding: 15
|
||||
},
|
||||
@@ -247,6 +253,10 @@ const Styles = StyleSheet.create({
|
||||
justifyContent: 'space-between',
|
||||
flexDirection: 'row'
|
||||
},
|
||||
rowSpaceBetweenReverse: {
|
||||
justifyContent: 'space-between',
|
||||
flexDirection: 'row-reverse'
|
||||
},
|
||||
rowItemsCenter: {
|
||||
flexDirection: 'row',
|
||||
alignItems: 'center'
|
||||
@@ -336,7 +346,9 @@ const Styles = StyleSheet.create({
|
||||
borderRadius: 15,
|
||||
backgroundColor: '#19345E',
|
||||
display: 'flex',
|
||||
width: '92%'
|
||||
width: '92%',
|
||||
resizeMode: 'stretch',
|
||||
overflow: 'hidden',
|
||||
},
|
||||
wrapGridContent: {
|
||||
shadowColor: '#171717',
|
||||
@@ -466,6 +478,7 @@ const Styles = StyleSheet.create({
|
||||
wrapHeadViewMember: {
|
||||
backgroundColor: '#19345E',
|
||||
paddingVertical: 30,
|
||||
paddingHorizontal: 15,
|
||||
alignItems: 'center',
|
||||
borderBottomLeftRadius: 25,
|
||||
borderBottomRightRadius: 25
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>2.0.1</string>
|
||||
<string>2.0.5</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleURLTypes</key>
|
||||
@@ -39,7 +39,7 @@
|
||||
</dict>
|
||||
</array>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>3</string>
|
||||
<string>7</string>
|
||||
<key>ITSAppUsesNonExemptEncryption</key>
|
||||
<false/>
|
||||
<key>LSMinimumSystemVersion</key>
|
||||
|
||||
81
lib/api.ts
81
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 => {
|
||||
@@ -212,8 +235,18 @@ export const apiEditDiscussionGeneral = async (data: { user: string, title: stri
|
||||
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 +266,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
|
||||
@@ -425,6 +478,10 @@ export const apiCreateDivision = async (data: { data: { idGroup: string, name: s
|
||||
return response.data;
|
||||
};
|
||||
|
||||
export const apiCheckDivisionName = async (data: { data: { idGroup: string, name: string, desc: string }, user: string }) => {
|
||||
const response = await api.put(`/mobile/division`, data)
|
||||
return response.data;
|
||||
};
|
||||
|
||||
export const apiGetDiscussion = async ({ user, search, division, active, page }: { user: string, search: string, division: string, active?: string, page?: number }) => {
|
||||
const response = await api.get(`mobile/discussion?user=${user}&active=${active}&search=${search}&division=${division}&page=${page}`);
|
||||
@@ -441,6 +498,16 @@ export const apiSendDiscussionCommentar = async ({ data, id }: { data: { user: s
|
||||
return response.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;
|
||||
|
||||
Reference in New Issue
Block a user