upd: diskusi umum
deskripsi : - integrasi api tambah data diskusi umum - integrasi api detail data diskusi umum file No Issues
This commit is contained in:
@@ -47,6 +47,13 @@ type PropsKomentar = {
|
|||||||
updatedAt: string
|
updatedAt: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type PropsFile = {
|
||||||
|
id: string;
|
||||||
|
idStorage: string;
|
||||||
|
name: string;
|
||||||
|
extension: string
|
||||||
|
}
|
||||||
|
|
||||||
export default function DetailDiscussionGeneral() {
|
export default function DetailDiscussionGeneral() {
|
||||||
const { token, decryptToken } = useAuthSession()
|
const { token, decryptToken } = useAuthSession()
|
||||||
const entityUser = useSelector((state: any) => state.user)
|
const entityUser = useSelector((state: any) => state.user)
|
||||||
@@ -55,6 +62,7 @@ export default function DetailDiscussionGeneral() {
|
|||||||
const [data, setData] = useState<Props>()
|
const [data, setData] = useState<Props>()
|
||||||
const [dataKomentar, setDataKomentar] = useState<PropsKomentar[]>([])
|
const [dataKomentar, setDataKomentar] = useState<PropsKomentar[]>([])
|
||||||
const [memberDiscussion, setMemberDiscussion] = useState(false)
|
const [memberDiscussion, setMemberDiscussion] = useState(false)
|
||||||
|
const [fileDiscussion, setFileDiscussion] = useState<PropsFile[]>([])
|
||||||
const [komentar, setKomentar] = useState('')
|
const [komentar, setKomentar] = useState('')
|
||||||
const update = useSelector((state: any) => state.discussionGeneralDetailUpdate)
|
const update = useSelector((state: any) => state.discussionGeneralDetailUpdate)
|
||||||
const [loading, setLoading] = useState(true)
|
const [loading, setLoading] = useState(true)
|
||||||
@@ -93,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 {
|
try {
|
||||||
if (cat == "detail") {
|
if (cat == "detail") {
|
||||||
setLoading(loading)
|
setLoading(loading)
|
||||||
@@ -110,6 +118,8 @@ export default function DetailDiscussionGeneral() {
|
|||||||
setDataKomentar(response.data)
|
setDataKomentar(response.data)
|
||||||
} else if (cat == 'cek-anggota') {
|
} else if (cat == 'cek-anggota') {
|
||||||
setMemberDiscussion(response.data)
|
setMemberDiscussion(response.data)
|
||||||
|
} else if (cat == 'file') {
|
||||||
|
setFileDiscussion(response.data)
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -130,6 +140,7 @@ export default function DetailDiscussionGeneral() {
|
|||||||
handleLoad('detail', true)
|
handleLoad('detail', true)
|
||||||
handleLoad('komentar', true)
|
handleLoad('komentar', true)
|
||||||
handleLoad('cek-anggota', true)
|
handleLoad('cek-anggota', true)
|
||||||
|
handleLoad('file', true)
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
async function handleKomentar() {
|
async function handleKomentar() {
|
||||||
@@ -216,6 +227,7 @@ export default function DetailDiscussionGeneral() {
|
|||||||
<SkeletonContent />
|
<SkeletonContent />
|
||||||
:
|
:
|
||||||
<BorderBottomItem2
|
<BorderBottomItem2
|
||||||
|
dataFile={fileDiscussion}
|
||||||
descEllipsize={false}
|
descEllipsize={false}
|
||||||
borderType="bottom"
|
borderType="bottom"
|
||||||
icon={
|
icon={
|
||||||
|
|||||||
@@ -125,9 +125,26 @@ export default function CreateDiscussionGeneral() {
|
|||||||
try {
|
try {
|
||||||
setLoading(true)
|
setLoading(true)
|
||||||
const hasil = await decryptToken(String(token?.current))
|
const hasil = await decryptToken(String(token?.current))
|
||||||
const response = await apiCreateDiscussionGeneral({
|
const fd = new FormData()
|
||||||
data: { ...dataForm, user: hasil, member: entitiesMember },
|
|
||||||
})
|
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) {
|
if (response.success) {
|
||||||
dispatch(setMemberChoose([]))
|
dispatch(setMemberChoose([]))
|
||||||
dispatch(setUpdateDiscussionGeneralDetail(!update))
|
dispatch(setUpdateDiscussionGeneralDetail(!update))
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { ColorsStatus } from "@/constants/ColorsStatus";
|
import { ColorsStatus } from "@/constants/ColorsStatus";
|
||||||
import Styles from "@/constants/Styles";
|
import Styles from "@/constants/Styles";
|
||||||
import { Ionicons } from "@expo/vector-icons";
|
import { Ionicons, Entypo, EvilIcons } from "@expo/vector-icons";
|
||||||
import React, { useState } from "react";
|
import React, { useState } from "react";
|
||||||
import { Dimensions, Pressable, View } from "react-native";
|
import { Dimensions, Pressable, View } from "react-native";
|
||||||
import { ScrollView } from "react-native-gesture-handler";
|
import { ScrollView } from "react-native-gesture-handler";
|
||||||
@@ -24,9 +24,10 @@ type Props = {
|
|||||||
textColor?: string,
|
textColor?: string,
|
||||||
colorPress?: boolean
|
colorPress?: boolean
|
||||||
titleShowAll?: 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 }: Props) {
|
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 lebarDim = Dimensions.get("window").width;
|
||||||
const lebar = width ? lebarDim * width / 100 : 'auto';
|
const lebar = width ? lebarDim * width / 100 : 'auto';
|
||||||
const textColorFix = textColor ? textColor : 'black';
|
const textColorFix = textColor ? textColor : 'black';
|
||||||
@@ -69,24 +70,18 @@ export default function BorderBottomItem2({ title, subtitle, icon, desc, onPress
|
|||||||
|
|
||||||
</View>
|
</View>
|
||||||
{desc && <Text style={[Styles.textDefault, Styles.mt05, { textAlign: 'left', color: textColorFix }]} numberOfLines={descEllipsize == false ? 0 : 2} ellipsizeMode='tail'>{desc}</Text>}
|
{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}>
|
<ScrollView horizontal style={[Styles.mv05]} showsHorizontalScrollIndicator={false}>
|
||||||
<View style={[Styles.rowItemsCenter, Styles.borderAll, Styles.round10, Styles.ph05, Styles.pv03, Styles.mr05]}>
|
{dataFile.map((item, index) => (
|
||||||
<Ionicons name="chatbox-ellipses-outline" size={18} color="grey" style={Styles.mr05} />
|
<View key={index} style={[Styles.rowItemsCenter, Styles.borderAll, Styles.round10, Styles.ph05, Styles.pv03, Styles.mr05]}>
|
||||||
<Text style={[Styles.textInformation, Styles.cGray, Styles.mb05]}>Text petama.pdf</Text>
|
<Ionicons name="document-text" size={18} color="grey" style={Styles.mr05} />
|
||||||
</View>
|
<Text style={[Styles.textInformation, Styles.cGray, Styles.mb05]}>{item.name}.{item.extension}</Text>
|
||||||
<View style={[Styles.rowItemsCenter, Styles.borderAll, Styles.round10, Styles.ph05, Styles.pv03, Styles.mr05]}>
|
|
||||||
<Ionicons name="chatbox-ellipses-outline" size={18} color="grey" style={Styles.mr05} />
|
|
||||||
<Text style={[Styles.textInformation, Styles.cGray, Styles.mb05]}>Text petama.pdf</Text>
|
|
||||||
</View>
|
|
||||||
<View style={[Styles.rowItemsCenter, Styles.borderAll, Styles.round10, Styles.ph05, Styles.pv03, Styles.mr05]}>
|
|
||||||
<Ionicons name="chatbox-ellipses-outline" size={18} color="grey" style={Styles.mr05} />
|
|
||||||
<Text style={[Styles.textInformation, Styles.cGray, Styles.mb05]}>Text petama.pdf</Text>
|
|
||||||
</View>
|
|
||||||
<View style={[Styles.rowItemsCenter, Styles.borderAll, Styles.round10, Styles.ph05, Styles.pv03, Styles.mr05]}>
|
|
||||||
<Ionicons name="chatbox-ellipses-outline" size={18} color="grey" style={Styles.mr05} />
|
|
||||||
<Text style={[Styles.textInformation, Styles.cGray, Styles.mb05]}>Text petama.pdf</Text>
|
|
||||||
</View>
|
</View>
|
||||||
|
))}
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
|
)
|
||||||
|
}
|
||||||
{
|
{
|
||||||
(leftBottomInfo || rightBottomInfo) &&
|
(leftBottomInfo || rightBottomInfo) &&
|
||||||
(
|
(
|
||||||
|
|||||||
14
lib/api.ts
14
lib/api.ts
@@ -235,8 +235,18 @@ export const apiEditDiscussionGeneral = async (data: { user: string, title: stri
|
|||||||
return response.data;
|
return response.data;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const apiCreateDiscussionGeneral = async ({ data }: { data: { idGroup: string, title: string, desc: string, user: string, member: [] } }) => {
|
// export const apiCreateDiscussionGeneral = async ({ data }: { data: { idGroup: string, title: string, desc: string, user: string, member: [] } }) => {
|
||||||
const response = await api.post(`/mobile/discussion-general`, data)
|
// 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;
|
return response.data;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user