diff --git a/client/src/Components/KindergartenForm/index.js b/client/src/Components/KindergartenForm/index.js index fefb110..87854f9 100644 --- a/client/src/Components/KindergartenForm/index.js +++ b/client/src/Components/KindergartenForm/index.js @@ -1,166 +1,215 @@ import React, { useState } from 'react'; -import { Typography, Form, Upload } from 'antd'; -import PropTypes from 'prop-types'; +import { Typography, Form, Row, Col, Upload } from 'antd'; +// import PropTypes from 'prop-types'; + +// import axios from 'axios'; import { UploadOutlined } from '@ant-design/icons'; import './style.css'; +// import { UploadOutlined } from '@ant-design/icons'; +import axios from 'axios'; import MainInput from '../Common/MainInput'; import DorpList from '../Common/DropList'; import MainButton from '../Common/MainButton'; const { Title } = Typography; -const KindergartenForm = ({ onAdd, dorpListOptions, sliderMin, sliderMax }) => { - const [selectValue, setSelectValue] = useState({}); - const [sliderValue, setSliderValue] = useState([]); - const [inputValue, setInputValue] = useState(''); +const KindergartenForm = () => { const [add, setAdd] = useState(false); const [fileList, setFileList] = useState([]); - const [pic, setPic] = useState([]); + const [minPrice, setMinPrice] = useState(400); + const [maxPrice, setMaxPrice] = useState(4000); + // const [selectValue, setSelectValue] = useState(''); - const onClick = () => { - onAdd(inputValue, sliderValue, selectValue); - }; + const onFinish = async (val) => { + const { + description, + kindergartenName, + period1, + period2, + phoneNumber, + } = val; - const onPeriodChange = () => { - setAdd(true); - }; + const periods = []; - const onSliderChange = (val) => { - setSliderValue(val); - }; + periods.push([ + period1[0].format('h:mm:ss a'), + period1[1].format('h:mm:ss a'), + ]); - const onDorpListSelect = (val) => { - setSelectValue(val); + if (period2) { + periods.push([ + period1[0].format('h:mm:ss a'), + period1[1].format('h:mm:ss a'), + ]); + } + // selectValue; + const values = { + description, + kindergartenName, + phoneNumber, + coverImage: + 'https://scontent.fgza2-1.fna.fbcdn.net/v/t1.0-9/127563203_2816927261908481_825163598039189311_o.jpg?_nc_cat=100&ccb=2&_nc_sid=e3f864&_nc_ohc=EOam1iTQLIcAX8jrnEj&_nc_ht=scontent.fgza2-1.fna&oh=e1cef81bf1cebbd72a6c1f1af651e01f&oe=604638FB', + locationId: 2, + minPrice, + maxPrice, + periods: JSON.stringify(periods), + imagesGallery: + '["https://scontent.fgza2-1.fna.fbcdn.net/v/t1.0-0/p526x395/126362711_2810037339264140_8115186378406081155_o.jpg?_nc_cat=106&ccb=2&_nc_sid=730e14&_nc_ohc=1pa0nWqLMVQAX8xj-8Z&_nc_ht=scontent.fgza2-1.fna&tp=6&oh=43ba32d04a1478c83ca4cee8950955f9&oe=6045D9DF","https://scontent.fgza2-1.fna.fbcdn.net/v/t1.0-0/p180x540/125246489_2806470342954173_5557632858147020336_o.jpg?_nc_cat=106&ccb=2&_nc_sid=e3f864&_nc_ohc=ZGPkuyaJoUEAX9lkFkC&_nc_ht=scontent.fgza2-1.fna&tp=6&oh=0a5795c9d04ed69df0ecf950260a8240&oe=60475C85","https://scontent.fgza2-1.fna.fbcdn.net/v/t1.0-9/127711338_2816934215241119_820060672107449619_o.jpg?_nc_cat=110&ccb=2&_nc_sid=730e14&_nc_ohc=lj0hKeD_FswAX-IthGI&_nc_ht=scontent.fgza2-1.fna&oh=ff73fc70463202e07ef1ab8945b1aaf6&oe=6047D28E","https://scontent.fgza2-1.fna.fbcdn.net/v/t1.0-9/125969111_2810046942596513_7374678634903478541_o.jpg?_nc_cat=106&ccb=2&_nc_sid=730e14&_nc_ohc=26lBVKEuxXgAX-LkaQx&_nc_ht=scontent.fgza2-1.fna&oh=98b4dfd19c0ec101fab0c68fcafb2ed7&oe=60489661","https://scontent.fgza2-1.fna.fbcdn.net/v/t1.0-0/p526x395/126221172_2810852509182623_3908586823989526775_o.jpg?_nc_cat=104&ccb=2&_nc_sid=730e14&_nc_ohc=r4JC03VXovYAX-ZDyZv&_nc_ht=scontent.fgza2-1.fna&tp=6&oh=a04d43782df65a5367387fa7d876a6cc&oe=6047FCA7","https://scontent.fgza2-1.fna.fbcdn.net/v/t1.0-9/126420691_2810858432515364_8382015493325068832_o.jpg?_nc_cat=102&ccb=2&_nc_sid=730e14&_nc_ohc=8m_uU2uLr9kAX-TeYbI&_nc_ht=scontent.fgza2-1.fna&oh=8b17321eb157fe3c7a9d7c09ba6182bc&oe=604782E5","https://scontent.fgza2-1.fna.fbcdn.net/v/t1.0-9/126361201_2810861959181678_2949636133222938705_o.jpg?_nc_cat=107&ccb=2&_nc_sid=e3f864&_nc_ohc=xj63fLB5DpYAX8g2PTJ&_nc_ht=scontent.fgza2-1.fna&oh=88ac8fb67a2c9c87ee2ed8940f2c14fb&oe=60451FF9"]', + }; + try { + const a = await axios.post(`/api/v1/kindergarten`, values); + console.log(a); + } catch (error) { + console.log(error); + } }; - const onMainInputChange = (e) => { - setInputValue(e.target.value); + const onPriceSliderChange = (val) => { + setMinPrice(val[0]); + setMaxPrice(val[0]); }; - const onUpload = ({ fileList: newFileList }) => { - setFileList(newFileList); + // const onDorpListSelect = (val) => { + // setSelectValue(val); + // if (val.key !== 'كل المنطقة') { + // setSelectValue( + // options.filter((data) => data.location_sub === val.key)[0].id + // ); + // } else { + // setSelectValue(''); + // } + // }; + + const onPeriodChange = () => { + setAdd(true); }; - const onUpload1 = ({ main: onePicture }) => { - setPic(onePicture); + const onMoreImageUpload = ({ fileList: newFileList }) => { + setFileList(newFileList); }; return ( -
Some contents...
-Some contents...
-Some contents...
+