Skip to content

Commit a6e7bfc

Browse files
committed
feat(frontend): remove new user guide
Instead they are automatically redirected to the movies search page if they have not added any movies
1 parent a2b580a commit a6e7bfc

File tree

7 files changed

+45
-48
lines changed

7 files changed

+45
-48
lines changed

apps/frontend/app/components/media.tsx

-16
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { $path } from "@ignisda/remix-routes";
22
import {
33
ActionIcon,
4-
Alert,
54
Anchor,
65
Avatar,
76
Badge,
@@ -47,7 +46,6 @@ import {
4746
} from "@ryot/ts-utils";
4847
import {
4948
IconArrowBigUp,
50-
IconArrowsRight,
5149
IconBackpack,
5250
IconBookmarks,
5351
IconCheck,
@@ -870,20 +868,6 @@ export const DisplayCollection = (props: {
870868
);
871869
};
872870

873-
export const NewUserGuideAlert = () => {
874-
return (
875-
<Alert icon={<IconArrowsRight />} variant="outline" color="teal">
876-
<Text>
877-
To get started, select a media type from the sidebar, enter a query in
878-
the search tab, and add a media to your seen history or watchlist.
879-
</Text>
880-
<Text mt="xs">
881-
This notice will disappear once your summary is re-calculated.
882-
</Text>
883-
</Alert>
884-
);
885-
};
886-
887871
export const MediaIsPartial = (props: { mediaType: string }) => {
888872
return (
889873
<Flex align="center" gap={4}>

apps/frontend/app/components/toaster.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export function Toaster({ toast }: { toast?: Toast | null }) {
1313
}
1414

1515
const ShowToast = (props: { toast: Toast }) => {
16-
const { id, type, title, message } = props.toast;
16+
const { id, type, title, message, closeAfter } = props.toast;
1717
useEffect(() => {
1818
setTimeout(() => {
1919
const [defaultTitle, defaultColor] = match(type)
@@ -26,6 +26,7 @@ const ShowToast = (props: { toast: Toast }) => {
2626
message,
2727
title: title ?? defaultTitle,
2828
color: defaultColor,
29+
autoClose: closeAfter,
2930
});
3031
}, 0);
3132
}, [message, id, title, type]);

apps/frontend/app/lib/utilities.server.ts

+1
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,7 @@ const ToastSchema = z.object({
321321
id: z.string().default(() => randomUUID()),
322322
title: z.string().optional(),
323323
type: TypeSchema.default("message"),
324+
closeAfter: z.number().optional(),
324325
});
325326

326327
export type Toast = z.infer<typeof ToastSchema>;

apps/frontend/app/routes/_dashboard._index.tsx

-4
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ import { displayWeightWithUnit } from "~/components/fitness";
4040
import {
4141
DisplayCollectionEntity,
4242
MetadataDisplayItem,
43-
NewUserGuideAlert,
4443
} from "~/components/media";
4544
import { dayjsLib, getLot, getMetadataIcon } from "~/lib/generals";
4645
import { useGetMantineColor, useUserPreferences } from "~/lib/hooks";
@@ -117,9 +116,6 @@ export default function Page() {
117116
return (
118117
<Container>
119118
<Stack gap={32}>
120-
{latestUserSummary.media.metadataOverall.interactedWith === 0 ? (
121-
<NewUserGuideAlert />
122-
) : null}
123119
{userPreferences.general.dashboard.map((de) =>
124120
match([de.section, de.hidden])
125121
.with([DashboardElementLot.Upcoming, false], () =>

apps/frontend/app/routes/_dashboard.media.$action.$lot.tsx

+1-16
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ import {
2727
import {
2828
EntityLot,
2929
GraphqlSortOrder,
30-
LatestUserSummaryDocument,
3130
MediaGeneralFilter,
3231
MediaLot,
3332
MediaSortBy,
@@ -58,11 +57,7 @@ import {
5857
DebouncedSearchInput,
5958
FiltersModal,
6059
} from "~/components/common";
61-
import {
62-
BaseMediaDisplayItem,
63-
MetadataDisplayItem,
64-
NewUserGuideAlert,
65-
} from "~/components/media";
60+
import { BaseMediaDisplayItem, MetadataDisplayItem } from "~/components/media";
6661
import { Verb, getLot, getVerb } from "~/lib/generals";
6762
import {
6863
useAppSearchParam,
@@ -124,13 +119,6 @@ export const loader = unstable_defineLoader(async ({ request, params }) => {
124119
request,
125120
);
126121
await redirectUsingEnhancedCookieSearchParams(request, cookieName);
127-
const [{ latestUserSummary }] = await Promise.all([
128-
serverGqlService.authenticatedRequest(
129-
request,
130-
LatestUserSummaryDocument,
131-
{},
132-
),
133-
]);
134122
const { query, page } = zx.parseQuery(request, {
135123
query: z.string().optional(),
136124
page: zx.IntAsString.default("1"),
@@ -201,8 +189,6 @@ export const loader = unstable_defineLoader(async ({ request, params }) => {
201189
cookieName,
202190
mediaSearch,
203191
url: withoutHost(url.href),
204-
mediaInteractedWith:
205-
latestUserSummary.data.media.metadataOverall.interactedWith,
206192
};
207193
});
208194

@@ -236,7 +222,6 @@ export default function Page() {
236222

237223
return (
238224
<Container>
239-
{loaderData.mediaInteractedWith === 0 ? <NewUserGuideAlert /> : null}
240225
<Tabs
241226
variant="default"
242227
mt="sm"

apps/frontend/app/routes/_dashboard.tsx

+11-5
Original file line numberDiff line numberDiff line change
@@ -1149,24 +1149,30 @@ const NewProgressUpdateForm = ({
11491149
{watchTime === WATCH_TIMES[2] ? (
11501150
<DatePickerInput
11511151
required
1152-
label="Enter exact date"
1152+
clearable
11531153
dropdownType="modal"
11541154
maxDate={new Date()}
11551155
onChange={setSelectedDate}
1156-
clearable
1156+
label="Enter exact date"
11571157
/>
11581158
) : null}
11591159
<Select
11601160
label={`Where did you ${getVerb(Verb.Read, metadataDetails.lot)} it?`}
11611161
data={userPreferences.general.watchProviders}
11621162
name="providerWatchedOn"
11631163
/>
1164+
{selectedDate ? (
1165+
<input
1166+
hidden
1167+
readOnly
1168+
name="date"
1169+
value={formatDateToNaiveDate(selectedDate)}
1170+
/>
1171+
) : null}
11641172
<Button
1173+
type="submit"
11651174
variant="outline"
11661175
disabled={selectedDate === undefined}
1167-
type="submit"
1168-
name="date"
1169-
value={selectedDate ? formatDateToNaiveDate(selectedDate) : undefined}
11701176
>
11711177
Submit
11721178
</Button>

apps/frontend/app/routes/auth.tsx

+30-6
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,10 @@ import {
2525
} from "@remix-run/react";
2626
import {
2727
GetOidcRedirectUrlDocument,
28+
LatestUserSummaryDocument,
2829
LoginErrorVariant,
2930
LoginUserDocument,
31+
MediaLot,
3032
RegisterErrorVariant,
3133
RegisterUserDocument,
3234
} from "@ryot/generated/graphql/backend/graphql";
@@ -38,11 +40,12 @@ import { match } from "ts-pattern";
3840
import { withQuery } from "ufo";
3941
import { z } from "zod";
4042
import { zx } from "zodix";
41-
import { redirectToQueryParam } from "~/lib/generals";
43+
import { dayjsLib, redirectToQueryParam } from "~/lib/generals";
4244
import {
4345
createToastHeaders,
4446
getAuthorizationCookie,
4547
getCachedCoreDetails,
48+
getCachedUserPreferences,
4649
getCookiesForApplication,
4750
getCoreEnabledFeatures,
4851
processSubmission,
@@ -61,10 +64,30 @@ export type SearchParams = z.infer<typeof searchParamsSchema> &
6164
export const loader = unstable_defineLoader(async ({ request }) => {
6265
const query = zx.parseQuery(request, searchParamsSchema);
6366
const isAuthenticated = !!getAuthorizationCookie(request);
64-
if (isAuthenticated)
67+
if (isAuthenticated) {
68+
const [userPreferences, { latestUserSummary }] = await Promise.all([
69+
getCachedUserPreferences(request),
70+
serverGqlService.authenticatedRequest(request, LatestUserSummaryDocument),
71+
]);
72+
if (
73+
latestUserSummary.data.media.metadataOverall.interactedWith === 0 &&
74+
userPreferences.featuresEnabled.media.enabled === true
75+
)
76+
throw await redirectWithToast(
77+
$path(
78+
"/media/:action/:lot",
79+
{ action: "search", lot: MediaLot.Movie },
80+
{ query: "avengers" },
81+
),
82+
{
83+
message: "Welcome to Ryot! Add any movie you want to your watchlist!",
84+
closeAfter: dayjsLib.duration(10, "second").asMilliseconds(),
85+
},
86+
);
6587
throw await redirectWithToast($path("/"), {
6688
message: "You were already logged in",
6789
});
90+
}
6891
const [enabledFeatures, { coreDetails }] = await Promise.all([
6992
getCoreEnabledFeatures(),
7093
getCachedCoreDetails(),
@@ -141,11 +164,12 @@ export const action = unstable_defineAction(async ({ request }) => {
141164
},
142165
});
143166
if (loginUser.__typename === "LoginResponse") {
144-
let redirectUrl = $path("/");
145-
if (submission[redirectToQueryParam])
146-
redirectUrl = safeRedirect(submission[redirectToQueryParam]);
147167
const headers = await getCookiesForApplication(loginUser.apiKey);
148-
return redirect(redirectUrl, { headers });
168+
if (submission[redirectToQueryParam])
169+
return redirect(safeRedirect(submission[redirectToQueryParam]), {
170+
headers,
171+
});
172+
return Response.json({}, { headers });
149173
}
150174
const message = match(loginUser.error)
151175
.with(

0 commit comments

Comments
 (0)