Skip to content

Commit f9b026a

Browse files
committed
feat(imports): move into settings
1 parent dcb5ea0 commit f9b026a

File tree

2 files changed

+33
-28
lines changed

2 files changed

+33
-28
lines changed

src/components/settings/Nav.tsx

+1-8
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,7 @@ const NavBody: FC = () => (
5555
</NavGroup>
5656

5757
<NavGroup title="Stats">
58-
<SideNavItem external href="/import">
59-
Import
60-
</SideNavItem>
61-
{/* <SideNavItem disabled href="/settings/algorithms">
62-
Algorithms
63-
</SideNavItem> */}
64-
{/* <SideNavItem href="/account/algorithms">Stats & Algorithms</SideNavItem> */}
65-
{/* <SideNavItem href="/account/lang">Language & Theme</SideNavItem> */}
58+
<SideNavItem href="/settings/imports">Import</SideNavItem>
6659
</NavGroup>
6760
</aside>
6861
</nav>

src/pages/import.tsx src/pages/settings/imports.tsx

+32-20
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
'use client';
22

33
/* eslint-disable no-continue */
4-
import { Container } from '@/components/Container';
54
import { Divider } from '@/components/Divider';
65
import { ImportList } from '@/components/Import/ImportList';
76
import { UploadedItem } from '@/components/Import/UploadedItem';
@@ -22,8 +21,7 @@ import Dropzone from 'react-dropzone';
2221
import { MdFileUpload, MdWarning } from 'react-icons/md';
2322
import { BlobReader, TextWriter, ZipReader } from '@zip.js/zip.js';
2423
import { Button } from '@/components/Button';
25-
26-
type Props = {};
24+
import { AccountLayout } from '@/components/settings/Layout';
2725

2826
export const getServerSideProps: GetServerSideProps<SSRProps> = async (ctx) => {
2927
const user = await fetchUser(ctx);
@@ -43,7 +41,7 @@ interface ImportService {
4341
handleFileUpload: (file: File[]) => Promise<void> | void;
4442
}
4543

46-
const ImportPage: NextPage<Props> = () => {
44+
const Imports = () => {
4745
const { user } = useAuth();
4846
const api = useApi();
4947
const toaster = useToaster();
@@ -199,8 +197,8 @@ const ImportPage: NextPage<Props> = () => {
199197
if (!user) return <></>;
200198

201199
return (
202-
<Container className="pt-20">
203-
<Title>Import</Title>
200+
<div className="relative w-full">
201+
<Title>Imports</Title>
204202
{importWarning?.asBoolean() && (
205203
<div className="my-8 w-full flex-row rounded-md border-l-4 border-l-yellow-400/80 bg-yellow-400/20 p-4">
206204
<div className="flex w-full flex-col">
@@ -223,7 +221,7 @@ const ImportPage: NextPage<Props> = () => {
223221
target="blank"
224222
onClick={() => event('IMPORT_guide_click')}
225223
>
226-
here in the support docs
224+
in the support documentation.
227225
</a>
228226
.
229227
</p>
@@ -232,17 +230,19 @@ const ImportPage: NextPage<Props> = () => {
232230
{importAvailable?.asBoolean() ? (
233231
<>
234232
<div className="mt-5 flex flex-col items-center justify-center">
235-
<SegmentedControls
236-
onChange={(id) => {
237-
setImportService(services.find((x) => x.id === id)!);
238-
}}
239-
>
240-
{services.map((service) => (
241-
<Segment key={service.id} value={service.id}>
242-
{service.name}
243-
</Segment>
244-
))}
245-
</SegmentedControls>
233+
{services.length > 1 && (
234+
<SegmentedControls
235+
onChange={(id) => {
236+
setImportService(services.find((x) => x.id === id)!);
237+
}}
238+
>
239+
{services.map((service) => (
240+
<Segment key={service.id} value={service.id}>
241+
{service.name}
242+
</Segment>
243+
))}
244+
</SegmentedControls>
245+
)}
246246
<div className="mt-2 flex w-full items-center justify-center">
247247
<Dropzone
248248
onDrop={(files) => importService.handleFileUpload(files)}
@@ -275,7 +275,9 @@ const ImportPage: NextPage<Props> = () => {
275275
{Object.values(importService.acceptFiles)
276276
.flatMap((x) => x)
277277
.join(', ')}{' '}
278-
for this service.
278+
for{' '}
279+
{services.length > 1 ? 'this service' : 'Spotify'}
280+
.
279281
</p>
280282
<input {...getInputProps()} />
281283
</>
@@ -345,7 +347,17 @@ const ImportPage: NextPage<Props> = () => {
345347
you need stats.fm Plus.
346348
</h4>
347349
)}
348-
</Container>
350+
</div>
351+
);
352+
};
353+
354+
const ImportPage: NextPage = () => {
355+
const { user } = useAuth();
356+
if (!user) return null;
357+
return (
358+
<AccountLayout>
359+
<Imports />
360+
</AccountLayout>
349361
);
350362
};
351363

0 commit comments

Comments
 (0)