update 11 files

master
Reza_ashrafi 3 years ago
parent 8931e08769
commit 9af3148b36
  1. 3
      app.json
  2. 8
      src/components/Drawer.js
  3. 6
      src/redux/actions/comment.js
  4. 25
      src/redux/actions/file.js
  5. 3
      src/redux/reducers/comment.js
  6. 7
      src/redux/reducers/file.js
  7. 79
      src/screens/Contact/layouts/Tickets.js
  8. 24
      src/screens/Product/components/Comments.js
  9. 4
      src/screens/Product/components/Rates.js
  10. 4
      src/screens/Profile/components/User.js
  11. 2
      src/screens/ShoppingCart/index.js

@ -25,7 +25,8 @@
"foregroundImage": "", "foregroundImage": "",
"backgroundColor": "#FFFFFF" "backgroundColor": "#FFFFFF"
}, },
"package": "com.appsazz.RnDanovinExpo" "package": "com.appsazz.RnDanovinExpo",
"permissions": ["READ_EXTERNAL_STORAGE", "WRITE_EXTERNAL_STORAGE"]
}, },
"web": { "web": {
"favicon": "" "favicon": ""

@ -397,7 +397,13 @@ const Drawer = ({
"flex flex-row-reverse items-center w-full justify-between" "flex flex-row-reverse items-center w-full justify-between"
)} )}
> >
<Avatar source={user?.picFileIds || image} size={width / 6} action={() => pickImage()} /> <Avatar
source={
`https://dnvn.ir/api/v1/file/${user?.picFileIds}` || image
}
size={width / 6}
action={() => pickImage()}
/>
{theme === "light" ? ( {theme === "light" ? (
<Svg <Svg
xmlns="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg"

@ -4,6 +4,10 @@ const comment = {
(data = {}) => (data = {}) =>
async (dispatch) => async (dispatch) =>
await proxy.get("comment/list", data, { dispatch }), await proxy.get("comment/list", data, { dispatch }),
myList:
(data = {}) =>
async (dispatch) =>
await proxy.get("comment/myList", data, { dispatch }),
info: info:
(data = {}) => (data = {}) =>
async (dispatch) => { async (dispatch) => {
@ -29,4 +33,4 @@ const comment = {
}, },
}; };
export default comment; export default comment;

@ -4,8 +4,10 @@ const file = {
(data = {}) => (data = {}) =>
async (dispatch) => { async (dispatch) => {
var formData = new FormData(); var formData = new FormData();
const myData = { ...data, file: { ...data.file, type: "image/jpg" } } const myData = { ...data, file: { ...data.file, type: "image/jpg" } };
for (let key in myData) formData.append(key, myData[key]); formData.append("file", myData.file);
formData.append("target", "file");
console.log(formData);
return await proxy.post( return await proxy.post(
"file/upload", "file/upload",
formData, formData,
@ -18,6 +20,25 @@ const file = {
formData formData
); );
}, },
upload2:
(data = {}) =>
async (dispatch) => {
var formData = new FormData();
const myData = { ...data, file: { ...data.file, type: "image/jpg" } };
for (let key in myData) formData.append(key, myData[key]);
console.log(formData);
// return await proxy.post(
// "file/upload2",
// formData,
// {
// dispatch,
// headers: {
// "Content-Type": "multipart/form-data",
// },
// },
// formData
// );
},
}; };
export default file; export default file;

@ -4,6 +4,7 @@ const initialState = {
loading: false, loading: false,
error: null, error: null,
list: null, list: null,
myList: [],
}; };
export default function comment(state = initialState, action) { export default function comment(state = initialState, action) {
@ -11,6 +12,8 @@ export default function comment(state = initialState, action) {
switch (type) { switch (type) {
case "comment/list": case "comment/list":
return { ...state, loading: false, error: null }; return { ...state, loading: false, error: null };
case "comment/myList":
return { ...state, myList: data, loading: false, error: null };
case "comment/update": case "comment/update":
return { ...state, loading: false, error: null }; return { ...state, loading: false, error: null };
case "comment/add": case "comment/add":

@ -7,6 +7,13 @@ export default function file(state = initialState, action) {
let { type, data, params } = action; let { type, data, params } = action;
switch (type) { switch (type) {
case "file/upload": case "file/upload":
console.log(data, params);
return {
...state,
loading: false,
error: null,
};
case "file/upload2":
return { return {
...state, ...state,
loading: false, loading: false,

@ -10,6 +10,9 @@ import {
} from "react-native"; } from "react-native";
import { connect } from "react-redux"; import { connect } from "react-redux";
import { useNavigation } from "@react-navigation/native"; import { useNavigation } from "@react-navigation/native";
import { comment } from "../../../redux/actions";
import moment from "jalali-moment";
//components //components
import CustomPressable from "../../../components/Pressable"; import CustomPressable from "../../../components/Pressable";
import Navbar from "../../../components/Navbar"; import Navbar from "../../../components/Navbar";
@ -20,29 +23,33 @@ import tw from "tailwind-rn";
import Colors from "../../../constants/Colors"; import Colors from "../../../constants/Colors";
import fontSize from "../../../constants/fontSize"; import fontSize from "../../../constants/fontSize";
export const Tickets = ({ theme }) => { export const Tickets = ({ theme, getTicketList, list }) => {
const navigation = useNavigation(); const navigation = useNavigation();
const tickets = React.useMemo(() => { React.useEffect(() => {
return [ getTicketList({ type: 2 });
{ }, []);
title: "موضوع تیکت",
message: "دریافت اشتباه کتاب های ارسالی از سامانه سفارشات", // const tickets = React.useMemo(() => {
target: "دپارتمان فروش و بازاریابی", // return [
date: "1400/09/12", // {
isNew: true, // title: "موضوع تیکت",
isAnswered: true, // message: "دریافت اشتباه کتاب های ارسالی از سامانه سفارشات",
}, // target: "دپارتمان فروش و بازاریابی",
{ // date: "1400/09/12",
title: "موضوع تیکت", // isNew: true,
message: "دریافت اشتباه کتاب های ارسالی از سامانه سفارشات", // isAnswered: true,
target: "دپارتمان فروش و بازاریابی", // },
date: "1400/09/12", // {
isNew: false, // title: "موضوع تیکت",
isAnswered: false, // message: "دریافت اشتباه کتاب های ارسالی از سامانه سفارشات",
}, // target: "دپارتمان فروش و بازاریابی",
]; // date: "1400/09/12",
}, [theme]); // isNew: false,
// isAnswered: false,
// },
// ];
// }, [theme]);
return ( return (
<SafeAreaView <SafeAreaView
style={{ style={{
@ -62,14 +69,21 @@ export const Tickets = ({ theme }) => {
back: true, back: true,
}} }}
/> />
{tickets.length ? ( {list?.length ? (
<ScrollView <ScrollView
contentContainerStyle={{ paddingBottom: 100 }} contentContainerStyle={{ paddingBottom: 100 }}
style={tw("px-4 pt-4 flex")} style={tw("px-4 pt-4 flex")}
> >
{tickets.map((ticket, index) => ( {list
<Ticket ticket={ticket} key={index} theme={theme} /> ?.filter((ticket) => ticket?.pid === null)
))} ?.map((ticket, index) => (
<Ticket
ticket={ticket}
key={index}
theme={theme}
isAnswered={list?.filter((tickett) => tickett?.pid === ticket?.id)?.length}
/>
))}
</ScrollView> </ScrollView>
) : ( ) : (
<Empty text="هیچ تیکتی وجود ندارد." /> <Empty text="هیچ تیکتی وجود ندارد." />
@ -88,9 +102,9 @@ export const Tickets = ({ theme }) => {
); );
}; };
const Ticket = ({ ticket, theme }) => { const Ticket = ({ ticket, theme, isAnswered }) => {
const navigation = useNavigation(); const navigation = useNavigation();
const { title, message, isNew, date, target, isAnswered } = ticket; const { title, text, isNew, date, unit, createdAt } = ticket;
const light = React.useMemo(() => { const light = React.useMemo(() => {
return theme === "light"; return theme === "light";
@ -124,7 +138,7 @@ const Ticket = ({ ticket, theme }) => {
textAlign: "left", textAlign: "left",
}} }}
> >
{date} {moment(createdAt).format("jYYYY/jMM/jDD")}
</Text> </Text>
<Text <Text
style={{ style={{
@ -153,7 +167,7 @@ const Ticket = ({ ticket, theme }) => {
marginTop: 5, marginTop: 5,
}} }}
> >
{message} {text}
</Text> </Text>
<View style={tw("flex flex-row-reverse justify-between mt-4")}> <View style={tw("flex flex-row-reverse justify-between mt-4")}>
<Text <Text
@ -168,7 +182,7 @@ const Ticket = ({ ticket, theme }) => {
: Colors.theme1.white, : Colors.theme1.white,
}} }}
> >
{target} {unit}
</Text> </Text>
<Text <Text
style={{ style={{
@ -201,8 +215,11 @@ const Ticket = ({ ticket, theme }) => {
const mapStateToProps = (state) => ({ const mapStateToProps = (state) => ({
theme: state.publicApi.theme, theme: state.publicApi.theme,
list: state.comment.myList,
}); });
const mapDispatchToProps = {}; const mapDispatchToProps = {
getTicketList: comment.myList,
};
export default connect(mapStateToProps, mapDispatchToProps)(Tickets); export default connect(mapStateToProps, mapDispatchToProps)(Tickets);

@ -33,6 +33,7 @@ function Commnets({
orderFullList, orderFullList,
theme, theme,
mobile, mobile,
user,
}) { }) {
React.useEffect(() => { React.useEffect(() => {
if (!orderFullList?.length) { if (!orderFullList?.length) {
@ -51,7 +52,13 @@ function Commnets({
renderItem={({ item }) => <Comment comment={item} theme={theme} />} renderItem={({ item }) => <Comment comment={item} theme={theme} />}
keyExtractor={(item) => item?.id} keyExtractor={(item) => item?.id}
/> />
<AddComment addComment={addComment} productId={productId} theme={theme} mobile={mobile} /> <AddComment
addComment={addComment}
productId={productId}
theme={theme}
mobile={mobile}
user={user}
/>
</View> </View>
); );
} }
@ -125,7 +132,14 @@ const Comment = ({ comment, theme }) => {
); );
}; };
const AddComment = ({ addComment, productId, theme, mobile, ...props }) => { const AddComment = ({
user,
addComment,
productId,
theme,
mobile,
...props
}) => {
const [commentForm, setCommentForm] = React.useState({ const [commentForm, setCommentForm] = React.useState({
title: "", title: "",
text: "", text: "",
@ -138,7 +152,10 @@ const AddComment = ({ addComment, productId, theme, mobile, ...props }) => {
behavior={ios ? "padding" : "height"} behavior={ios ? "padding" : "height"}
style={[tw("flex items-end")]} style={[tw("flex items-end")]}
> >
<Avatar source={null} size={mobile ? width / 5.5 : width / 7} /> <Avatar
source={`https://dnvn.ir/api/v1/file/${user?.picFileId}`}
size={mobile ? width / 5.5 : width / 7}
/>
<TextInput <TextInput
style={[ style={[
tw("w-full mt-4 px-2 rounded-md"), tw("w-full mt-4 px-2 rounded-md"),
@ -215,6 +232,7 @@ const mapStateToProps = (state) => ({
orderFullList: state.userFactor.fullList, orderFullList: state.userFactor.fullList,
theme: state.publicApi.theme, theme: state.publicApi.theme,
mobile: state.publicApi.mobile, mobile: state.publicApi.mobile,
user: state.user.status,
}); });
const mapDispatchToProps = { const mapDispatchToProps = {

@ -38,11 +38,11 @@ function Rates({ productId, addVote, isBuyed = null, theme, rateDetail }) {
}, [rateDetail]); }, [rateDetail]);
const rate = React.useMemo(() => { const rate = React.useMemo(() => {
return ((oneCount?.count || 0) * 1 + return rateDetail?.length ? ((oneCount?.count || 0) * 1 +
(twoCount?.count || 0) * 2 + (twoCount?.count || 0) * 2 +
(threeCount?.count || 0) * 3 + (threeCount?.count || 0) * 3 +
(fourCount?.count || 0) * 4 + (fourCount?.count || 0) * 4 +
(fiveCount?.count || 0) * 5) / rateDetail?.length; (fiveCount?.count || 0) * 5) / rateDetail?.length : 0;
}, [rateDetail]); }, [rateDetail]);
return ( return (

@ -26,7 +26,7 @@ const User = ({ user, mobile, theme, upload }) => {
const pickImage = React.useCallback(async () => { const pickImage = React.useCallback(async () => {
// No permissions request is necessary for launching the image library // No permissions request is necessary for launching the image library
let result = await ImagePicker.launchImageLibraryAsync({ let result = await ImagePicker.launchImageLibraryAsync({
mediaTypes: ImagePicker.MediaTypeOptions.All, mediaTypes: ImagePicker.MediaTypeOptions.Images,
allowsEditing: true, allowsEditing: true,
aspect: [1, 1], aspect: [1, 1],
quality: 1, quality: 1,
@ -55,7 +55,7 @@ const User = ({ user, mobile, theme, upload }) => {
> >
<View style={tw(`flex items-center flex-row-reverse`)}> <View style={tw(`flex items-center flex-row-reverse`)}>
<Avatar <Avatar
source={user?.picFileIds || image} source={`https://dnvn.ir/api/v1/file/${user?.picFileId}` || image}
size={mobile ? width / 5.5 : width / 7} size={mobile ? width / 5.5 : width / 7}
action={() => pickImage()} action={() => pickImage()}
/> />

@ -220,7 +220,7 @@ function ShoppingCart({
}, },
]} ]}
> >
{isEmpty ? 0 : separate(factorInfo?.payPrice)} {isEmpty ? 0 : separate(factorInfo?.payPrice - factorInfo?.transportPrice)}
</Text> </Text>
<Text <Text

Loading…
Cancel
Save