-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(checkout): build shipping info flow (#57)
* feat(checkout): build shipping info flow * build current locations view * Add progress bar * remvoe console log * rearrange imports * add missing trackPageView * linter * add gap * add newline at eof
- Loading branch information
Showing
26 changed files
with
929 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from './location-info' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { Text } from '~/components' | ||
|
||
import type { LocationInfoProps } from "./types" | ||
|
||
const LocationInfo = ({ location }: LocationInfoProps) => { | ||
const { street_address, postal_code, city, country, extra_info } = location | ||
|
||
return ( | ||
<div className="flex flex-col sm:flex-row sm:gap-4 sm:items-center"> | ||
<Text variant="heading-6"> | ||
{ street_address } | ||
</Text> | ||
<Text variant="body"> | ||
{ postal_code } { city }, { country } | ||
</Text> | ||
<Text variant="body" className="opacity-50"> | ||
{ extra_info } | ||
</Text> | ||
</div> | ||
) | ||
} | ||
|
||
export default LocationInfo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import type { Location } from '~/models/location' | ||
|
||
export interface LocationInfoProps { | ||
location: Location | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from './progress-bar' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import type { ProgressBarProps } from "./types" | ||
|
||
const ProgressBar = ({ progress }: ProgressBarProps) => { | ||
return ( | ||
<div className="w-full"> | ||
<div style={{width: progress}} className="h-1 bg-orange transition-all" /> | ||
</div> | ||
) | ||
} | ||
|
||
export default ProgressBar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export interface ProgressBarProps { | ||
progress: string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
import type { InputHTMLAttributes } from 'react' | ||
import type { ReactNode, InputHTMLAttributes } from 'react' | ||
|
||
export interface RadioInputProps extends InputHTMLAttributes<HTMLInputElement> { | ||
label: string | ||
label: ReactNode | ||
className?: string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from './use-map' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import type { LngLatLike } from 'mapbox-gl' | ||
|
||
export interface MarkerArgs { | ||
position: LngLatLike | ||
} | ||
|
||
export interface UseMapArgs { | ||
containerId: string | ||
mapboxToken: string | ||
center?: LngLatLike | ||
marker?: MarkerArgs | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { useEffect, useState } from 'react'; | ||
import mapboxgl from 'mapbox-gl' | ||
|
||
import type { Map } from 'mapbox-gl' | ||
import type { UseMapArgs } from './types' | ||
|
||
const MAP_ZOOM_LEVEL = 17 | ||
const MAP_STYLES_URL = 'mapbox://styles/mapbox/streets-v12' | ||
|
||
const useMap = ({ containerId, center, marker, mapboxToken }: UseMapArgs) => { | ||
const [map, setMap] = useState<Map | undefined>() | ||
|
||
useEffect(() => { | ||
if (!containerId || !center || !mapboxToken) return; | ||
if (map) return | ||
|
||
mapboxgl.accessToken = mapboxToken; | ||
const createdMap = new mapboxgl.Map({ | ||
container: containerId, | ||
style: MAP_STYLES_URL, | ||
center, | ||
zoom: MAP_ZOOM_LEVEL | ||
}); | ||
|
||
setMap(createdMap) | ||
}, [map, containerId, center, mapboxToken]) | ||
|
||
useEffect(() => { | ||
if (!map) return; | ||
if (!marker) return; | ||
|
||
const { position } = marker | ||
|
||
new mapboxgl.Marker() | ||
.setLngLat(position) | ||
.addTo(map) | ||
|
||
setMap(map) | ||
}, [map, marker]) | ||
|
||
return { | ||
map | ||
} | ||
} | ||
|
||
export default useMap |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './location.server' | ||
export * from './schema' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import z from 'zod' | ||
import * as AudiophileClient from '~/utils/audiophile-client' | ||
import { LocationSchema } from './schema' | ||
|
||
import type { LocationPayload } from './schema' | ||
|
||
export const createLocation = async (authToken: string, locationPayload: LocationPayload) => { | ||
const response = await AudiophileClient.sendRequest('post', 'locations', { | ||
authToken, | ||
body: locationPayload | ||
}) | ||
|
||
const location = LocationSchema.parse(response) | ||
return location | ||
} | ||
|
||
export const getLocation = async(authToken: string, locationUuid: string) => { | ||
const response = await AudiophileClient.sendRequest('get', `locations/${locationUuid}`, { authToken }) | ||
|
||
const location = LocationSchema.parse(response) | ||
return location | ||
} | ||
|
||
export const deleteLocation = async(authToken: string, locationUuid: string) => { | ||
await AudiophileClient.sendRequest('delete', `locations/${locationUuid}`, { authToken }) | ||
} | ||
|
||
export const getAllLocations = async(authToken: string) => { | ||
const response = await AudiophileClient.sendRequest('get', 'locations', { authToken }) | ||
const locations = z.array(LocationSchema).parse(response) | ||
|
||
return locations | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import z from 'zod' | ||
|
||
export interface LocationPayload { | ||
street_address: string | ||
city: string | ||
country: string | ||
postal_code: string | ||
extra_info?: string | ||
} | ||
|
||
export const LocationSchema = z.object({ | ||
uuid: z.string(), | ||
extra_info: z.string().nullable(), | ||
street_address: z.string(), | ||
city: z.string(), | ||
country: z.string(), | ||
postal_code: z.string(), | ||
longitude: z.string(), | ||
latitude: z.string() | ||
}) | ||
|
||
export type Location = z.infer<typeof LocationSchema> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { Outlet } from '@remix-run/react' | ||
import { Text } from '~/components' | ||
|
||
export default () => { | ||
return ( | ||
<div> | ||
<Text variant="subtitle" as="h3" className="mb-4"> | ||
Shipping Info | ||
</Text> | ||
|
||
<Outlet /> | ||
</div> | ||
) | ||
} |
Oops, something went wrong.