Skip to content

Commit ddbfd16

Browse files
committed
feat: faster remove of socials from scheduling
1 parent b692813 commit ddbfd16

File tree

2 files changed

+53
-13
lines changed

2 files changed

+53
-13
lines changed

apps/frontend/src/components/new-launch/select.current.tsx

Lines changed: 53 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
11
'use client';
22

3-
import { FC, RefObject, useEffect, useRef, useState } from 'react';
4-
import { useLaunchStore } from '@gitroom/frontend/components/new-launch/store';
3+
import { FC, RefObject, useCallback, useEffect, useRef, useState } from 'react';
4+
import {
5+
SelectedIntegrations,
6+
useLaunchStore,
7+
} from '@gitroom/frontend/components/new-launch/store';
58
import clsx from 'clsx';
69
import Image from 'next/image';
710
import { useShallow } from 'zustand/react/shallow';
811
import { GlobalIcon } from '@gitroom/frontend/components/ui/icons';
912
import { useT } from '@gitroom/react/translation/get.transation.service.client';
13+
import { Integrations } from '@gitroom/frontend/components/launches/calendar.context';
14+
import {
15+
useDecisionModal,
16+
useModals,
17+
} from '@gitroom/frontend/components/layout/new-modal';
1018

1119
export function useHasScroll(ref: RefObject<HTMLElement>): boolean {
1220
const [hasHorizontalScroll, setHasHorizontalScroll] = useState(false);
@@ -43,20 +51,47 @@ export function useHasScroll(ref: RefObject<HTMLElement>): boolean {
4351
}
4452

4553
export const SelectCurrent: FC = () => {
46-
const { selectedIntegrations, current, setCurrent, locked, setHide } =
47-
useLaunchStore(
48-
useShallow((state) => ({
49-
selectedIntegrations: state.selectedIntegrations,
50-
current: state.current,
51-
setCurrent: state.setCurrent,
52-
locked: state.locked,
53-
setHide: state.setHide,
54-
}))
55-
);
54+
const modals = useDecisionModal();
55+
const {
56+
selectedIntegrations,
57+
current,
58+
setCurrent,
59+
locked,
60+
setHide,
61+
addOrRemoveSelectedIntegration,
62+
} = useLaunchStore(
63+
useShallow((state) => ({
64+
selectedIntegrations: state.selectedIntegrations,
65+
addOrRemoveSelectedIntegration: state.addOrRemoveSelectedIntegration,
66+
current: state.current,
67+
setCurrent: state.setCurrent,
68+
locked: state.locked,
69+
setHide: state.setHide,
70+
}))
71+
);
5672

5773
const contentRef = useRef<HTMLDivElement>(null);
5874
const hasScroll = useHasScroll(contentRef);
5975

76+
const removeSocial = useCallback(
77+
(sIntegration: Integrations) => async (e: any) => {
78+
e.stopPropagation();
79+
e.preventDefault();
80+
const open = await modals.open({
81+
title: 'Remove Social Account',
82+
description:
83+
'Are you sure you want to remove this social from scheduling?',
84+
});
85+
86+
if (!open) {
87+
return;
88+
}
89+
90+
addOrRemoveSelectedIntegration(sIntegration, {});
91+
},
92+
[]
93+
);
94+
6095
return (
6196
<>
6297
<div className="select-none left-0 absolute w-full z-[100] px-[20px]">
@@ -97,6 +132,12 @@ export const SelectCurrent: FC = () => {
97132
: 'border-transparent'
98133
)}
99134
>
135+
<div
136+
onClick={removeSocial(integration)}
137+
className="absolute justify-center items-center flex w-[8px] h-[8px] -top-[1px] -start-[3px] bg-red-500 rounded-full text-white text-[8px]"
138+
>
139+
X
140+
</div>
100141
<IsGlobal id={integration.id} />
101142
<div
102143
{...{

libraries/nestjs-libraries/src/integrations/social/tiktok.provider.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,6 @@ export class TiktokProvider extends SocialAbstract implements SocialProvider {
312312
})
313313
).json();
314314

315-
console.log(this.scopes, scope);
316315
this.checkScopes(this.scopes, scope);
317316

318317
const {

0 commit comments

Comments
 (0)