@n1xyz/wallet-widget 0.0.14 → 0.0.15

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.
Files changed (111) hide show
  1. package/dist/Modal/LoadingFallback.js +1 -1
  2. package/dist/Modal/LoadingFallback.js.map +1 -1
  3. package/dist/Modal/N1WalletModal.js +6 -5
  4. package/dist/Modal/N1WalletModal.js.map +1 -1
  5. package/dist/Modal/NTSFlow/LoadingFallback.js +1 -1
  6. package/dist/Modal/NTSFlow/LoadingFallback.js.map +1 -1
  7. package/dist/Modal/NTSFlow/components/BackButton.js +1 -1
  8. package/dist/Modal/NTSFlow/components/BackButton.js.map +1 -1
  9. package/dist/Modal/NTSFlow/components/ModalHeader.js +1 -1
  10. package/dist/Modal/NTSFlow/components/ModalHeader.js.map +1 -1
  11. package/dist/Modal/NTSFlow/views/ConnectView.js +2 -2
  12. package/dist/Modal/NTSFlow/views/ConnectView.js.map +1 -1
  13. package/dist/Modal/NTSFlow/views/CreateSessionView.js +5 -5
  14. package/dist/Modal/NTSFlow/views/CreateSessionView.js.map +1 -1
  15. package/dist/Modal/NTSFlow/views/CreateUserView.js +1 -1
  16. package/dist/Modal/NTSFlow/views/CreateUserView.js.map +1 -1
  17. package/dist/Modal/NTSFlow/views/NoWhitelistView.js +3 -3
  18. package/dist/Modal/NTSFlow/views/NoWhitelistView.js.map +1 -1
  19. package/dist/Modal/NTSFlow/views/SigningView.js +1 -1
  20. package/dist/Modal/NTSFlow/views/SigningView.js.map +1 -1
  21. package/dist/Modal/NordFlow/NordFlow.js +2 -2
  22. package/dist/Modal/NordFlow/NordFlow.js.map +1 -1
  23. package/dist/Modal/NordFlow/components/ChainButton.js +5 -5
  24. package/dist/Modal/NordFlow/components/ChainButton.js.map +1 -1
  25. package/dist/Modal/NordFlow/components/EVMChainsButton.js +4 -4
  26. package/dist/Modal/NordFlow/components/EVMChainsButton.js.map +1 -1
  27. package/dist/Modal/NordFlow/components/Header.js +1 -1
  28. package/dist/Modal/NordFlow/components/Header.js.map +1 -1
  29. package/dist/Modal/NordFlow/components/ImageWithFallback.js +1 -1
  30. package/dist/Modal/NordFlow/components/ImageWithFallback.js.map +1 -1
  31. package/dist/Modal/NordFlow/components/LoadingSquares.js +1 -1
  32. package/dist/Modal/NordFlow/components/LoadingSquares.js.map +1 -1
  33. package/dist/Modal/NordFlow/components/MoreButton.js +4 -4
  34. package/dist/Modal/NordFlow/components/MoreButton.js.map +1 -1
  35. package/dist/Modal/NordFlow/components/TransactionTable.js +6 -6
  36. package/dist/Modal/NordFlow/components/TransactionTable.js.map +1 -1
  37. package/dist/Modal/NordFlow/components/WaitingMessage.js +1 -1
  38. package/dist/Modal/NordFlow/components/WaitingMessage.js.map +1 -1
  39. package/dist/Modal/NordFlow/screens/00-IdleScreen.js +1 -1
  40. package/dist/Modal/NordFlow/screens/00-IdleScreen.js.map +1 -1
  41. package/dist/Modal/NordFlow/screens/01-ConnectWalletScreen.js +3 -3
  42. package/dist/Modal/NordFlow/screens/01-ConnectWalletScreen.js.map +1 -1
  43. package/dist/Modal/NordFlow/screens/02-EvmWalletAuthScreen.js +4 -4
  44. package/dist/Modal/NordFlow/screens/02-EvmWalletAuthScreen.js.map +1 -1
  45. package/dist/Modal/NordFlow/screens/03-ChainSelectionScreen.js +2 -2
  46. package/dist/Modal/NordFlow/screens/03-ChainSelectionScreen.js.map +1 -1
  47. package/dist/Modal/NordFlow/screens/04-AmountInputScreen.js +4 -4
  48. package/dist/Modal/NordFlow/screens/04-AmountInputScreen.js.map +1 -1
  49. package/dist/Modal/NordFlow/screens/05-DepositProgressScreen.js +1 -1
  50. package/dist/Modal/NordFlow/screens/05-DepositProgressScreen.js.map +1 -1
  51. package/dist/Modal/NordFlow/screens/06-DepositSuccessScreen.js +4 -4
  52. package/dist/Modal/NordFlow/screens/06-DepositSuccessScreen.js.map +1 -1
  53. package/dist/Modal/NordFlow/screens/07-AuthLoadingScreen.js +3 -3
  54. package/dist/Modal/NordFlow/screens/07-AuthLoadingScreen.js.map +1 -1
  55. package/dist/Modal/NordFlow/screens/08-FinalSuccessScreen.js +2 -2
  56. package/dist/Modal/NordFlow/screens/08-FinalSuccessScreen.js.map +1 -1
  57. package/dist/Modal/NordFlow/screens/09-ErrorScreen.js +2 -2
  58. package/dist/Modal/NordFlow/screens/09-ErrorScreen.js.map +1 -1
  59. package/dist/Modal/Sidebar/N1Sidebar.js +10 -10
  60. package/dist/Modal/Sidebar/N1Sidebar.js.map +1 -1
  61. package/dist/Modal/Sidebar/NordTradingView/MarketOverview/MarketSelector.js +5 -5
  62. package/dist/Modal/Sidebar/NordTradingView/MarketOverview/MarketSelector.js.map +1 -1
  63. package/dist/Modal/Sidebar/NordTradingView/MarketOverview/MarketStats.js +3 -3
  64. package/dist/Modal/Sidebar/NordTradingView/MarketOverview/MarketStats.js.map +1 -1
  65. package/dist/Modal/Sidebar/NordTradingView/NordTradingView.js +2 -2
  66. package/dist/Modal/Sidebar/NordTradingView/NordTradingView.js.map +1 -1
  67. package/dist/Modal/Sidebar/NordTradingView/OrderBook/OrderBook.js +2 -2
  68. package/dist/Modal/Sidebar/NordTradingView/OrderBook/OrderBook.js.map +1 -1
  69. package/dist/Modal/Sidebar/NordTradingView/OrderBook/OrderBookDepthVisualizer.js +1 -1
  70. package/dist/Modal/Sidebar/NordTradingView/OrderBook/OrderBookDepthVisualizer.js.map +1 -1
  71. package/dist/Modal/Sidebar/NordTradingView/OrderBook/OrderBookHeader.js +4 -4
  72. package/dist/Modal/Sidebar/NordTradingView/OrderBook/OrderBookHeader.js.map +1 -1
  73. package/dist/Modal/Sidebar/NordTradingView/OrderBook/OrderBookTable.js +6 -6
  74. package/dist/Modal/Sidebar/NordTradingView/OrderBook/OrderBookTable.js.map +1 -1
  75. package/dist/Modal/Sidebar/NordTradingView/TradeForm/AmountInput.js +1 -1
  76. package/dist/Modal/Sidebar/NordTradingView/TradeForm/AmountInput.js.map +1 -1
  77. package/dist/Modal/Sidebar/NordTradingView/TradeForm/BuySellTabs.js +3 -3
  78. package/dist/Modal/Sidebar/NordTradingView/TradeForm/BuySellTabs.js.map +1 -1
  79. package/dist/Modal/Sidebar/NordTradingView/TradeForm/FillModeSelector.js +7 -7
  80. package/dist/Modal/Sidebar/NordTradingView/TradeForm/FillModeSelector.js.map +1 -1
  81. package/dist/Modal/Sidebar/NordTradingView/TradeForm/OrderTypeSelector.js +13 -13
  82. package/dist/Modal/Sidebar/NordTradingView/TradeForm/OrderTypeSelector.js.map +1 -1
  83. package/dist/Modal/Sidebar/NordTradingView/TradeForm/PriceInput.js +1 -1
  84. package/dist/Modal/Sidebar/NordTradingView/TradeForm/PriceInput.js.map +1 -1
  85. package/dist/Modal/Sidebar/NordTradingView/TradeForm/SubmitButton.js +2 -2
  86. package/dist/Modal/Sidebar/NordTradingView/TradeForm/SubmitButton.js.map +1 -1
  87. package/dist/Modal/Sidebar/NordTradingView/TradeForm/TotalCalculator.js +1 -1
  88. package/dist/Modal/Sidebar/NordTradingView/TradeForm/TotalCalculator.js.map +1 -1
  89. package/dist/Modal/Sidebar/NordTradingView/TradeForm/TradeForm.js +5 -5
  90. package/dist/Modal/Sidebar/NordTradingView/TradeForm/TradeForm.js.map +1 -1
  91. package/dist/Modal/Sidebar/NordTradingView/UserBalances/UserBalances.js +1 -1
  92. package/dist/Modal/Sidebar/NordTradingView/UserBalances/UserBalances.js.map +1 -1
  93. package/dist/Modal/Sidebar/NordTradingView/UserOrders/UserOrders.js +5 -5
  94. package/dist/Modal/Sidebar/NordTradingView/UserOrders/UserOrders.js.map +1 -1
  95. package/dist/Modal/Sidebar/NordTradingView/UserPositions/UserPositions.js +4 -4
  96. package/dist/Modal/Sidebar/NordTradingView/UserPositions/UserPositions.js.map +1 -1
  97. package/dist/Provider/N1WalletProvider.js.map +1 -1
  98. package/dist/WidgetButton/N1ConnectButton.js +1 -1
  99. package/dist/WidgetButton/N1ConnectButton.js.map +1 -1
  100. package/dist/components/Logo.js.map +1 -1
  101. package/dist/components/QRCodeLoader.js +1 -1
  102. package/dist/components/QRCodeLoader.js.map +1 -1
  103. package/dist/components/logos/EVMChainsGroup.js +1 -1
  104. package/dist/components/logos/EVMChainsGroup.js.map +1 -1
  105. package/dist/components/logos/MoreChainsGroup.js +1 -1
  106. package/dist/components/logos/MoreChainsGroup.js.map +1 -1
  107. package/dist/index.d.ts +1 -1
  108. package/dist/index.js +1 -1
  109. package/dist/index.js.map +1 -1
  110. package/dist/main.css +2 -1
  111. package/package.json +2 -2
