upd: dokumen divisi

Deskripsi:
- update akses role pada dokumen divisi

No Issues
This commit is contained in:
2025-09-26 15:08:59 +08:00
parent 907b56feaf
commit 14e9bf15c7
3 changed files with 47 additions and 16 deletions

View File

@@ -18,6 +18,7 @@ import Styles from "@/constants/Styles";
import { import {
apiDocumentDelete, apiDocumentDelete,
apiDocumentRename, apiDocumentRename,
apiGetDivisionOneFeature,
apiGetDocument, apiGetDocument,
apiShareDocument, apiShareDocument,
} from "@/lib/api"; } from "@/lib/api";
@@ -85,6 +86,8 @@ export default function DocumentDivision() {
const update = useSelector((state: any) => state.dokumenUpdate) const update = useSelector((state: any) => state.dokumenUpdate)
const [refreshing, setRefreshing] = useState(false) const [refreshing, setRefreshing] = useState(false)
const [loadingOpen, setLoadingOpen] = useState(false) const [loadingOpen, setLoadingOpen] = useState(false)
const [isMemberDivision, setIsMemberDivision] = useState(false)
const entityUser = useSelector((state: any) => state.user)
const [bodyRename, setBodyRename] = useState({ const [bodyRename, setBodyRename] = useState({
id: "", id: "",
name: "", name: "",
@@ -93,6 +96,24 @@ export default function DocumentDivision() {
extension: "", extension: "",
}); });
async function handleCheckMember() {
try {
const hasil = await decryptToken(String(token?.current));
const response = await apiGetDivisionOneFeature({
id,
user: hasil,
cat: "check-member",
});
setIsMemberDivision(response.data);
} catch (error) {
console.error(error);
}
}
useEffect(() => {
handleCheckMember()
}, [id])
async function handleLoad(loading: boolean) { async function handleLoad(loading: boolean) {
try { try {
setLoading(loading) setLoading(loading)
@@ -347,7 +368,7 @@ export default function DocumentDivision() {
}} }}
/> />
) : ( ) : (
<HeaderRightDocument path={path} /> <HeaderRightDocument path={path} isMember={isMemberDivision} />
), ),
}} }}
/> />
@@ -407,6 +428,7 @@ export default function DocumentDivision() {
: `${item.name}.${item.extension}` : `${item.name}.${item.extension}`
} }
dateTime={item.createdAt} dateTime={item.createdAt}
canChecked={(entityUser.role != "user" && entityUser.role != "coadmin") || isMemberDivision}
onChecked={() => { onChecked={() => {
handleCheckboxChange(index); handleCheckboxChange(index);
}} }}

View File

@@ -15,7 +15,7 @@ import { InputForm } from "../inputForm";
import MenuItemRow from "../menuItemRow"; import MenuItemRow from "../menuItemRow";
import ModalFloat from "../modalFloat"; import ModalFloat from "../modalFloat";
export default function HeaderRightDocument({ path }: { path: string }) { export default function HeaderRightDocument({ path, isMember }: { path: string, isMember: boolean }) {
const [isVisible, setVisible] = useState(false); const [isVisible, setVisible] = useState(false);
const [newFolder, setNewFolder] = useState(false); const [newFolder, setNewFolder] = useState(false);
const { id } = useLocalSearchParams<{ id: string }>(); const { id } = useLocalSearchParams<{ id: string }>();
@@ -25,6 +25,7 @@ export default function HeaderRightDocument({ path }: { path: string }) {
const update = useSelector((state: any) => state.dokumenUpdate) const update = useSelector((state: any) => state.dokumenUpdate)
const [loading, setLoading] = useState(false) const [loading, setLoading] = useState(false)
const [loadingFolder, setLoadingFolder] = useState(false) const [loadingFolder, setLoadingFolder] = useState(false)
const entityUser = useSelector((state: any) => state.user)
async function handleCreateFolder() { async function handleCreateFolder() {
try { try {
@@ -102,11 +103,14 @@ export default function HeaderRightDocument({ path }: { path: string }) {
return ( return (
<> <>
<ButtonMenuHeader {
onPress={() => { ((entityUser.role != "user" && entityUser.role != "coadmin") || isMember) &&
setVisible(true); <ButtonMenuHeader
}} onPress={() => {
/> setVisible(true);
}}
/>
}
<DrawerBottom <DrawerBottom
animation="slide" animation="slide"
isVisible={isVisible} isVisible={isVisible}

View File

@@ -11,9 +11,10 @@ type Props = {
checked?: boolean checked?: boolean
onChecked?: () => void onChecked?: () => void
onPress?: () => void onPress?: () => void
canChecked?: boolean
} }
export default function ItemFile({ category, checked, dateTime, title, onChecked, onPress }: Props) { export default function ItemFile({ category, checked, dateTime, title, onChecked, onPress, canChecked }: Props) {
return ( return (
<View style={[Styles.wrapItemBorderBottom]}> <View style={[Styles.wrapItemBorderBottom]}>
<View style={[Styles.rowItemsCenter]}> <View style={[Styles.rowItemsCenter]}>
@@ -43,18 +44,22 @@ export default function ItemFile({ category, checked, dateTime, title, onChecked
</Pressable> </Pressable>
<View style={[Styles.rowSpaceBetween, { flex: 1, alignItems: 'center' }]}> <View style={[Styles.rowSpaceBetween, { flex: 1, alignItems: 'center' }]}>
<Pressable style={[Styles.ml10, {flex:1},]} onPress={onPress}> <Pressable style={[Styles.ml10, { flex: 1 },]} onPress={onPress}>
<Text style={[Styles.textDefault]} numberOfLines={1} ellipsizeMode="tail">{title}</Text> <Text style={[Styles.textDefault]} numberOfLines={1} ellipsizeMode="tail">{title}</Text>
<Text style={[Styles.textInformation]}>{dateTime}</Text> <Text style={[Styles.textInformation]}>{dateTime}</Text>
</Pressable> </Pressable>
<Pressable onPress={onChecked}> {
{ !canChecked ? <></>
checked :
? <MaterialCommunityIcons name="checkbox-marked-circle" size={25} color={'black'} /> <Pressable onPress={onChecked}>
: <MaterialCommunityIcons name="checkbox-blank-circle-outline" size={25} color={'#ced4da'} /> {
} checked
? <MaterialCommunityIcons name="checkbox-marked-circle" size={25} color={'black'} />
: <MaterialCommunityIcons name="checkbox-blank-circle-outline" size={25} color={'#ced4da'} />
}
</Pressable> </Pressable>
}
</View> </View>
</View> </View>
</View> </View>