Changeset 13f1472 for frontend/src/Dashboard
- Timestamp:
- 09/18/22 18:09:53 (2 years ago)
- Branches:
- master
- Parents:
- 49b0bbd
- Location:
- frontend/src/Dashboard
- Files:
-
- 1 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
frontend/src/Dashboard/Menu.js
r49b0bbd r13f1472 1 1 import React, {useEffect, useState} from 'react' 2 import {Button, Form, Input, Card, notification } from "antd";2 import {Button, Form, Input, Card, notification, Checkbox, message, Upload} from "antd"; 3 3 import axios from "axios"; 4 4 import env from "../env"; 5 import {PlusOutlined} from "@ant-design/icons"; 5 6 6 7 const Menu = props => { … … 23 24 } 24 25 26 const beforeUpload = (file) => { 27 const isJpgOrPng = file.type === 'image/jpeg' || file.type === 'image/png'; 28 if (!isJpgOrPng) { 29 message.error('Сликата мора да е формат jpg или png'); 30 } 31 if(isJpgOrPng) setLoadingSave(true); 32 return isJpgOrPng; 33 } 34 const uploadChanged = (ev) =>{ 35 if(ev.file.status == 'done'){ 36 getRestaurant() 37 } 38 } 39 25 40 const addMenu = (data) => { 26 41 setLoadingSave(true); 42 console.log(data) 27 43 axios.post(env.api + 'Menu/',{...data,price: parseInt(data.price)}, { headers: {Authorization: localStorage.getItem('Auth')} 28 44 }).then(res => { … … 97 113 </Form.Item> 98 114 <Form.Item 115 label="Алергени" 116 name="alergens" 117 > 118 <Input/> 119 </Form.Item> 120 <Form.Item 99 121 label="Цена" 100 122 name="price" … … 109 131 <Input placeholder="Цена" type={'number'}/> 110 132 </Form.Item> 133 <Form.Item 134 name="isVipOnly" 135 valuePropName="checked" 136 > 137 <Checkbox>Само за VIP</Checkbox> 138 </Form.Item> 111 139 <Form.Item style={{textAlign: 'center'}}> 112 140 <Button type="primary" htmlType="submit" loading={loadingSave}> … … 118 146 <div style={{textAlign:'start'}}> 119 147 {restaurant.menu.map(el => 120 <Card title={el.title} extra={<p style={{color:'red',cursor:'pointer'}} onClick={()=>deleteMenu(el.id)}>Избриши</p>} style={{ width: 300, display:'inline-block', margin:'10px' }} size="small"> 148 <Card key={el.id} title={el.title} extra={<div>{el.isVipOnly ? <span style={{color:'orange',fontWeight:'bold'}}>VIP </span>:''}<span style={{color:'red',cursor:'pointer'}} onClick={()=>deleteMenu(el.id)}>Избриши</span></div>} style={{ width: 300, display:'inline-block', margin:'10px' }} size="small"> 149 <div style={{height:'100px', width:'270px'}}> 150 <Upload 151 name="file" 152 onChange={uploadChanged} 153 showUploadList={false} 154 beforeUpload={beforeUpload} 155 style={{height: '100px', overflow: 'hidden'}} 156 action={env.api+'Menu/'+el.id+'/upload'} 157 > 158 {el.image != "data:image/png;base64," ? <img style={{cursor: 'pointer'}} src={el.image} alt="avatar" 159 height='100px' width={'270px'}/> : <div style={{cursor:'pointer',margin: 15,border:'1px solid gray',padding: 5}}><PlusOutlined /><div style={{ marginTop: 8}}>Додади слика</div></div>} 160 </Upload> 161 </div> 121 162 <p>{el.description}</p> 163 <p>Алергени: {el.alergens.length ==0 ? 'Нема' : el.alergens}</p> 122 164 <b>{el.price} ден.</b> 123 165 </Card>
Note:
See TracChangeset
for help on using the changeset viewer.