diff --git a/package-lock.json b/package-lock.json index bf81bb0..6d9763a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -26,7 +26,7 @@ "axios": "^1.6.7", "bcrypt": "^5.1.1", "change-case": "^5.2.0", - "cloudinary": "^1.41.0", + "cloudinary": "^1.41.3", "date-fns": "^2.30.0", "eslint": "latest", "eslint-config-next": "latest", diff --git a/package.json b/package.json index e5e70a7..1000c4d 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ "axios": "^1.6.7", "bcrypt": "^5.1.1", "change-case": "^5.2.0", - "cloudinary": "^1.41.0", + "cloudinary": "^1.41.3", "date-fns": "^2.30.0", "eslint": "latest", "eslint-config-next": "latest", diff --git a/public/images/KakaoTalk_logo.svg b/public/images/KakaoTalk_logo.svg new file mode 100644 index 0000000..e721ec2 --- /dev/null +++ b/public/images/KakaoTalk_logo.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/components/_main/product/summary/index.jsx b/src/components/_main/product/summary/index.jsx index 529b9db..a8a5825 100644 --- a/src/components/_main/product/summary/index.jsx +++ b/src/components/_main/product/summary/index.jsx @@ -17,7 +17,7 @@ import { Rating, Tooltip, Grid, - Card, + Card // alpha, // Divider } from '@mui/material'; @@ -52,6 +52,8 @@ import { MdContentCopy } from 'react-icons/md'; import { LiaShippingFastSolid } from 'react-icons/lia'; import { MdLockOutline } from 'react-icons/md'; import { FaRegStar } from 'react-icons/fa'; +import Image from 'next/image'; +import Kakao from '../../../../../public/images/KakaoTalk_logo.svg'; // import { TbMessage } from 'react-icons/tb'; // import { MdOutlineShoppingBasket } from 'react-icons/md'; // import { FiShoppingCart } from 'react-icons/fi'; @@ -271,7 +273,7 @@ export default function ProductDetailsSumary({ ...props }) { {category?.name || 'Nextall'} - + {/* {product?.price > product?.priceSale && ( Discount: @@ -411,7 +413,7 @@ export default function ProductDetailsSumary({ ...props }) { )} */} - + + { + window?.open('http://pf.kakao.com/_xlxhIxbn/chat'); + }} + > + + 카카오톡 + + {/* diff --git a/src/components/dialog/search/search.jsx b/src/components/dialog/search/search.jsx index a101ece..ee4bf48 100644 --- a/src/components/dialog/search/search.jsx +++ b/src/components/dialog/search/search.jsx @@ -10,13 +10,12 @@ import Typography from '@mui/material/Typography'; import SearchIcon from '@mui/icons-material/Search'; import TextField from '@mui/material/TextField'; import Skeleton from '@mui/material/Skeleton'; -import { InputAdornment, Stack, Button, Modal, IconButton } from '@mui/material'; +import { InputAdornment, Stack, Button } from '@mui/material'; import MenuList from '@mui/material/MenuList'; import MenuItem from '@mui/material/MenuItem'; import ListItemIcon from '@mui/material/ListItemIcon'; import CircularProgress from '@mui/material/CircularProgress'; import Divider from '@mui/material/Divider'; -import CloseRoundedIcon from '@mui/icons-material/CloseRounded'; // components import NoDataFound from 'src/illustrations/dataNotFound'; @@ -26,68 +25,12 @@ import FormControl from '@mui/material/FormControl'; import Select from '@mui/material/Select'; import { useCurrencyConvert } from 'src/hooks/convertCurrency'; import { useCurrencyFormatter } from 'src/hooks/formatCurrency'; +const axios = require("axios"); +const fs = require("fs"); +const FormData = require('form-data'); // api import * as api from 'src/services'; -const axios = require('axios'); - -const getImageUrl = async (ids) => { - const requestOptions = { - method: 'GET', - redirect: 'follow' - }; - - try { - const responses = await Promise.all( - ids.map(async (id) => { - const response = await fetch( - `https://api.roboflow.com/picup/picup/images/${id}?api_key=s9OJq0UPljSqkPsJY6xP`, - requestOptions - ); - if (!response.ok) { - throw new Error(`Error fetching image for ID: ${id}, Status: ${response.status}`); - } - return response.json(); // JSON 응답 반환 - }) - ); - - return responses; // 모든 이미지 정보를 배열로 반환 - } catch (error) { - console.error('Error fetching image URLs:', error); - return null; // 오류 발생 시 null 반환 - } -}; - -const searchImages = async (imageBase64) => { - const myHeaders = new Headers(); - myHeaders.append('Content-Type', 'application/json'); - - const raw = JSON.stringify({ - like_image: 'MV09CPgMSn9uhQ5D2nl5', - limit: 3, - in_dataset: true - }); - - const requestOptions = { - method: 'POST', - headers: myHeaders, - body: raw, - redirect: 'follow' - }; - - try { - const response = await fetch( - 'https://api.roboflow.com/picup/picup/search?api_key=s9OJq0UPljSqkPsJY6xP', - requestOptions - ); - const result = await response.json(); - return result; // 반환 추가 - } catch (error) { - console.error('Error fetching images:', error); - throw error; - } -}; - Search.propTypes = { onClose: PropTypes.func.isRequired, mobile: PropTypes.bool.isRequired @@ -116,9 +59,6 @@ export default function Search({ ...props }) { const router = useRouter(); const [search, setSearch] = React.useState(''); - const [image, setImage] = React.useState(null); - const [imagesResultID, setImagesResultID] = React.useState(null); - const [roboFlowUrlLists, setRoboFlowUrlLists] = React.useState([]); const { data: filters, isLoading: filtersLoading } = useQuery(['get-search-filters'], () => api.getSearchFilters()); const { mutate, isLoading } = useMutation('search', api.search, { @@ -171,45 +111,58 @@ export default function Search({ ...props }) { } }; + // 파일 선택 시 호출되는 함수 + // const handleFileChange = (event) => { + // const file = event.target.files?.[0]; + // if (file) { + // console.log('Selected File:', file); + + // // 예: 파일을 서버에 업로드하거나 처리 + // const reader = new FileReader(); + // reader.onload = () => { + // console.log('Image Preview URL:', reader.result); + // }; + // reader.readAsDataURL(file); + // } + // }; + const handleFileChange = async (event) => { - const file = event.target.files?.[0]; + const file = event.target.files[0]; if (file) { - const reader = new FileReader(); - reader.onloadend = async () => { - const base64Image = reader.result.split(',')[1]; // base64 변환 후 접두사 제거 - setImage(reader.result); - }; - reader.readAsDataURL(file); + const formData = new FormData(); + formData.append('name', file.name); + formData.append('file', file); + formData.append('split', 'train'); + + console.log(formData) + + axios({ + method: 'POST', + url: 'https://api.roboflow.com/dataset/picup/upload', + params: { + api_key: 's9OJq0UPljSqkPsJY6xP' + }, + data: formData, + headers: { + "Content-Type": "multipart/form-data" + } + }) + .then(function (response) { + console.log(response.data); + }) + .catch(function (error) { + console.log(error.message); + }); } }; - const objectDetect = async (image) => { - try { - const result = await searchImages(image); - - // id 배열 추출 - const imageIds = result.results.map((r) => r.id); - - // 배열을 한 번에 저장 - setImagesResultID(imageIds); - - console.log('Image IDs:', imageIds); // 디버깅 출력 - } catch (error) { - console.error('Error in image search:', error); + const handleSubmit = (event) => { + event.preventDefault(); + if (fileInputRef.current && fileInputRef.current.files.length > 0) { + handleFileChange({ target: { files: fileInputRef.current.files } }); } }; - React.useEffect(() => { - if (imagesResultID && imagesResultID.length > 0) { - getImageUrl(imagesResultID).then((url) => { - setRoboFlowUrlLists(url); - }).finally(() => { - setImage(null) - }); - } - }, [imagesResultID]); - - return ( <> @@ -255,17 +208,22 @@ export default function Search({ ...props }) { } }} /> - - +
+ + + +
@@ -422,13 +380,13 @@ export default function Search({ ...props }) { {isLoading ? : product.category} - {/* + {isLoading ? ( ) : ( fCurrency(cCurrency(product.priceSale)) )} - */} + @@ -437,63 +395,6 @@ export default function Search({ ...props }) { )} {' '} - {roboFlowUrlLists && - roboFlowUrlLists.map((i, index) => ( - `1px solid ${theme.palette.primary.main}`, - bgcolor: (theme) => alpha(theme.palette.primary.main, 0.16), - h6: { - color: 'primary.main' - } - }, - '&.active': { - border: (theme) => `1px solid ${theme.palette.primary.main}`, - bgcolor: (theme) => alpha(theme.palette.primary.main, 0.16), - h6: { - color: 'primary.main' - } - } - } - }} - autoFocusItem={!focus} - > - - - 이미지 - - - -
- - Object Data Set {index} - - - {i.image.tags.map((i) => { - return i; - })} - {` `} - {i.image.r * 100}% - -
-
-
-
-
- ))} {multiSelect && ( - - - - )} ); }