Skip to content

Commit a127d15

Browse files
committed
more fixes
1 parent 3a598de commit a127d15

File tree

102 files changed

+512
-417
lines changed

Some content is hidden

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

102 files changed

+512
-417
lines changed

content/6_Advanced/Extend_Euclid.problems.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"name": "Modular Arithmetic",
77
"url": "https://open.kattis.com/problems/modulararithmetic",
88
"source": "Kattis",
9-
"difficulty": null,
9+
"difficulty": "N/A",
1010
"isStarred": false,
1111
"tags": [],
1212
"solutionMetadata": {
@@ -20,7 +20,7 @@
2020
"name": "Chinese Remainder",
2121
"url": "https://open.kattis.com/problems/chineseremainder",
2222
"source": "Kattis",
23-
"difficulty": null,
23+
"difficulty": "N/A",
2424
"isStarred": false,
2525
"tags": [],
2626
"solutionMetadata": {
@@ -32,7 +32,7 @@
3232
"name": "Chinese Remainder (non-relatively prime moduli)",
3333
"url": "https://open.kattis.com/problems/generalchineseremainder",
3434
"source": "Kattis",
35-
"difficulty": null,
35+
"difficulty": "N/A",
3636
"isStarred": false,
3737
"tags": [],
3838
"solutionMetadata": {

gatsby-node.ts

+1-81
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { execSync } from 'child_process';
22
import fs from 'fs';
33
import path from 'path';
44
import * as freshOrdering from './content/ordering';
5+
import { typeDefs } from './graphql-types';
56
import div_to_probs from './src/components/markdown/ProblemsList/DivisionList/div_to_probs.json';
67
import { createXdmNode } from './src/gatsby/create-xdm-node';
78
import {
@@ -491,87 +492,6 @@ exports.createPages = async ({ graphql, actions, reporter }) => {
491492

492493
exports.createSchemaCustomization = ({ actions }) => {
493494
const { createTypes } = actions;
494-
const typeDefs = `
495-
type Xdm implements Node {
496-
body: String
497-
fileAbsolutePath: String
498-
frontmatter: XdmFrontmatter!
499-
isIncomplete: Boolean
500-
cppOc: Int
501-
javaOc: Int
502-
pyOc: Int
503-
toc: TableOfContents
504-
mdast: String
505-
}
506-
507-
type XdmFrontmatter implements Node {
508-
id: String
509-
title: String!
510-
author: String
511-
contributors: String
512-
description: String
513-
prerequisites: [String]
514-
redirects: [String]
515-
frequency: Int
516-
}
517-
518-
type Heading {
519-
depth: Int
520-
value: String
521-
slug: String
522-
}
523-
524-
type TableOfContents {
525-
cpp: [Heading]
526-
java: [Heading]
527-
py: [Heading]
528-
}
529-
530-
type ModuleProblemLists implements Node {
531-
moduleId: String
532-
problemLists: [ModuleProblemList]
533-
}
534-
535-
type ModuleProblemList {
536-
listId: String!
537-
problems: [ModuleProblemInfo]
538-
}
539-
540-
type ProblemInfo implements Node {
541-
uniqueId: String!
542-
name: String!
543-
url: String!
544-
source: String!
545-
sourceDescription: String
546-
isStarred: Boolean!
547-
difficulty: String!
548-
tags: [String!]!
549-
solution: ProblemSolutionInfo!
550-
inModule: Boolean!
551-
module: Xdm @link(by: "frontmatter.id")
552-
}
553-
554-
type ModuleProblemInfo {
555-
uniqueId: String!
556-
name: String!
557-
url: String!
558-
source: String!
559-
sourceDescription: String
560-
isStarred: Boolean!
561-
difficulty: String!
562-
tags: [String!]!
563-
solution: ProblemSolutionInfo
564-
}
565-
566-
type ProblemSolutionInfo {
567-
kind: String!
568-
label: String
569-
labelTooltip: String
570-
url: String
571-
sketch: String
572-
hasHints:Boolean
573-
}
574-
`;
575495
createTypes(typeDefs);
576496
};
577497
const FilterWarningsPlugin = require('webpack-filter-warnings-plugin');

graphql-types.ts

+81
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
export const typeDefs = `
2+
type Xdm implements Node {
3+
body: String
4+
fileAbsolutePath: String
5+
frontmatter: XdmFrontmatter!
6+
isIncomplete: Boolean
7+
cppOc: Int
8+
javaOc: Int
9+
pyOc: Int
10+
toc: TableOfContents
11+
mdast: String
12+
}
13+
14+
type XdmFrontmatter implements Node {
15+
id: String
16+
title: String!
17+
author: String
18+
contributors: String
19+
description: String
20+
prerequisites: [String]
21+
redirects: [String]
22+
frequency: Int
23+
}
24+
25+
type Heading {
26+
depth: Int
27+
value: String
28+
slug: String
29+
}
30+
31+
type TableOfContents {
32+
cpp: [Heading]
33+
java: [Heading]
34+
py: [Heading]
35+
}
36+
37+
type ModuleProblemLists implements Node {
38+
moduleId: String
39+
problemLists: [ModuleProblemList]
40+
}
41+
42+
type ModuleProblemList {
43+
listId: String!
44+
problems: [ModuleProblemInfo]
45+
}
46+
47+
type ProblemInfo implements Node {
48+
uniqueId: String!
49+
name: String!
50+
url: String!
51+
source: String!
52+
sourceDescription: String
53+
isStarred: Boolean!
54+
difficulty: String
55+
tags: [String!]!
56+
solution: ProblemSolutionInfo
57+
inModule: Boolean!
58+
module: Xdm @link(by: "frontmatter.id")
59+
}
60+
61+
type ModuleProblemInfo {
62+
uniqueId: String!
63+
name: String!
64+
url: String!
65+
source: String!
66+
sourceDescription: String
67+
isStarred: Boolean!
68+
difficulty: String
69+
tags: [String!]!
70+
solution: ProblemSolutionInfo
71+
}
72+
73+
type ProblemSolutionInfo {
74+
kind: String!
75+
label: String
76+
labelTooltip: String
77+
url: String
78+
sketch: String
79+
hasHints:Boolean
80+
}
81+
`;

src/atoms/editor.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@ const baseActiveFileAtom = atomWithStorage(
4848
null as string | null
4949
);
5050
export const branchAtom = atomWithStorage('guide:editor:branch', null);
51-
export const tokenAtom = atom(null);
51+
export const tokenAtom = atom<string | null>(null);
5252
export const octokitAtom = atom(get =>
5353
get(tokenAtom) === null ? null : new Octokit({ auth: get(tokenAtom) })
5454
);
55-
export const forkAtom = atom(undefined);
55+
export const forkAtom = atom<string | undefined>(undefined);
5656
export const baseTabAtom = atom('content');
5757
export const editingSolutionAtom = atom(get => {
5858
const activeFile = get(activeFileAtom);
@@ -257,7 +257,7 @@ export const closeFileAtom = atom(null, (get, set, filePath: string) => {
257257
filesFamily.remove(filePath);
258258
});
259259

260-
const baseMonacoEditorInstanceAtom = atom({ monaco: null });
260+
const baseMonacoEditorInstanceAtom = atom({ monaco: null as any });
261261
export const monacoEditorInstanceAtom = atom(
262262
get => get(baseMonacoEditorInstanceAtom),
263263
(get, _set, val: any) => {

src/components/ContactUsSlideover/ContactUsSlideover.tsx

+9-3
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,13 @@ import SlideoverForm from './SlideoverForm';
1212

1313
// Warning: this file is insanely messy. This should be rewritten soon :)
1414

15-
const Field = ({ label, id, value, onChange, errorMsg = null }) => {
15+
const Field = ({
16+
label,
17+
id,
18+
value,
19+
onChange,
20+
errorMsg = null as string | null,
21+
}) => {
1622
return (
1723
<div className="space-y-1">
1824
<label
@@ -113,10 +119,10 @@ export default function ContactUsSlideover({
113119
useEffect(() => {
114120
if (!firebaseUser) return;
115121
if (email === '') {
116-
setEmail(firebaseUser.email);
122+
setEmail(firebaseUser.email!);
117123
}
118124
if (name === '') {
119-
setName(firebaseUser.displayName);
125+
setName(firebaseUser.displayName!);
120126
}
121127
}, [firebaseUser]);
122128

src/components/Dashboard/DashboardProgress.tsx

+8-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const FancyNumber = ({
3232
text,
3333
textColor,
3434
bgColor,
35-
subTextColor = null,
35+
subTextColor = null as string | null,
3636
}) => (
3737
<div className="text-center">
3838
<span
@@ -104,7 +104,13 @@ export default function DashboardProgress({
104104
);
105105
}
106106

107-
const ProgressBarSmall = ({ className = null, text, green, yellow, blue }) => {
107+
const ProgressBarSmall = ({
108+
className = undefined as string | undefined,
109+
text,
110+
green,
111+
yellow,
112+
blue,
113+
}) => {
108114
return (
109115
<div className={className}>
110116
<div className="inline-block">

src/components/Dashboard/ModuleLink.tsx

+5-5
Original file line numberDiff line numberDiff line change
@@ -196,14 +196,14 @@ const ModuleLink = ({ link }: { link: ModuleLinkInfo }): JSX.Element => {
196196
darkDotColorStyle = tw`bg-gray-800`;
197197
}
198198
const userLang = useUserLangSetting();
199-
const maxLangOc = Math.max(link.cppOc, link.javaOc, link.pyOc);
199+
const maxLangOc = Math.max(link.cppOc ?? 0, link.javaOc ?? 0, link.pyOc ?? 0);
200200
const langToOc = {
201201
cpp: link.cppOc,
202202
java: link.javaOc,
203203
py: link.pyOc,
204204
showAll: maxLangOc,
205205
};
206-
const isMissingLang = langToOc[userLang] < maxLangOc;
206+
const isMissingLang = langToOc[userLang] ?? 0 < maxLangOc;
207207
return (
208208
<LinkWithProgress
209209
lineColorStyle={lineColorStyle}
@@ -253,16 +253,16 @@ const ModuleLink = ({ link }: { link: ModuleLinkInfo }): JSX.Element => {
253253
totalCount={4}
254254
color={
255255
'transition text-gray-400 ' +
256-
FrequencyCircleColors[link.frequency]
256+
FrequencyCircleColors[link.frequency ?? 0]
257257
}
258258
/>
259259
<span
260260
className={
261261
`ml-1 transition text-gray-500 ` +
262-
FrequencyTextColors[link.frequency]
262+
FrequencyTextColors[link.frequency ?? 0]
263263
}
264264
>
265-
{FrequencyLabels[link.frequency]}
265+
{FrequencyLabels[link.frequency ?? 0]}
266266
</span>
267267
</p>
268268
)}

src/components/Editor/AddFileModal.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ export default function AddFileModal(props) {
7070
source: info.source,
7171
division,
7272
problemModules: [],
73-
} as AlgoliaEditorSolutionFile);
73+
} as unknown as AlgoliaEditorSolutionFile);
7474
setFileStatus('Create File');
7575
} catch (e) {
7676
setFileStatus('Create File');

src/components/Editor/EditorFileModalInterface.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ const FileSearch = ({
4747
onSelect,
4848
openAddFile,
4949
}: {
50-
onSelect: (file: AlgoliaEditorFile) => void;
50+
onSelect: (file: AlgoliaEditorFile | undefined) => void;
5151
openAddFile: () => void;
5252
}) => {
5353
const { query, refine: setQuery } = useSearchBox();

src/components/Editor/EditorOutput.tsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ export const EditorOutput = (): JSX.Element => {
2121
const activeFile = useAtomValue(activeFileAtom);
2222
const saveFile = useSetAtom(saveFileAtom);
2323

24-
const markdown: string | null = activeFile?.markdown;
25-
const problems: string | null = activeFile?.problems;
24+
const markdown: string = activeFile?.markdown ?? '';
25+
const problems: string = activeFile?.problems ?? '';
2626

2727
const [
2828
markdownProblemListsProviderValue,
2929
setMarkdownProblemListsProviderValue,
30-
] = useState([]);
30+
] = useState<{ listId: string; problems: any }[]>([]);
3131
React.useEffect(() => {
3232
try {
3333
const parsedProblems = JSON.parse(problems || '{}');
@@ -81,7 +81,7 @@ export const EditorOutput = (): JSX.Element => {
8181
plugins: [babelParser],
8282
});
8383
saveFile({
84-
path: activeFile.path,
84+
path: activeFile!.path,
8585
update: prev => ({
8686
...prev,
8787
problems: formattedNewContent,

src/components/Editor/EditorSidebar/EditorSidebar.tsx

+4-3
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ function GithubActions() {
5353
})
5454
.then(res =>
5555
setFork(
56-
res.data.find(repo => repo.name === 'usaco-guide')?.html_url ?? null
56+
res.data.find(repo => repo.name === 'usaco-guide')?.html_url ??
57+
undefined
5758
)
5859
);
5960
}, [githubInfo, branch, octokit, setFork]);
@@ -158,7 +159,7 @@ function GithubActions() {
158159
Fork detected!
159160
</a>
160161
</p>
161-
{branch ? (
162+
{branch && githubInfo ? (
162163
<p>
163164
Current branch:{' '}
164165
<a
@@ -183,7 +184,7 @@ function GithubActions() {
183184
>
184185
{branchState}
185186
</button>
186-
{branch && (
187+
{branch && githubInfo && (
187188
<a
188189
className="btn mt-4"
189190
href={`https://github.com/${githubInfo.login}/usaco-guide/pull/new/${branch}`}

src/components/Editor/MainEditorInterface.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ export const MainEditorInterface = ({ className }): JSX.Element => {
6464
path: activeFile.path,
6565
update: prev => ({
6666
...prev,
67-
problems: x(prev.problems),
67+
problems: x(prev.problems!),
6868
}),
6969
});
7070
}

0 commit comments

Comments
 (0)