Advertisement
RupeshAcharya60

Landing page gpt 1

May 4th, 2023
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.16 KB | None | 0 0
  1. import React, { useState, useEffect } from 'react';
  2. import { useSelector } from 'react-redux';
  3. import axios from 'axios';
  4. import Navbar from './Navbar';
  5. import { Card, CardBody, CardFooter, CardHeader } from '@material-tailwind/react';
  6. import { TbCurrencyRupeeNepalese } from 'react-icons/tb';
  7. import { BiMap } from 'react-icons/bi';
  8. import { Typography } from '@material-tailwind/react';
  9.  
  10. function LandingPage() {
  11. const { user } = useSelector(state => state);
  12. const [postList, setPostList] = useState([]);
  13. const [recommendations, setRecommendations] = useState([]);
  14.  
  15. useEffect(() => {
  16. axios.get("http://localhost:8000/post/").then(res => {
  17. setPostList(res.data);
  18. });
  19.  
  20. axios.get(`http://localhost:8000/recommendation/${user.userState.id}`).then(res => {
  21. setRecommendations(res.data);
  22. });
  23. }, []);
  24.  
  25. return (
  26. <div>
  27. <Navbar />
  28. <div className="flex justify-between">
  29. <div className="flex flex-col gap-12 mt-14 ml-36">
  30. {postList.map(post => (
  31. <Card key={post.id} className="w-[96] h-[400px]">
  32. <CardHeader
  33. color="blue"
  34. className="relative h-72"
  35. style={{
  36. backgroundImage: "https://www.google.com/url?sa=i&url=https%3A%2F%2Fwww.pexels.com%2Fsearch%2Fhouses%2F&psig=AOvVaw3zUVQWy4pyWV7lu67CNLrE&ust=1683308930554000&source=images&cd=vfe&ved=0CBEQjRxqFwoTCMCxm8ic3P4CFQAAAAAdAAAAABAE",
  37. backgroundSize: 'cover',
  38. backgroundPosition: 'center',
  39. }}
  40. />
  41. <CardBody className="text-left p-6">
  42. <Typography variant="h6" gutterBottom>
  43. {post.title}
  44. </Typography>
  45. <Typography variant="body2" gutterBottom>
  46. {post.content.substring(0, 100)}...
  47. </Typography>
  48. <div className="flex items-center justify-between">
  49. <Typography variant="body1">
  50. <TbCurrencyRupeeNepalese className="inline-block mr-1" />
  51. {post.price}
  52. </Typography>
  53. <Typography variant="body1" color="textSecondary">
  54. <BiMap className="inline-block mr-1" />
  55. {post.location.split(',')[2]}
  56. </Typography>
  57. </div>
  58. </CardBody>
  59. </Card>
  60. ))}
  61. </div>
  62.  
  63. <div className="flex flex-col gap-12 mt-14 ml-36 h-[500px] w-1/2 overflow-auto">
  64. <Typography variant="h5" gutterBottom>
  65. Recommendation List
  66. </Typography>
  67. {recommendations.map(post => (
  68. <Card key={post.id} className="w-96">
  69. <CardHeader
  70. color="blue"
  71. className="relative h-56"
  72. style={{
  73. backgroundImage: "https://www.google.com/url?sa=i&url=https%3A%2F%2Fwww.pexels.com%2Fsearch%2Fhouses%2F&psig=AOvVaw3zUVQWy4pyWV7lu67CNLrE&ust=1683308930554000&source=images&cd=vfe&ved=0CBEQjRxqFwoTCMCxm8ic3P4CFQAAAAAdAAAAABAE",
  74. backgroundSize: 'cover',
  75. backgroundPosition: 'center',
  76. }}
  77. />
  78. <CardBody className="text-left p-6">
  79. <Typography variant="h6" gutterBottom>
  80. {post.title}
  81. </Typography>
  82. <Typography variant="body2" gutterBottom>
  83. {post.content.substring(0, 100)}...
  84. </Typography>
  85. <div className="flex items-center justify-between">
  86. <Typography variant="body1">
  87. <TbCurrencyRupeeNepalese className="inline-block mr-1" />
  88. {post.price}
  89. </Typography>
  90. <Typography variant="body1" color="textSecondary">
  91. <BiMap className="inline-block mr-1" />
  92. {post.location.split(',')[2]}
  93.  
  94. </Typography>
  95. </div>
  96. </CardBody>
  97. </Card>
  98. ))}
  99. </div>
  100. </div>
  101. </div>)}
  102. export default LandingPage
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement