@hoddy-ui/core 1.0.46 → 1.0.47

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.ts CHANGED
@@ -10,6 +10,7 @@ export { default as Button } from "./src/Components/Button";
10
10
  export * from "./src/Components/Checkbox";
11
11
  export * from "./src/Components/FlashMessage";
12
12
  export * from "./src/Components/FormWrapper";
13
+ export * from "./src/Components/StarRating";
13
14
  export * from "./src/Components/Grid";
14
15
  export * from "./src/Components/Locator";
15
16
  export * from "./src/Components/Popup";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hoddy-ui/core",
3
- "version": "1.0.46",
3
+ "version": "1.0.47",
4
4
  "description": "Core rich react native components written in typescript",
5
5
  "main": "index.ts",
6
6
  "repository": {
@@ -16,6 +16,7 @@
16
16
  "@react-navigation/native": ">=6.1.7",
17
17
  "@types/react": "^18.2.6",
18
18
  "@types/react-native": "^0.72.0",
19
+ "expo-haptics": "^12.6.0",
19
20
  "expo-location": ">=15.1.1",
20
21
  "expo-navigation-bar": ">=2.1.1",
21
22
  "expo-system-ui": ">=2.2.1",
@@ -1,18 +1,13 @@
1
1
  import { Ionicons } from "@expo/vector-icons";
2
2
  import * as Haptics from "expo-haptics";
3
- import { FC, useContext, useEffect, useState } from "react";
4
- import { Alert, TouchableOpacity, View } from "react-native";
5
- import { TextInput } from "react-native-gesture-handler";
3
+ import { FC, useEffect, useState } from "react";
4
+ import { TextInput, TouchableOpacity, View } from "react-native";
6
5
  import { ScaledSheet } from "react-native-size-matters";
7
- import { GlobalContext } from "../../context";
8
- import colors from "../../theme/colors";
6
+ import { useColors } from "../hooks";
7
+ import { RatingInputProps, RatingStarsProps } from "../types";
9
8
  import Button from "./Button";
10
- import Popup from "./Popup";
9
+ import { Popup } from "./Popup";
11
10
  import Typography from "./Typography";
12
- import { errorMessage } from "../../utility";
13
- import client from "../../api/client";
14
- import { useColors } from "../hooks";
15
- import { RatingInputProps, RatingStarsProps, StarRatingProps } from "../types";
16
11
 
17
12
  export const RatingStars: FC<RatingStarsProps> = ({
18
13
  rating = 0,
@@ -45,13 +40,12 @@ export const RatingStars: FC<RatingStarsProps> = ({
45
40
 
46
41
  export const RatingInput: FC<RatingInputProps> = ({
47
42
  onSubmit: _onSubmit,
48
- _id,
49
43
  rating = 0,
50
44
  size = 16,
51
45
  }) => {
52
- const { themeState } = useContext(GlobalContext);
53
46
  const [showReviewsModal, setShowReviewsModal] = useState(false);
54
47
  const [rate, setRate] = useState(0);
48
+ const colors = useColors();
55
49
  const [loading, setLoading] = useState(false);
56
50
  const [review, setReview] = useState("");
57
51
  const styles = ScaledSheet.create({
@@ -61,13 +55,13 @@ export const RatingInput: FC<RatingInputProps> = ({
61
55
  },
62
56
  inputCon: {
63
57
  marginBottom: "20@vs",
64
- backgroundColor: colors(themeState.value).white[3],
58
+ backgroundColor: colors.white[3],
65
59
  padding: "15@ms",
66
60
  borderRadius: 20,
67
61
  },
68
62
  input: {
69
63
  fontSize: "16@ms",
70
- color: colors(themeState.value).dark.main,
64
+ color: colors.dark.main,
71
65
  height: "100@vs",
72
66
  },
73
67
  });
@@ -75,7 +69,7 @@ export const RatingInput: FC<RatingInputProps> = ({
75
69
  useEffect(() => {
76
70
  setRate(rating);
77
71
  }, [rating]);
78
- const onRate = (index) => {
72
+ const onRate = (index: number) => {
79
73
  setRate(index + 1);
80
74
  Haptics.selectionAsync();
81
75
 
@@ -86,23 +80,7 @@ export const RatingInput: FC<RatingInputProps> = ({
86
80
 
87
81
  const onSubmit = async () => {
88
82
  setLoading(true);
89
- try {
90
- const res = (
91
- await client.post("customer/review/product", {
92
- rate,
93
- review,
94
- productId: _id,
95
- })
96
- ).data;
97
-
98
- console.log("R", res);
99
- _onSubmit(res.data);
100
- setShowReviewsModal(false);
101
- Alert.alert("Review received", "Thank you for your review");
102
- } catch (error) {
103
- console.log("Couldn't add review", errorMessage(error));
104
- Alert.alert("couldn't add review", errorMessage(error));
105
- }
83
+ await _onSubmit({ rating: rate, review });
106
84
  setLoading(false);
107
85
  };
108
86
  return (
@@ -120,14 +98,13 @@ export const RatingInput: FC<RatingInputProps> = ({
120
98
  style={{ marginLeft: 10 }}
121
99
  name={index < rate ? "star" : "star-outline"}
122
100
  size={size}
123
- color={colors(themeState.value).primary.light}
101
+ color={colors.primary.light}
124
102
  />
125
103
  </TouchableOpacity>
126
104
  ))}
127
105
  </View>
128
106
  <Popup
129
107
  sheet
130
- port
131
108
  open={showReviewsModal}
132
109
  onClose={() => {
133
110
  setShowReviewsModal(false);
@@ -139,7 +116,7 @@ export const RatingInput: FC<RatingInputProps> = ({
139
116
  marginBottom: 5,
140
117
  }}
141
118
  >
142
- <StarRating rating={rate} size={24} />
119
+ <RatingStars rating={rate} size={24} />
143
120
  </View>
144
121
  <Typography
145
122
  align="center"
package/src/types.ts CHANGED
@@ -302,4 +302,5 @@ export interface RatingStarsProps {
302
302
  export interface RatingInputProps {
303
303
  rating: number;
304
304
  size: number;
305
+ onSubmit: (data: { rating: number; review: string }) => Promise<void>;
305
306
  }