class Coord(BaseModel):
lat: float
lon: float
class Data(BaseModel):
coord: dict[float, Coord] | None = None
class Coord(BaseModel):
lat: float
lon: float
class Data(BaseModel):
coord: dict[Coord] | None = None
// Reducer
const SET_PARAMETER_COUNTRY_LIST = 'SET_PARAMETER_COUNTRY_LIST'
const SET_PARAMETER_POSITION_LIST = 'SET_PARAMETER_POSITION_LIST'
const SET_PARAMETER_NEWS_AGENCY_LIST = 'SET_PARAMETER_NEWS_AGENCY_LIST'
const defaultState = {
parameterCountry: [],
parameterPosition: [],
parameterNewsAgency: [],
}
export default function searchFaceReducer(state = defaultState, action) {
switch (action.type) {
case SET_PARAMETER_COUNTRY_LIST:
return {
...state,
parameterCountry: action.payload,
}
case SET_PARAMETER_POSITION_LIST:
return {
...state,
parameterPosition: action.payload,
}
case SET_PARAMETER_NEWS_AGENCY_LIST:
return {
...state,
parameterNewsAgency: action.payload,
}
default:
return state
}
}
export const setParameterCountryList = (parameterCountry) => ({type: SET_PARAMETER_COUNTRY_LIST, payload: parameterCountry})
export const setParameterPositionList = (parameterPosition) => ({type: SET_PARAMETER_POSITION_LIST, payload: parameterPosition})
export const setParameterNewsAgencyList = (parameterNewsAgency) => ({type: SET_PARAMETER_NEWS_AGENCY_LIST, payload: parameterNewsAgency})
//было
export const setParameterList = (parameter) => ({type: SET_PARAMETER_LIST, payload: parameter})
import React, { useState } from 'react';
import { useDispatch } from 'react-redux';
// ответ от БД
const sizelist = [1,2,3,4,5,6,7]
const SET_SIZE_LIST ="SET_SIZE_LIST"
const defaultState = {
items: [],
sizeList: [],
};
const setSizeList = (sizelist) => ({type: SET_SIZE_LIST, payload: sizelist})
function sizediskReducer(state = defaultState, action) {
console.log(action.type)
switch (action.type) {
case SET_SIZE_LIST:
const size=3;
return {
...state,
sizeList: [...state.sizeList, size],
}
default:
return state
}
};
function updSizeList () {
useDispatch(setSizeList());
};
const Dropdown = ({ text, children }) => {
const [isOpen, setIsOpen] = useState(false);
const toggleOpen = () => setIsOpen((isOpen) => !isOpen);
return (
<div>
<button
className={isOpen ? 'dropdown-btn-close' : 'dropdown-btn-active'}
onClick={toggleOpen}
>
{text}
<span className="fa-caret-down">▼</span>
</button>
{isOpen && <div>{children}</div>}
</div>
);
};
const App = () => (
<>
<Dropdown text="Drop 1">
<div >
<input id="1" type="checkbox" onChange={updSizeList}/>
<label htmlFor="1" >1</label>
</div>
</Dropdown>
<Dropdown text="Drop 2">
<div>
<label>
Item 4
<input type="checkbox" />
</label>
</div>
<div>
<label>
Item 5
<input type="checkbox" />
</label>
</div>
<div>
<label>
Item 6
<input type="checkbox" />
</label>
</div>
</Dropdown>
</>
);
export default App;
# Все модели дисков с сортировкой по брендам
class CatalogDiskBrandsViewSet(viewsets.ReadOnlyModelViewSet):
def get_queryset(self):
parameterBrand = self.request.query_params.get('brand')
queryset = CatalogDisks.objects.all().filter(brand=parameterBrand)
return queryset
serializer_class = CatalogDisksSerializer
pagination_class = PaginationDisks
def get_serializer_class(self):
return CatalogDisksSerializer
for i in range(3):
widget = Entry(frame)
class MyTableRow(Frame):
def __init__(self, master, *args, **kwargs):
super().__init__(master, *args, **kwargs)
self.widgets = []
self.frames=[]
for i in range(3):
widget = Entry(frame)
widget.pack(side="left")
self.widgets.append(widget)
self.update_btn = Button(self, text="Добавить", command=self.update_clicked)
self.update_btn.pack(side="right")
self.delete_btn = Button(self, text="Удалить", command=self.delete_clicked)
self.delete_btn.pack(side="right")
def update_clicked(self):
print(self.widgets[0].get())
def delete_clicked(self):
print("whatever")
def test_dinamic():
global widgets
global frames
doth=tix.Tk()
frames = []
widgets = []
for i in range(2):
frame = MyTableRow(doth, borderwidth=2, relief="groove")
frames.append(frame)
frame.pack(side="top", fill="x")
buttonFrame_update=Button(frame,text="Добавить", command=lambda arg=i: update_main_db(arg))
buttonFrame_update.pack(side="right")
def update_main_db(arg):
global widgets
print(widgets[arg].get())