Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
B
burger-builder-template
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
Нұрасыл Қайратұлы
burger-builder-template
Commits
f3cae6c1
Commit
f3cae6c1
authored
Jan 09, 2025
by
Нұрасыл Қайратұлы
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updts
parent
6633a6d1
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
201 additions
and
27 deletions
+201
-27
CheckoutSummary.css
src/components/Order/CheckoutSummary/CheckoutSummary.css
+11
-0
CheckoutSummary.tsx
src/components/Order/CheckoutSummary/CheckoutSummary.tsx
+39
-0
Button.css
src/components/UI/Button/Button.css
+25
-0
Button.tsx
src/components/UI/Button/Button.tsx
+16
-0
BurgerBuilder.tsx
src/containers/BurgerBuilder/BurgerBuilder.tsx
+6
-5
Checkout.tsx
src/containers/Checkout/Checkout.tsx
+35
-0
ContactData.css
src/containers/Checkout/ContactData/ContactData.css
+19
-0
ContactData.tsx
src/containers/Checkout/ContactData/ContactData.tsx
+46
-0
CheckoutSummary.tsx
src/containers/CheckoutSummary/CheckoutSummary.tsx
+0
-18
main.tsx
src/main.tsx
+4
-4
No files found.
src/components/Order/CheckoutSummary/CheckoutSummary.css
0 → 100644
View file @
f3cae6c1
.CheckoutSummary
{
text-align
:
center
;
width
:
80%
;
margin
:
auto
;
}
@media
(
min-width
:
600px
)
{
.CheckoutSummary
{
width
:
500px
;
}
}
\ No newline at end of file
src/components/Order/CheckoutSummary/CheckoutSummary.tsx
0 → 100644
View file @
f3cae6c1
import
Burger
from
"@/components/Burger/Burger"
;
import
Button
from
"@/components/UI/Button/Button"
;
import
type
{
Ingredients
}
from
"@/interfaces/Ingredients"
;
import
{
MouseEventHandler
}
from
"react"
;
import
"./CheckoutSummary.css"
;
interface
Props
{
ingredients
:
Ingredients
;
checkoutContinued
:
MouseEventHandler
<
HTMLButtonElement
>
;
checkoutCancelled
:
MouseEventHandler
<
HTMLButtonElement
>
;
}
const
CheckoutSummary
=
(
props
:
Props
)
=>
{
return
(
<
div
className=
"CheckoutSummary"
>
<
h1
>
We hope it tastes well!
</
h1
>
<
div
style=
{
{
width
:
"100%"
,
margin
:
"auto"
}
}
>
<
Burger
ingredients=
{
props
.
ingredients
}
/>
</
div
>
<
Button
btnType=
"Danger"
click=
{
props
.
checkoutCancelled
}
>
CANCEL
</
Button
>
<
Button
btnType=
"Success"
click=
{
props
.
checkoutContinued
}
>
CONTINUE
</
Button
>
</
div
>
);
};
export
default
CheckoutSummary
;
src/components/UI/Button/Button.css
0 → 100644
View file @
f3cae6c1
.Button
{
background-color
:
transparent
;
border
:
none
;
color
:
white
;
outline
:
none
;
cursor
:
pointer
;
font
:
inherit
;
padding
:
10px
;
margin
:
10px
;
font-weight
:
bold
;
}
.Button
:first-of-type
{
margin-left
:
0
;
padding-left
:
0
;
}
.Success
{
color
:
#5C9210
;
}
.Danger
{
color
:
#944317
;
}
\ No newline at end of file
src/components/UI/Button/Button.tsx
0 → 100644
View file @
f3cae6c1
import
type
{
MouseEventHandler
,
ReactNode
}
from
"react"
;
import
"./Button.css"
;
interface
Props
{
click
:
MouseEventHandler
<
HTMLButtonElement
>
;
btnType
:
"Success"
|
"Danger"
;
children
:
ReactNode
;
}
const
Button
=
(
props
:
Props
)
=>
(
<
button
onClick=
{
props
.
click
}
className=
{
[
"Button"
,
props
.
btnType
].
join
(
" "
)
}
>
{
props
.
children
}
</
button
>
);
export
default
Button
;
src/containers/BurgerBuilder/BurgerBuilder.tsx
View file @
f3cae6c1
...
@@ -4,12 +4,11 @@ import OrderSummary from '@/components/Burger/OrderSummary/OrderSummary';
...
@@ -4,12 +4,11 @@ import OrderSummary from '@/components/Burger/OrderSummary/OrderSummary';
import
Modal
from
'@/components/UI/Modal/Modal'
;
import
Modal
from
'@/components/UI/Modal/Modal'
;
import
{
IngredientNames
,
IngredientPrices
,
Ingredients
}
from
'@/interfaces/Ingredients'
;
import
{
IngredientNames
,
IngredientPrices
,
Ingredients
}
from
'@/interfaces/Ingredients'
;
import
{
useState
}
from
'react'
;
import
{
useState
}
from
'react'
;
import
{
createSearchParams
,
URLSearchParamsInit
,
useNavigate
,
useSearchParams
}
from
'react-router-dom'
import
{
createSearchParams
,
URLSearchParamsInit
,
useNavigate
}
from
'react-router-dom'
const
BurgerBuilder
=
()
=>
{
const
BurgerBuilder
=
()
=>
{
const
navigate
=
useNavigate
()
const
navigate
=
useNavigate
()
const
[
searchParams
,
setSearchParams
]
=
useSearchParams
();
const
[
totalPrice
,
setTotalPrice
]
=
useState
<
number
>
(
IngredientPrices
.
bread
);
const
[
totalPrice
,
setTotalPrice
]
=
useState
<
number
>
(
IngredientPrices
.
bread
);
const
[
purchasable
,
setPurchasable
]
=
useState
<
boolean
>
(
false
);
const
[
purchasable
,
setPurchasable
]
=
useState
<
boolean
>
(
false
);
const
[
open
,
setOpen
]
=
useState
<
boolean
>
(
false
);
const
[
open
,
setOpen
]
=
useState
<
boolean
>
(
false
);
...
@@ -61,10 +60,12 @@ const BurgerBuilder = () => {
...
@@ -61,10 +60,12 @@ const BurgerBuilder = () => {
}
}
const
onContinueHandler
=
()
=>
{
const
onContinueHandler
=
()
=>
{
const
params
=
createSearchParams
(
ingredients
as
unknown
as
URLSearchParamsInit
)
const
params
=
createSearchParams
(
ingredients
as
unknown
as
URLSearchParamsInit
)
;
setSearchParams
(
params
)
navigate
({
navigate
(
'/checkout'
)
pathname
:
'/checkout'
,
search
:
`?
${
params
.
toString
()}
`
})
}
}
return
(
return
(
...
...
src/containers/Checkout/Checkout.tsx
0 → 100644
View file @
f3cae6c1
import
{
useRef
}
from
'react'
;
import
type
{
Ingredients
}
from
'@/interfaces/Ingredients'
;
import
CheckoutSummary
from
'@/components/Order/CheckoutSummary/CheckoutSummary'
;
import
{
useNavigate
,
useSearchParams
,
Outlet
}
from
'react-router-dom'
;
const
parseSearch
=
<
T
extends
Object
,
>
(searchParams: URLSearchParams): T =
>
{
return
Object
.
fromEntries
(
searchParams
)
as
unknown
as
T
;
}
const Checkout = () =
>
{
const
navigate
=
useNavigate
();
const
[
searchParams
]
=
useSearchParams
();
const
ingredients
=
useRef
(
parseSearch
<
Ingredients
>
(
searchParams
));
const
checkoutCancelledHandler
=
()
=>
{
navigate
(
-
1
);
};
const
checkoutContinuedHandler
=
()
=>
{
navigate
(
'contact-data'
,
{
state
:
{
ingredients
:
ingredients
.
current
}});
};
return
(
<>
<
CheckoutSummary
ingredients=
{
ingredients
.
current
}
checkoutCancelled=
{
checkoutCancelledHandler
}
checkoutContinued=
{
checkoutContinuedHandler
}
/>
<
Outlet
/>
</>
)
}
;
export default Checkout;
\ No newline at end of file
src/containers/Checkout/ContactData/ContactData.css
0 → 100644
View file @
f3cae6c1
.ContactData
{
margin
:
20px
auto
;
width
:
80%
;
text-align
:
center
;
box-shadow
:
0
2px
3px
#ccc
;
border
:
1px
solid
#eee
;
padding
:
10px
;
box-sizing
:
border-box
;
}
.Input
{
display
:
block
;
}
@media
(
min-width
:
600px
)
{
.ContactData
{
width
:
500px
;
}
}
\ No newline at end of file
src/containers/Checkout/ContactData/ContactData.tsx
0 → 100644
View file @
f3cae6c1
import
Button
from
"@/components/UI/Button/Button"
;
import
"./ContactData.css"
;
const
ContactData
=
()
=>
{
return
(
<
div
className=
"ContactData"
>
<
h4
>
Enter your Contact Data
</
h4
>
<
form
>
<
input
className=
"Input"
type=
"text"
name=
"name"
placeholder=
"Your Name"
/>
<
input
className=
"Input"
type=
"email"
name=
"email"
placeholder=
"Your Mail"
/>
<
input
className=
"Input"
type=
"text"
name=
"street"
placeholder=
"Street"
/>
<
input
className=
"Input"
type=
"text"
name=
"postal"
placeholder=
"Postal Code"
/>
<
Button
click=
{
()
=>
{}
}
btnType=
"Success"
>
ORDER
</
Button
>
</
form
>
</
div
>
);
};
export
default
ContactData
;
src/containers/CheckoutSummary/CheckoutSummary.tsx
deleted
100644 → 0
View file @
6633a6d1
import
{
useNavigate
,
Outlet
,
NavLink
}
from
"react-router-dom"
const
CheckoutSummary
=
()
=>
{
const
navigate
=
useNavigate
()
return
(
<
div
>
<
h1
>
CheckoutSummary
</
h1
>
<
NavLink
to=
{
'/'
}
end
>
contact
</
NavLink
>
<
Outlet
/>
</
div
>
)
}
export
default
CheckoutSummary
\ No newline at end of file
src/main.tsx
View file @
f3cae6c1
import
ReactDOM
from
'react-dom/client'
import
ReactDOM
from
'react-dom/client'
import
{
BrowserRouter
,
Route
,
Routes
}
from
'react-router-dom'
import
{
BrowserRouter
,
Route
,
Routes
}
from
'react-router-dom'
import
BurgerBuilder
from
'./containers/BurgerBuilder/BurgerBuilder'
import
BurgerBuilder
from
'./containers/BurgerBuilder/BurgerBuilder'
import
CheckoutSummary
from
'./containers/CheckoutSummary/CheckoutSummary'
import
Checkout
from
'./containers/Checkout/Checkout'
import
ContactData
from
'./containers/Checkout/ContactData/ContactData'
import
'./index.css'
import
'./index.css'
ReactDOM
.
createRoot
(
document
.
getElementById
(
'root'
)
as
HTMLElement
).
render
(
ReactDOM
.
createRoot
(
document
.
getElementById
(
'root'
)
as
HTMLElement
).
render
(
<
BrowserRouter
>
<
BrowserRouter
>
<
Routes
>
<
Routes
>
<
Route
path=
'/'
element=
{
<
BurgerBuilder
/>
}
/>
<
Route
path=
'/'
element=
{
<
BurgerBuilder
/>
}
/>
<
Route
path=
'/checkout'
element=
{
<
CheckoutSummary
/>
}
>
<
Route
path=
"/checkout"
element=
{
<
Checkout
/>
}
>
<
Route
index
element=
{
<
h1
>
I am product
</
h1
>
}
/>
<
Route
path=
"contact-data"
element=
{
<
ContactData
/>
}
/>
<
Route
element=
{
<
h1
>
I am contact
</
h1
>
}
/>
</
Route
>
</
Route
>
</
Routes
>
</
Routes
>
</
BrowserRouter
>
</
BrowserRouter
>
...
...
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