Skip to content

Commit d4a27f9

Browse files
committed
Removed state-manaement package
1 parent 4dbe484 commit d4a27f9

56 files changed

Lines changed: 491 additions & 1318 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.changeset/config.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
"updateInternalDependencies": "patch",
1010
"ignore": [
1111
"@courselit/web",
12-
"@courselit/state-management",
1312
"@courselit/utils",
1413
"@courselit/queue",
1514
"@courselit/icons",
Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
"use client";
22

33
import DashboardContent from "@components/admin/dashboard-content";
4-
import { AddressContext } from "@components/contexts";
54
import {
65
MANAGE_PAGES_PAGE_HEADING,
76
NEW_PAGE_HEADING,
87
} from "@ui-config/strings";
98
import dynamic from "next/dynamic";
10-
import { useContext } from "react";
119
const NewPage = dynamic(() => import("@components/admin/pages/new-page"));
1210

1311
const breadcrumbs = [
@@ -16,11 +14,9 @@ const breadcrumbs = [
1614
];
1715

1816
export default function Page() {
19-
const address = useContext(AddressContext);
20-
2117
return (
2218
<DashboardContent breadcrumbs={breadcrumbs}>
23-
<NewPage address={address} />
19+
<NewPage />
2420
</DashboardContent>
2521
);
2622
}

apps/web/components/admin/blogs/editor/course-hook.ts

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
import { Address, Course } from "@courselit/common-models";
1+
import { AddressContext } from "@components/contexts";
2+
import { Course } from "@courselit/common-models";
23
import { useToast } from "@courselit/components-library";
3-
import { AppDispatch /*AppState*/ } from "@courselit/state-management";
4-
import { networkAction } from "@courselit/state-management/dist/action-creators";
54
import { FetchBuilder } from "@courselit/utils";
65
import { TOAST_TITLE_ERROR } from "@ui-config/strings";
7-
import { useCallback, useEffect, useState } from "react";
6+
import { useCallback, useContext, useEffect, useState } from "react";
87

98
type CourseWithAdminProps = Partial<
109
Course & {
@@ -15,13 +14,11 @@ type CourseWithAdminProps = Partial<
1514

1615
export default function useCourse(
1716
id: string,
18-
address: Address,
19-
dispatch?: AppDispatch,
2017
): CourseWithAdminProps | undefined | null {
21-
// const address = useSelector((state: AppState) => state.address);
2218
const [course, setCourse] = useState<
2319
CourseWithAdminProps | undefined | null
2420
>();
21+
const address = useContext(AddressContext);
2522
const { toast } = useToast();
2623

2724
const loadCourse = useCallback(
@@ -54,7 +51,6 @@ export default function useCourse(
5451
.setIsGraphQLEndpoint(true)
5552
.build();
5653
try {
57-
dispatch && dispatch(networkAction(true));
5854
const response = await fetch.exec();
5955
if (response.course) {
6056
setCourse(response.course);
@@ -69,10 +65,9 @@ export default function useCourse(
6965
variant: "destructive",
7066
});
7167
} finally {
72-
dispatch && dispatch(networkAction(false));
7368
}
7469
},
75-
[address?.backend, dispatch],
70+
[address?.backend],
7671
);
7772

7873
useEffect(() => {

apps/web/components/admin/blogs/editor/layout/header.tsx

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from "react";
1+
import React, { useContext } from "react";
22
import dynamic from "next/dynamic";
33
import useCourse from "../course-hook";
44
import {
@@ -13,13 +13,12 @@ import {
1313
DELETE_PRODUCT_POPUP_TEXT,
1414
MENU_BLOG_VISIT,
1515
PRODUCT_TABLE_CONTEXT_MENU_DELETE_PRODUCT,
16-
} from "../../../../../ui-config/strings";
16+
} from "@/ui-config/strings";
1717
import { MoreVert } from "@courselit/icons";
1818
import { deleteProduct } from "../../helpers";
19-
import { AppDispatch } from "@courselit/state-management";
20-
import { Address } from "@courselit/common-models";
2119
import { useRouter } from "next/navigation";
2220
import { truncate } from "@ui-lib/utils";
21+
import { AddressContext } from "@components/contexts";
2322

2423
const AppLoader = dynamic(() => import("../../../../app-loader"));
2524

@@ -29,21 +28,15 @@ interface Breadcrumb {
2928
}
3029

3130
interface BlogHeaderProps {
32-
breadcrumbs?: Breadcrumb[];
3331
id: string;
34-
address: Address;
35-
dispatch?: AppDispatch;
32+
breadcrumbs?: Breadcrumb[];
3633
}
3734

38-
export default function BlogHeader({
39-
id,
40-
breadcrumbs,
41-
address,
42-
dispatch,
43-
}: BlogHeaderProps) {
44-
const course = useCourse(id, address);
35+
export default function BlogHeader({ id, breadcrumbs }: BlogHeaderProps) {
36+
const course = useCourse(id);
4537
const router = useRouter();
4638
const { toast } = useToast();
39+
const address = useContext(AddressContext);
4740

4841
if (!course) {
4942
return <></>;
@@ -91,7 +84,6 @@ export default function BlogHeader({
9184
deleteProduct({
9285
id: course!.id as string,
9386
backend: address.backend,
94-
dispatch,
9587
onDeleteComplete: () => {
9688
router.replace(`/dashboard/blogs`);
9789
},

apps/web/components/admin/mails/index.tsx

Lines changed: 5 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,16 @@ import {
55
Domain,
66
SequenceType,
77
} from "@courselit/common-models";
8-
import {
9-
AppDispatch,
10-
AppState,
11-
actionCreators,
12-
} from "@courselit/state-management";
138
import {
149
BTN_NEW_MAIL,
1510
PAGE_HEADER_ALL_MAILS,
1611
BROADCASTS,
1712
SEQUENCES,
1813
BTN_NEW_SEQUENCE,
1914
TOAST_TITLE_ERROR,
20-
} from "../../../ui-config/strings";
15+
} from "@/ui-config/strings";
2116
import { FetchBuilder } from "@courselit/utils";
2217
import { useRouter } from "next/navigation";
23-
import { ThunkDispatch } from "redux-thunk";
2418
import {
2519
// Button,
2620
Tabbs,
@@ -32,27 +26,19 @@ import {
3226
CardTitle,
3327
useToast,
3428
} from "@courselit/components-library";
35-
import { AnyAction } from "redux";
3629
import RequestForm from "./request-form";
3730
import SequencesList from "./sequences-list";
38-
const { networkAction } = actionCreators;
3931
import { Button } from "@components/ui/button";
4032

4133
interface MailsProps {
4234
address: Address;
4335
selectedTab: typeof BROADCASTS | typeof SEQUENCES;
44-
dispatch?: AppDispatch;
4536
loading: boolean;
4637
}
4738

4839
type MailsTab = typeof BROADCASTS | typeof SEQUENCES;
4940

50-
export default function Mails({
51-
address,
52-
dispatch,
53-
selectedTab,
54-
loading,
55-
}: MailsProps) {
41+
export default function Mails({ address, selectedTab }: MailsProps) {
5642
const [siteInfo, setSiteInfo] = useState<Domain>();
5743
const router = useRouter();
5844
const { toast } = useToast();
@@ -81,7 +67,6 @@ export default function Mails({
8167
const fetcher = fetch.setPayload({ query }).build();
8268

8369
try {
84-
dispatch && dispatch(networkAction(true));
8570
const response = await fetcher.exec();
8671
if (response.siteInfo) {
8772
setSiteInfo(response.siteInfo);
@@ -92,8 +77,6 @@ export default function Mails({
9277
description: e.message,
9378
variant: "destructive",
9479
});
95-
} finally {
96-
dispatch && dispatch(networkAction(false));
9780
}
9881
};
9982

@@ -121,10 +104,6 @@ export default function Mails({
121104
.setIsGraphQLEndpoint(true)
122105
.build();
123106
try {
124-
dispatch &&
125-
(dispatch as ThunkDispatch<AppState, null, AnyAction>)(
126-
networkAction(true),
127-
);
128107
const response = await fetch.exec();
129108
if (response.sequence && response.sequence.sequenceId) {
130109
router.push(
@@ -140,10 +119,6 @@ export default function Mails({
140119
variant: "destructive",
141120
});
142121
} finally {
143-
dispatch &&
144-
(dispatch as ThunkDispatch<AppState, null, AnyAction>)(
145-
networkAction(false),
146-
);
147122
}
148123
};
149124

@@ -203,7 +178,7 @@ export default function Mails({
203178
</CardDescription>
204179
</CardHeader>
205180
<CardContent>
206-
<RequestForm address={address} />
181+
<RequestForm />
207182
</CardContent>
208183
</Card>
209184
)}
@@ -233,18 +208,8 @@ export default function Mails({
233208
router.replace(`/dashboard/mails?tab=${tab}`);
234209
}}
235210
>
236-
<SequencesList
237-
type={Constants.mailTypes[0] as SequenceType}
238-
address={address}
239-
loading={loading}
240-
dispatch={dispatch}
241-
/>
242-
<SequencesList
243-
type={Constants.mailTypes[1] as SequenceType}
244-
address={address}
245-
loading={loading}
246-
dispatch={dispatch}
247-
/>
211+
<SequencesList type={Constants.mailTypes[0] as SequenceType} />
212+
<SequencesList type={Constants.mailTypes[1] as SequenceType} />
248213
</Tabbs>
249214
</div>
250215
);

apps/web/components/admin/mails/request-form.tsx

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
1-
import { Address } from "@courselit/common-models";
21
import {
32
Form,
43
FormField,
54
FormSubmit,
65
useToast,
76
} from "@courselit/components-library";
8-
import { AppDispatch } from "@courselit/state-management";
9-
import { networkAction } from "@courselit/state-management/dist/action-creators";
107
import { FetchBuilder, capitalize } from "@courselit/utils";
118
import {
129
TOAST_TITLE_ERROR,
@@ -17,18 +14,18 @@ import {
1714
MAIL_REQUEST_RECEIVED,
1815
TOAST_TITLE_SUCCESS,
1916
} from "@ui-config/strings";
20-
import { ChangeEvent, useEffect, useState } from "react";
17+
import { ChangeEvent, useEffect, useState, useContext } from "react";
18+
import { AddressContext } from "@components/contexts";
2119

2220
interface RequestFormProps {
23-
address: Address;
2421
loading?: boolean;
25-
dispatch?: AppDispatch;
2622
}
2723

28-
const RequestForm = ({ address, dispatch, loading }: RequestFormProps) => {
24+
const RequestForm = ({ loading }: RequestFormProps) => {
2925
const [reason, setReason] = useState("");
3026
const [message, setMessage] = useState("");
3127
const [status, setStatus] = useState("");
28+
const address = useContext(AddressContext);
3229
const { toast } = useToast();
3330

3431
useEffect(() => {
@@ -49,7 +46,6 @@ const RequestForm = ({ address, dispatch, loading }: RequestFormProps) => {
4946
.setIsGraphQLEndpoint(true)
5047
.setPayload(query)
5148
.build();
52-
dispatch && dispatch(networkAction(true));
5349
const response = await fetch.exec();
5450
if (response.getMailRequest) {
5551
const { reason, message, status } = response.getMailRequest;
@@ -63,8 +59,6 @@ const RequestForm = ({ address, dispatch, loading }: RequestFormProps) => {
6359
description: e.message,
6460
variant: "destructive",
6561
});
66-
} finally {
67-
dispatch && dispatch(networkAction(false));
6862
}
6963
};
7064

@@ -101,7 +95,6 @@ const RequestForm = ({ address, dispatch, loading }: RequestFormProps) => {
10195
},
10296
})
10397
.build();
104-
dispatch && dispatch(networkAction(true));
10598
const response = await fetch.exec();
10699
if (response.updateMailRequest) {
107100
toast({
@@ -115,8 +108,6 @@ const RequestForm = ({ address, dispatch, loading }: RequestFormProps) => {
115108
description: e.message,
116109
variant: "destructive",
117110
});
118-
} finally {
119-
dispatch && dispatch(networkAction(false));
120111
}
121112
};
122113

0 commit comments

Comments
 (0)