The start side of the dashboard.js file
Code: Select all
const [ozeltarih, setOzeltarih] = useState(null);
useEffect(() => {
const productService = new ProductService();
productService.getOzelTarih().then((data2) => setOzeltarih(data2));
productService.getMagazalar().then((data) => setProducts(data));
}, []); // eslint-disable-line react-hooks/exhaustive-deps
const onRowEditCompletetarih = (e) => {
let _ozeltarih = [...ozeltarih];
let { newData, index } = e;
_ozeltarih[index] = newData;
setOzeltarih(_ozeltarih);
};
const textEditortarih = (options) => {
return <InputText type="text" value={options.value} onChange={(e) => options.editorCallback(e.target.value)} />;
};
Code: Select all
<DataTable paginator size="small" value={ozeltarih} editMode="row" onRowEditComplete={onRowEditCompletetarih} responsiveLayout="scroll">
<Column field="tarih" header="Tarih" editor={(options) => textEditortarih(options)} style={{ width: "20%" }}></Column>
<Column field="aSaat" header="Açılış Saati" editor={(options) => textEditortarih(options)} style={{ width: "20%" }}></Column>
<Column field="kSaat" header="Kapanış Saati" editor={(options) => textEditortarih(options)} style={{ width: "20%" }}></Column>
<Column rowEditor headerStyle={{ width: "10%", minWidth: "8rem" }} bodyStyle={{ textAlign: "center" }}></Column>
</DataTable>
Code: Select all
getOzelTarih() {
return axios.get('assets/demo/data/ozeltarih.json').then(res => res.data.data);
}
Code: Select all
{
"data": [
{"tarih": "09/08/22", "aSaat": "11:30", "kSaat": "22:00"},
{"tarih": "09/07/22", "aSaat": "11:30", "kSaat": "22:00"}
]
}