Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@ import './a-page-template.scss';

const slug = 'books/biology-2e';

function Pagename({data: {heading}}) {
type PageData = {
heading: string;
};

function Pagename({data}: {data: PageData}) {
return (
<div className="content">
<h1>{heading}</h1>
<h1>{data.heading}</h1>
</div>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import React from 'react';
import useMatchingSchools from '~/models/use-school-suggestion-list';
import {FilteringSelect} from '~/components/form-elements/form-elements';

// Left as JS because I couldn't get the tests to cover these
export default function SchoolSelector({value, setValue}) {
export default function SchoolSelector({value, setValue}: {value: string; setValue: (value: string) => void}) {
const {schoolIsOk, schoolOptions} = useMatchingSchools(value);

return (
Expand All @@ -18,17 +17,17 @@ export default function SchoolSelector({value, setValue}) {
required: true,
value,
autoComplete: 'off',
onChange({target}) {setValue(target.value);}
onChange({target}: React.ChangeEvent<HTMLInputElement>) {setValue(target.value);}
}}
accept={(option) => setValue(option.value)}
accept={(option: {value: string}) => setValue(option.value)}
accepted={schoolIsOk}
/>
</div>
);
}

export function useDoSubmit(afterSubmit) {
return React.useCallback((form) => {
export function useDoSubmit(afterSubmit: () => void) {
return React.useCallback((form: HTMLFormElement) => {
form.submit();
afterSubmit();
}, [afterSubmit]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,20 @@
import Carousel from '~/components/carousel/carousel';
import './testimonials.scss';

function Card({data: {image, testimonial}}) {
type ImageData = {
file: string;
title: string;
};

type TestimonialData = {
image?: ImageData;
testimonial: string;
description: string;
};

function Card({data}: {data: TestimonialData}) {
const {image, testimonial} = data;

return (
<div className='card'>
<div className='picture-part'>
Expand All @@ -18,13 +31,13 @@
}

export default function Testimonials() {
const {testimonials: [testimonials]} = usePageContext();

Check failure on line 34 in src/app/pages/press/testimonials/testimonials.tsx

View workflow job for this annotation

GitHub Actions / osweb

Property 'testimonials' does not exist on type 'PressPageData | undefined'.

return (
<div className='content-block'>
<h2>Making an impact</h2>
<Carousel atATime={2} hoverTextThing='testimonials'>
{testimonials.map((c) => (
{testimonials.map((c: TestimonialData) => (
<Card data={c} key={c.description} />
))}
</Carousel>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
import LanguageSelector from '~/components/language-selector/language-selector';
import {FormattedMessage} from 'react-intl';

export default function LanguageSelectorSection(props) {
export default function LanguageSelectorSection(props: Record<string, unknown>) {
return (
<section className='language-selector-section'>
<div className='content'>
<LanguageSelector LeadIn={LeadIn} {...props} />

Check failure on line 9 in src/app/pages/subjects/new/language-selector-section.tsx

View workflow job for this annotation

GitHub Actions / osweb

Type '{ LeadIn: () => Element; }' is missing the following properties from type '{ LeadIn: () => Element; otherLocales: string[]; LinkPresentation: LinkPresentationType; addPolish?: boolean | undefined; }': otherLocales, LinkPresentation
</div>
</section>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
import useSubjectsContext from './context';
import useSubjectCategoryContext from '~/contexts/subject-category';

export default function useCategorizedBooks() {
type Book = {
subjects: string[];
};

type CategoryWithBooks = Book[] & {
label?: string;
};

type CategorizedBooks = Record<string, CategoryWithBooks>;

export default function useCategorizedBooks(): CategorizedBooks {
const {books} = useSubjectsContext();
const categories = useSubjectCategoryContext();
const result = {};
const result: CategorizedBooks = {};
const addLabels = () => {
for (const category of categories) {
if (result[category.cms]) {
Expand All @@ -13,13 +23,13 @@
}
};

for (const book of books) {

Check failure on line 26 in src/app/pages/subjects/new/use-categorized-books.tsx

View workflow job for this annotation

GitHub Actions / osweb

'books' is possibly 'undefined'.
book.subjects.forEach((cmsCategory) => {
book.subjects.forEach((cmsCategory: string) => {

Check failure on line 27 in src/app/pages/subjects/new/use-categorized-books.tsx

View workflow job for this annotation

GitHub Actions / osweb

Property 'subjects' does not exist on type '{ bookState: string; }'.
if (!(cmsCategory in result)) {
result[cmsCategory] = [];
result[cmsCategory] = [] as CategoryWithBooks;
}
if (!result[cmsCategory].includes(book)) {

Check failure on line 31 in src/app/pages/subjects/new/use-categorized-books.tsx

View workflow job for this annotation

GitHub Actions / osweb

Argument of type '{ bookState: string; }' is not assignable to parameter of type 'Book'.
result[cmsCategory].push(book);

Check failure on line 32 in src/app/pages/subjects/new/use-categorized-books.tsx

View workflow job for this annotation

GitHub Actions / osweb

Argument of type '{ bookState: string; }' is not assignable to parameter of type 'Book'.
}
});
}
Expand Down
Loading