feat(market-card.tsx): add loading state to MarketCardComponent to show loading spinner when adding flow
fix(market-card.tsx): fix typo in cloneFlowWithParent function call fix(market-card.tsx): set loading state to false after flow is successfully saved fix(market-card.tsx): set loading state to true when Add to Account button is clicked fix(market-card.tsx): add animate-spin class to IconComponent when loading state is true fix(market-card.tsx): change button text to "Install Locally" when flow is already added feat(styleUtils.ts): add Loader2 icon from lucide-react library
This commit is contained in:
parent
ed8acfb8af
commit
7c177a9930
3 changed files with 315 additions and 302 deletions
594
src/frontend/package-lock.json
generated
594
src/frontend/package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
|
@ -18,6 +18,7 @@ import cloneFLowWithParent from "../../../utils/storeUtils";
|
||||||
|
|
||||||
export const MarketCardComponent = ({ data }: { data: FlowComponent }) => {
|
export const MarketCardComponent = ({ data }: { data: FlowComponent }) => {
|
||||||
const [added, setAdded] = useState(false);
|
const [added, setAdded] = useState(false);
|
||||||
|
const [loading, setLoading] = useState(false);
|
||||||
const { addFlow } = useContext(TabsContext);
|
const { addFlow } = useContext(TabsContext);
|
||||||
const flowData = useRef<FlowType>();
|
const flowData = useRef<FlowType>();
|
||||||
|
|
||||||
|
|
@ -25,15 +26,14 @@ export const MarketCardComponent = ({ data }: { data: FlowComponent }) => {
|
||||||
getComponent(data.id).then(
|
getComponent(data.id).then(
|
||||||
(res) => {
|
(res) => {
|
||||||
console.log(res);
|
console.log(res);
|
||||||
const newFLow = cloneFLowWithParent(
|
const newFLow = cloneFLowWithParent(res, res.id, data.is_component);
|
||||||
res.data,
|
|
||||||
res.id,
|
|
||||||
data.is_component
|
|
||||||
);
|
|
||||||
flowData.current = newFLow;
|
flowData.current = newFLow;
|
||||||
console.log(newFLow);
|
console.log(newFLow);
|
||||||
saveFlowStore(newFLow)
|
saveFlowStore(newFLow)
|
||||||
.then(() => setAdded(true))
|
.then(() => {
|
||||||
|
setAdded(true);
|
||||||
|
setLoading(false);
|
||||||
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
});
|
});
|
||||||
|
|
@ -145,6 +145,7 @@ export const MarketCardComponent = ({ data }: { data: FlowComponent }) => {
|
||||||
size="sm"
|
size="sm"
|
||||||
className="whitespace-nowrap "
|
className="whitespace-nowrap "
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
|
setLoading(true);
|
||||||
if (!added) {
|
if (!added) {
|
||||||
handleAdd();
|
handleAdd();
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -153,8 +154,12 @@ export const MarketCardComponent = ({ data }: { data: FlowComponent }) => {
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<IconComponent
|
<IconComponent
|
||||||
name={added ? "GitBranchPlus" : "BookmarkPlus"}
|
name={
|
||||||
className="main-page-nav-button"
|
loading ? "Loader2" : added ? "GitBranchPlus" : "BookmarkPlus"
|
||||||
|
}
|
||||||
|
className={
|
||||||
|
"main-page-nav-button" + (loading ? " animate-spin" : "")
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
{added ? "Install Localy" : "Add to Account"}
|
{added ? "Install Localy" : "Add to Account"}
|
||||||
</Button>
|
</Button>
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,7 @@ import {
|
||||||
Layers,
|
Layers,
|
||||||
Lightbulb,
|
Lightbulb,
|
||||||
Link,
|
Link,
|
||||||
|
Loader2,
|
||||||
Lock,
|
Lock,
|
||||||
LucideSend,
|
LucideSend,
|
||||||
Maximize2,
|
Maximize2,
|
||||||
|
|
@ -331,5 +332,6 @@ export const nodeIconsLucide: iconsType = {
|
||||||
SaveAll,
|
SaveAll,
|
||||||
Share2,
|
Share2,
|
||||||
GitBranchPlus,
|
GitBranchPlus,
|
||||||
|
Loader2,
|
||||||
BookmarkPlus,
|
BookmarkPlus,
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue