Skip to content

Commit

Permalink
chore: card code optimised
Browse files Browse the repository at this point in the history
  • Loading branch information
yp969803 committed Jan 22, 2024
1 parent fd0109d commit bd5531f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
16 changes: 9 additions & 7 deletions src/features/workspace-view/workspace-card/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,19 +118,21 @@ const WorkspaceCard = (props: workspaceCardProps) => {
const HandleArchive = async () => {
if (!workspaceName.endsWith('-userspace') && token) {
const initArc = archeive;

const func = async () => {
let status: { [key: string]: boolean } = {
[workspaceName]: !bookmark,
const status: { [key: string]: boolean } = {
[workspaceName]: (!archeive),
};

const res = await setOrgArcheiveStatus(token, status);
console.log(status)
const res = await setOrgArcheiveStatus(token, status);
console.log(res)
const orgs = userContext?.userOrgs;
if (orgs?.userOrgs.hasOwnProperty(workspaceName)) {
orgs.userOrgs[workspaceName].archive = (!bookmark).toString();
orgs.userOrgs[workspaceName].archive = (!archeive).toString();
userContext?.setUserOrgs(orgs);
}
};
if (initArc) {
if (!initArc) {
toast.promise(func(), {
loading: 'Archiving',
success: <b>Successfully archived</b>,
Expand All @@ -147,7 +149,7 @@ const WorkspaceCard = (props: workspaceCardProps) => {
};
useEffect(() => {
workSpaceData();
}, [workspaceName, userContext?.setUserOrgs, HandleArchive, HandleDelete, HandlePin]);
}, [ userContext?.setUserOrgs ]);


return (
Expand Down
2 changes: 1 addition & 1 deletion src/features/workspace/components/projectCard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ const ProjectCard: React.FC<Props> = ({
useEffect(()=>{
fetchProjectData()
fetchProjectMembers()
},[ PinHandler, ArchiveHandler, DeleteHandler,userContext?.setUserOrgs, userContext?.setUserOrgs])
},[ userContext?.setUsername, userContext?.setUserOrgs])


return (
Expand Down

0 comments on commit bd5531f

Please sign in to comment.