upd: tambah komentar
Deskripsi: - mendeteksi jika yg diinputkan hanya spasi atau enter maka tidak bisa mengirim komentar - diskusi umum dan diskusi divisi No Issues
This commit is contained in:
@@ -9,6 +9,7 @@ import SkeletonContent from "@/components/skeletonContent";
|
|||||||
import Text from '@/components/Text';
|
import Text from '@/components/Text';
|
||||||
import { ColorsStatus } from "@/constants/ColorsStatus";
|
import { ColorsStatus } from "@/constants/ColorsStatus";
|
||||||
import { ConstEnv } from "@/constants/ConstEnv";
|
import { ConstEnv } from "@/constants/ConstEnv";
|
||||||
|
import { regexOnlySpacesOrEnter } from "@/constants/OnlySpaceOrEnter";
|
||||||
import Styles from "@/constants/Styles";
|
import Styles from "@/constants/Styles";
|
||||||
import { apiGetDiscussionGeneralOne, apiSendDiscussionGeneralCommentar } from "@/lib/api";
|
import { apiGetDiscussionGeneralOne, apiSendDiscussionGeneralCommentar } from "@/lib/api";
|
||||||
import { getDB } from "@/lib/firebaseDatabase";
|
import { getDB } from "@/lib/firebaseDatabase";
|
||||||
@@ -221,14 +222,14 @@ export default function DetailDiscussionGeneral() {
|
|||||||
multiline
|
multiline
|
||||||
itemRight={
|
itemRight={
|
||||||
<Pressable onPress={() => {
|
<Pressable onPress={() => {
|
||||||
(komentar != '' && data?.status === 1 && data?.isActive && (memberDiscussion || (entityUser.role != "user" && entityUser.role != "coadmin")))
|
(komentar != '' && !regexOnlySpacesOrEnter.test(komentar) && data?.status === 1 && data?.isActive && (memberDiscussion || (entityUser.role != "user" && entityUser.role != "coadmin")))
|
||||||
&& handleKomentar()
|
&& handleKomentar()
|
||||||
}}
|
}}
|
||||||
style={[
|
style={[
|
||||||
Platform.OS == 'android' && Styles.mb12,
|
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} />
|
<MaterialIcons name="send" size={25} style={(komentar == '' || regexOnlySpacesOrEnter.test(komentar) || data?.status === 2 || !data?.isActive || (!memberDiscussion && (entityUser.role == "user" || entityUser.role == "coadmin"))) ? Styles.cGray : Styles.cDefault} />
|
||||||
</Pressable>
|
</Pressable>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import Skeleton from "@/components/skeleton";
|
|||||||
import SkeletonContent from "@/components/skeletonContent";
|
import SkeletonContent from "@/components/skeletonContent";
|
||||||
import Text from "@/components/Text";
|
import Text from "@/components/Text";
|
||||||
import { ConstEnv } from "@/constants/ConstEnv";
|
import { ConstEnv } from "@/constants/ConstEnv";
|
||||||
|
import { regexOnlySpacesOrEnter } from "@/constants/OnlySpaceOrEnter";
|
||||||
import Styles from "@/constants/Styles";
|
import Styles from "@/constants/Styles";
|
||||||
import {
|
import {
|
||||||
apiGetDiscussionOne,
|
apiGetDiscussionOne,
|
||||||
@@ -312,6 +313,7 @@ export default function DiscussionDetail() {
|
|||||||
<Pressable
|
<Pressable
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
komentar != "" &&
|
komentar != "" &&
|
||||||
|
!regexOnlySpacesOrEnter.test(komentar) &&
|
||||||
!loadingSend &&
|
!loadingSend &&
|
||||||
data?.status != 2 &&
|
data?.status != 2 &&
|
||||||
data?.isActive &&
|
data?.isActive &&
|
||||||
@@ -333,6 +335,7 @@ export default function DiscussionDetail() {
|
|||||||
size={25}
|
size={25}
|
||||||
style={
|
style={
|
||||||
[komentar == "" ||
|
[komentar == "" ||
|
||||||
|
regexOnlySpacesOrEnter.test(komentar) ||
|
||||||
loadingSend ||
|
loadingSend ||
|
||||||
data?.status == 2 ||
|
data?.status == 2 ||
|
||||||
data?.isActive == false ||
|
data?.isActive == false ||
|
||||||
|
|||||||
1
constants/OnlySpaceOrEnter.ts
Normal file
1
constants/OnlySpaceOrEnter.ts
Normal file
@@ -0,0 +1 @@
|
|||||||
|
export const regexOnlySpacesOrEnter = /^[\s\r\n]+$/;
|
||||||
Reference in New Issue
Block a user