diff --git a/app.json b/app.json index 811bf95..053062f 100644 --- a/app.json +++ b/app.json @@ -25,7 +25,8 @@ "foregroundImage": "", "backgroundColor": "#FFFFFF" }, - "package": "com.appsazz.RnDanovinExpo" + "package": "com.appsazz.RnDanovinExpo", + "permissions": ["READ_EXTERNAL_STORAGE", "WRITE_EXTERNAL_STORAGE"] }, "web": { "favicon": "" diff --git a/src/components/Drawer.js b/src/components/Drawer.js index d4a8b6d..7791632 100644 --- a/src/components/Drawer.js +++ b/src/components/Drawer.js @@ -397,7 +397,13 @@ const Drawer = ({ "flex flex-row-reverse items-center w-full justify-between" )} > - pickImage()} /> + pickImage()} + /> {theme === "light" ? ( async (dispatch) => await proxy.get("comment/list", data, { dispatch }), + myList: + (data = {}) => + async (dispatch) => + await proxy.get("comment/myList", data, { dispatch }), info: (data = {}) => async (dispatch) => { @@ -29,4 +33,4 @@ const comment = { }, }; -export default comment; \ No newline at end of file +export default comment; diff --git a/src/redux/actions/file.js b/src/redux/actions/file.js index bb281c1..d07e363 100644 --- a/src/redux/actions/file.js +++ b/src/redux/actions/file.js @@ -4,8 +4,10 @@ const file = { (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]); + const myData = { ...data, file: { ...data.file, type: "image/jpg" } }; + formData.append("file", myData.file); + formData.append("target", "file"); + console.log(formData); return await proxy.post( "file/upload", formData, @@ -18,6 +20,25 @@ const file = { 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; diff --git a/src/redux/reducers/comment.js b/src/redux/reducers/comment.js index 9bbb3cb..c0275ca 100644 --- a/src/redux/reducers/comment.js +++ b/src/redux/reducers/comment.js @@ -4,6 +4,7 @@ const initialState = { loading: false, error: null, list: null, + myList: [], }; export default function comment(state = initialState, action) { @@ -11,6 +12,8 @@ export default function comment(state = initialState, action) { switch (type) { case "comment/list": return { ...state, loading: false, error: null }; + case "comment/myList": + return { ...state, myList: data, loading: false, error: null }; case "comment/update": return { ...state, loading: false, error: null }; case "comment/add": diff --git a/src/redux/reducers/file.js b/src/redux/reducers/file.js index 9aa975a..1be2e7e 100644 --- a/src/redux/reducers/file.js +++ b/src/redux/reducers/file.js @@ -7,6 +7,13 @@ export default function file(state = initialState, action) { let { type, data, params } = action; switch (type) { case "file/upload": + console.log(data, params); + return { + ...state, + loading: false, + error: null, + }; + case "file/upload2": return { ...state, loading: false, diff --git a/src/screens/Contact/layouts/Tickets.js b/src/screens/Contact/layouts/Tickets.js index b76cab1..ea96e56 100644 --- a/src/screens/Contact/layouts/Tickets.js +++ b/src/screens/Contact/layouts/Tickets.js @@ -10,6 +10,9 @@ import { } from "react-native"; import { connect } from "react-redux"; import { useNavigation } from "@react-navigation/native"; +import { comment } from "../../../redux/actions"; +import moment from "jalali-moment"; + //components import CustomPressable from "../../../components/Pressable"; import Navbar from "../../../components/Navbar"; @@ -20,29 +23,33 @@ import tw from "tailwind-rn"; import Colors from "../../../constants/Colors"; import fontSize from "../../../constants/fontSize"; -export const Tickets = ({ theme }) => { +export const Tickets = ({ theme, getTicketList, list }) => { const navigation = useNavigation(); - const tickets = React.useMemo(() => { - return [ - { - title: "موضوع تیکت", - message: "دریافت اشتباه کتاب های ارسالی از سامانه سفارشات", - target: "دپارتمان فروش و بازاریابی", - date: "1400/09/12", - isNew: true, - isAnswered: true, - }, - { - title: "موضوع تیکت", - message: "دریافت اشتباه کتاب های ارسالی از سامانه سفارشات", - target: "دپارتمان فروش و بازاریابی", - date: "1400/09/12", - isNew: false, - isAnswered: false, - }, - ]; - }, [theme]); + React.useEffect(() => { + getTicketList({ type: 2 }); + }, []); + + // const tickets = React.useMemo(() => { + // return [ + // { + // title: "موضوع تیکت", + // message: "دریافت اشتباه کتاب های ارسالی از سامانه سفارشات", + // target: "دپارتمان فروش و بازاریابی", + // date: "1400/09/12", + // isNew: true, + // isAnswered: true, + // }, + // { + // title: "موضوع تیکت", + // message: "دریافت اشتباه کتاب های ارسالی از سامانه سفارشات", + // target: "دپارتمان فروش و بازاریابی", + // date: "1400/09/12", + // isNew: false, + // isAnswered: false, + // }, + // ]; + // }, [theme]); return ( { back: true, }} /> - {tickets.length ? ( + {list?.length ? ( - {tickets.map((ticket, index) => ( - - ))} + {list + ?.filter((ticket) => ticket?.pid === null) + ?.map((ticket, index) => ( + tickett?.pid === ticket?.id)?.length} + /> + ))} ) : ( @@ -88,9 +102,9 @@ export const Tickets = ({ theme }) => { ); }; -const Ticket = ({ ticket, theme }) => { +const Ticket = ({ ticket, theme, isAnswered }) => { const navigation = useNavigation(); - const { title, message, isNew, date, target, isAnswered } = ticket; + const { title, text, isNew, date, unit, createdAt } = ticket; const light = React.useMemo(() => { return theme === "light"; @@ -124,7 +138,7 @@ const Ticket = ({ ticket, theme }) => { textAlign: "left", }} > - {date} + {moment(createdAt).format("jYYYY/jMM/jDD")} { marginTop: 5, }} > - {message} + {text} { : Colors.theme1.white, }} > - {target} + {unit} { const mapStateToProps = (state) => ({ theme: state.publicApi.theme, + list: state.comment.myList, }); -const mapDispatchToProps = {}; +const mapDispatchToProps = { + getTicketList: comment.myList, +}; export default connect(mapStateToProps, mapDispatchToProps)(Tickets); diff --git a/src/screens/Product/components/Comments.js b/src/screens/Product/components/Comments.js index 907deca..b86ebb6 100644 --- a/src/screens/Product/components/Comments.js +++ b/src/screens/Product/components/Comments.js @@ -33,6 +33,7 @@ function Commnets({ orderFullList, theme, mobile, + user, }) { React.useEffect(() => { if (!orderFullList?.length) { @@ -51,7 +52,13 @@ function Commnets({ renderItem={({ item }) => } keyExtractor={(item) => item?.id} /> - + ); } @@ -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({ title: "", text: "", @@ -138,7 +152,10 @@ const AddComment = ({ addComment, productId, theme, mobile, ...props }) => { behavior={ios ? "padding" : "height"} style={[tw("flex items-end")]} > - + ({ orderFullList: state.userFactor.fullList, theme: state.publicApi.theme, mobile: state.publicApi.mobile, + user: state.user.status, }); const mapDispatchToProps = { diff --git a/src/screens/Product/components/Rates.js b/src/screens/Product/components/Rates.js index c2a005b..e38159b 100644 --- a/src/screens/Product/components/Rates.js +++ b/src/screens/Product/components/Rates.js @@ -38,11 +38,11 @@ function Rates({ productId, addVote, isBuyed = null, theme, rateDetail }) { }, [rateDetail]); const rate = React.useMemo(() => { - return ((oneCount?.count || 0) * 1 + + return rateDetail?.length ? ((oneCount?.count || 0) * 1 + (twoCount?.count || 0) * 2 + (threeCount?.count || 0) * 3 + (fourCount?.count || 0) * 4 + - (fiveCount?.count || 0) * 5) / rateDetail?.length; + (fiveCount?.count || 0) * 5) / rateDetail?.length : 0; }, [rateDetail]); return ( diff --git a/src/screens/Profile/components/User.js b/src/screens/Profile/components/User.js index b1ae28f..e1cd42d 100644 --- a/src/screens/Profile/components/User.js +++ b/src/screens/Profile/components/User.js @@ -26,7 +26,7 @@ const User = ({ user, mobile, theme, upload }) => { const pickImage = React.useCallback(async () => { // No permissions request is necessary for launching the image library let result = await ImagePicker.launchImageLibraryAsync({ - mediaTypes: ImagePicker.MediaTypeOptions.All, + mediaTypes: ImagePicker.MediaTypeOptions.Images, allowsEditing: true, aspect: [1, 1], quality: 1, @@ -55,7 +55,7 @@ const User = ({ user, mobile, theme, upload }) => { > pickImage()} /> diff --git a/src/screens/ShoppingCart/index.js b/src/screens/ShoppingCart/index.js index d517fb8..b03006a 100644 --- a/src/screens/ShoppingCart/index.js +++ b/src/screens/ShoppingCart/index.js @@ -220,7 +220,7 @@ function ShoppingCart({ }, ]} > - {isEmpty ? 0 : separate(factorInfo?.payPrice)} + {isEmpty ? 0 : separate(factorInfo?.payPrice - factorInfo?.transportPrice)}