@@ -18,7 +18,7 @@ export default function SubmitButton(_a) {
18
18
  var getButtonClass = function () {
19
19
  var baseClasses = 'w-full py-3 rounded-sm font-medium transition-all duration-200 flex items-center justify-center relative overflow-hidden';
20
20
  if (disabled || loading) {
21
- return "".concat(baseClasses, " bg-n1-gray-200 dark:bg-n1-gray-800 text-n1-gray-400 dark:text-n1-gray-500 cursor-not-allowed");
21
+ return "".concat(baseClasses, " bg-n1-ww-gray-200 dark:bg-n1-ww-gray-800 text-n1-ww-gray-400 dark:text-n1-ww-gray-500 cursor-not-allowed");
22
22
  }
23
23
  if (side === 'BUY') {
24
24
  return "".concat(baseClasses, " bg-emerald-600 hover:bg-emerald-700 text-white shadow-sm transform hover:scale-[0.99] active:scale-[0.98]");
@@ -30,7 +30,7 @@ export default function SubmitButton(_a) {
30
30
  return (_jsxs("button", { type: "submit", disabled: disabled || loading, className: getButtonClass(), onMouseEnter: function () { return setIsHovered(true); }, onMouseLeave: function () {
31
31
  setIsHovered(false);
32
32
  setIsPressed(false);
33
- }, onMouseDown: function () { return setIsPressed(true); }, onMouseUp: function () { return setIsPressed(false); }, children: [_jsx("span", { className: "relative z-10 flex items-center justify-center transition-transform duration-200 ".concat(isPressed ? 'scale-95' : ''), children: loading ? (_jsxs(_Fragment, { children: [_jsx(Loader2, { size: 18, className: "n1-animate-spin mr-2 inline-block" }), "Processing..."] })) : (_jsxs(_Fragment, { children: [side === 'BUY' ? (_jsx("svg", { className: "w-4 h-4 mr-2", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: _jsx("path", { d: "M12 5L12 19M12 5L6 11M12 5L18 11", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", className: "transition-transform duration-300 ".concat(isHovered ? 'translate-y-[-2px]' : '') }) })) : (_jsx("svg", { className: "w-4 h-4 mr-2", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: _jsx("path", { d: "M12 19L12 5M12 19L6 13M12 19L18 13", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", className: "transition-transform duration-300 ".concat(isHovered ? 'translate-y-[2px]' : '') }) })), getButtonText()] })) }), !disabled && !loading && (_jsxs(_Fragment, { children: [_jsx("span", { className: "absolute inset-0 bg-gradient-to-r from-transparent via-white to-transparent opacity-25 pointer-events-none translate-x-[-200%] ".concat(isHovered ? 'animate-shimmer' : ''), style: {
33
+ }, onMouseDown: function () { return setIsPressed(true); }, onMouseUp: function () { return setIsPressed(false); }, children: [_jsx("span", { className: "relative z-10 flex items-center justify-center transition-transform duration-200 ".concat(isPressed ? 'scale-95' : ''), children: loading ? (_jsxs(_Fragment, { children: [_jsx(Loader2, { size: 18, className: "n1-ww-animate-spin mr-2 inline-block" }), "Processing..."] })) : (_jsxs(_Fragment, { children: [side === 'BUY' ? (_jsx("svg", { className: "w-4 h-4 mr-2", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: _jsx("path", { d: "M12 5L12 19M12 5L6 11M12 5L18 11", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", className: "transition-transform duration-300 ".concat(isHovered ? 'translate-y-[-2px]' : '') }) })) : (_jsx("svg", { className: "w-4 h-4 mr-2", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: _jsx("path", { d: "M12 19L12 5M12 19L6 13M12 19L18 13", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", className: "transition-transform duration-300 ".concat(isHovered ? 'translate-y-[2px]' : '') }) })), getButtonText()] })) }), !disabled && !loading && (_jsxs(_Fragment, { children: [_jsx("span", { className: "absolute inset-0 bg-gradient-to-r from-transparent via-white to-transparent opacity-25 pointer-events-none translate-x-[-200%] ".concat(isHovered ? 'animate-shimmer' : ''), style: {
34
34
  backgroundSize: '200% 100%',
35
35
  animationDuration: '1.5s',
36
36
  } }), _jsx("span", { className: "absolute inset-0 rounded-sm transition-opacity duration-300 pointer-events-none ".concat(isPressed
@@ -1 +1 @@
1
- {"version":3,"file":"SubmitButton.js","sourceRoot":"","sources":["../../../../../src/Modal/Sidebar/NordTradingView/TradeForm/SubmitButton.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAUjC,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,EAKjB;QAJlB,OAAO,aAAA,EACP,IAAI,UAAA,EACJ,SAAS,eAAA,EACT,QAAQ,cAAA;IAEF,IAAA,KAA4B,QAAQ,CAAC,KAAK,CAAC,EAA1C,SAAS,QAAA,EAAE,YAAY,QAAmB,CAAC;IAC5C,IAAA,KAA4B,QAAQ,CAAC,KAAK,CAAC,EAA1C,SAAS,QAAA,EAAE,YAAY,QAAmB,CAAC;IAElD,oDAAoD;IACpD,IAAM,aAAa,GAAG;QACpB,IAAI,IAAI,KAAK,KAAK,EAAE,CAAC;YACnB,OAAO,cAAO,SAAS,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAE,CAAC;QAC9D,CAAC;aAAM,CAAC;YACN,OAAO,eAAQ,SAAS,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAE,CAAC;QAC/D,CAAC;IACH,CAAC,CAAC;IAEF,sCAAsC;IACtC,IAAM,cAAc,GAAG;Q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ACtB,SAAS,EAAE,4CAAqC,SAAS,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,EAAE,CAAE,GACvF,GACE,CACP,CAAC,CAAC,CAAC,CACF,cACE,SAAS,EAAC,cAAc,EACxB,OAAO,EAAC,WAAW,EACnB,IAAI,EAAC,MAAM,EACX,KAAK,EAAC,4BAA4B,YAElC,eACE,CAAC,EAAC,oCAAoC,EACtC,MAAM,EAAC,cAAc,EACrB,WAAW,EAAC,GAAG,EACf,aAAa,EAAC,OAAO,EACrB,cAAc,EAAC,OAAO,EACtB,SAAS,EAAE,4CAAqC,SAAS,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,EAAE,CAAE,GACtF,GACE,CACP,EACA,aAAa,EAAE,IACf,CACJ,GACI,EAEN,CAAC,QAAQ,IAAI,CAAC,OAAO,IAAI,CACxB,8BACE,eACE,SAAS,EAAE,yIAAkI,SAAS,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,EAAE,CAAE,EACjL,KAAK,EAAE;4BACL,cAAc,EAAE,WAAW;4BAC3B,iBAAiB,EAAE,MAAM;yBAC1B,GACD,EACF,eACE,SAAS,EAAE,0FACT,SAAS;4BACP,CAAC,CAAC,mDAAmD;4BACrD,CAAC,CAAC,WAAW,CACf,GACF,IACD,CACJ,IACM,CACV,CAAC;AACJ,CAAC","sourcesContent":["import { Loader2 } from 'lucide-react';\nimport { useState } from 'react';\nimport { OrderSide, OrderType } from './TradeForm';\n\ninterface SubmitButtonProps {\n loading: boolean;\n side: OrderSide;\n orderType: OrderType;\n disabled: boolean;\n}\n\nexport default function SubmitButton({\n loading,\n side,\n orderType,\n disabled,\n}: SubmitButtonProps) {\n const [isHovered, setIsHovered] = useState(false);\n const [isPressed, setIsPressed] = useState(false);\n\n // Generate button text based on side and order type\n const getButtonText = () => {\n if (side === 'BUY') {\n return `Buy ${orderType === 'MARKET' ? 'Market' : 'Limit'}`;\n } else {\n return `Sell ${orderType === 'MARKET' ? 'Market' : 'Limit'}`;\n }\n };\n\n // Generate button color based on side\n const getButtonClass = () => {\n const baseClasses =\n 'w-full py-3 rounded-sm font-medium transition-all duration-200 flex items-center justify-center relative overflow-hidden';\n\n if (disabled || loading) {\n return `${baseClasses} bg-n1-gray-200 dark:bg-n1-gray-800 text-n1-gray-400 dark:text-n1-gray-500 cursor-not-allowed`;\n }\n\n if (side === 'BUY') {\n return `${baseClasses} bg-emerald-600 hover:bg-emerald-700 text-white shadow-sm transform hover:scale-[0.99] active:scale-[0.98]`;\n } else {\n return `${baseClasses} bg-red-700 hover:bg-red-800 text-white shadow-sm transform hover:scale-[0.99] active:scale-[0.98]`;\n }\n };\n\n return (\n <button\n type=\"submit\"\n disabled={disabled || loading}\n className={getButtonClass()}\n onMouseEnter={() => setIsHovered(true)}\n onMouseLeave={() => {\n setIsHovered(false);\n setIsPressed(false);\n }}\n onMouseDown={() => setIsPressed(true)}\n onMouseUp={() => setIsPressed(false)}\n >\n <span\n className={`relative z-10 flex items-center justify-center transition-transform duration-200 ${isPressed ? 'scale-95' : ''}`}\n >\n {loading ? (\n <>\n <Loader2 size={18} className=\"n1-animate-spin mr-2 inline-block\" />\n Processing...\n </>\n ) : (\n <>\n {side === 'BUY' ? (\n <svg\n className=\"w-4 h-4 mr-2\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path\n d=\"M12 5L12 19M12 5L6 11M12 5L18 11\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n className={`transition-transform duration-300 ${isHovered ? 'translate-y-[-2px]' : ''}`}\n />\n </svg>\n ) : (\n <svg\n className=\"w-4 h-4 mr-2\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path\n d=\"M12 19L12 5M12 19L6 13M12 19L18 13\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n className={`transition-transform duration-300 ${isHovered ? 'translate-y-[2px]' : ''}`}\n />\n </svg>\n )}\n {getButtonText()}\n </>\n )}\n </span>\n\n {!disabled && !loading && (\n <>\n <span\n className={`absolute inset-0 bg-gradient-to-r from-transparent via-white to-transparent opacity-25 pointer-events-none translate-x-[-200%] ${isHovered ? 'animate-shimmer' : ''}`}\n style={{\n backgroundSize: '200% 100%',\n animationDuration: '1.5s',\n }}\n />\n <span\n className={`absolute inset-0 rounded-sm transition-opacity duration-300 pointer-events-none ${\n isPressed\n ? 'bg-black opacity-10 dark:bg-white dark:opacity-10'\n : 'opacity-0'\n }`}\n />\n </>\n )}\n </button>\n );\n}\n"]}
1
+ {"version":3,"file":"SubmitButton.js","sourceRoot":"","sources":["../../../../../src/Modal/Sidebar/NordTradingView/TradeForm/SubmitButton.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAUjC,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,EAKjB;QAJlB,OAAO,aAAA,EACP,IAAI,UAAA,EACJ,SAAS,eAAA,EACT,QAAQ,cAAA;IAEF,IAAA,KAA4B,QAAQ,CAAC,KAAK,CAAC,EAA1C,SAAS,QAAA,EAAE,YAAY,QAAmB,CAAC;IAC5C,IAAA,KAA4B,QAAQ,CAAC,KAAK,CAAC,EAA1C,SAAS,QAAA,EAAE,YAAY,QAAmB,CAAC;IAElD,oDAAoD;IACpD,IAAM,aAAa,GAAG;QACpB,IAAI,IAAI,KAAK,KAAK,EAAE,CAAC;YACnB,OAAO,cAAO,SAAS,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAE,CAAC;QAC9D,CAAC;aAAM,CAAC;YACN,OAAO,eAAQ,SAAS,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CA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,EACpC,MAAM,EAAC,cAAc,EACrB,WAAW,EAAC,GAAG,EACf,aAAa,EAAC,OAAO,EACrB,cAAc,EAAC,OAAO,EACtB,SAAS,EAAE,4CAAqC,SAAS,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,EAAE,CAAE,GACvF,GACE,CACP,CAAC,CAAC,CAAC,CACF,cACE,SAAS,EAAC,cAAc,EACxB,OAAO,EAAC,WAAW,EACnB,IAAI,EAAC,MAAM,EACX,KAAK,EAAC,4BAA4B,YAElC,eACE,CAAC,EAAC,oCAAoC,EACtC,MAAM,EAAC,cAAc,EACrB,WAAW,EAAC,GAAG,EACf,aAAa,EAAC,OAAO,EACrB,cAAc,EAAC,OAAO,EACtB,SAAS,EAAE,4CAAqC,SAAS,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,EAAE,CAAE,GACtF,GACE,CACP,EACA,aAAa,EAAE,IACf,CACJ,GACI,EAEN,CAAC,QAAQ,IAAI,CAAC,OAAO,IAAI,CACxB,8BACE,eACE,SAAS,EAAE,yIAAkI,SAAS,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,EAAE,CAAE,EACjL,KAAK,EAAE;4BACL,cAAc,EAAE,WAAW;4BAC3B,iBAAiB,EAAE,MAAM;yBAC1B,GACD,EACF,eACE,SAAS,EAAE,0FACT,SAAS;4BACP,CAAC,CAAC,mDAAmD;4BACrD,CAAC,CAAC,WAAW,CACf,GACF,IACD,CACJ,IACM,CACV,CAAC;AACJ,CAAC","sourcesContent":["import { Loader2 } from 'lucide-react';\nimport { useState } from 'react';\nimport { OrderSide, OrderType } from './TradeForm';\n\ninterface SubmitButtonProps {\n loading: boolean;\n side: OrderSide;\n orderType: OrderType;\n disabled: boolean;\n}\n\nexport default function SubmitButton({\n loading,\n side,\n orderType,\n disabled,\n}: SubmitButtonProps) {\n const [isHovered, setIsHovered] = useState(false);\n const [isPressed, setIsPressed] = useState(false);\n\n // Generate button text based on side and order type\n const getButtonText = () => {\n if (side === 'BUY') {\n return `Buy ${orderType === 'MARKET' ? 'Market' : 'Limit'}`;\n } else {\n return `Sell ${orderType === 'MARKET' ? 'Market' : 'Limit'}`;\n }\n };\n\n // Generate button color based on side\n const getButtonClass = () => {\n const baseClasses =\n 'w-full py-3 rounded-sm font-medium transition-all duration-200 flex items-center justify-center relative overflow-hidden';\n\n if (disabled || loading) {\n return `${baseClasses} bg-n1-ww-gray-200 dark:bg-n1-ww-gray-800 text-n1-ww-gray-400 dark:text-n1-ww-gray-500 cursor-not-allowed`;\n }\n\n if (side === 'BUY') {\n return `${baseClasses} bg-emerald-600 hover:bg-emerald-700 text-white shadow-sm transform hover:scale-[0.99] active:scale-[0.98]`;\n } else {\n return `${baseClasses} bg-red-700 hover:bg-red-800 text-white shadow-sm transform hover:scale-[0.99] active:scale-[0.98]`;\n }\n };\n\n return (\n <button\n type=\"submit\"\n disabled={disabled || loading}\n className={getButtonClass()}\n onMouseEnter={() => setIsHovered(true)}\n onMouseLeave={() => {\n setIsHovered(false);\n setIsPressed(false);\n }}\n onMouseDown={() => setIsPressed(true)}\n onMouseUp={() => setIsPressed(false)}\n >\n <span\n className={`relative z-10 flex items-center justify-center transition-transform duration-200 ${isPressed ? 'scale-95' : ''}`}\n >\n {loading ? (\n <>\n <Loader2 size={18} className=\"n1-ww-animate-spin mr-2 inline-block\" />\n Processing...\n </>\n ) : (\n <>\n {side === 'BUY' ? (\n <svg\n className=\"w-4 h-4 mr-2\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path\n d=\"M12 5L12 19M12 5L6 11M12 5L18 11\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n className={`transition-transform duration-300 ${isHovered ? 'translate-y-[-2px]' : ''}`}\n />\n </svg>\n ) : (\n <svg\n className=\"w-4 h-4 mr-2\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path\n d=\"M12 19L12 5M12 19L6 13M12 19L18 13\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n className={`transition-transform duration-300 ${isHovered ? 'translate-y-[2px]' : ''}`}\n />\n </svg>\n )}\n {getButtonText()}\n </>\n )}\n </span>\n\n {!disabled && !loading && (\n <>\n <span\n className={`absolute inset-0 bg-gradient-to-r from-transparent via-white to-transparent opacity-25 pointer-events-none translate-x-[-200%] ${isHovered ? 'animate-shimmer' : ''}`}\n style={{\n backgroundSize: '200% 100%',\n animationDuration: '1.5s',\n }}\n />\n <span\n className={`absolute inset-0 rounded-sm transition-opacity duration-300 pointer-events-none ${\n isPressed\n ? 'bg-black opacity-10 dark:bg-white dark:opacity-10'\n : 'opacity-0'\n }`}\n />\n </>\n )}\n </button>\n );\n}\n"]}
@@ -5,6 +5,6 @@ export default function TotalCalculator(_a) {
5
5
  var fee = total && orderType === 'LIMIT'
6
6
  ? (parseFloat(total) * 0.001).toFixed(6)
7
7
  : '0.00';
8
- return (_jsxs("div", { className: "relative z-20", children: [_jsx("label", { className: "block text-xs font-medium text-n1-gray-700 dark:text-n1-gray-300 mb-1", children: "Total" }), _jsx("div", { className: "px-3 py-2 border border-n1-gray-200 dark:border-n1-gray-800 rounded-sm text-sm text-n1-gray-900 dark:text-n1-gray-100 bg-n1-gray-50 dark:bg-n1-dark-950 font-mono", children: orderType === 'MARKET' ? (_jsx("span", { className: "text-n1-gray-500 dark:text-n1-gray-400", children: "Market Order" })) : total ? (total) : (_jsx("span", { className: "text-n1-gray-400 dark:text-n1-gray-500", children: "0.00" })) }), _jsxs("div", { className: "mt-1 text-[10px] text-n1-gray-500 dark:text-n1-gray-400 flex justify-between", children: [_jsx("span", { children: "Estimated fee:" }), _jsx("span", { className: "font-mono", children: fee })] })] }));
8
+ return (_jsxs("div", { className: "relative z-20", children: [_jsx("label", { className: "block text-xs font-medium text-n1-ww-gray-700 dark:text-n1-ww-gray-300 mb-1", children: "Total" }), _jsx("div", { className: "px-3 py-2 border border-n1-ww-gray-200 dark:border-n1-ww-gray-800 rounded-sm text-sm text-n1-ww-gray-900 dark:text-n1-ww-gray-100 bg-n1-ww-gray-50 dark:bg-n1-ww-dark-950 font-mono", children: orderType === 'MARKET' ? (_jsx("span", { className: "text-n1-ww-gray-500 dark:text-n1-ww-gray-400", children: "Market Order" })) : total ? (total) : (_jsx("span", { className: "text-n1-ww-gray-400 dark:text-n1-ww-gray-500", children: "0.00" })) }), _jsxs("div", { className: "mt-1 text-[10px] text-n1-ww-gray-500 dark:text-n1-ww-gray-400 flex justify-between", children: [_jsx("span", { children: "Estimated fee:" }), _jsx("span", { className: "font-mono", children: fee })] })] }));
9
9
  }
10
10
  //# sourceMappingURL=TotalCalculator.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"TotalCalculator.js","sourceRoot":"","sources":["../../../../../src/Modal/Sidebar/NordTradingView/TradeForm/TotalCalculator.tsx"],"names":[],"mappings":";AAUA,MAAM,CAAC,OAAO,UAAU,eAAe,CAAC,EAGjB;QAFrB,KAAK,WAAA,EACL,SAAS,eAAA;IAET,oCAAoC;IACpC,IAAM,GAAG,GACP,KAAK,IAAI,SAAS,KAAK,OAAO;QAC5B,CAAC,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;QACxC,CAAC,CAAC,MAAM,CAAC;IAEb,OAAO,CACL,eAAK,SAAS,EAAC,eAAe,aAC5B,gBAAO,SAAS,EAAC,uEAAuE,sBAEhF,EACR,cAAK,SAAS,EAAC,mKAAmK,YAC/K,SAAS,KAAK,QAAQ,CAAC,CAAC,CAAC,CACxB,eAAM,SAAS,EAAC,wCAAwC,6BAAoB,CAC7E,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CACV,KAAK,CACN,CAAC,CAAC,CAAC,CACF,eAAM,SAAS,EAAC,wCAAwC,qBAAY,CACrE,GACG,EAGN,eAAK,SAAS,EAAC,8EAA8E,aAC3F,4CAA2B,EAC3B,eAAM,SAAS,EAAC,WAAW,YAAE,GAAG,GAAQ,IACpC,IACF,CACP,CAAC;AACJ,CAAC","sourcesContent":["import React from 'react';\n\n// We still need OrderType for backward compatibility with the TotalCalculator\ntype OrderType = 'LIMIT' | 'MARKET';\n\ninterface TotalCalculatorProps {\n total: string;\n orderType: OrderType;\n}\n\nexport default function TotalCalculator({\n total,\n orderType,\n}: TotalCalculatorProps) {\n // Calculate fee (example: 0.1% fee)\n const fee =\n total && orderType === 'LIMIT'\n ? (parseFloat(total) * 0.001).toFixed(6)\n : '0.00';\n\n return (\n <div className=\"relative z-20\">\n <label className=\"block text-xs font-medium text-n1-gray-700 dark:text-n1-gray-300 mb-1\">\n Total\n </label>\n <div className=\"px-3 py-2 border border-n1-gray-200 dark:border-n1-gray-800 rounded-sm text-sm text-n1-gray-900 dark:text-n1-gray-100 bg-n1-gray-50 dark:bg-n1-dark-950 font-mono\">\n {orderType === 'MARKET' ? (\n <span className=\"text-n1-gray-500 dark:text-n1-gray-400\">Market Order</span>\n ) : total ? (\n total\n ) : (\n <span className=\"text-n1-gray-400 dark:text-n1-gray-500\">0.00</span>\n )}\n </div>\n\n {/* Fee estimate */}\n <div className=\"mt-1 text-[10px] text-n1-gray-500 dark:text-n1-gray-400 flex justify-between\">\n <span>Estimated fee:</span>\n <span className=\"font-mono\">{fee}</span>\n </div>\n </div>\n );\n}\n"]}
1
+ {"version":3,"file":"TotalCalculator.js","sourceRoot":"","sources":["../../../../../src/Modal/Sidebar/NordTradingView/TradeForm/TotalCalculator.tsx"],"names":[],"mappings":";AAUA,MAAM,CAAC,OAAO,UAAU,eAAe,CAAC,EAGjB;QAFrB,KAAK,WAAA,EACL,SAAS,eAAA;IAET,oCAAoC;IACpC,IAAM,GAAG,GACP,KAAK,IAAI,SAAS,KAAK,OAAO;QAC5B,CAAC,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;QACxC,CAAC,CAAC,MAAM,CAAC;IAEb,OAAO,CACL,eAAK,SAAS,EAAC,eAAe,aAC5B,gBAAO,SAAS,EAAC,6EAA6E,sBAEtF,EACR,cAAK,SAAS,EAAC,qLAAqL,YACjM,SAAS,KAAK,QAAQ,CAAC,CAAC,CAAC,CACxB,eAAM,SAAS,EAAC,8CAA8C,6BAAoB,CACnF,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CACV,KAAK,CACN,CAAC,CAAC,CAAC,CACF,eAAM,SAAS,EAAC,8CAA8C,qBAAY,CAC3E,GACG,EAGN,eAAK,SAAS,EAAC,oFAAoF,aACjG,4CAA2B,EAC3B,eAAM,SAAS,EAAC,WAAW,YAAE,GAAG,GAAQ,IACpC,IACF,CACP,CAAC;AACJ,CAAC","sourcesContent":["import React from 'react';\n\n// We still need OrderType for backward compatibility with the TotalCalculator\ntype OrderType = 'LIMIT' | 'MARKET';\n\ninterface TotalCalculatorProps {\n total: string;\n orderType: OrderType;\n}\n\nexport default function TotalCalculator({\n total,\n orderType,\n}: TotalCalculatorProps) {\n // Calculate fee (example: 0.1% fee)\n const fee =\n total && orderType === 'LIMIT'\n ? (parseFloat(total) * 0.001).toFixed(6)\n : '0.00';\n\n return (\n <div className=\"relative z-20\">\n <label className=\"block text-xs font-medium text-n1-ww-gray-700 dark:text-n1-ww-gray-300 mb-1\">\n Total\n </label>\n <div className=\"px-3 py-2 border border-n1-ww-gray-200 dark:border-n1-ww-gray-800 rounded-sm text-sm text-n1-ww-gray-900 dark:text-n1-ww-gray-100 bg-n1-ww-gray-50 dark:bg-n1-ww-dark-950 font-mono\">\n {orderType === 'MARKET' ? (\n <span className=\"text-n1-ww-gray-500 dark:text-n1-ww-gray-400\">Market Order</span>\n ) : total ? (\n total\n ) : (\n <span className=\"text-n1-ww-gray-400 dark:text-n1-ww-gray-500\">0.00</span>\n )}\n </div>\n\n {/* Fee estimate */}\n <div className=\"mt-1 text-[10px] text-n1-ww-gray-500 dark:text-n1-ww-gray-400 flex justify-between\">\n <span>Estimated fee:</span>\n <span className=\"font-mono\">{fee}</span>\n </div>\n </div>\n );\n}\n"]}
@@ -237,21 +237,21 @@ export default function TradeForm(_a) {
237
237
  }
238
238
  });
239
239
  }); };
240
- return (_jsxs("div", { className: "p-4 bg-white dark:bg-n1-dark-950 transition-colors duration-300", children: [_jsxs("h2", { className: "text-base font-semibold text-n1-gray-900 dark:text-n1-gray-100 mb-3 transform transition-all duration-500 ".concat(formVisible ? 'translate-y-0 opacity-100' : 'translate-y-4 opacity-0'), children: ["Place Order", ' ', marketSymbol ? (_jsx("span", { className: side === 'BUY'
240
+ return (_jsxs("div", { className: "p-4 bg-white dark:bg-n1-ww-dark-950 transition-colors duration-300", children: [_jsxs("h2", { className: "text-base font-semibold text-n1-ww-gray-900 dark:text-n1-ww-gray-100 mb-3 transform transition-all duration-500 ".concat(formVisible ? 'translate-y-0 opacity-100' : 'translate-y-4 opacity-0'), children: ["Place Order", ' ', marketSymbol ? (_jsx("span", { className: side === 'BUY'
241
241
  ? 'text-emerald-600 dark:text-emerald-500'
242
- : 'text-red-700 dark:text-red-600', children: marketSymbol })) : ('')] }), !marketSymbol ? (_jsx("div", { className: "p-3 border border-n1-gray-200 dark:border-n1-gray-800 rounded-sm text-n1-gray-500 dark:text-n1-gray-400 text-xs bg-n1-gray-50 dark:bg-n1-dark-950 transform transition-all duration-500 ".concat(formVisible ? 'translate-y-0 opacity-100' : 'translate-y-4 opacity-0'), children: "Select a market to place orders" })) : (_jsx("form", { onSubmit: handleSubmit, children: _jsxs("div", { className: "space-y-3", children: [_jsx("div", { className: "transform transition-all duration-500 delay-100 ".concat(formVisible ? 'translate-y-0 opacity-100' : 'translate-y-4 opacity-0'), children: _jsx(BuySellTabs, { side: side, onChange: setSide }) }), _jsx("div", { className: "transform transition-all duration-500 delay-200 ".concat(formVisible ? 'translate-y-0 opacity-100' : 'translate-y-4 opacity-0'), children: _jsx(FillModeSelector, { fillMode: fillMode, onFillModeChange: setFillMode }) }), !isMarketOrder(fillMode) && (_jsx("div", { className: "transform transition-all duration-500 delay-300 ".concat(formVisible ? 'translate-y-0 opacity-100' : 'translate-y-4 opacity-0'), children: _jsx(PriceInput, { price: price, onChange: setPrice, marketPrice: marketInfo === null || marketInfo === void 0 ? void 0 : marketInfo.lastPrice }) })), _jsx("div", { className: "transform transition-all duration-500 delay-400 ".concat(formVisible ? 'translate-y-0 opacity-100' : 'translate-y-4 opacity-0'), children: _jsx(AmountInput, { amount: amount, onChange: setAmount, marketInfo: marketInfo }) }), _jsx("div", { className: "transform transition-all duration-500 delay-500 ".concat(formVisible ? 'translate-y-0 opacity-100' : 'translate-y-4 opacity-0'), children: _jsx(TotalCalculator, { total: total, orderType: isMarketOrder(fillMode) ? 'MARKET' : 'LIMIT' }) }), accountId && (_jsx("div", { className: "transform transition-all duration-500 delay-550 ".concat(formVisible ? 'translate-y-0 opacity-100' : 'translate-y-4 opacity-0'), children: _jsxs("div", { className: "flex items-center text-xs text-n1-gray-500 dark:text-n1-gray-400", children: [_jsx(Info, { size: 12, className: "mr-1" }), _jsxs("span", { children: ["Account ID: ", accountId] })] }) })), _jsx("div", { className: "transform transition-all duration-500 delay-600 ".concat(formVisible ? 'translate-y-0 opacity-100' : 'translate-y-4 opacity-0'), children: _jsxs("button", { type: "button", onClick: function () { return setIsReduceOnly(!isReduceOnly); }, className: "w-full flex items-center justify-between px-3 py-2 rounded-sm text-sm transition-all duration-300 ".concat(isReduceOnly
242
+ : 'text-red-700 dark:text-red-600', children: marketSymbol })) : ('')] }), !marketSymbol ? (_jsx("div", { className: "p-3 border border-n1-ww-gray-200 dark:border-n1-ww-gray-800 rounded-sm text-n1-ww-gray-500 dark:text-n1-ww-gray-400 text-xs bg-n1-ww-gray-50 dark:bg-n1-ww-dark-950 transform transition-all duration-500 ".concat(formVisible ? 'translate-y-0 opacity-100' : 'translate-y-4 opacity-0'), children: "Select a market to place orders" })) : (_jsx("form", { onSubmit: handleSubmit, children: _jsxs("div", { className: "space-y-3", children: [_jsx("div", { className: "transform transition-all duration-500 delay-100 ".concat(formVisible ? 'translate-y-0 opacity-100' : 'translate-y-4 opacity-0'), children: _jsx(BuySellTabs, { side: side, onChange: setSide }) }), _jsx("div", { className: "transform transition-all duration-500 delay-200 ".concat(formVisible ? 'translate-y-0 opacity-100' : 'translate-y-4 opacity-0'), children: _jsx(FillModeSelector, { fillMode: fillMode, onFillModeChange: setFillMode }) }), !isMarketOrder(fillMode) && (_jsx("div", { className: "transform transition-all duration-500 delay-300 ".concat(formVisible ? 'translate-y-0 opacity-100' : 'translate-y-4 opacity-0'), children: _jsx(PriceInput, { price: price, onChange: setPrice, marketPrice: marketInfo === null || marketInfo === void 0 ? void 0 : marketInfo.lastPrice }) })), _jsx("div", { className: "transform transition-all duration-500 delay-400 ".concat(formVisible ? 'translate-y-0 opacity-100' : 'translate-y-4 opacity-0'), children: _jsx(AmountInput, { amount: amount, onChange: setAmount, marketInfo: marketInfo }) }), _jsx("div", { className: "transform transition-all duration-500 delay-500 ".concat(formVisible ? 'translate-y-0 opacity-100' : 'translate-y-4 opacity-0'), children: _jsx(TotalCalculator, { total: total, orderType: isMarketOrder(fillMode) ? 'MARKET' : 'LIMIT' }) }), accountId && (_jsx("div", { className: "transform transition-all duration-500 delay-550 ".concat(formVisible ? 'translate-y-0 opacity-100' : 'translate-y-4 opacity-0'), children: _jsxs("div", { className: "flex items-center text-xs text-n1-ww-gray-500 dark:text-n1-ww-gray-400", children: [_jsx(Info, { size: 12, className: "mr-1" }), _jsxs("span", { children: ["Account ID: ", accountId] })] }) })), _jsx("div", { className: "transform transition-all duration-500 delay-600 ".concat(formVisible ? 'translate-y-0 opacity-100' : 'translate-y-4 opacity-0'), children: _jsxs("button", { type: "button", onClick: function () { return setIsReduceOnly(!isReduceOnly); }, className: "w-full flex items-center justify-between px-3 py-2 rounded-sm text-sm transition-all duration-300 ".concat(isReduceOnly
243
243
  ? side === 'BUY'
244
244
  ? 'bg-emerald-50 dark:bg-emerald-900/10 text-emerald-700 dark:text-emerald-400 border border-emerald-200 dark:border-emerald-800/30'
245
245
  : 'bg-red-50 dark:bg-red-900/10 text-red-700 dark:text-red-400 border border-red-200 dark:border-red-800/30'
246
- : 'bg-n1-gray-50 dark:bg-n1-gray-900 text-n1-gray-700 dark:text-n1-gray-300 border border-n1-gray-200 dark:border-n1-gray-800 hover:border-n1-gray-300 dark:hover:border-n1-gray-600'), children: [_jsxs("div", { className: "flex items-center", children: [_jsx("div", { className: "mr-2 transition-colors duration-300 ".concat(isReduceOnly
246
+ : 'bg-n1-ww-gray-50 dark:bg-n1-ww-gray-900 text-n1-ww-gray-700 dark:text-n1-ww-gray-300 border border-n1-ww-gray-200 dark:border-n1-ww-gray-800 hover:border-n1-ww-gray-300 dark:hover:border-n1-ww-gray-600'), children: [_jsxs("div", { className: "flex items-center", children: [_jsx("div", { className: "mr-2 transition-colors duration-300 ".concat(isReduceOnly
247
247
  ? side === 'BUY'
248
248
  ? 'text-emerald-600 dark:text-emerald-500'
249
249
  : 'text-red-600 dark:text-red-500'
250
- : 'text-n1-gray-500 dark:text-n1-gray-400'), children: isReduceOnly ? _jsx(Lock, { size: 14 }) : _jsx(Unlock, { size: 14 }) }), _jsx("span", { className: "text-xs", children: "Reduce Only" })] }), _jsx("div", { className: "flex items-center justify-center w-4 h-4 rounded-full transition-all duration-300 ".concat(isReduceOnly
250
+ : 'text-n1-ww-gray-500 dark:text-n1-ww-gray-400'), children: isReduceOnly ? _jsx(Lock, { size: 14 }) : _jsx(Unlock, { size: 14 }) }), _jsx("span", { className: "text-xs", children: "Reduce Only" })] }), _jsx("div", { className: "flex items-center justify-center w-4 h-4 rounded-full transition-all duration-300 ".concat(isReduceOnly
251
251
  ? side === 'BUY'
252
252
  ? 'bg-emerald-600 dark:bg-emerald-500 text-white'
253
253
  : 'bg-red-600 dark:bg-red-500 text-white'
254
- : 'bg-n1-gray-200 dark:bg-n1-gray-700'), children: isReduceOnly && _jsx(Check, { size: 10 }) })] }) }), _jsxs("div", { className: "p-2 border rounded-sm text-xs transition-all duration-300 transform ".concat(error
254
+ : 'bg-n1-ww-gray-200 dark:bg-n1-ww-gray-700'), children: isReduceOnly && _jsx(Check, { size: 10 }) })] }) }), _jsxs("div", { className: "p-2 border rounded-sm text-xs transition-all duration-300 transform ".concat(error
255
255
  ? 'opacity-100 max-h-20 border-red-200 dark:border-red-900/30 bg-red-50 dark:bg-red-900/10 text-red-700 dark:text-red-400 flex items-center translate-y-0'
256
256
  : 'opacity-0 max-h-0 overflow-hidden border-transparent translate-y-2'), children: [error && (_jsx(AlertCircle, { size: 14, className: "mr-2 flex-shrink-0" })), error] }), _jsx("div", { className: "p-2 border rounded-sm text-xs transition-all duration-300 transform ".concat(success
257
257
  ? 'opacity-100 max-h-20 border-emerald-200 dark:border-emerald-900/30 bg-emerald-50 dark:bg-emerald-900/10 text-emerald-700 dark:text-emerald-400 translate-y-0'
@@ -1 +1 @@
1
- {"version":3,"file":"TradeForm.js","sourceRoot":"","sources":["../../../../../src/Modal/Sidebar/NordTradingView/TradeForm/TradeForm.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,WAAW,MAAM,eAAe,CAAC;AACxC,OAAO,gBAAgB,MAAM,oBAAoB,CAAC;AAClD,OAAO,UAAU,MAAM,cAAc,CAAC;AACtC,OAAO,WAAW,MAAM,eAAe,CAAC;AACxC,OAAO,eAAe,MAAM,mBAAmB,CAAC;AAChD,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;A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YAED,YAAY,CAAC,CAAC,CAAC,KAAC,IAAI,IAAC,IAAI,EAAE,EAAE,GAAI,CAAC,CAAC,CAAC,KAAC,MAAM,IAAC,IAAI,EAAE,EAAE,GAAI,GACrD,EACN,eAAM,SAAS,EAAC,SAAS,4BAAmB,IACxC,EACN,cACE,SAAS,EAAE,4FACT,YAAY;4CACV,CAAC,CAAC,IAAI,KAAK,KAAK;gDACd,CAAC,CAAC,+CAA+C;gDACjD,CAAC,CAAC,uCAAuC;4CAC3C,CAAC,CAAC,oCAAoC,CACxC,YAED,YAAY,IAAI,KAAC,KAAK,IAAC,IAAI,EAAE,EAAE,GAAI,GAChC,IACC,GACL,EAGN,eACE,SAAS,EAAE,8EACT,KAAK;gCACH,CAAC,CAAC,wJAAwJ;gCAC1J,CAAC,CAAC,oEAAoE,CACxE,aAED,KAAK,IAAI,CACR,KAAC,WAAW,IAAC,IAAI,EAAE,EAAE,EAAE,SAAS,EAAC,oBAAoB,GAAG,CACzD,EACA,KAAK,IACF,EAGN,cACE,SAAS,EAAE,8EACT,OAAO;gCACL,CAAC,CAAC,8JAA8J;gCAChK,CAAC,CAAC,oEAAoE,CACxE,YAED,OAAO,GACJ,EAGN,cACE,SAAS,EAAE,0DAAmD,WAAW,CAAC,CAAC,CAAC,2BAA2B,CAAC,CAAC,CAAC,yBAAyB,CAAE,YAErI,KAAC,YAAY,IACX,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,IAAI,EACV,SAAS,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,EACvD,QAAQ,EAAE,CAAC,YAAY,IAAI,OAAO,GAClC,GACE,IACF,GACD,CACR,IACG,CACP,CAAC;AACJ,CAAC","sourcesContent":["import { useState, useEffect } from 'react';\nimport { useN1WalletContext } from '../../../../Provider/hooks';\nimport BuySellTabs from './BuySellTabs';\nimport FillModeSelector from './FillModeSelector';\nimport PriceInput from './PriceInput';\nimport AmountInput from './AmountInput';\nimport TotalCalculator from './TotalCalculator';\nimport SubmitButton from './SubmitButton';\nimport { AlertCircle, Check, Lock, Unlock, Info } from 'lucide-react';\nimport { logger } from '../../../../utils/logger';\n\ninterface TradeFormProps {\n marketSymbol: string | null;\n}\n\n// Define order types\nexport type OrderSide = 'BUY' | 'SELL';\nexport type OrderType = 'LIMIT' | 'MARKET'; // Keep for backward compatibility\nexport type FillMode = 'GTC' | 'POST_ONLY' | 'IOC' | 'FOK';\n\n// Map our FillMode to the Nord FillMode enum\nconst mapFillMode = (mode: FillMode): number => {\n switch (mode) {\n case 'GTC':\n return 0; // LIMIT\n case 'POST_ONLY':\n return 1; // POST_ONLY\n case 'IOC':\n return 2; // IMMEDIATE_OR_CANCEL\n case 'FOK':\n return 3; // FILL_OR_KILL\n default:\n return 0;\n }\n};\n\n// Map our OrderSide to the Nord Side enum\nconst mapSide = (side: OrderSide): number => {\n return side === 'BUY' ? 1 : 0; // BID = 1, ASK = 0\n};\n\n// Helper to determine if a fill mode is a market order\nconst isMarketOrder = (mode: FillMode): boolean => {\n return mode === 'IOC'; // IOC is used for market orders\n};\n\nexport default function TradeForm({ marketSymbol }: TradeFormProps) {\n const { nord, nordUser } = useN1WalletContext();\n\n // Form state\n const [side, setSide] = useState<OrderSide>('BUY');\n const [fillMode, setFillMode] = useState<FillMode>('GTC');\n const [price, setPrice] = useState<string>('');\n const [amount, setAmount] = useState<string>('');\n const [total, setTotal] = useState<string>('');\n const [isReduceOnly, setIsReduceOnly] = useState<boolean>(false);\n const [accountId, setAccountId] = useState<number | undefined>(undefined);\n\n // UI state\n const [loading, setLoading] = useState<boolean>(false);\n const [error, setError] = useState<string | null>(null);\n const [success, setSuccess] = useState<string | null>(null);\n const [formVisible, setFormVisible] = useState<boolean>(false);\n\n // Market data\n const [marketInfo, setMarketInfo] = useState<any>(null);\n\n // Show form with animation after initial render\n useEffect(() => {\n const timer = setTimeout(() => {\n setFormVisible(true);\n }, 100);\n return () => clearTimeout(timer);\n }, []);\n\n // Fetch market info and user account ID when market changes\n useEffect(() => {\n if (!marketSymbol || !nord) return;\n\n const fetchMarketInfo = async () => {\n try {\n const stats = await nord.getMarketStats();\n const selectedMarket = stats.markets.find(\n (m: any) => m.symbol === marketSymbol\n );\n setMarketInfo(selectedMarket || null);\n\n // Set default price to current market price\n if ((selectedMarket as any)?.lastPrice) {\n setPrice((selectedMarket as any).lastPrice.toString());\n }\n } catch (err) {\n console.error('Error fetching market info:', err);\n }\n };\n\n const fetchUserAccount = async () => {\n if (nordUser) {\n try {\n // Update account ID\n await nordUser.updateAccountId();\n // Set the first account ID if available\n if (nordUser.accountIds && nordUser.accountIds.length > 0) {\n setAccountId(nordUser.accountIds[0]);\n }\n } catch (err) {\n console.error('Error fetching user account:', err);\n }\n }\n };\n\n fetchMarketInfo();\n fetchUserAccount();\n }, [marketSymbol, nord, nordUser]);\n\n // Calculate total when price or amount changes\n useEffect(() => {\n if (!isMarketOrder(fillMode) && price && amount) {\n const calculatedTotal = parseFloat(price) * parseFloat(amount);\n setTotal(calculatedTotal.toFixed(8));\n } else if (isMarketOrder(fillMode)) {\n setTotal('Market');\n } else {\n setTotal('');\n }\n }, [price, amount, fillMode]);\n\n // Handle order submission\n const handleSubmit = async (e: React.FormEvent) => {\n e.preventDefault();\n\n if (!marketSymbol || !nordUser) {\n setError('User or market not available');\n return;\n }\n\n if (!isMarketOrder(fillMode) && (!price || parseFloat(price) <= 0)) {\n setError('Please enter a valid price');\n return;\n }\n\n if (!amount || parseFloat(amount) <= 0) {\n setError('Please enter a valid amount');\n return;\n }\n\n setLoading(true);\n setError(null);\n setSuccess(null);\n\n try {\n // Find market ID from symbol\n const market = nord?.markets?.find((m) => m.symbol === marketSymbol);\n const marketId = market\n ? (market as any).id || (market as any).marketId || 0\n : 0;\n\n // Prepare order parameters\n const orderParams = {\n marketId,\n side: mapSide(side),\n fillMode: mapFillMode(fillMode),\n isReduceOnly,\n // For limit orders or SELL orders, we need size\n size: !isMarketOrder(fillMode) || side === 'SELL' ? amount : undefined,\n // For limit orders, we need price\n price: !isMarketOrder(fillMode) ? price : undefined,\n // For market BUY orders, we need quoteSize (total amount to spend)\n quoteSize:\n isMarketOrder(fillMode) && side === 'BUY' ? total : undefined,\n // Use the first account ID if available\n accountId: accountId,\n };\n\n logger.debug('Placing order with params:', orderParams);\n\n // Place order\n const orderId = await nordUser.placeOrder(orderParams);\n\n if (orderId) {\n setSuccess(`Order placed successfully! Order ID: ${orderId}`);\n // Reset form\n setAmount('');\n if (isMarketOrder(fillMode)) {\n setPrice('');\n }\n } else {\n throw new Error('Failed to place order');\n }\n } catch (err: any) {\n logger.error('Error placing order:', err);\n setError(err.message || 'Failed to place order');\n } finally {\n setLoading(false);\n }\n };\n\n return (\n <div className=\"p-4 bg-white dark:bg-n1-dark-950 transition-colors duration-300\">\n <h2\n className={`text-base font-semibold text-n1-gray-900 dark:text-n1-gray-100 mb-3 transform transition-all duration-500 ${formVisible ? 'translate-y-0 opacity-100' : 'translate-y-4 opacity-0'}`}\n >\n Place Order{' '}\n {marketSymbol ? (\n <span\n className={\n side === 'BUY'\n ? 'text-emerald-600 dark:text-emerald-500'\n : 'text-red-700 dark:text-red-600'\n }\n >\n {marketSymbol}\n </span>\n ) : (\n ''\n )}\n </h2>\n\n {!marketSymbol ? (\n <div\n className={`p-3 border border-n1-gray-200 dark:border-n1-gray-800 rounded-sm text-n1-gray-500 dark:text-n1-gray-400 text-xs bg-n1-gray-50 dark:bg-n1-dark-950 transform transition-all duration-500 ${formVisible ? 'translate-y-0 opacity-100' : 'translate-y-4 opacity-0'}`}\n >\n Select a market to place orders\n </div>\n ) : (\n <form onSubmit={handleSubmit}>\n <div className=\"space-y-3\">\n {/* Buy/Sell Tabs */}\n <div\n className={`transform transition-all duration-500 delay-100 ${formVisible ? 'translate-y-0 opacity-100' : 'translate-y-4 opacity-0'}`}\n >\n <BuySellTabs side={side} onChange={setSide} />\n </div>\n\n {/* Order Type (Fill Mode) */}\n <div\n className={`transform transition-all duration-500 delay-200 ${formVisible ? 'translate-y-0 opacity-100' : 'translate-y-4 opacity-0'}`}\n >\n <FillModeSelector\n fillMode={fillMode}\n onFillModeChange={setFillMode}\n />\n </div>\n\n {/* Price Input (hidden for market orders) */}\n {!isMarketOrder(fillMode) && (\n <div\n className={`transform transition-all duration-500 delay-300 ${formVisible ? 'translate-y-0 opacity-100' : 'translate-y-4 opacity-0'}`}\n >\n <PriceInput\n price={price}\n onChange={setPrice}\n marketPrice={(marketInfo as any)?.lastPrice}\n />\n </div>\n )}\n\n {/* Amount Input */}\n <div\n className={`transform transition-all duration-500 delay-400 ${formVisible ? 'translate-y-0 opacity-100' : 'translate-y-4 opacity-0'}`}\n >\n <AmountInput\n amount={amount}\n onChange={setAmount}\n marketInfo={marketInfo}\n />\n </div>\n\n {/* Total Calculator */}\n <div\n className={`transform transition-all duration-500 delay-500 ${formVisible ? 'translate-y-0 opacity-100' : 'translate-y-4 opacity-0'}`}\n >\n <TotalCalculator\n total={total}\n orderType={isMarketOrder(fillMode) ? 'MARKET' : 'LIMIT'}\n />\n </div>\n\n {/* Account ID Info */}\n {accountId && (\n <div\n className={`transform transition-all duration-500 delay-550 ${formVisible ? 'translate-y-0 opacity-100' : 'translate-y-4 opacity-0'}`}\n >\n <div className=\"flex items-center text-xs text-n1-gray-500 dark:text-n1-gray-400\">\n <Info size={12} className=\"mr-1\" />\n <span>Account ID: {accountId}</span>\n </div>\n </div>\n )}\n\n {/* Reduce Only Button */}\n <div\n className={`transform transition-all duration-500 delay-600 ${formVisible ? 'translate-y-0 opacity-100' : 'translate-y-4 opacity-0'}`}\n >\n <button\n type=\"button\"\n onClick={() => setIsReduceOnly(!isReduceOnly)}\n className={`w-full flex items-center justify-between px-3 py-2 rounded-sm text-sm transition-all duration-300 ${\n isReduceOnly\n ? side === 'BUY'\n ? 'bg-emerald-50 dark:bg-emerald-900/10 text-emerald-700 dark:text-emerald-400 border border-emerald-200 dark:border-emerald-800/30'\n : 'bg-red-50 dark:bg-red-900/10 text-red-700 dark:text-red-400 border border-red-200 dark:border-red-800/30'\n : 'bg-n1-gray-50 dark:bg-n1-gray-900 text-n1-gray-700 dark:text-n1-gray-300 border border-n1-gray-200 dark:border-n1-gray-800 hover:border-n1-gray-300 dark:hover:border-n1-gray-600'\n }`}\n >\n <div className=\"flex items-center\">\n <div\n className={`mr-2 transition-colors duration-300 ${\n isReduceOnly\n ? side === 'BUY'\n ? 'text-emerald-600 dark:text-emerald-500'\n : 'text-red-600 dark:text-red-500'\n : 'text-n1-gray-500 dark:text-n1-gray-400'\n }`}\n >\n {isReduceOnly ? <Lock size={14} /> : <Unlock size={14} />}\n </div>\n <span className=\"text-xs\">Reduce Only</span>\n </div>\n <div\n className={`flex items-center justify-center w-4 h-4 rounded-full transition-all duration-300 ${\n isReduceOnly\n ? side === 'BUY'\n ? 'bg-emerald-600 dark:bg-emerald-500 text-white'\n : 'bg-red-600 dark:bg-red-500 text-white'\n : 'bg-n1-gray-200 dark:bg-n1-gray-700'\n }`}\n >\n {isReduceOnly && <Check size={10} />}\n </div>\n </button>\n </div>\n\n {/* Error Message */}\n <div\n className={`p-2 border rounded-sm text-xs transition-all duration-300 transform ${\n error\n ? 'opacity-100 max-h-20 border-red-200 dark:border-red-900/30 bg-red-50 dark:bg-red-900/10 text-red-700 dark:text-red-400 flex items-center translate-y-0'\n : 'opacity-0 max-h-0 overflow-hidden border-transparent translate-y-2'\n }`}\n >\n {error && (\n <AlertCircle size={14} className=\"mr-2 flex-shrink-0\" />\n )}\n {error}\n </div>\n\n {/* Success Message */}\n <div\n className={`p-2 border rounded-sm text-xs transition-all duration-300 transform ${\n success\n ? 'opacity-100 max-h-20 border-emerald-200 dark:border-emerald-900/30 bg-emerald-50 dark:bg-emerald-900/10 text-emerald-700 dark:text-emerald-400 translate-y-0'\n : 'opacity-0 max-h-0 overflow-hidden border-transparent translate-y-2'\n }`}\n >\n {success}\n </div>\n\n {/* Submit Button */}\n <div\n className={`transform transition-all duration-500 delay-700 ${formVisible ? 'translate-y-0 opacity-100' : 'translate-y-4 opacity-0'}`}\n >\n <SubmitButton\n loading={loading}\n side={side}\n orderType={isMarketOrder(fillMode) ? 'MARKET' : 'LIMIT'}\n disabled={!marketSymbol || loading}\n />\n </div>\n </div>\n </form>\n )}\n </div>\n );\n}\n"]}
1
+ {"version":3,"file":"TradeForm.js","sourceRoot":"","sources":["../../../../../src/Modal/Sidebar/NordTradingView/TradeForm/TradeForm.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,WAAW,MAAM,eAAe,CAAC;AACxC,OAAO,gBAAgB,MAAM,oBAAoB,CAAC;AAClD,OAAO,UAAU,MAAM,cAAc,CAAC;AACtC,OAAO,WAAW,MAAM,eAAe,CAAC;AACxC,OAAO,eAAe,MAAM,mBAAmB,CAAC;AAChD,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACtE,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAWlD,6CAA6C;AAC7C,IAAM,WAAW,GAAG,UAAC,IAAc;IACjC,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,KAAK;YACR,OAAO,CAAC,CAAC,CAAC,QAAQ;QACpB,KAAK,WAAW;YACd,OAAO,CAAC,CAAC,CAAC,YAAY;QACxB,KAAK,KAAK;YACR,OAAO,CAAC,CAAC,CAAC,sBAAsB;QAClC,KAAK,KAAK;YACR,OAAO,CAAC,CAAC,CAAC,eAAe;QAC3B;YACE,OAAO,CAAC,CAAC;IACb,CAAC;AACH,CAAC,CAAC;AAEF,0CAA0C;AAC1C,IAAM,OAAO,GAAG,UAAC,IAAe;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,CAAC,wJAAwJ;gCAC1J,CAAC,CAAC,oEAAoE,CACxE,aAED,KAAK,IAAI,CACR,KAAC,WAAW,IAAC,IAAI,EAAE,EAAE,EAAE,SAAS,EAAC,oBAAoB,GAAG,CACzD,EACA,KAAK,IACF,EAGN,cACE,SAAS,EAAE,8EACT,OAAO;gCACL,CAAC,CAAC,8JAA8J;gCAChK,CAAC,CAAC,oEAAoE,CACxE,YAED,OAAO,GACJ,EAGN,cACE,SAAS,EAAE,0DAAmD,WAAW,CAAC,CAAC,CAAC,2BAA2B,CAAC,CAAC,CAAC,yBAAyB,CAAE,YAErI,KAAC,YAAY,IACX,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,IAAI,EACV,SAAS,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,EACvD,QAAQ,EAAE,CAAC,YAAY,IAAI,OAAO,GAClC,GACE,IACF,GACD,CACR,IACG,CACP,CAAC;AACJ,CAAC","sourcesContent":["import { useState, useEffect } from 'react';\nimport { useN1WalletContext } from '../../../../Provider/hooks';\nimport BuySellTabs from './BuySellTabs';\nimport FillModeSelector from './FillModeSelector';\nimport PriceInput from './PriceInput';\nimport AmountInput from './AmountInput';\nimport TotalCalculator from './TotalCalculator';\nimport SubmitButton from './SubmitButton';\nimport { AlertCircle, Check, Lock, Unlock, Info } from 'lucide-react';\nimport { logger } from '../../../../utils/logger';\n\ninterface TradeFormProps {\n marketSymbol: string | null;\n}\n\n// Define order types\nexport type OrderSide = 'BUY' | 'SELL';\nexport type OrderType = 'LIMIT' | 'MARKET'; // Keep for backward compatibility\nexport type FillMode = 'GTC' | 'POST_ONLY' | 'IOC' | 'FOK';\n\n// Map our FillMode to the Nord FillMode enum\nconst mapFillMode = (mode: FillMode): number => {\n switch (mode) {\n case 'GTC':\n return 0; // LIMIT\n case 'POST_ONLY':\n return 1; // POST_ONLY\n case 'IOC':\n return 2; // IMMEDIATE_OR_CANCEL\n case 'FOK':\n return 3; // FILL_OR_KILL\n default:\n return 0;\n }\n};\n\n// Map our OrderSide to the Nord Side enum\nconst mapSide = (side: OrderSide): number => {\n return side === 'BUY' ? 1 : 0; // BID = 1, ASK = 0\n};\n\n// Helper to determine if a fill mode is a market order\nconst isMarketOrder = (mode: FillMode): boolean => {\n return mode === 'IOC'; // IOC is used for market orders\n};\n\nexport default function TradeForm({ marketSymbol }: TradeFormProps) {\n const { nord, nordUser } = useN1WalletContext();\n\n // Form state\n const [side, setSide] = useState<OrderSide>('BUY');\n const [fillMode, setFillMode] = useState<FillMode>('GTC');\n const [price, setPrice] = useState<string>('');\n const [amount, setAmount] = useState<string>('');\n const [total, setTotal] = useState<string>('');\n const [isReduceOnly, setIsReduceOnly] = useState<boolean>(false);\n const [accountId, setAccountId] = useState<number | undefined>(undefined);\n\n // UI state\n const [loading, setLoading] = useState<boolean>(false);\n const [error, setError] = useState<string | null>(null);\n const [success, setSuccess] = useState<string | null>(null);\n const [formVisible, setFormVisible] = useState<boolean>(false);\n\n // Market data\n const [marketInfo, setMarketInfo] = useState<any>(null);\n\n // Show form with animation after initial render\n useEffect(() => {\n const timer = setTimeout(() => {\n setFormVisible(true);\n }, 100);\n return () => clearTimeout(timer);\n }, []);\n\n // Fetch market info and user account ID when market changes\n useEffect(() => {\n if (!marketSymbol || !nord) return;\n\n const fetchMarketInfo = async () => {\n try {\n const stats = await nord.getMarketStats();\n const selectedMarket = stats.markets.find(\n (m: any) => m.symbol === marketSymbol\n );\n setMarketInfo(selectedMarket || null);\n\n // Set default price to current market price\n if ((selectedMarket as any)?.lastPrice) {\n setPrice((selectedMarket as any).lastPrice.toString());\n }\n } catch (err) {\n console.error('Error fetching market info:', err);\n }\n };\n\n const fetchUserAccount = async () => {\n if (nordUser) {\n try {\n // Update account ID\n await nordUser.updateAccountId();\n // Set the first account ID if available\n if (nordUser.accountIds && nordUser.accountIds.length > 0) {\n setAccountId(nordUser.accountIds[0]);\n }\n } catch (err) {\n console.error('Error fetching user account:', err);\n }\n }\n };\n\n fetchMarketInfo();\n fetchUserAccount();\n }, [marketSymbol, nord, nordUser]);\n\n // Calculate total when price or amount changes\n useEffect(() => {\n if (!isMarketOrder(fillMode) && price && amount) {\n const calculatedTotal = parseFloat(price) * parseFloat(amount);\n setTotal(calculatedTotal.toFixed(8));\n } else if (isMarketOrder(fillMode)) {\n setTotal('Market');\n } else {\n setTotal('');\n }\n }, [price, amount, fillMode]);\n\n // Handle order submission\n const handleSubmit = async (e: React.FormEvent) => {\n e.preventDefault();\n\n if (!marketSymbol || !nordUser) {\n setError('User or market not available');\n return;\n }\n\n if (!isMarketOrder(fillMode) && (!price || parseFloat(price) <= 0)) {\n setError('Please enter a valid price');\n return;\n }\n\n if (!amount || parseFloat(amount) <= 0) {\n setError('Please enter a valid amount');\n return;\n }\n\n setLoading(true);\n setError(null);\n setSuccess(null);\n\n try {\n // Find market ID from symbol\n const market = nord?.markets?.find((m) => m.symbol === marketSymbol);\n const marketId = market\n ? (market as any).id || (market as any).marketId || 0\n : 0;\n\n // Prepare order parameters\n const orderParams = {\n marketId,\n side: mapSide(side),\n fillMode: mapFillMode(fillMode),\n isReduceOnly,\n // For limit orders or SELL orders, we need size\n size: !isMarketOrder(fillMode) || side === 'SELL' ? amount : undefined,\n // For limit orders, we need price\n price: !isMarketOrder(fillMode) ? price : undefined,\n // For market BUY orders, we need quoteSize (total amount to spend)\n quoteSize:\n isMarketOrder(fillMode) && side === 'BUY' ? total : undefined,\n // Use the first account ID if available\n accountId: accountId,\n };\n\n logger.debug('Placing order with params:', orderParams);\n\n // Place order\n const orderId = await nordUser.placeOrder(orderParams);\n\n if (orderId) {\n setSuccess(`Order placed successfully! Order ID: ${orderId}`);\n // Reset form\n setAmount('');\n if (isMarketOrder(fillMode)) {\n setPrice('');\n }\n } else {\n throw new Error('Failed to place order');\n }\n } catch (err: any) {\n logger.error('Error placing order:', err);\n setError(err.message || 'Failed to place order');\n } finally {\n setLoading(false);\n }\n };\n\n return (\n <div className=\"p-4 bg-white dark:bg-n1-ww-dark-950 transition-colors duration-300\">\n <h2\n className={`text-base font-semibold text-n1-ww-gray-900 dark:text-n1-ww-gray-100 mb-3 transform transition-all duration-500 ${formVisible ? 'translate-y-0 opacity-100' : 'translate-y-4 opacity-0'}`}\n >\n Place Order{' '}\n {marketSymbol ? (\n <span\n className={\n side === 'BUY'\n ? 'text-emerald-600 dark:text-emerald-500'\n : 'text-red-700 dark:text-red-600'\n }\n >\n {marketSymbol}\n </span>\n ) : (\n ''\n )}\n </h2>\n\n {!marketSymbol ? (\n <div\n className={`p-3 border border-n1-ww-gray-200 dark:border-n1-ww-gray-800 rounded-sm text-n1-ww-gray-500 dark:text-n1-ww-gray-400 text-xs bg-n1-ww-gray-50 dark:bg-n1-ww-dark-950 transform transition-all duration-500 ${formVisible ? 'translate-y-0 opacity-100' : 'translate-y-4 opacity-0'}`}\n >\n Select a market to place orders\n </div>\n ) : (\n <form onSubmit={handleSubmit}>\n <div className=\"space-y-3\">\n {/* Buy/Sell Tabs */}\n <div\n className={`transform transition-all duration-500 delay-100 ${formVisible ? 'translate-y-0 opacity-100' : 'translate-y-4 opacity-0'}`}\n >\n <BuySellTabs side={side} onChange={setSide} />\n </div>\n\n {/* Order Type (Fill Mode) */}\n <div\n className={`transform transition-all duration-500 delay-200 ${formVisible ? 'translate-y-0 opacity-100' : 'translate-y-4 opacity-0'}`}\n >\n <FillModeSelector\n fillMode={fillMode}\n onFillModeChange={setFillMode}\n />\n </div>\n\n {/* Price Input (hidden for market orders) */}\n {!isMarketOrder(fillMode) && (\n <div\n className={`transform transition-all duration-500 delay-300 ${formVisible ? 'translate-y-0 opacity-100' : 'translate-y-4 opacity-0'}`}\n >\n <PriceInput\n price={price}\n onChange={setPrice}\n marketPrice={(marketInfo as any)?.lastPrice}\n />\n </div>\n )}\n\n {/* Amount Input */}\n <div\n className={`transform transition-all duration-500 delay-400 ${formVisible ? 'translate-y-0 opacity-100' : 'translate-y-4 opacity-0'}`}\n >\n <AmountInput\n amount={amount}\n onChange={setAmount}\n marketInfo={marketInfo}\n />\n </div>\n\n {/* Total Calculator */}\n <div\n className={`transform transition-all duration-500 delay-500 ${formVisible ? 'translate-y-0 opacity-100' : 'translate-y-4 opacity-0'}`}\n >\n <TotalCalculator\n total={total}\n orderType={isMarketOrder(fillMode) ? 'MARKET' : 'LIMIT'}\n />\n </div>\n\n {/* Account ID Info */}\n {accountId && (\n <div\n className={`transform transition-all duration-500 delay-550 ${formVisible ? 'translate-y-0 opacity-100' : 'translate-y-4 opacity-0'}`}\n >\n <div className=\"flex items-center text-xs text-n1-ww-gray-500 dark:text-n1-ww-gray-400\">\n <Info size={12} className=\"mr-1\" />\n <span>Account ID: {accountId}</span>\n </div>\n </div>\n )}\n\n {/* Reduce Only Button */}\n <div\n className={`transform transition-all duration-500 delay-600 ${formVisible ? 'translate-y-0 opacity-100' : 'translate-y-4 opacity-0'}`}\n >\n <button\n type=\"button\"\n onClick={() => setIsReduceOnly(!isReduceOnly)}\n className={`w-full flex items-center justify-between px-3 py-2 rounded-sm text-sm transition-all duration-300 ${\n isReduceOnly\n ? side === 'BUY'\n ? 'bg-emerald-50 dark:bg-emerald-900/10 text-emerald-700 dark:text-emerald-400 border border-emerald-200 dark:border-emerald-800/30'\n : 'bg-red-50 dark:bg-red-900/10 text-red-700 dark:text-red-400 border border-red-200 dark:border-red-800/30'\n : 'bg-n1-ww-gray-50 dark:bg-n1-ww-gray-900 text-n1-ww-gray-700 dark:text-n1-ww-gray-300 border border-n1-ww-gray-200 dark:border-n1-ww-gray-800 hover:border-n1-ww-gray-300 dark:hover:border-n1-ww-gray-600'\n }`}\n >\n <div className=\"flex items-center\">\n <div\n className={`mr-2 transition-colors duration-300 ${\n isReduceOnly\n ? side === 'BUY'\n ? 'text-emerald-600 dark:text-emerald-500'\n : 'text-red-600 dark:text-red-500'\n : 'text-n1-ww-gray-500 dark:text-n1-ww-gray-400'\n }`}\n >\n {isReduceOnly ? <Lock size={14} /> : <Unlock size={14} />}\n </div>\n <span className=\"text-xs\">Reduce Only</span>\n </div>\n <div\n className={`flex items-center justify-center w-4 h-4 rounded-full transition-all duration-300 ${\n isReduceOnly\n ? side === 'BUY'\n ? 'bg-emerald-600 dark:bg-emerald-500 text-white'\n : 'bg-red-600 dark:bg-red-500 text-white'\n : 'bg-n1-ww-gray-200 dark:bg-n1-ww-gray-700'\n }`}\n >\n {isReduceOnly && <Check size={10} />}\n </div>\n </button>\n </div>\n\n {/* Error Message */}\n <div\n className={`p-2 border rounded-sm text-xs transition-all duration-300 transform ${\n error\n ? 'opacity-100 max-h-20 border-red-200 dark:border-red-900/30 bg-red-50 dark:bg-red-900/10 text-red-700 dark:text-red-400 flex items-center translate-y-0'\n : 'opacity-0 max-h-0 overflow-hidden border-transparent translate-y-2'\n }`}\n >\n {error && (\n <AlertCircle size={14} className=\"mr-2 flex-shrink-0\" />\n )}\n {error}\n </div>\n\n {/* Success Message */}\n <div\n className={`p-2 border rounded-sm text-xs transition-all duration-300 transform ${\n success\n ? 'opacity-100 max-h-20 border-emerald-200 dark:border-emerald-900/30 bg-emerald-50 dark:bg-emerald-900/10 text-emerald-700 dark:text-emerald-400 translate-y-0'\n : 'opacity-0 max-h-0 overflow-hidden border-transparent translate-y-2'\n }`}\n >\n {success}\n </div>\n\n {/* Submit Button */}\n <div\n className={`transform transition-all duration-500 delay-700 ${formVisible ? 'translate-y-0 opacity-100' : 'translate-y-4 opacity-0'}`}\n >\n <SubmitButton\n loading={loading}\n side={side}\n orderType={isMarketOrder(fillMode) ? 'MARKET' : 'LIMIT'}\n disabled={!marketSymbol || loading}\n />\n </div>\n </div>\n </form>\n )}\n </div>\n );\n}\n"]}
@@ -104,6 +104,6 @@ export default function UserBalances() {
104
104
  var intervalId = setInterval(fetchBalances, 10000); // Update every 10 seconds
105
105
  return function () { return clearInterval(intervalId); };
106
106
  }, [nordUser, nord]);
107
- return (_jsx("div", { className: "bg-white dark:bg-n1-gray-950 overflow-hidden", children: _jsxs("div", { className: "p-4", children: [_jsx("h2", { className: "text-lg font-semibold text-n1-gray-900 dark:text-n1-gray-100 mb-4", children: "Balances" }), loading && balances.length === 0 ? (_jsx("div", { className: "flex items-center justify-center h-32", children: _jsx(RefreshCw, { size: 20, className: "text-n1-gray-400 n1-animate-spin" }) })) : error ? (_jsx("div", { className: "p-3 bg-red-50 dark:bg-red-900/20 rounded-lg text-red-600 dark:text-red-400 text-sm", children: error })) : balances.length === 0 ? (_jsx("div", { className: "p-3 bg-n1-gray-50 dark:bg-n1-gray-950 rounded-lg text-n1-gray-500 dark:text-n1-gray-400 text-sm text-center", children: "No balances found" })) : (_jsxs("div", { className: "space-y-3", children: [balances.map(function (balance, index) { return (_jsxs("div", { className: "p-3 bg-n1-gray-50 dark:bg-n1-gray-950 rounded-lg", children: [_jsxs("div", { className: "flex items-center justify-between mb-2", children: [_jsx("div", { className: "flex items-center", children: _jsx("span", { className: "font-medium text-n1-gray-900 dark:text-n1-gray-100", children: balance.symbol }) }), _jsx("div", { className: "font-medium text-n1-gray-900 dark:text-n1-gray-100 font-mono", children: balance.balance.toFixed(6) })] }), _jsxs("div", { className: "text-xs text-n1-gray-500 dark:text-n1-gray-400", children: ["Account ID: ", balance.accountId] })] }, index)); }), loading && balances.length > 0 && (_jsx("div", { className: "flex justify-center mt-2", children: _jsx(RefreshCw, { size: 16, className: "text-n1-gray-400 n1-animate-spin" }) }))] }))] }) }));
107
+ return (_jsx("div", { className: "bg-white dark:bg-n1-ww-gray-950 overflow-hidden", children: _jsxs("div", { className: "p-4", children: [_jsx("h2", { className: "text-lg font-semibold text-n1-ww-gray-900 dark:text-n1-ww-gray-100 mb-4", children: "Balances" }), loading && balances.length === 0 ? (_jsx("div", { className: "flex items-center justify-center h-32", children: _jsx(RefreshCw, { size: 20, className: "text-n1-ww-gray-400 n1-ww-animate-spin" }) })) : error ? (_jsx("div", { className: "p-3 bg-red-50 dark:bg-red-900/20 rounded-lg text-red-600 dark:text-red-400 text-sm", children: error })) : balances.length === 0 ? (_jsx("div", { className: "p-3 bg-n1-ww-gray-50 dark:bg-n1-ww-gray-950 rounded-lg text-n1-ww-gray-500 dark:text-n1-ww-gray-400 text-sm text-center", children: "No balances found" })) : (_jsxs("div", { className: "space-y-3", children: [balances.map(function (balance, index) { return (_jsxs("div", { className: "p-3 bg-n1-ww-gray-50 dark:bg-n1-ww-gray-950 rounded-lg", children: [_jsxs("div", { className: "flex items-center justify-between mb-2", children: [_jsx("div", { className: "flex items-center", children: _jsx("span", { className: "font-medium text-n1-ww-gray-900 dark:text-n1-ww-gray-100", children: balance.symbol }) }), _jsx("div", { className: "font-medium text-n1-ww-gray-900 dark:text-n1-ww-gray-100 font-mono", children: balance.balance.toFixed(6) })] }), _jsxs("div", { className: "text-xs text-n1-ww-gray-500 dark:text-n1-ww-gray-400", children: ["Account ID: ", balance.accountId] })] }, index)); }), loading && balances.length > 0 && (_jsx("div", { className: "flex justify-center mt-2", children: _jsx(RefreshCw, { size: 16, className: "text-n1-ww-gray-400 n1-ww-animate-spin" }) }))] }))] }) }));
108
108
  }
109
109
  //# sourceMappingURL=UserBalances.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"UserBalances.js","sourceRoot":"","sources":["../../../../../src/Modal/Sidebar/NordTradingView/UserBalances/UserBalances.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAQzC,MAAM,CAAC,OAAO,UAAU,YAAY;IAApC,iBAiHC;IAhHO,IAAA,KAAqB,kBAAkB,EAAE,EAAvC,IAAI,UAAA,EAAE,QAAQ,cAAyB,CAAC;IAC1C,IAAA,KAA0B,QAAQ,CAAY,EAAE,CAAC,EAAhD,QAAQ,QAAA,EAAE,WAAW,QAA2B,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AA8D,YAC1E,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,GACvB,IACF,EACN,eAAK,SAAS,EAAC,gDAAgD,6BAChD,OAAO,CAAC,SAAS,IAC1B,KAfD,KAAK,CAgBN,CACP,EAnBiC,CAmBjC,CAAC,EAGD,OAAO,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,IAAI,CACjC,cAAK,SAAS,EAAC,0BAA0B,YACvC,KAAC,SAAS,IAAC,IAAI,EAAE,EAAE,EAAE,SAAS,EAAC,kCAAkC,GAAG,GAChE,CACP,IACG,CACP,IACG,GACF,CACP,CAAC;AACJ,CAAC","sourcesContent":["import { useState, useEffect } from 'react';\nimport { useN1WalletContext } from '../../../../Provider/hooks';\nimport { RefreshCw } from 'lucide-react';\n\ninterface Balance {\n symbol: string;\n balance: number;\n accountId: number;\n}\n\nexport default function UserBalances() {\n const { nord, nordUser } = useN1WalletContext();\n const [balances, setBalances] = useState<Balance[]>([]);\n const [loading, setLoading] = useState(false);\n const [error, setError] = useState<string | null>(null);\n\n // Fetch user balances\n useEffect(() => {\n if (!nordUser || !nord) return;\n\n const fetchBalances = async () => {\n setLoading(true);\n setError(null);\n\n try {\n // Refresh user info to get latest balances\n await nordUser.fetchInfo();\n\n // Extract real balances from nordUser\n const realBalances: Balance[] = [];\n\n // Loop through all accounts\n if (nordUser.accountIds) {\n for (const accountId of nordUser.accountIds) {\n // Check if this account has balances\n const accountBalances = nordUser.balances[accountId];\n\n if (accountBalances && accountBalances.length > 0) {\n // Add each balance to our list\n for (const balance of accountBalances) {\n // Only include non-zero balances\n if (balance.balance > 0) {\n realBalances.push({\n symbol: balance.symbol,\n balance: balance.balance,\n accountId: accountId,\n });\n }\n }\n }\n }\n }\n\n setBalances(realBalances);\n } catch (err) {\n console.error('Error fetching balances:', err);\n setError('Failed to load balances');\n } finally {\n setLoading(false);\n }\n };\n\n fetchBalances();\n\n // Set up polling for balance updates\n const intervalId = setInterval(fetchBalances, 10000); // Update every 10 seconds\n\n return () => clearInterval(intervalId);\n }, [nordUser, nord]);\n\n return (\n <div className=\"bg-white dark:bg-n1-gray-950 overflow-hidden\">\n <div className=\"p-4\">\n <h2 className=\"text-lg font-semibold text-n1-gray-900 dark:text-n1-gray-100 mb-4\">\n Balances\n </h2>\n\n {loading && balances.length === 0 ? (\n <div className=\"flex items-center justify-center h-32\">\n <RefreshCw size={20} className=\"text-n1-gray-400 n1-animate-spin\" />\n </div>\n ) : error ? (\n <div className=\"p-3 bg-red-50 dark:bg-red-900/20 rounded-lg text-red-600 dark:text-red-400 text-sm\">\n {error}\n </div>\n ) : balances.length === 0 ? (\n <div className=\"p-3 bg-n1-gray-50 dark:bg-n1-gray-950 rounded-lg text-n1-gray-500 dark:text-n1-gray-400 text-sm text-center\">\n No balances found\n </div>\n ) : (\n <div className=\"space-y-3\">\n {balances.map((balance, index) => (\n <div\n key={index}\n className=\"p-3 bg-n1-gray-50 dark:bg-n1-gray-950 rounded-lg\"\n >\n <div className=\"flex items-center justify-between mb-2\">\n <div className=\"flex items-center\">\n <span className=\"font-medium text-n1-gray-900 dark:text-n1-gray-100\">\n {balance.symbol}\n </span>\n </div>\n <div className=\"font-medium text-n1-gray-900 dark:text-n1-gray-100 font-mono\">\n {balance.balance.toFixed(6)}\n </div>\n </div>\n <div className=\"text-xs text-n1-gray-500 dark:text-n1-gray-400\">\n Account ID: {balance.accountId}\n </div>\n </div>\n ))}\n\n {/* Loading indicator for refreshing */}\n {loading && balances.length > 0 && (\n <div className=\"flex justify-center mt-2\">\n <RefreshCw size={16} className=\"text-n1-gray-400 n1-animate-spin\" />\n </div>\n )}\n </div>\n )}\n </div>\n </div>\n );\n}\n"]}
1
+ {"version":3,"file":"UserBalances.js","sourceRoot":"","sources":["../../../../../src/Modal/Sidebar/NordTradingView/UserBalances/UserBalances.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAA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,SAAS,EAAC,yHAAyH,kCAElI,CACP,CAAC,CAAC,CAAC,CACF,eAAK,SAAS,EAAC,WAAW,aACvB,QAAQ,CAAC,GAAG,CAAC,UAAC,OAAO,EAAE,KAAK,IAAK,OAAA,CAChC,eAEE,SAAS,EAAC,wDAAwD,aAElE,eAAK,SAAS,EAAC,wCAAwC,aACrD,cAAK,SAAS,EAAC,mBAAmB,YAChC,eAAM,SAAS,EAAC,0DAA0D,YACvE,OAAO,CAAC,MAAM,GACV,GACH,EACN,cAAK,SAAS,EAAC,oEAAoE,YAChF,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,GACvB,IACF,EACN,eAAK,SAAS,EAAC,sDAAsD,6BACtD,OAAO,CAAC,SAAS,IAC1B,KAfD,KAAK,CAgBN,CACP,EAnBiC,CAmBjC,CAAC,EAGD,OAAO,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,IAAI,CACjC,cAAK,SAAS,EAAC,0BAA0B,YACvC,KAAC,SAAS,IAAC,IAAI,EAAE,EAAE,EAAE,SAAS,EAAC,wCAAwC,GAAG,GACtE,CACP,IACG,CACP,IACG,GACF,CACP,CAAC;AACJ,CAAC","sourcesContent":["import { useState, useEffect } from 'react';\nimport { useN1WalletContext } from '../../../../Provider/hooks';\nimport { RefreshCw } from 'lucide-react';\n\ninterface Balance {\n symbol: string;\n balance: number;\n accountId: number;\n}\n\nexport default function UserBalances() {\n const { nord, nordUser } = useN1WalletContext();\n const [balances, setBalances] = useState<Balance[]>([]);\n const [loading, setLoading] = useState(false);\n const [error, setError] = useState<string | null>(null);\n\n // Fetch user balances\n useEffect(() => {\n if (!nordUser || !nord) return;\n\n const fetchBalances = async () => {\n setLoading(true);\n setError(null);\n\n try {\n // Refresh user info to get latest balances\n await nordUser.fetchInfo();\n\n // Extract real balances from nordUser\n const realBalances: Balance[] = [];\n\n // Loop through all accounts\n if (nordUser.accountIds) {\n for (const accountId of nordUser.accountIds) {\n // Check if this account has balances\n const accountBalances = nordUser.balances[accountId];\n\n if (accountBalances && accountBalances.length > 0) {\n // Add each balance to our list\n for (const balance of accountBalances) {\n // Only include non-zero balances\n if (balance.balance > 0) {\n realBalances.push({\n symbol: balance.symbol,\n balance: balance.balance,\n accountId: accountId,\n });\n }\n }\n }\n }\n }\n\n setBalances(realBalances);\n } catch (err) {\n console.error('Error fetching balances:', err);\n setError('Failed to load balances');\n } finally {\n setLoading(false);\n }\n };\n\n fetchBalances();\n\n // Set up polling for balance updates\n const intervalId = setInterval(fetchBalances, 10000); // Update every 10 seconds\n\n return () => clearInterval(intervalId);\n }, [nordUser, nord]);\n\n return (\n <div className=\"bg-white dark:bg-n1-ww-gray-950 overflow-hidden\">\n <div className=\"p-4\">\n <h2 className=\"text-lg font-semibold text-n1-ww-gray-900 dark:text-n1-ww-gray-100 mb-4\">\n Balances\n </h2>\n\n {loading && balances.length === 0 ? (\n <div className=\"flex items-center justify-center h-32\">\n <RefreshCw size={20} className=\"text-n1-ww-gray-400 n1-ww-animate-spin\" />\n </div>\n ) : error ? (\n <div className=\"p-3 bg-red-50 dark:bg-red-900/20 rounded-lg text-red-600 dark:text-red-400 text-sm\">\n {error}\n </div>\n ) : balances.length === 0 ? (\n <div className=\"p-3 bg-n1-ww-gray-50 dark:bg-n1-ww-gray-950 rounded-lg text-n1-ww-gray-500 dark:text-n1-ww-gray-400 text-sm text-center\">\n No balances found\n </div>\n ) : (\n <div className=\"space-y-3\">\n {balances.map((balance, index) => (\n <div\n key={index}\n className=\"p-3 bg-n1-ww-gray-50 dark:bg-n1-ww-gray-950 rounded-lg\"\n >\n <div className=\"flex items-center justify-between mb-2\">\n <div className=\"flex items-center\">\n <span className=\"font-medium text-n1-ww-gray-900 dark:text-n1-ww-gray-100\">\n {balance.symbol}\n </span>\n </div>\n <div className=\"font-medium text-n1-ww-gray-900 dark:text-n1-ww-gray-100 font-mono\">\n {balance.balance.toFixed(6)}\n </div>\n </div>\n <div className=\"text-xs text-n1-ww-gray-500 dark:text-n1-ww-gray-400\">\n Account ID: {balance.accountId}\n </div>\n </div>\n ))}\n\n {/* Loading indicator for refreshing */}\n {loading && balances.length > 0 && (\n <div className=\"flex justify-center mt-2\">\n <RefreshCw size={16} className=\"text-n1-ww-gray-400 n1-ww-animate-spin\" />\n </div>\n )}\n </div>\n )}\n </div>\n </div>\n );\n}\n"]}
@@ -170,14 +170,14 @@ export default function UserOrders() {
170
170
  }
171
171
  });
172
172
  }); };
173
- return (_jsx("div", { className: "bg-white dark:bg-n1-gray-950 shadow-sm border border-n1-gray-200 dark:border-n1-gray-800 overflow-hidden", children: _jsxs("div", { className: "p-4", children: [_jsx("h2", { className: "text-lg font-semibold text-n1-gray-900 dark:text-n1-gray-100 mb-4", children: "Orders" }), _jsxs("div", { className: "overflow-hidden", ref: containerRef, children: [loading && activeOrders.length === 0 && orderHistory.length === 0 ? (_jsx("div", { className: "flex items-center justify-center h-32", children: _jsx(RefreshCw, { size: 20, className: "text-n1-gray-400 n1-animate-spin" }) })) : error ? (_jsx("div", { className: "p-3 bg-red-50 dark:bg-red-900/20 text-red-600 dark:text-red-400 text-sm", children: error })) : activeOrders.length === 0 ? (_jsx("div", { className: "p-3 bg-n1-gray-50 dark:bg-n1-gray-800 text-n1-gray-500 dark:text-n1-gray-400 text-sm text-center", children: "No active orders" })) : !compactView ? (
173
+ return (_jsx("div", { className: "bg-white dark:bg-n1-ww-gray-950 shadow-sm border border-n1-ww-gray-200 dark:border-n1-ww-gray-800 overflow-hidden", children: _jsxs("div", { className: "p-4", children: [_jsx("h2", { className: "text-lg font-semibold text-n1-ww-gray-900 dark:text-n1-ww-gray-100 mb-4", children: "Orders" }), _jsxs("div", { className: "overflow-hidden", ref: containerRef, children: [loading && activeOrders.length === 0 && orderHistory.length === 0 ? (_jsx("div", { className: "flex items-center justify-center h-32", children: _jsx(RefreshCw, { size: 20, className: "text-n1-ww-gray-400 n1-ww-animate-spin" }) })) : error ? (_jsx("div", { className: "p-3 bg-red-50 dark:bg-red-900/20 text-red-600 dark:text-red-400 text-sm", children: error })) : activeOrders.length === 0 ? (_jsx("div", { className: "p-3 bg-n1-ww-gray-50 dark:bg-n1-ww-gray-800 text-n1-ww-gray-500 dark:text-n1-ww-gray-400 text-sm text-center", children: "No active orders" })) : !compactView ? (
174
174
  // Standard table view for larger containers
175
- _jsx("div", { className: "overflow-x-auto", children: _jsxs("table", { className: "min-w-full divide-y divide-n1-gray-200 dark:divide-n1-gray-800", children: [_jsx("thead", { className: "bg-n1-gray-50 dark:bg-n1-gray-800", children: _jsxs("tr", { children: [_jsx("th", { className: "px-3 py-2 text-left text-xs font-medium text-n1-gray-500 dark:text-n1-gray-400 uppercase tracking-wider", children: "Market" }), _jsx("th", { className: "px-3 py-2 text-left text-xs font-medium text-n1-gray-500 dark:text-n1-gray-400 uppercase tracking-wider", children: "Side" }), _jsx("th", { className: "px-3 py-2 text-right text-xs font-medium text-n1-gray-500 dark:text-n1-gray-400 uppercase tracking-wider", children: "Size" }), _jsx("th", { className: "px-3 py-2 text-right text-xs font-medium text-n1-gray-500 dark:text-n1-gray-400 uppercase tracking-wider", children: "Price" }), _jsx("th", { className: "px-3 py-2 text-right text-xs font-medium text-n1-gray-500 dark:text-n1-gray-400 uppercase tracking-wider", children: "Action" })] }) }), _jsx("tbody", { className: "bg-white dark:bg-n1-gray-950 divide-y divide-n1-gray-200 dark:divide-n1-gray-800", children: activeOrders.map(function (order) { return (_jsxs("tr", { className: "hover:bg-n1-gray-50 dark:hover:bg-n1-gray-800", children: [_jsx("td", { className: "px-3 py-2 whitespace-nowrap text-sm text-n1-gray-900 dark:text-n1-gray-100", children: order.symbol }), _jsx("td", { className: "px-3 py-2 whitespace-nowrap text-sm", children: _jsx("span", { className: "font-medium ".concat(order.isLong ? 'text-green-600 dark:text-green-400' : 'text-red-600 dark:text-red-400'), children: order.isLong ? 'BUY' : 'SELL' }) }), _jsx("td", { className: "px-3 py-2 whitespace-nowrap text-sm text-n1-gray-900 dark:text-n1-gray-100 text-right font-mono", children: order.size }), _jsx("td", { className: "px-3 py-2 whitespace-nowrap text-sm text-n1-gray-900 dark:text-n1-gray-100 text-right font-mono", children: order.price }), _jsx("td", { className: "px-3 py-2 whitespace-nowrap text-sm text-right", children: _jsx("button", { onClick: function () { return handleCancelOrder(order.orderId); }, disabled: cancellingOrderId === order.orderId, className: "text-red-600 dark:text-red-400 hover:text-red-800 dark:hover:text-red-300 relative ".concat(cancellingOrderId === order.orderId
175
+ _jsx("div", { className: "overflow-x-auto", children: _jsxs("table", { className: "min-w-full divide-y divide-n1-ww-gray-200 dark:divide-n1-ww-gray-800", children: [_jsx("thead", { className: "bg-n1-ww-gray-50 dark:bg-n1-ww-gray-800", children: _jsxs("tr", { children: [_jsx("th", { className: "px-3 py-2 text-left text-xs font-medium text-n1-ww-gray-500 dark:text-n1-ww-gray-400 uppercase tracking-wider", children: "Market" }), _jsx("th", { className: "px-3 py-2 text-left text-xs font-medium text-n1-ww-gray-500 dark:text-n1-ww-gray-400 uppercase tracking-wider", children: "Side" }), _jsx("th", { className: "px-3 py-2 text-right text-xs font-medium text-n1-ww-gray-500 dark:text-n1-ww-gray-400 uppercase tracking-wider", children: "Size" }), _jsx("th", { className: "px-3 py-2 text-right text-xs font-medium text-n1-ww-gray-500 dark:text-n1-ww-gray-400 uppercase tracking-wider", children: "Price" }), _jsx("th", { className: "px-3 py-2 text-right text-xs font-medium text-n1-ww-gray-500 dark:text-n1-ww-gray-400 uppercase tracking-wider", children: "Action" })] }) }), _jsx("tbody", { className: "bg-white dark:bg-n1-ww-gray-950 divide-y divide-n1-ww-gray-200 dark:divide-n1-ww-gray-800", children: activeOrders.map(function (order) { return (_jsxs("tr", { className: "hover:bg-n1-ww-gray-50 dark:hover:bg-n1-ww-gray-800", children: [_jsx("td", { className: "px-3 py-2 whitespace-nowrap text-sm text-n1-ww-gray-900 dark:text-n1-ww-gray-100", children: order.symbol }), _jsx("td", { className: "px-3 py-2 whitespace-nowrap text-sm", children: _jsx("span", { className: "font-medium ".concat(order.isLong ? 'text-green-600 dark:text-green-400' : 'text-red-600 dark:text-red-400'), children: order.isLong ? 'BUY' : 'SELL' }) }), _jsx("td", { className: "px-3 py-2 whitespace-nowrap text-sm text-n1-ww-gray-900 dark:text-n1-ww-gray-100 text-right font-mono", children: order.size }), _jsx("td", { className: "px-3 py-2 whitespace-nowrap text-sm text-n1-ww-gray-900 dark:text-n1-ww-gray-100 text-right font-mono", children: order.price }), _jsx("td", { className: "px-3 py-2 whitespace-nowrap text-sm text-right", children: _jsx("button", { onClick: function () { return handleCancelOrder(order.orderId); }, disabled: cancellingOrderId === order.orderId, className: "text-red-600 dark:text-red-400 hover:text-red-800 dark:hover:text-red-300 relative ".concat(cancellingOrderId === order.orderId
176
176
  ? 'cursor-not-allowed'
177
- : ''), children: cancellingOrderId === order.orderId ? (_jsxs(_Fragment, { children: [_jsx("span", { className: "opacity-0", children: "Cancel" }), _jsx(X, { size: 16, className: "absolute inset-0 m-auto n1-animate-pulse text-red-500" })] })) : ('Cancel') }) })] }, order.orderId)); }) })] }) })) : (
177
+ : ''), children: cancellingOrderId === order.orderId ? (_jsxs(_Fragment, { children: [_jsx("span", { className: "opacity-0", children: "Cancel" }), _jsx(X, { size: 16, className: "absolute inset-0 m-auto n1-ww-animate-pulse text-red-500" })] })) : ('Cancel') }) })] }, order.orderId)); }) })] }) })) : (
178
178
  // Compact card view for smaller containers
179
- _jsx("div", { className: "grid gap-2", children: activeOrders.map(function (order) { return (_jsxs("div", { className: "bg-white dark:bg-n1-gray-900 border border-n1-gray-200 dark:border-n1-gray-800 rounded p-2 hover:bg-n1-gray-50 dark:hover:bg-n1-gray-800", children: [_jsxs("div", { className: "flex justify-between items-start mb-1", children: [_jsx("div", { className: "font-medium text-sm text-n1-gray-900 dark:text-n1-gray-100", children: order.symbol }), _jsx("button", { onClick: function () { return handleCancelOrder(order.orderId); }, disabled: cancellingOrderId === order.orderId, className: "text-red-600 dark:text-red-400 hover:text-red-800 dark:hover:text-red-300 text-xs relative ".concat(cancellingOrderId === order.orderId
179
+ _jsx("div", { className: "grid gap-2", children: activeOrders.map(function (order) { return (_jsxs("div", { className: "bg-white dark:bg-n1-ww-gray-900 border border-n1-ww-gray-200 dark:border-n1-ww-gray-800 rounded p-2 hover:bg-n1-ww-gray-50 dark:hover:bg-n1-ww-gray-800", children: [_jsxs("div", { className: "flex justify-between items-start mb-1", children: [_jsx("div", { className: "font-medium text-sm text-n1-ww-gray-900 dark:text-n1-ww-gray-100", children: order.symbol }), _jsx("button", { onClick: function () { return handleCancelOrder(order.orderId); }, disabled: cancellingOrderId === order.orderId, className: "text-red-600 dark:text-red-400 hover:text-red-800 dark:hover:text-red-300 text-xs relative ".concat(cancellingOrderId === order.orderId
180
180
  ? 'cursor-not-allowed'
181
- : ''), children: cancellingOrderId === order.orderId ? (_jsxs(_Fragment, { children: [_jsx("span", { className: "opacity-0", children: "Cancel" }), _jsx(X, { size: 14, className: "absolute inset-0 m-auto n1-animate-pulse text-red-500" })] })) : ('Cancel') })] }), _jsxs("div", { className: "grid grid-cols-3 gap-1 text-xs", children: [_jsx("div", { children: _jsx("span", { className: "font-medium ".concat(order.isLong ? 'text-green-600 dark:text-green-400' : 'text-red-600 dark:text-red-400'), children: order.isLong ? 'BUY' : 'SELL' }) }), _jsx("div", { className: "text-right font-mono text-n1-gray-700 dark:text-n1-gray-300", children: order.size }), _jsx("div", { className: "text-right font-mono text-n1-gray-700 dark:text-n1-gray-300", children: order.price })] })] }, order.orderId)); }) })), loading && (activeOrders.length > 0 || orderHistory.length > 0) && (_jsx("div", { className: "flex justify-center mt-2", children: _jsx(RefreshCw, { size: 16, className: "text-n1-gray-400 n1-animate-spin" }) }))] })] }) }));
181
+ : ''), children: cancellingOrderId === order.orderId ? (_jsxs(_Fragment, { children: [_jsx("span", { className: "opacity-0", children: "Cancel" }), _jsx(X, { size: 14, className: "absolute inset-0 m-auto n1-ww-animate-pulse text-red-500" })] })) : ('Cancel') })] }), _jsxs("div", { className: "grid grid-cols-3 gap-1 text-xs", children: [_jsx("div", { children: _jsx("span", { className: "font-medium ".concat(order.isLong ? 'text-green-600 dark:text-green-400' : 'text-red-600 dark:text-red-400'), children: order.isLong ? 'BUY' : 'SELL' }) }), _jsx("div", { className: "text-right font-mono text-n1-ww-gray-700 dark:text-n1-ww-gray-300", children: order.size }), _jsx("div", { className: "text-right font-mono text-n1-ww-gray-700 dark:text-n1-ww-gray-300", children: order.price })] })] }, order.orderId)); }) })), loading && (activeOrders.length > 0 || orderHistory.length > 0) && (_jsx("div", { className: "flex justify-center mt-2", children: _jsx(RefreshCw, { size: 16, className: "text-n1-ww-gray-400 n1-ww-animate-spin" }) }))] })] }) }));
182
182
  }
183
183
  //# sourceMappingURL=UserOrders.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"UserOrders.js","sourceRoot":"","sources":["../../../../../src/Modal/Sidebar/NordTradingView/UserOrders/UserOrders.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,SAAS,EAAE,CAAC,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAalD,MAAM,CAAC,OAAO,UAAU,UAAU;IAAlC,iBAqRC;IApRO,IAAA,KAAqB,kBAAkB,EAAE,EAAvC,IAAI,UAAA,EAAE,QAAQ,cAAyB,CAAC;IAC1C,IAAA,KAAkC,QAAQ,CAAU,EAAE,CAAC,EAAtD,YAAY,QAAA,EAAE,eAAe,QAAyB,CAAC;IACxD,IAAA,KAAkC,QAAQ,CAAU,EAAE,CAAC,EAAtD,YAAY,QAAA,EAAE,eAAe,QAAyB,CAAC;IACxD,IAAA,KAAwB,QAAQ,CAAC,KAAK,CAAC,EAAtC,OAAO,QAAA,EAAE,UAA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M,OAAA,iBAAiB,CAAC,KAAK,CAAC,OAAO,CAAC,EAAhC,CAAgC,EAC/C,QAAQ,EAAE,iBAAiB,KAAK,KAAK,CAAC,OAAO,EAC7C,SAAS,EAAE,qGACT,iBAAiB,KAAK,KAAK,CAAC,OAAO;oDACjC,CAAC,CAAC,oBAAoB;oDACtB,CAAC,CAAC,EAAE,CACN,YAED,iBAAiB,KAAK,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CACrC,8BACE,eAAM,SAAS,EAAC,WAAW,uBAAc,EACzC,KAAC,CAAC,IACA,IAAI,EAAE,EAAE,EACR,SAAS,EAAC,uDAAuD,GACjE,IACD,CACJ,CAAC,CAAC,CAAC,CACF,QAAQ,CACT,GACM,IACL,EACN,eAAK,SAAS,EAAC,gCAAgC,aAC7C,wBACE,eACE,SAAS,EAAE,sBAAe,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,oCAAoC,CAAC,CAAC,CAAC,gCAAgC,CAAE,YAEjH,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,GACzB,GACH,EACN,cAAK,SAAS,EAAC,6DAA6D,YACzE,KAAK,CAAC,IAAI,GACP,EACN,cAAK,SAAS,EAAC,6DAA6D,YACzE,KAAK,CAAC,KAAK,GACR,IACF,KA3CD,KAAK,CAAC,OAAO,CA4Cd,CACP,EA/C4B,CA+C5B,CAAC,GACE,CACP,EAGA,OAAO,IAAI,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC,CAAC,IAAI,CAClE,cAAK,SAAS,EAAC,0BAA0B,YACvC,KAAC,SAAS,IAAC,IAAI,EAAE,EAAE,EAAE,SAAS,EAAC,kCAAkC,GAAG,GAChE,CACP,IACG,IACF,GACF,CACP,CAAC;AACJ,CAAC","sourcesContent":["import { RefreshCw, X } from 'lucide-react';\nimport { useEffect, useState, useRef } from 'react';\nimport { useN1WalletContext } from '../../../../Provider/hooks';\nimport { logger } from '../../../../utils/logger';\n\ninterface Order {\n orderId: number;\n marketId: number;\n symbol: string;\n isLong: boolean;\n size: number;\n price: number;\n status: 'OPEN' | 'FILLED' | 'CANCELLED' | 'EXPIRED';\n createdAt: number;\n}\n\nexport default function UserOrders() {\n const { nord, nordUser } = useN1WalletContext();\n const [activeOrders, setActiveOrders] = useState<Order[]>([]);\n const [orderHistory, setOrderHistory] = useState<Order[]>([]);\n const [loading, setLoading] = useState(false);\n const [error, setError] = useState<string | null>(null);\n const [cancellingOrderId, setCancellingOrderId] = useState<number | null>(\n null\n );\n const [compactView, setCompactView] = useState(false);\n const containerRef = useRef<HTMLDivElement>(null);\n\n // Fetch user orders\n useEffect(() => {\n if (!nordUser) return;\n\n const fetchOrders = async () => {\n setLoading(true);\n setError(null);\n\n try {\n // Refresh user info to get latest orders\n await nordUser.fetchInfo();\n\n // Process orders from all accounts\n const allOrders: Order[] = [];\n\n // This is a simplified approach - in a real implementation, you would\n // properly extract and format orders from the nordUser object\n logger.debug(nord?.markets, nordUser.orders);\n Object.values(nordUser.orders || {}).forEach((accountOrders: any) => {\n if (Array.isArray(accountOrders)) {\n accountOrders.forEach((order: any) => {\n // Get market name from nord object\n const market = nord?.markets?.find(\n (m: any) => m.marketId === order.marketId\n );\n const marketName = market?.symbol || `Unknown Market`;\n\n // Convert to our Order interface format\n const formattedOrder: Order = {\n orderId: order.orderId,\n marketId: order.marketId,\n symbol: marketName,\n isLong: order.isLong,\n size: order.size,\n price: order.price,\n status: order.status || 'OPEN',\n createdAt: order.createdAt || Date.now(),\n };\n allOrders.push(formattedOrder);\n });\n }\n });\n\n // Split into active and historical orders\n setActiveOrders(allOrders.filter((order) => order.status === 'OPEN'));\n setOrderHistory(allOrders.filter((order) => order.status !== 'OPEN'));\n } catch (err) {\n logger.error('Error fetching orders:', err);\n setError('Failed to load orders');\n } finally {\n setLoading(false);\n }\n };\n\n fetchOrders();\n\n // Set up polling for order updates\n const intervalId = setInterval(fetchOrders, 10000); // Update every 10 seconds\n\n return () => clearInterval(intervalId);\n }, [nordUser, nord]);\n\n // Check container width and update layout\n useEffect(() => {\n if (!containerRef.current) return;\n\n const checkWidth = () => {\n if (containerRef.current) {\n setCompactView(containerRef.current.offsetWidth < 400);\n }\n };\n\n // Initial check\n checkWidth();\n\n // Set up resize observer\n const resizeObserver = new ResizeObserver(checkWidth);\n resizeObserver.observe(containerRef.current);\n\n return () => {\n if (containerRef.current) {\n resizeObserver.unobserve(containerRef.current);\n }\n };\n }, []);\n\n // Handle order cancellation\n const handleCancelOrder = async (orderId: number) => {\n if (!nordUser) return;\n\n try {\n setCancellingOrderId(orderId); // Set the cancelling order ID to show animation\n await nordUser.cancelOrder(orderId);\n // Refresh orders after cancellation\n await nordUser.fetchInfo();\n // Update state (simplified - would be better to wait for the fetchOrders to run)\n setActiveOrders(\n activeOrders.filter((order) => order.orderId !== orderId)\n );\n } catch (err) {\n logger.error('Error cancelling order:', err);\n setError('Failed to cancel order');\n } finally {\n setCancellingOrderId(null); // Reset cancelling order ID\n }\n };\n\n return (\n <div className=\"bg-white dark:bg-n1-gray-950 shadow-sm border border-n1-gray-200 dark:border-n1-gray-800 overflow-hidden\">\n <div className=\"p-4\">\n <h2 className=\"text-lg font-semibold text-n1-gray-900 dark:text-n1-gray-100 mb-4\">\n Orders\n </h2>\n\n {/* Order list */}\n <div className=\"overflow-hidden\" ref={containerRef}>\n {loading && activeOrders.length === 0 && orderHistory.length === 0 ? (\n <div className=\"flex items-center justify-center h-32\">\n <RefreshCw size={20} className=\"text-n1-gray-400 n1-animate-spin\" />\n </div>\n ) : error ? (\n <div className=\"p-3 bg-red-50 dark:bg-red-900/20 text-red-600 dark:text-red-400 text-sm\">\n {error}\n </div>\n ) : activeOrders.length === 0 ? (\n <div className=\"p-3 bg-n1-gray-50 dark:bg-n1-gray-800 text-n1-gray-500 dark:text-n1-gray-400 text-sm text-center\">\n No active orders\n </div>\n ) : !compactView ? (\n // Standard table view for larger containers\n <div className=\"overflow-x-auto\">\n <table className=\"min-w-full divide-y divide-n1-gray-200 dark:divide-n1-gray-800\">\n <thead className=\"bg-n1-gray-50 dark:bg-n1-gray-800\">\n <tr>\n <th className=\"px-3 py-2 text-left text-xs font-medium text-n1-gray-500 dark:text-n1-gray-400 uppercase tracking-wider\">\n Market\n </th>\n <th className=\"px-3 py-2 text-left text-xs font-medium text-n1-gray-500 dark:text-n1-gray-400 uppercase tracking-wider\">\n Side\n </th>\n <th className=\"px-3 py-2 text-right text-xs font-medium text-n1-gray-500 dark:text-n1-gray-400 uppercase tracking-wider\">\n Size\n </th>\n <th className=\"px-3 py-2 text-right text-xs font-medium text-n1-gray-500 dark:text-n1-gray-400 uppercase tracking-wider\">\n Price\n </th>\n <th className=\"px-3 py-2 text-right text-xs font-medium text-n1-gray-500 dark:text-n1-gray-400 uppercase tracking-wider\">\n Action\n </th>\n </tr>\n </thead>\n <tbody className=\"bg-white dark:bg-n1-gray-950 divide-y divide-n1-gray-200 dark:divide-n1-gray-800\">\n {activeOrders.map((order) => (\n <tr\n key={order.orderId}\n className=\"hover:bg-n1-gray-50 dark:hover:bg-n1-gray-800\"\n >\n <td className=\"px-3 py-2 whitespace-nowrap text-sm text-n1-gray-900 dark:text-n1-gray-100\">\n {order.symbol}\n </td>\n <td className=\"px-3 py-2 whitespace-nowrap text-sm\">\n <span\n className={`font-medium ${order.isLong ? 'text-green-600 dark:text-green-400' : 'text-red-600 dark:text-red-400'}`}\n >\n {order.isLong ? 'BUY' : 'SELL'}\n </span>\n </td>\n <td className=\"px-3 py-2 whitespace-nowrap text-sm text-n1-gray-900 dark:text-n1-gray-100 text-right font-mono\">\n {order.size}\n </td>\n <td className=\"px-3 py-2 whitespace-nowrap text-sm text-n1-gray-900 dark:text-n1-gray-100 text-right font-mono\">\n {order.price}\n </td>\n <td className=\"px-3 py-2 whitespace-nowrap text-sm text-right\">\n <button\n onClick={() => handleCancelOrder(order.orderId)}\n disabled={cancellingOrderId === order.orderId}\n className={`text-red-600 dark:text-red-400 hover:text-red-800 dark:hover:text-red-300 relative ${\n cancellingOrderId === order.orderId\n ? 'cursor-not-allowed'\n : ''\n }`}\n >\n {cancellingOrderId === order.orderId ? (\n <>\n <span className=\"opacity-0\">Cancel</span>\n <X\n size={16}\n className=\"absolute inset-0 m-auto n1-animate-pulse text-red-500\"\n />\n </>\n ) : (\n 'Cancel'\n )}\n </button>\n </td>\n </tr>\n ))}\n </tbody>\n </table>\n </div>\n ) : (\n // Compact card view for smaller containers\n <div className=\"grid gap-2\">\n {activeOrders.map((order) => (\n <div\n key={order.orderId}\n className=\"bg-white dark:bg-n1-gray-900 border border-n1-gray-200 dark:border-n1-gray-800 rounded p-2 hover:bg-n1-gray-50 dark:hover:bg-n1-gray-800\"\n >\n <div className=\"flex justify-between items-start mb-1\">\n <div className=\"font-medium text-sm text-n1-gray-900 dark:text-n1-gray-100\">\n {order.symbol}\n </div>\n <button\n onClick={() => handleCancelOrder(order.orderId)}\n disabled={cancellingOrderId === order.orderId}\n className={`text-red-600 dark:text-red-400 hover:text-red-800 dark:hover:text-red-300 text-xs relative ${\n cancellingOrderId === order.orderId\n ? 'cursor-not-allowed'\n : ''\n }`}\n >\n {cancellingOrderId === order.orderId ? (\n <>\n <span className=\"opacity-0\">Cancel</span>\n <X\n size={14}\n className=\"absolute inset-0 m-auto n1-animate-pulse text-red-500\"\n />\n </>\n ) : (\n 'Cancel'\n )}\n </button>\n </div>\n <div className=\"grid grid-cols-3 gap-1 text-xs\">\n <div>\n <span\n className={`font-medium ${order.isLong ? 'text-green-600 dark:text-green-400' : 'text-red-600 dark:text-red-400'}`}\n >\n {order.isLong ? 'BUY' : 'SELL'}\n </span>\n </div>\n <div className=\"text-right font-mono text-n1-gray-700 dark:text-n1-gray-300\">\n {order.size}\n </div>\n <div className=\"text-right font-mono text-n1-gray-700 dark:text-n1-gray-300\">\n {order.price}\n </div>\n </div>\n </div>\n ))}\n </div>\n )}\n\n {/* Loading indicator for refreshing */}\n {loading && (activeOrders.length > 0 || orderHistory.length > 0) && (\n <div className=\"flex justify-center mt-2\">\n <RefreshCw size={16} className=\"text-n1-gray-400 n1-animate-spin\" />\n </div>\n )}\n </div>\n </div>\n </div>\n );\n}\n"]}
1
+ {"version":3,"file":"UserOrders.js","sourceRoot":"","sources":["../../../../../src/Modal/Sidebar/NordTradingView/UserOrders/UserOrders.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,SAAS,EAAE,CAAC,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAalD,MAAM,CAAC,OAAO,UAAU,UAAU;IAAlC,iBAqRC;IApRO,IAAA,KAAqB,kBAAkB,EAAE,EAAvC,IAAI,UAAA,EAAE,QAAQ,cAAyB,CAAC;IAC1C,IAAA,KAAkC,QAAQ,CAAU,EAAE,CAAC,EAAtD,YAAY,QAAA,EAAE,eAAe,QAAyB,CAAC;IACxD,IAAA,KAAkC,QAAQ,CAAU,EAAE,CAAC,EAAtD,YAAY,QAAA,EAAE,eAAe,QAAyB,CAAC;IACxD,IAAA,KAAwB,QAAQ,CAAC,KAAK,CAAC,EAAtC,OAAO,QAAA,EAAE,UAAU,QAAmB,CAAC;IACxC,IAAA,KAAoB,QAAQ,CAAgB,IAAI,CAAC,EAAhD,KAAK,QAAA,EAAE,QAAQ,QAAiC,CAAC;IAClD,IAAA,KAA4C,QAAQ,CACxD,IAAI,CACL,EAFM,iBAAiB,QAAA,EAAE,oBAAoB,QAE7C,CAAC;IACI,IAAA,KAAgC,QAAQ,CAAC,KAAK,CAAC,EAA9C,WAAW,QAAA,EAAE,cAAc,QAAmB,CAAC;IACtD,IAAM,YAAY,GAAG,MAAM,CAAiB,IAAI,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C,KAAC,CAAC,IACA,IAAI,EAAE,EAAE,EACR,SAAS,EAAC,0DAA0D,GACpE,IACD,CACJ,CAAC,CAAC,CAAC,CACF,QAAQ,CACT,GACM,IACL,EACN,eAAK,SAAS,EAAC,gCAAgC,aAC7C,wBACE,eACE,SAAS,EAAE,sBAAe,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,oCAAoC,CAAC,CAAC,CAAC,gCAAgC,CAAE,YAEjH,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,GACzB,GACH,EACN,cAAK,SAAS,EAAC,mEAAmE,YAC/E,KAAK,CAAC,IAAI,GACP,EACN,cAAK,SAAS,EAAC,mEAAmE,YAC/E,KAAK,CAAC,KAAK,GACR,IACF,KA3CD,KAAK,CAAC,OAAO,CA4Cd,CACP,EA/C4B,CA+C5B,CAAC,GACE,CACP,EAGA,OAAO,IAAI,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC,CAAC,IAAI,CAClE,cAAK,SAAS,EAAC,0BAA0B,YACvC,KAAC,SAAS,IAAC,IAAI,EAAE,EAAE,EAAE,SAAS,EAAC,wCAAwC,GAAG,GACtE,CACP,IACG,IACF,GACF,CACP,CAAC;AACJ,CAAC","sourcesContent":["import { RefreshCw, X } from 'lucide-react';\nimport { useEffect, useState, useRef } from 'react';\nimport { useN1WalletContext } from '../../../../Provider/hooks';\nimport { logger } from '../../../../utils/logger';\n\ninterface Order {\n orderId: number;\n marketId: number;\n symbol: string;\n isLong: boolean;\n size: number;\n price: number;\n status: 'OPEN' | 'FILLED' | 'CANCELLED' | 'EXPIRED';\n createdAt: number;\n}\n\nexport default function UserOrders() {\n const { nord, nordUser } = useN1WalletContext();\n const [activeOrders, setActiveOrders] = useState<Order[]>([]);\n const [orderHistory, setOrderHistory] = useState<Order[]>([]);\n const [loading, setLoading] = useState(false);\n const [error, setError] = useState<string | null>(null);\n const [cancellingOrderId, setCancellingOrderId] = useState<number | null>(\n null\n );\n const [compactView, setCompactView] = useState(false);\n const containerRef = useRef<HTMLDivElement>(null);\n\n // Fetch user orders\n useEffect(() => {\n if (!nordUser) return;\n\n const fetchOrders = async () => {\n setLoading(true);\n setError(null);\n\n try {\n // Refresh user info to get latest orders\n await nordUser.fetchInfo();\n\n // Process orders from all accounts\n const allOrders: Order[] = [];\n\n // This is a simplified approach - in a real implementation, you would\n // properly extract and format orders from the nordUser object\n logger.debug(nord?.markets, nordUser.orders);\n Object.values(nordUser.orders || {}).forEach((accountOrders: any) => {\n if (Array.isArray(accountOrders)) {\n accountOrders.forEach((order: any) => {\n // Get market name from nord object\n const market = nord?.markets?.find(\n (m: any) => m.marketId === order.marketId\n );\n const marketName = market?.symbol || `Unknown Market`;\n\n // Convert to our Order interface format\n const formattedOrder: Order = {\n orderId: order.orderId,\n marketId: order.marketId,\n symbol: marketName,\n isLong: order.isLong,\n size: order.size,\n price: order.price,\n status: order.status || 'OPEN',\n createdAt: order.createdAt || Date.now(),\n };\n allOrders.push(formattedOrder);\n });\n }\n });\n\n // Split into active and historical orders\n setActiveOrders(allOrders.filter((order) => order.status === 'OPEN'));\n setOrderHistory(allOrders.filter((order) => order.status !== 'OPEN'));\n } catch (err) {\n logger.error('Error fetching orders:', err);\n setError('Failed to load orders');\n } finally {\n setLoading(false);\n }\n };\n\n fetchOrders();\n\n // Set up polling for order updates\n const intervalId = setInterval(fetchOrders, 10000); // Update every 10 seconds\n\n return () => clearInterval(intervalId);\n }, [nordUser, nord]);\n\n // Check container width and update layout\n useEffect(() => {\n if (!containerRef.current) return;\n\n const checkWidth = () => {\n if (containerRef.current) {\n setCompactView(containerRef.current.offsetWidth < 400);\n }\n };\n\n // Initial check\n checkWidth();\n\n // Set up resize observer\n const resizeObserver = new ResizeObserver(checkWidth);\n resizeObserver.observe(containerRef.current);\n\n return () => {\n if (containerRef.current) {\n resizeObserver.unobserve(containerRef.current);\n }\n };\n }, []);\n\n // Handle order cancellation\n const handleCancelOrder = async (orderId: number) => {\n if (!nordUser) return;\n\n try {\n setCancellingOrderId(orderId); // Set the cancelling order ID to show animation\n await nordUser.cancelOrder(orderId);\n // Refresh orders after cancellation\n await nordUser.fetchInfo();\n // Update state (simplified - would be better to wait for the fetchOrders to run)\n setActiveOrders(\n activeOrders.filter((order) => order.orderId !== orderId)\n );\n } catch (err) {\n logger.error('Error cancelling order:', err);\n setError('Failed to cancel order');\n } finally {\n setCancellingOrderId(null); // Reset cancelling order ID\n }\n };\n\n return (\n <div className=\"bg-white dark:bg-n1-ww-gray-950 shadow-sm border border-n1-ww-gray-200 dark:border-n1-ww-gray-800 overflow-hidden\">\n <div className=\"p-4\">\n <h2 className=\"text-lg font-semibold text-n1-ww-gray-900 dark:text-n1-ww-gray-100 mb-4\">\n Orders\n </h2>\n\n {/* Order list */}\n <div className=\"overflow-hidden\" ref={containerRef}>\n {loading && activeOrders.length === 0 && orderHistory.length === 0 ? (\n <div className=\"flex items-center justify-center h-32\">\n <RefreshCw size={20} className=\"text-n1-ww-gray-400 n1-ww-animate-spin\" />\n </div>\n ) : error ? (\n <div className=\"p-3 bg-red-50 dark:bg-red-900/20 text-red-600 dark:text-red-400 text-sm\">\n {error}\n </div>\n ) : activeOrders.length === 0 ? (\n <div className=\"p-3 bg-n1-ww-gray-50 dark:bg-n1-ww-gray-800 text-n1-ww-gray-500 dark:text-n1-ww-gray-400 text-sm text-center\">\n No active orders\n </div>\n ) : !compactView ? (\n // Standard table view for larger containers\n <div className=\"overflow-x-auto\">\n <table className=\"min-w-full divide-y divide-n1-ww-gray-200 dark:divide-n1-ww-gray-800\">\n <thead className=\"bg-n1-ww-gray-50 dark:bg-n1-ww-gray-800\">\n <tr>\n <th className=\"px-3 py-2 text-left text-xs font-medium text-n1-ww-gray-500 dark:text-n1-ww-gray-400 uppercase tracking-wider\">\n Market\n </th>\n <th className=\"px-3 py-2 text-left text-xs font-medium text-n1-ww-gray-500 dark:text-n1-ww-gray-400 uppercase tracking-wider\">\n Side\n </th>\n <th className=\"px-3 py-2 text-right text-xs font-medium text-n1-ww-gray-500 dark:text-n1-ww-gray-400 uppercase tracking-wider\">\n Size\n </th>\n <th className=\"px-3 py-2 text-right text-xs font-medium text-n1-ww-gray-500 dark:text-n1-ww-gray-400 uppercase tracking-wider\">\n Price\n </th>\n <th className=\"px-3 py-2 text-right text-xs font-medium text-n1-ww-gray-500 dark:text-n1-ww-gray-400 uppercase tracking-wider\">\n Action\n </th>\n </tr>\n </thead>\n <tbody className=\"bg-white dark:bg-n1-ww-gray-950 divide-y divide-n1-ww-gray-200 dark:divide-n1-ww-gray-800\">\n {activeOrders.map((order) => (\n <tr\n key={order.orderId}\n className=\"hover:bg-n1-ww-gray-50 dark:hover:bg-n1-ww-gray-800\"\n >\n <td className=\"px-3 py-2 whitespace-nowrap text-sm text-n1-ww-gray-900 dark:text-n1-ww-gray-100\">\n {order.symbol}\n </td>\n <td className=\"px-3 py-2 whitespace-nowrap text-sm\">\n <span\n className={`font-medium ${order.isLong ? 'text-green-600 dark:text-green-400' : 'text-red-600 dark:text-red-400'}`}\n >\n {order.isLong ? 'BUY' : 'SELL'}\n </span>\n </td>\n <td className=\"px-3 py-2 whitespace-nowrap text-sm text-n1-ww-gray-900 dark:text-n1-ww-gray-100 text-right font-mono\">\n {order.size}\n </td>\n <td className=\"px-3 py-2 whitespace-nowrap text-sm text-n1-ww-gray-900 dark:text-n1-ww-gray-100 text-right font-mono\">\n {order.price}\n </td>\n <td className=\"px-3 py-2 whitespace-nowrap text-sm text-right\">\n <button\n onClick={() => handleCancelOrder(order.orderId)}\n disabled={cancellingOrderId === order.orderId}\n className={`text-red-600 dark:text-red-400 hover:text-red-800 dark:hover:text-red-300 relative ${\n cancellingOrderId === order.orderId\n ? 'cursor-not-allowed'\n : ''\n }`}\n >\n {cancellingOrderId === order.orderId ? (\n <>\n <span className=\"opacity-0\">Cancel</span>\n <X\n size={16}\n className=\"absolute inset-0 m-auto n1-ww-animate-pulse text-red-500\"\n />\n </>\n ) : (\n 'Cancel'\n )}\n </button>\n </td>\n </tr>\n ))}\n </tbody>\n </table>\n </div>\n ) : (\n // Compact card view for smaller containers\n <div className=\"grid gap-2\">\n {activeOrders.map((order) => (\n <div\n key={order.orderId}\n className=\"bg-white dark:bg-n1-ww-gray-900 border border-n1-ww-gray-200 dark:border-n1-ww-gray-800 rounded p-2 hover:bg-n1-ww-gray-50 dark:hover:bg-n1-ww-gray-800\"\n >\n <div className=\"flex justify-between items-start mb-1\">\n <div className=\"font-medium text-sm text-n1-ww-gray-900 dark:text-n1-ww-gray-100\">\n {order.symbol}\n </div>\n <button\n onClick={() => handleCancelOrder(order.orderId)}\n disabled={cancellingOrderId === order.orderId}\n className={`text-red-600 dark:text-red-400 hover:text-red-800 dark:hover:text-red-300 text-xs relative ${\n cancellingOrderId === order.orderId\n ? 'cursor-not-allowed'\n : ''\n }`}\n >\n {cancellingOrderId === order.orderId ? (\n <>\n <span className=\"opacity-0\">Cancel</span>\n <X\n size={14}\n className=\"absolute inset-0 m-auto n1-ww-animate-pulse text-red-500\"\n />\n </>\n ) : (\n 'Cancel'\n )}\n </button>\n </div>\n <div className=\"grid grid-cols-3 gap-1 text-xs\">\n <div>\n <span\n className={`font-medium ${order.isLong ? 'text-green-600 dark:text-green-400' : 'text-red-600 dark:text-red-400'}`}\n >\n {order.isLong ? 'BUY' : 'SELL'}\n </span>\n </div>\n <div className=\"text-right font-mono text-n1-ww-gray-700 dark:text-n1-ww-gray-300\">\n {order.size}\n </div>\n <div className=\"text-right font-mono text-n1-ww-gray-700 dark:text-n1-ww-gray-300\">\n {order.price}\n </div>\n </div>\n </div>\n ))}\n </div>\n )}\n\n {/* Loading indicator for refreshing */}\n {loading && (activeOrders.length > 0 || orderHistory.length > 0) && (\n <div className=\"flex justify-center mt-2\">\n <RefreshCw size={16} className=\"text-n1-ww-gray-400 n1-ww-animate-spin\" />\n </div>\n )}\n </div>\n </div>\n </div>\n );\n}\n"]}
@@ -185,12 +185,12 @@ export default function UserPositions() {
185
185
  }
186
186
  });
187
187
  }); };
188
- return (_jsx("div", { className: "bg-white dark:bg-n1-gray-950 overflow-hidden", children: _jsxs("div", { className: "p-4", children: [_jsx("h2", { className: "text-lg font-semibold text-n1-gray-900 dark:text-n1-gray-100 mb-4", children: "Positions" }), loading && positions.length === 0 ? (_jsx("div", { className: "flex items-center justify-center h-32", children: _jsx(RefreshCw, { size: 20, className: "text-n1-gray-400 n1-animate-spin" }) })) : error ? (_jsx("div", { className: "p-3 bg-red-50 dark:bg-red-900/20 rounded-lg text-red-600 dark:text-red-400 text-sm", children: error })) : positions.length === 0 ? (_jsx("div", { className: "p-3 bg-n1-gray-50 dark:bg-n1-gray-950 rounded-lg text-n1-gray-500 dark:text-n1-gray-400 text-sm text-center", children: "No open positions" })) : (_jsxs("div", { className: "space-y-3", children: [positions.map(function (position, index) { return (_jsxs("div", { className: "p-3 bg-n1-gray-50 dark:bg-n1-gray-950 rounded-lg", children: [_jsx("div", { className: "flex items-center justify-between mb-2", children: _jsxs("div", { className: "flex items-center", children: [_jsx("span", { className: "font-medium text-n1-gray-900 dark:text-n1-gray-100 mr-2", children: position.symbol }), _jsxs("span", { className: "text-xs px-2 py-0.5 rounded ".concat(position.size > 0
188
+ return (_jsx("div", { className: "bg-white dark:bg-n1-ww-gray-950 overflow-hidden", children: _jsxs("div", { className: "p-4", children: [_jsx("h2", { className: "text-lg font-semibold text-n1-ww-gray-900 dark:text-n1-ww-gray-100 mb-4", children: "Positions" }), loading && positions.length === 0 ? (_jsx("div", { className: "flex items-center justify-center h-32", children: _jsx(RefreshCw, { size: 20, className: "text-n1-ww-gray-400 n1-ww-animate-spin" }) })) : error ? (_jsx("div", { className: "p-3 bg-red-50 dark:bg-red-900/20 rounded-lg text-red-600 dark:text-red-400 text-sm", children: error })) : positions.length === 0 ? (_jsx("div", { className: "p-3 bg-n1-ww-gray-50 dark:bg-n1-ww-gray-950 rounded-lg text-n1-ww-gray-500 dark:text-n1-ww-gray-400 text-sm text-center", children: "No open positions" })) : (_jsxs("div", { className: "space-y-3", children: [positions.map(function (position, index) { return (_jsxs("div", { className: "p-3 bg-n1-ww-gray-50 dark:bg-n1-ww-gray-950 rounded-lg", children: [_jsx("div", { className: "flex items-center justify-between mb-2", children: _jsxs("div", { className: "flex items-center", children: [_jsx("span", { className: "font-medium text-n1-ww-gray-900 dark:text-n1-ww-gray-100 mr-2", children: position.symbol }), _jsxs("span", { className: "text-xs px-2 py-0.5 rounded ".concat(position.size > 0
189
189
  ? 'bg-green-100 dark:bg-green-900/20 text-green-600 dark:text-green-400'
190
- : 'bg-red-100 dark:bg-red-900/20 text-red-600 dark:text-red-400'), children: [position.size > 0 ? 'Long' : 'Short', ' ', Math.abs(position.size)] })] }) }), _jsxs("div", { className: "grid grid-cols-2 gap-2 text-sm", children: [_jsxs("div", { children: [_jsx("div", { className: "text-n1-gray-500 dark:text-n1-gray-400", children: "Entry Price" }), _jsx("div", { className: "font-medium text-n1-gray-900 dark:text-n1-gray-100 font-mono", children: position.entryPrice.toFixed(2) })] }), _jsxs("div", { children: [_jsx("div", { className: "text-n1-gray-500 dark:text-n1-gray-400", children: "Mark Price" }), _jsx("div", { className: "font-medium text-n1-gray-900 dark:text-n1-gray-100 font-mono", children: position.markPrice.toFixed(2) })] }), _jsxs("div", { children: [_jsx("div", { className: "text-n1-gray-500 dark:text-n1-gray-400", children: "PnL" }), _jsxs("div", { className: "font-medium font-mono ".concat(position.pnl >= 0
190
+ : 'bg-red-100 dark:bg-red-900/20 text-red-600 dark:text-red-400'), children: [position.size > 0 ? 'Long' : 'Short', ' ', Math.abs(position.size)] })] }) }), _jsxs("div", { className: "grid grid-cols-2 gap-2 text-sm", children: [_jsxs("div", { children: [_jsx("div", { className: "text-n1-ww-gray-500 dark:text-n1-ww-gray-400", children: "Entry Price" }), _jsx("div", { className: "font-medium text-n1-ww-gray-900 dark:text-n1-ww-gray-100 font-mono", children: position.entryPrice.toFixed(2) })] }), _jsxs("div", { children: [_jsx("div", { className: "text-n1-ww-gray-500 dark:text-n1-ww-gray-400", children: "Mark Price" }), _jsx("div", { className: "font-medium text-n1-ww-gray-900 dark:text-n1-ww-gray-100 font-mono", children: position.markPrice.toFixed(2) })] }), _jsxs("div", { children: [_jsx("div", { className: "text-n1-ww-gray-500 dark:text-n1-ww-gray-400", children: "PnL" }), _jsxs("div", { className: "font-medium font-mono ".concat(position.pnl >= 0
191
191
  ? 'text-green-600 dark:text-green-400'
192
- : 'text-red-600 dark:text-red-400'), children: [position.pnl >= 0 ? '+' : '', position.pnl.toFixed(2), " (", position.pnlPercentage.toFixed(2), "%)"] })] }), _jsxs("div", { children: [_jsx("div", { className: "text-n1-gray-500 dark:text-n1-gray-400", children: "Liquidation" }), _jsx("div", { className: "font-medium text-n1-gray-900 dark:text-n1-gray-100 font-mono", children: position.liquidationPrice
192
+ : 'text-red-600 dark:text-red-400'), children: [position.pnl >= 0 ? '+' : '', position.pnl.toFixed(2), " (", position.pnlPercentage.toFixed(2), "%)"] })] }), _jsxs("div", { children: [_jsx("div", { className: "text-n1-ww-gray-500 dark:text-n1-ww-gray-400", children: "Liquidation" }), _jsx("div", { className: "font-medium text-n1-ww-gray-900 dark:text-n1-ww-gray-100 font-mono", children: position.liquidationPrice
193
193
  ? position.liquidationPrice.toFixed(2)
194
- : 'N/A' })] })] })] }, index)); }), loading && positions.length > 0 && (_jsx("div", { className: "flex justify-center mt-2", children: _jsx(RefreshCw, { size: 16, className: "text-n1-gray-400 n1-animate-spin" }) }))] }))] }) }));
194
+ : 'N/A' })] })] })] }, index)); }), loading && positions.length > 0 && (_jsx("div", { className: "flex justify-center mt-2", children: _jsx(RefreshCw, { size: 16, className: "text-n1-ww-gray-400 n1-ww-animate-spin" }) }))] }))] }) }));
195
195
  }
196
196
  //# sourceMappingURL=UserPositions.js.map