Skip to content
This repository was archived by the owner on Aug 29, 2025. It is now read-only.

Commit bf8544e

Browse files
committed
change invoice action impl. changing .http sample file
1 parent ae47021 commit bf8544e

File tree

13 files changed

+127
-95
lines changed

13 files changed

+127
-95
lines changed

media-store/app-src/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"@testing-library/user-event": "^7.1.2",
1616
"@umijs/hooks": "^1.9.3",
1717
"antd": "^4.8.2",
18+
"@ant-design/icons": "4.3.0",
1819
"axios": "^0.20.0",
1920
"clean-webpack-plugin": "^3.0.0",
2021
"copy-webpack-plugin": "^6.3.2",

media-store/app-src/src/api/calls.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,10 @@ const invoice = (tracks) => {
4343
return axiosInstance.post(
4444
`${INVOICES_SERVICE}/invoice`,
4545
{
46-
tracks: tracks.map(({ unitPrice, ID }) => ({
47-
unitPrice: `${unitPrice}`,
48-
ID,
49-
})),
46+
tracks,
5047
},
5148
{
52-
headers: { 'content-type': 'application/json;IEEE754Compatible=true' },
49+
headers: { 'content-type': 'application/json' },
5350
}
5451
);
5552
};

media-store/app-src/src/components/Header.jsx

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ const Header = () => {
3636
history.go(RELOAD_LOCATION_NUMBER);
3737
};
3838
const localeElements = AVAILABLE_LOCALES.filter((localeName) => localeName !== locale).map(
39-
(curLocale, index) => (
40-
<Menu.Item key={`${index}${curLocale}`} onClick={() => onChangeLocale(curLocale)}>
39+
(curLocale) => (
40+
<Menu.Item key={curLocale} onClick={() => onChangeLocale(curLocale)}>
4141
{curLocale}
4242
</Menu.Item>
4343
)
@@ -83,9 +83,6 @@ const Header = () => {
8383
Manages
8484
</Menu.Item>
8585
)}
86-
<span>
87-
{loading && <Spin indicator={<LoadingOutlined style={{ fontSize: 24 }} spin />} />}
88-
</span>
8986
</Menu>
9087

9188
<Menu
@@ -94,6 +91,9 @@ const Header = () => {
9491
mode="horizontal"
9592
selectedKeys={currentKey}
9693
>
94+
<Menu.Item>
95+
{loading && <Spin indicator={<LoadingOutlined style={{ fontSize: 24 }} spin />} />}
96+
</Menu.Item>
9797
{haveInvoicedItems && (
9898
<Menu.Item
9999
style={{
@@ -119,21 +119,19 @@ const Header = () => {
119119
</div>
120120
</Menu.Item>
121121
)}
122-
123122
<SubMenu title={locale}>{localeElements}</SubMenu>
124-
125-
{!!user ? (
123+
{user ? (
126124
<Menu.Item
127125
onClick={onUserLogout}
128126
danger
129127
icon={<LogoutOutlined style={{ fontSize: 16 }} />}
130-
></Menu.Item>
128+
/>
131129
) : (
132130
<Menu.Item
133131
key="/login"
134132
onClick={() => history.push('/login')}
135133
icon={<LoginOutlined style={{ fontSize: 16 }} />}
136-
></Menu.Item>
134+
/>
137135
)}
138136
</Menu>
139137
</div>

media-store/app-src/src/components/InvoicePage.jsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,8 @@ const InvoicePage = () => {
3838
const onBuy = () => {
3939
setLoading(true);
4040
invoice(
41-
invoicedItems.map(({ ID, unitPrice }) => ({
41+
invoicedItems.map(({ ID }) => ({
4242
ID,
43-
unitPrice,
4443
}))
4544
)
4645
.then(() => {

media-store/app-src/src/components/TracksPage.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ const TracksContainer = () => {
153153
const isAlreadyOrdered = !isEmployee && track.alreadyOrdered;
154154
const onDeleteTrack = isEmployee && ((ID) => deleteTrack(ID));
155155
return (
156-
<Col key={track.ID} className="gutter-row" span={8}>
156+
<Col key={`track-col${track.ID}`} className="gutter-row" span={8}>
157157
<TrackComponent
158158
initialTrack={track}
159159
onDeleteTrack={onDeleteTrack}

media-store/app-src/src/components/manage-store/TrackForm.jsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ const REQUIRED = [
1515
},
1616
];
1717

18-
const getAlbums = function (value) {
18+
function getAlbums(value) {
1919
return fetchAlbumsByName(value, ALBUMS_LIMIT)
2020
.then((response) => response.data.value)
2121
.catch(this.handleError);
22-
};
22+
}
2323

2424
const TrackForm = ({ initialAlbumTitle }) => {
2525
const { handleError } = useErrors();
@@ -89,5 +89,8 @@ const TrackForm = ({ initialAlbumTitle }) => {
8989
TrackForm.propTypes = {
9090
initialAlbumTitle: PropTypes.string,
9191
};
92+
TrackForm.defaultProps = {
93+
initialAlbumTitle: undefined,
94+
};
9295

9396
export { TrackForm };

media-store/app-src/src/components/tracks/EditAction.jsx

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,16 @@ const EditAction = ({ ID, name, composer, genre, unitPrice, album, afterTrackUpd
1818
setVisible(true);
1919
};
2020

21+
const afterCloseModal = () => {
22+
setUpdateLoading(true);
23+
getTrack(ID)
24+
.then((response) => {
25+
afterTrackUpdate(response.data);
26+
setUpdateLoading(false);
27+
})
28+
.catch(handleError);
29+
};
30+
2131
const onFinish = (value) => {
2232
setConfirmLoading(true);
2333
updateTrack({
@@ -45,16 +55,6 @@ const EditAction = ({ ID, name, composer, genre, unitPrice, album, afterTrackUpd
4555
setVisible(false);
4656
};
4757

48-
const afterCloseModal = () => {
49-
setUpdateLoading(true);
50-
getTrack(ID)
51-
.then((response) => {
52-
afterTrackUpdate(response.data);
53-
setUpdateLoading(false);
54-
})
55-
.catch(handleError);
56-
};
57-
5858
return (
5959
<>
6060
{updateLoading ? <LoadingOutlined /> : <EditOutlined onClick={onShowModal} />}
@@ -86,11 +86,11 @@ const EditAction = ({ ID, name, composer, genre, unitPrice, album, afterTrackUpd
8686
onFinish={onFinish}
8787
onFinishFailed={() => console.log('Not valid params provided')}
8888
initialValues={{
89-
name: name,
90-
composer: composer,
89+
name,
90+
composer,
9191
genreID: genre.ID,
9292
albumID: album.ID,
93-
unitPrice: unitPrice,
93+
unitPrice,
9494
}}
9595
>
9696
<TrackForm initialAlbumTitle={album.title} />

media-store/app-src/src/components/tracks/ManagedTrack.jsx

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
import React, { useState, useRef } from "react";
2-
import { Card } from "antd";
3-
import { EditAction } from "./EditAction";
4-
import { DeleteAction } from "./DeleteAction";
5-
import { TrackCardBody } from "./TrackCardBody";
6-
import "./ManagedTrack.css";
1+
import React, { useState, useRef } from 'react';
2+
import { Card } from 'antd';
3+
import PropTypes from 'prop-types';
4+
import { EditAction } from './EditAction';
5+
import { DeleteAction } from './DeleteAction';
6+
import { TrackCardBody } from './TrackCardBody';
7+
import './ManagedTrack.css';
78

89
const ManagedTrack = ({ initialTrack, onDeleteTrack }) => {
910
const trackElement = useRef();
@@ -39,4 +40,9 @@ const ManagedTrack = ({ initialTrack, onDeleteTrack }) => {
3940
);
4041
};
4142

43+
ManagedTrack.propTypes = {
44+
initialTrack: PropTypes.object.isRequired,
45+
onDeleteTrack: PropTypes.func.isRequired,
46+
};
47+
4248
export { ManagedTrack };

media-store/app-src/src/components/tracks/Track.jsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,11 @@ const Track = ({ initialTrack, isAlreadyOrdered }) => {
5353
};
5454

5555
Track.propTypes = {
56-
initialTrack: PropTypes.object,
56+
initialTrack: PropTypes.object.isRequired,
5757
isAlreadyOrdered: PropTypes.bool,
5858
};
59+
Track.defaultProps = {
60+
isAlreadyOrdered: undefined,
61+
};
5962

6063
export { Track };

media-store/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,4 @@
4141
}
4242
}
4343
}
44-
}
44+
}

0 commit comments

Comments
 (0)