|
|
|
@ -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 ( |
|
|
|
|
<SafeAreaView |
|
|
|
|
style={{ |
|
|
|
@ -62,14 +69,21 @@ export const Tickets = ({ theme }) => { |
|
|
|
|
back: true, |
|
|
|
|
}} |
|
|
|
|
/> |
|
|
|
|
{tickets.length ? ( |
|
|
|
|
{list?.length ? ( |
|
|
|
|
<ScrollView |
|
|
|
|
contentContainerStyle={{ paddingBottom: 100 }} |
|
|
|
|
style={tw("px-4 pt-4 flex")} |
|
|
|
|
> |
|
|
|
|
{tickets.map((ticket, index) => ( |
|
|
|
|
<Ticket ticket={ticket} key={index} theme={theme} /> |
|
|
|
|
))} |
|
|
|
|
{list |
|
|
|
|
?.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> |
|
|
|
|
) : ( |
|
|
|
|
<Empty text="هیچ تیکتی وجود ندارد." /> |
|
|
|
@ -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")} |
|
|
|
|
</Text> |
|
|
|
|
<Text |
|
|
|
|
style={{ |
|
|
|
@ -153,7 +167,7 @@ const Ticket = ({ ticket, theme }) => { |
|
|
|
|
marginTop: 5, |
|
|
|
|
}} |
|
|
|
|
> |
|
|
|
|
{message} |
|
|
|
|
{text} |
|
|
|
|
</Text> |
|
|
|
|
<View style={tw("flex flex-row-reverse justify-between mt-4")}> |
|
|
|
|
<Text |
|
|
|
@ -168,7 +182,7 @@ const Ticket = ({ ticket, theme }) => { |
|
|
|
|
: Colors.theme1.white, |
|
|
|
|
}} |
|
|
|
|
> |
|
|
|
|
{target} |
|
|
|
|
{unit} |
|
|
|
|
</Text> |
|
|
|
|
<Text |
|
|
|
|
style={{ |
|
|
|
@ -201,8 +215,11 @@ const Ticket = ({ ticket, theme }) => { |
|
|
|
|
|
|
|
|
|
const mapStateToProps = (state) => ({ |
|
|
|
|
theme: state.publicApi.theme, |
|
|
|
|
list: state.comment.myList, |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
const mapDispatchToProps = {}; |
|
|
|
|
const mapDispatchToProps = { |
|
|
|
|
getTicketList: comment.myList, |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
export default connect(mapStateToProps, mapDispatchToProps)(Tickets); |
|
|
|
|