Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
C
classwork-55
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Нұрасыл Қайратұлы
classwork-55
Commits
8f61cc6a
Commit
8f61cc6a
authored
May 14, 2024
by
Nurasyl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
24d58738
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
40 additions
and
4 deletions
+40
-4
App.tsx
src/App.tsx
+3
-1
OrderItem.css
src/components/Order/OrderItem/OrderItem.css
+1
-0
OrderItem.tsx
src/components/Order/OrderItem/OrderItem.tsx
+4
-3
Context.tsx
src/containers/Context.tsx
+21
-0
Orders.tsx
src/containers/Orders/Orders.tsx
+11
-0
No files found.
src/App.tsx
View file @
8f61cc6a
...
@@ -6,6 +6,7 @@ import { NotFound } from './components/NotFound/NotFound';
...
@@ -6,6 +6,7 @@ import { NotFound } from './components/NotFound/NotFound';
import
{
ContactData
}
from
'./containers/ContactData/ContactData'
;
import
{
ContactData
}
from
'./containers/ContactData/ContactData'
;
import
{
Layout
}
from
'./components/Layout/Layout'
;
import
{
Layout
}
from
'./components/Layout/Layout'
;
import
{
Orders
}
from
'./containers/Orders/Orders'
;
import
{
Orders
}
from
'./containers/Orders/Orders'
;
import
{
Context
}
from
'./containers/Context'
;
function
App
()
{
function
App
()
{
return
(
return
(
...
@@ -13,7 +14,8 @@ function App() {
...
@@ -13,7 +14,8 @@ function App() {
<
Routes
>
<
Routes
>
<
Route
path=
'/'
element=
{
<
Layout
/>
}
>
<
Route
path=
'/'
element=
{
<
Layout
/>
}
>
<
Route
index
element=
{
<
BurgerBuilder
/>
}
/>
<
Route
index
element=
{
<
BurgerBuilder
/>
}
/>
<
Route
path=
'/orders'
element=
{
<
Orders
/>
}
/>
<
Route
path=
'/orders'
element=
{
<
Context
/>
}
/>
<
Route
path=
'/order'
element=
{
<
Context
/>
}
/>
<
Route
path=
'/checkout'
element=
{
<
Checkout
/>
}
>
<
Route
path=
'/checkout'
element=
{
<
Checkout
/>
}
>
<
Route
path=
'contactData'
element=
{
<
ContactData
/>
}
/>
<
Route
path=
'contactData'
element=
{
<
ContactData
/>
}
/>
</
Route
>
</
Route
>
...
...
src/components/Order/OrderItem/OrderItem.css
View file @
8f61cc6a
...
@@ -5,6 +5,7 @@
...
@@ -5,6 +5,7 @@
padding
:
10px
;
padding
:
10px
;
margin
:
10px
auto
;
margin
:
10px
auto
;
box-sizing
:
border-box
;
box-sizing
:
border-box
;
cursor
:
pointer
;
}
}
.OrderItem
span
{
.OrderItem
span
{
text-transform
:
capitalize
;
text-transform
:
capitalize
;
...
...
src/components/Order/OrderItem/OrderItem.tsx
View file @
8f61cc6a
...
@@ -4,10 +4,11 @@ import "./OrderItem.css";
...
@@ -4,10 +4,11 @@ import "./OrderItem.css";
type
TProps
=
{
type
TProps
=
{
ingredients
:
Ingredients
,
ingredients
:
Ingredients
,
price
:
number
price
:
number
,
onClick
:
VoidFunction
};
};
export
const
OrderItem
=
({
ingredients
,
price
}:
TProps
)
=>
{
export
const
OrderItem
=
({
ingredients
,
price
,
onClick
}:
TProps
)
=>
{
const
ings
=
Object
.
keys
(
ingredients
).
map
(
igName
=>
{
const
ings
=
Object
.
keys
(
ingredients
).
map
(
igName
=>
{
return
{
return
{
name
:
igName
,
name
:
igName
,
...
@@ -20,7 +21,7 @@ export const OrderItem = ({ingredients, price}: TProps) => {
...
@@ -20,7 +21,7 @@ export const OrderItem = ({ingredients, price}: TProps) => {
));
));
return
(
return
(
<
div
className=
"OrderItem"
>
<
div
className=
"OrderItem"
onClick=
{
onClick
}
>
<
p
>
Ingredients:
{
ingredientOutput
}
</
p
>
<
p
>
Ingredients:
{
ingredientOutput
}
</
p
>
<
p
>
Price:
<
strong
>
{
price
}
KZT
</
strong
></
p
>
<
p
>
Price:
<
strong
>
{
price
}
KZT
</
strong
></
p
>
</
div
>
</
div
>
...
...
src/containers/Context.tsx
0 → 100644
View file @
8f61cc6a
import
React
,
{
useEffect
}
from
"react"
;
import
{
useLocation
}
from
"react-router-dom"
;
export
const
Context
=
()
=>
{
const
location
=
useLocation
();
useEffect
(()
=>
{
console
.
log
(
location
,
'location'
);
},
[]);
return
(
location
.
pathname
===
"/order"
?
<
div
>
Order Page
</
div
>
:
<
div
>
Orders Page
</
div
>
);
};
\ No newline at end of file
src/containers/Orders/Orders.tsx
View file @
8f61cc6a
import
React
,
{
useState
,
useEffect
,
useCallback
}
from
"react"
;
import
React
,
{
useState
,
useEffect
,
useCallback
}
from
"react"
;
import
{
useNavigate
}
from
"react-router-dom"
;
import
axiosBurger
from
"@/config/axiosBurger"
;
import
axiosBurger
from
"@/config/axiosBurger"
;
import
{
parseGetOrders
}
from
"@/helpers/parseGetOrders"
;
import
{
parseGetOrders
}
from
"@/helpers/parseGetOrders"
;
import
{
TOrder
}
from
"@/interfaces/order"
;
import
{
TOrder
}
from
"@/interfaces/order"
;
...
@@ -6,6 +7,8 @@ import { OrderItem } from "@/components/Order/OrderItem/OrderItem";
...
@@ -6,6 +7,8 @@ import { OrderItem } from "@/components/Order/OrderItem/OrderItem";
import
{
Spinner
}
from
"@/components/UI/Spinner/Spinner"
;
import
{
Spinner
}
from
"@/components/UI/Spinner/Spinner"
;
export
const
Orders
=
()
=>
{
export
const
Orders
=
()
=>
{
const
navigate
=
useNavigate
();
const
[
orders
,
setOrders
]
=
useState
<
TOrder
[]
>
([]);
const
[
orders
,
setOrders
]
=
useState
<
TOrder
[]
>
([]);
const
[
isLoading
,
setIsLoading
]
=
useState
<
boolean
>
(
false
);
const
[
isLoading
,
setIsLoading
]
=
useState
<
boolean
>
(
false
);
...
@@ -20,12 +23,20 @@ export const Orders = () => {
...
@@ -20,12 +23,20 @@ export const Orders = () => {
getOrders
();
getOrders
();
},
[]);
},
[]);
const
onClickHandler
=
(
id
:
string
)
=>
{
navigate
({
pathname
:
`/order`
})
};
return
(
return
(
<>
<>
<
Spinner
show=
{
isLoading
}
/>
<
Spinner
show=
{
isLoading
}
/>
{
{
orders
.
map
(
order
=>
(
orders
.
map
(
order
=>
(
<
OrderItem
<
OrderItem
onClick=
{
()
=>
onClickHandler
(
order
.
id
)
}
key=
{
order
.
id
}
key=
{
order
.
id
}
ingredients=
{
order
.
ingredients
}
ingredients=
{
order
.
ingredients
}
price=
{
order
.
price
}
price=
{
order
.
price
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment