All files / src/components/features/checkout ShippingMethod.tsx

100% Statements 127/127
100% Branches 10/10
100% Functions 4/4
100% Lines 127/127

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 1281x 1x 1x 1x 1x 1x 28x 28x 28x 28x 28x 28x 28x 28x 28x 28x 28x 28x 28x 28x 28x 28x 28x 28x 28x 28x 28x 28x 28x 28x 28x 28x 28x 28x 28x 28x 28x 28x 28x 28x 28x 28x 28x 28x 28x 28x 28x 28x 28x 28x 28x 28x 28x 28x 28x 28x 28x 28x 28x 28x 28x 28x 28x 28x 28x 28x 28x 28x 28x 28x 28x 28x 28x 28x 28x 28x 28x 28x 28x 28x 28x 28x 28x 28x 28x 28x 28x 28x 28x 28x 28x 28x 28x 28x 28x 28x 28x 28x 28x 28x 28x 28x 28x 28x 28x 28x 28x 28x 28x 28x 28x 28x 28x 28x 28x 28x 28x 28x 28x 28x 28x 28x 28x 28x 28x 1x 1x  
"use client";
 
import React, { useState } from "react";
import Image from "next/image";
 
const ShippingMethod = () => {
  const [shippingMethod, setShippingMethod] = useState("free");
  return (
    <div className="bg-white dark:bg-gray-800 shadow-1 rounded-[10px] mt-7.5">
      <div className="border-b border-gray-3 dark:border-gray-700 py-5 px-4 sm:px-8.5">
        <h3 className="font-medium text-xl text-dark dark:text-gray-100">Shipping Method</h3>
      </div>
 
      <div className="p-4 sm:p-8.5">
        <div className="flex flex-col gap-4">
          <label
            htmlFor="free"
            className="flex cursor-pointer select-none items-center gap-3.5 dark:text-gray-300"
          >
            <div className="relative">
              <input
                type="checkbox"
                name="free"
                id="free"
                className="sr-only"
                onChange={() => setShippingMethod("free")}
              />
              {/* selectShipping === 'free' ? 'border-4 border-blue' : 'border border-gray-4' */}
              <div
                className={`flex h-4 w-4 items-center justify-center rounded-full ${
                  shippingMethod === "free"
                    ? "border-4 border-blue"
                    : "border border-gray-4 dark:border-gray-600"
                }`}
              ></div>
            </div>
            Free Shipping
          </label>
 
          <label
            htmlFor="fedex"
            className="flex cursor-pointer select-none items-center gap-3.5 dark:text-gray-300"
          >
            <div className="relative">
              <input
                type="checkbox"
                name="fedex"
                id="fedex"
                className="sr-only"
                onChange={() => setShippingMethod("fedex")}
              />
              <div
                className={`flex h-4 w-4 items-center justify-center rounded-full ${
                  shippingMethod === "fedex"
                    ? "border-4 border-blue"
                    : "border border-gray-4 dark:border-gray-600"
                }`}
              ></div>
            </div>
 
            <div className="rounded-md border-[0.5px] border-gray-4 dark:border-gray-600 py-3.5 px-5 ease-out duration-200 hover:bg-gray-2 dark:hover:bg-gray-700 hover:border-transparent hover:shadow-none">
              <div className="flex items-center">
                <div className="pr-4">
                  <Image
                    src="/images/checkout/fedex.svg"
                    alt="fedex"
                    width={64}
                    height={18}
                    style={{ width: 'auto', height: 'auto' }}
                  />
                </div>
 
                <div className="border-l border-gray-4 dark:border-gray-600 pl-4">
                  <p className="font-semibold text-dark dark:text-gray-100">$10.99</p>
                  <p className="text-custom-xs dark:text-gray-400">Standard Shipping</p>
                </div>
              </div>
            </div>
          </label>
 
          <label
            htmlFor="dhl"
            className="flex cursor-pointer select-none items-center gap-3.5 dark:text-gray-300"
          >
            <div className="relative">
              <input
                type="checkbox"
                name="dhl"
                id="dhl"
                className="sr-only"
                onChange={() => setShippingMethod("dhl")}
              />
              <div
                className={`flex h-4 w-4 items-center justify-center rounded-full ${
                  shippingMethod === "dhl"
                    ? "border-4 border-blue"
                    : "border border-gray-4 dark:border-gray-600"
                }`}
              ></div>
            </div>
 
            <div className="rounded-md border-[0.5px] border-gray-4 dark:border-gray-600 py-3.5 px-5 ease-out duration-200 hover:bg-gray-2 dark:hover:bg-gray-700 hover:border-transparent hover:shadow-none">
              <div className="flex items-center">
                <div className="pr-4">
                  <Image
                    src="/images/checkout/dhl.svg"
                    alt="dhl"
                    width={64}
                    height={20}
                    style={{ width: 'auto', height: 'auto' }}
                  />
                </div>
 
                <div className="border-l border-gray-4 dark:border-gray-600 pl-4">
                  <p className="font-semibold text-dark dark:text-gray-100">$12.50</p>
                  <p className="text-custom-xs dark:text-gray-400">Standard Shipping</p>
                </div>
              </div>
            </div>
          </label>
        </div>
      </div>
    </div>
  );
};
 
export default ShippingMethod;