|
| 1 | +module Checkout.View exposing (PopupConfig, TextData, addPopupContainerView, failedAddressVerificationPopupView, textData) |
| 2 | + |
| 3 | +import Components.Address.Address as Address |
| 4 | +import Components.Button as Button exposing (defaultButton) |
| 5 | +import Data.Locations exposing (AddressLocations) |
| 6 | +import Html exposing (..) |
| 7 | +import Html.Attributes exposing (..) |
| 8 | + |
| 9 | + |
| 10 | + |
| 11 | +--------------------------------------------------------- |
| 12 | +-- Types |
| 13 | +--------------------------------------------------------- |
| 14 | + |
| 15 | + |
| 16 | +type alias PopupConfig msg = |
| 17 | + { onEdit : msg |
| 18 | + , onContinue : msg |
| 19 | + , address : Address.Form |
| 20 | + , locations : AddressLocations |
| 21 | + } |
| 22 | + |
| 23 | + |
| 24 | +type alias TextData = |
| 25 | + { title : String |
| 26 | + , descriptionLine1 : String |
| 27 | + , descriptionLine2 : String |
| 28 | + , shippingDetailsHeader : String |
| 29 | + , editAddressLabel : String |
| 30 | + , continueAnywayLabelMobile : String |
| 31 | + , continueAnywayLabelDesktop : String |
| 32 | + } |
| 33 | + |
| 34 | + |
| 35 | +textData : TextData |
| 36 | +textData = |
| 37 | + { title = "We couldn't automatically verify this address" |
| 38 | + , descriptionLine1 = "An unverified address is not necessarily incorrect, but it may cause delivery issues." |
| 39 | + , descriptionLine2 = "Please check the address again or continue if you're sure it's correct." |
| 40 | + , shippingDetailsHeader = "Shipping Details" |
| 41 | + , editAddressLabel = "Edit address" |
| 42 | + , continueAnywayLabelMobile = "Continue" |
| 43 | + , continueAnywayLabelDesktop = "Continue anyway" |
| 44 | + } |
| 45 | + |
| 46 | + |
| 47 | + |
| 48 | +--------------------------------------------------------- |
| 49 | +-- Views |
| 50 | +--------------------------------------------------------- |
| 51 | + |
| 52 | + |
| 53 | +addPopupContainerView : Html msg -> Html msg |
| 54 | +addPopupContainerView content = |
| 55 | + div [ class "tw:fixed tw:inset-0 tw:z-50 tw:flex tw:items-center tw:justify-center tw:bg-[#1E0C03]/50 tw:p-[16px]" ] |
| 56 | + [ content ] |
| 57 | + |
| 58 | + |
| 59 | +failedAddressVerificationPopupView : PopupConfig msg -> Html msg |
| 60 | +failedAddressVerificationPopupView config = |
| 61 | + div [ class "tw:relative tw:w-full tw:max-w-[696px] tw:rounded-[16px] tw:bg-white tw:p-[32px] tw:shadow-xl" ] |
| 62 | + [ -- Title |
| 63 | + div [ class "tw:pb-[24px] tw:pr-[24px]" ] |
| 64 | + [ h2 [ class "tw:!text-[24px] tw:!font-[600] tw:!leading-[32px] tw:!text-[#1E0C03]" ] |
| 65 | + [ text textData.title ] |
| 66 | + ] |
| 67 | + |
| 68 | + -- Description |
| 69 | + , div [ class "tw:pb-[16px]" ] |
| 70 | + [ p [ class "tw:!text-[16px] tw:!font-[400] tw:!leading-[24px] tw:!text-[#1E0C03]" ] |
| 71 | + [ text textData.descriptionLine1 |
| 72 | + , br [] [] |
| 73 | + , strong [ class "tw:!font-[600]" ] [ text textData.descriptionLine2 ] |
| 74 | + ] |
| 75 | + ] |
| 76 | + |
| 77 | + -- Shipping Details Box |
| 78 | + , div [ class "tw:pb-[32px]" ] |
| 79 | + [ div [ class "tw:rounded-[8px] tw:bg-[#F9F9F9] tw:p-[24px]" ] |
| 80 | + [ div [ class "tw:pb-[16px]" ] |
| 81 | + [ h3 [ class "tw:!text-[14px] tw:!font-[400] tw:opacity-70" ] [ text textData.shippingDetailsHeader ] ] |
| 82 | + , div [ class "tw:text-[16px] tw:leading-[24px] tw:text-[#1E0C03]" ] |
| 83 | + [ Address.card config.address.model config.locations ] |
| 84 | + ] |
| 85 | + ] |
| 86 | + |
| 87 | + -- Actions |
| 88 | + , div [ class "tw:flex tw:gap-[12px] tw:justify-center" ] |
| 89 | + [ Button.view |
| 90 | + { defaultButton |
| 91 | + | label = textData.editAddressLabel |
| 92 | + , style = Button.Outline |
| 93 | + , type_ = Button.TriggerMsg config.onEdit |
| 94 | + , size = Button.Large |
| 95 | + , padding = Button.Width "tw:w-1/2 tw:lg:w-[194px]" |
| 96 | + } |
| 97 | + , Button.view |
| 98 | + { defaultButton |
| 99 | + | label = "" |
| 100 | + , icon = |
| 101 | + Just <| |
| 102 | + div [] |
| 103 | + [ span [ class "tw:inline tw:lg:hidden" ] [ text textData.continueAnywayLabelMobile ] |
| 104 | + , span [ class "tw:hidden tw:lg:inline" ] [ text textData.continueAnywayLabelDesktop ] |
| 105 | + ] |
| 106 | + , style = Button.Solid |
| 107 | + , type_ = Button.TriggerMsg config.onContinue |
| 108 | + , size = Button.Large |
| 109 | + , padding = Button.Width "tw:w-1/2 tw:lg:w-[194px]" |
| 110 | + } |
| 111 | + ] |
| 112 | + ] |
0 commit comments