Skip to content

Commit

Permalink
add loading for custom properties
Browse files Browse the repository at this point in the history
  • Loading branch information
kaleykwan committed Apr 21, 2024
1 parent fd5b2e3 commit 772458c
Showing 1 changed file with 25 additions and 18 deletions.
43 changes: 25 additions & 18 deletions mobile/Components/CustomPropertyReview/CustomPropertyReview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { client } from "@/appwrite";
import { Account } from "appwrite";
import React from "react";
import {
ActivityIndicator,
Alert,
Pressable,
StyleSheet,
Expand Down Expand Up @@ -173,6 +174,7 @@ function CustomPropertyReview({ navigation, route }) {
const { rating } = route.params;
const [properties, setProperties] = React.useState([]);
const [propertyData, setPropertyData] = React.useState([]);
const [loading, setLoading] = React.useState(true);

function dismiss() {
Alert.alert("Discard review?", "You have an unsaved review.", [
Expand Down Expand Up @@ -224,6 +226,7 @@ function CustomPropertyReview({ navigation, route }) {

getCustomProperty()
.then((data) => {
setLoading(false);
setProperties(data);
})
.catch((error) => {
Expand All @@ -242,24 +245,28 @@ function CustomPropertyReview({ navigation, route }) {
<Icon name={"close"} color="black" size={25} />
</TouchableOpacity>
<Text style={styles.title}>Custom Properties</Text>
{properties.length == 0 && (
<View>
<Text style={styles.propertyInput}>
You have no custom properties!
</Text>
</View>
)}
{properties &&
properties.map((item, index) => (
<View key={index}>
<PropertyInput
property={item}
propertyData={propertyData}
setPropertyData={setPropertyData}
index={index}
/>
</View>
))}
{loading ? (
<ActivityIndicator
color={Colors.BUTTON_TEXT_GRAY}
style={{ transform: [{ scaleX: 2 }, { scaleY: 2 }] }}
/>
) : (
properties.length == 0 ? (
<View>
<Text style={styles.propertyInput}>
You have no custom properties!
</Text>
</View>
) : (properties.map((item, index) => (
<View key={index}>
<PropertyInput
property={item}
propertyData={propertyData}
setPropertyData={setPropertyData}
index={index}
/>
</View>
))))}
<Pressable
onPress={() =>
navigation.navigate("textReviewModal", {
Expand Down

0 comments on commit 772458c

Please sign in to comment.