@bikdotai/bik-component-library 0.0.115683-beta.1 → 0.0.115684-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("react/jsx-runtime"),i=require("date-fns"),a=require("react"),s=require("../../custom-date-time/CustomDateTime.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("react/jsx-runtime"),i=require("date-fns"),a=require("react"),s=require("../../custom-date-time/CustomDateTime.js"),r=require("../../input/Input.js"),o=require("../../radioButton/RadioButton.js"),n=require("../../TypographyStyle.js");exports.COUPON_EXPIRATION=void 0,(e=exports.COUPON_EXPIRATION||(exports.COUPON_EXPIRATION={})).FIXED_EXPIRATION="fixedExpiration",e.DYNAMIC_EXPIRATION="dynamicExpiration";exports.CouponExpiration=e=>{var I;const[O,d]=a.useState(e.discountData.expireAt?exports.COUPON_EXPIRATION.FIXED_EXPIRATION:e.discountData.expireAfter?exports.COUPON_EXPIRATION.DYNAMIC_EXPIRATION:void 0),[p,x]=a.useState(),[u,A]=a.useState(),N=(new Date).setDate((new Date).getDate()+1);a.useEffect((()=>{d(e.discountData.expireAt?exports.COUPON_EXPIRATION.FIXED_EXPIRATION:e.discountData.expireAfter?exports.COUPON_EXPIRATION.DYNAMIC_EXPIRATION:void 0)}),[]),a.useEffect((()=>{(null==O||p||u)&&e.setDiscountData(Object.assign(Object.assign({},e.discountData),{expireAfter:void 0,expireAt:void 0})),O&&(p||u)&&(O===exports.COUPON_EXPIRATION.FIXED_EXPIRATION?A(void 0):x(void 0))}),[O,p,u]);return t.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:13}},{children:[t.jsx(n.TitleRegular,{children:"Coupon expiration (optional)"}),t.jsxs("div",Object.assign({style:{display:"flex",gap:18}},{children:[t.jsx(o.RadioButton,{isActive:O===exports.COUPON_EXPIRATION.DYNAMIC_EXPIRATION,onValueChange:()=>{A(void 0),d(O===exports.COUPON_EXPIRATION.DYNAMIC_EXPIRATION?void 0:exports.COUPON_EXPIRATION.DYNAMIC_EXPIRATION)}}),t.jsx(n.BodySecondary,{children:"Validity days from coupon claim"})]})),O===exports.COUPON_EXPIRATION.DYNAMIC_EXPIRATION&&t.jsx(r.Input,{errorMessage:u,value:null===(I=e.discountData.expireAfter)||void 0===I?void 0:I.toString(),placeholder:"Enter the number of days",width:"400px",type:"number",onChangeText:t=>{(t=>{A(void 0);const i=Number.parseInt(t);i>0?e.setDiscountData(Object.assign(Object.assign({},e.discountData),{expireAfter:i,expireAt:void 0})):A("Please enter valid input")})(t)}}),t.jsxs("div",Object.assign({style:{display:"flex",gap:18}},{children:[t.jsx(o.RadioButton,{isActive:O===exports.COUPON_EXPIRATION.FIXED_EXPIRATION,onValueChange:()=>{d(O===exports.COUPON_EXPIRATION.FIXED_EXPIRATION?void 0:exports.COUPON_EXPIRATION.FIXED_EXPIRATION)}}),t.jsx(n.BodySecondary,{children:"Fixed expiry date"})]})),O===exports.COUPON_EXPIRATION.FIXED_EXPIRATION&&t.jsxs(t.Fragment,{children:[t.jsx(n.BodySecondary,{children:"Ending on"}),t.jsx(s.CustomDateTime,{placement:"bottom-start",time:e.discountData.expireAt?i.format(new Date(e.discountData.expireAt),"hh:mm a"):i.format(new Date(N),"hh:mm a"),date:e.discountData.expireAt?new Date(e.discountData.expireAt):new Date(N),error:p,setError:x,onChange:t=>{e.setDiscountData(Object.assign(Object.assign({},e.discountData),{expireAt:t,expireAfter:void 0}))},minDate:new Date(N)})]})]}))};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as e,jsx as t,Fragment as i}from"react/jsx-runtime";import{format as a}from"date-fns";import{useState as
|
|
1
|
+
import{jsxs as e,jsx as t,Fragment as i}from"react/jsx-runtime";import{format as a}from"date-fns";import{useState as n,useEffect as o}from"react";import{CustomDateTime as r}from"../../custom-date-time/CustomDateTime.js";import{Input as s}from"../../input/Input.js";import{RadioButton as d}from"../../radioButton/RadioButton.js";import{TitleRegular as c,BodySecondary as I}from"../../TypographyStyle.js";var p;!function(e){e.FIXED_EXPIRATION="fixedExpiration",e.DYNAMIC_EXPIRATION="dynamicExpiration"}(p||(p={}));const D=D=>{var A;const[u,l]=n(D.discountData.expireAt?p.FIXED_EXPIRATION:D.discountData.expireAfter?p.DYNAMIC_EXPIRATION:void 0),[m,x]=n(),[E,O]=n(),v=(new Date).setDate((new Date).getDate()+1);o((()=>{l(D.discountData.expireAt?p.FIXED_EXPIRATION:D.discountData.expireAfter?p.DYNAMIC_EXPIRATION:void 0)}),[]),o((()=>{(null==u||m||E)&&D.setDiscountData(Object.assign(Object.assign({},D.discountData),{expireAfter:void 0,expireAt:void 0})),u&&(m||E)&&(u===p.FIXED_EXPIRATION?O(void 0):x(void 0))}),[u,m,E]);return e("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:13}},{children:[t(c,{children:"Coupon expiration (optional)"}),e("div",Object.assign({style:{display:"flex",gap:18}},{children:[t(d,{isActive:u===p.DYNAMIC_EXPIRATION,onValueChange:()=>{O(void 0),l(u===p.DYNAMIC_EXPIRATION?void 0:p.DYNAMIC_EXPIRATION)}}),t(I,{children:"Validity days from coupon claim"})]})),u===p.DYNAMIC_EXPIRATION&&t(s,{errorMessage:E,value:null===(A=D.discountData.expireAfter)||void 0===A?void 0:A.toString(),placeholder:"Enter the number of days",width:"400px",type:"number",onChangeText:e=>{(e=>{O(void 0);const t=Number.parseInt(e);t>0?D.setDiscountData(Object.assign(Object.assign({},D.discountData),{expireAfter:t,expireAt:void 0})):O("Please enter valid input")})(e)}}),e("div",Object.assign({style:{display:"flex",gap:18}},{children:[t(d,{isActive:u===p.FIXED_EXPIRATION,onValueChange:()=>{l(u===p.FIXED_EXPIRATION?void 0:p.FIXED_EXPIRATION)}}),t(I,{children:"Fixed expiry date"})]})),u===p.FIXED_EXPIRATION&&e(i,{children:[t(I,{children:"Ending on"}),t(r,{placement:"bottom-start",time:D.discountData.expireAt?a(new Date(D.discountData.expireAt),"hh:mm a"):a(new Date(v),"hh:mm a"),date:D.discountData.expireAt?new Date(D.discountData.expireAt):new Date(v),error:m,setError:x,onChange:e=>{D.setDiscountData(Object.assign(Object.assign({},D.discountData),{expireAt:e,expireAfter:void 0}))},minDate:new Date(v)})]})]}))};export{p as COUPON_EXPIRATION,D as CouponExpiration};
|