Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
197 commits
Select commit Hold shift + click to select a range
e6bbca1
"ejected" from apollo-boost for local state management
dafrie Apr 7, 2019
1b683ce
add currentRole to authClient
dafrie Apr 7, 2019
8088970
add local resolver & query for settings (for now)
dafrie Apr 7, 2019
bd59ac9
Setting wizard + setting screen in sections
dafrie Apr 7, 2019
7013760
use formik for newChapter mutations
dafrie Apr 8, 2019
c5ed6ff
removed unecessary comment
dafrie Apr 8, 2019
307463f
add changes from other branch regarding codegen
dafrie Apr 8, 2019
1e38eeb
Add initial files
YanickSchraner Apr 13, 2019
475302b
Merge branch '#2--basic-views' into 9-manage-vocabulary
YanickSchraner Apr 13, 2019
4e76c8b
Add initial code for wordgroups
YanickSchraner Apr 14, 2019
03632ac
Update voggi view
YanickSchraner Apr 14, 2019
9790176
Update queries
YanickSchraner Apr 22, 2019
7d2ee4a
Fix merge conflict
YanickSchraner Apr 22, 2019
c82a968
Use generated types
YanickSchraner May 30, 2019
2b93b06
Fix merge conflict
YanickSchraner May 30, 2019
e6dafd3
Change for relay
YanickSchraner May 30, 2019
a4e57d1
Merge branch 'master' into 9-manage-vocabulary
YanickSchraner May 30, 2019
ad25ee2
Add new gql queries
YanickSchraner May 31, 2019
815b01a
Add generated queries
YanickSchraner Jul 12, 2019
eea5c7a
Merge branch 'master' into 9-manage-vocabulary
YanickSchraner Jul 12, 2019
28652d9
Fix querries, types and handle null data
YanickSchraner Jul 12, 2019
c09e4da
Improve voggi and create chapters
YanickSchraner Jul 13, 2019
99c96a0
Work on new word and new word group
YanickSchraner Jul 14, 2019
8bbd387
Work on searchable multi select
YanickSchraner Jul 14, 2019
644b3b2
initial multi select
YanickSchraner Jul 14, 2019
8174072
Further work on add words
YanickSchraner Jul 17, 2019
2c7975a
Merge branch 'master' into 9-manage-vocabulary
YanickSchraner Jul 17, 2019
9795d26
Setup of "new" AuthContext
dafrie Jul 28, 2019
e700868
Add necessary TODO for Apollo Client setup with new AuthContext
dafrie Jul 28, 2019
4d5615f
Adds a RBAC rules definition file. Contains all roles, permissions...
dafrie Jul 28, 2019
539568f
Adds the "Can" component
dafrie Jul 28, 2019
8e23752
Necessary fixes due to role name change + adds Role enum everywhere p…
dafrie Jul 28, 2019
ff5682e
adds Can component in both "NewChapter" locations
dafrie Jul 28, 2019
c4b360d
Further work on word management
YanickSchraner Jul 28, 2019
76708ab
merge master with rbac/authContext into branch
dafrie Jul 28, 2019
36b5510
updated namespace of token
dafrie Jul 28, 2019
c7f963c
remove debug
dafrie Jul 28, 2019
2fd74b8
Properly configure apollo codegen with same config values as .env fil…
dafrie Jul 28, 2019
2116600
fix Voggi query (tmp)
dafrie Jul 28, 2019
911effa
query fixes necessary for apollo codegen
dafrie Jul 28, 2019
1551149
additional query fixes for acg
dafrie Jul 28, 2019
da1c02e
Fix merge conflict
YanickSchraner Jul 28, 2019
8fac070
Ignore wordgroup queries for now for codegen
dafrie Jul 28, 2019
783f213
add generated types
dafrie Jul 28, 2019
2bf4dfe
Update queries to new hasura endpoint
YanickSchraner Jul 28, 2019
6537d05
resolve merge conflict
YanickSchraner Jul 28, 2019
fe7626e
some aliasing in wordgroup queries
dafrie Jul 28, 2019
b59fb75
reverting apollo codegen exclusion
dafrie Jul 29, 2019
30b95d1
updates generated types
dafrie Jul 29, 2019
346d46e
fix wordgroup fragment + switch to _by_pk query
dafrie Jul 29, 2019
68dee7a
WordCard + WordGroup fixes
dafrie Jul 29, 2019
47bf94c
remaining fixes for WordGroup
dafrie Jul 29, 2019
9cabf28
warnings (unused imports) cleanup
dafrie Jul 29, 2019
ab4b7ea
update & audit fix packages to latest version
dafrie Jul 29, 2019
e3545a6
update mutations to fix compatibility with apollo hooks 0.5, which su…
dafrie Jul 29, 2019
799ebc9
Removes "old" class based Auth everywhere in the app
dafrie Jul 31, 2019
a4a4c57
Switch "Chapter" queries to Hasura types
dafrie Jul 31, 2019
169d40c
Adds missing WebSockets configuration of ApolloClient
dafrie Aug 1, 2019
39ab1c7
Fix type
dafrie Aug 1, 2019
472e78f
Adds ApolloClient error handling for graphql errors and network errors
dafrie Aug 1, 2019
b74597d
Fix for undefined idToken in Websockets setup
dafrie Aug 1, 2019
3e794ae
Changes Wordgroup query to subscription
dafrie Aug 1, 2019
bce83cc
Fix types of subchapters
dafrie Aug 1, 2019
6daccca
Fixes permission lookup in "Can" Component
dafrie Aug 1, 2019
b257080
Properly type window hack (sharing state), add currentRole
dafrie Aug 2, 2019
b0a7a66
Fixes role not updating properly on settings save
dafrie Aug 2, 2019
72e3395
Fix voggi section
YanickSchraner Aug 2, 2019
513230b
Merge branch '8-manage-vocabulary' of github.com:vochabular/admin-fro…
YanickSchraner Aug 2, 2019
b940320
Remove id decoding
YanickSchraner Aug 2, 2019
9857023
Readd uuid param
YanickSchraner Aug 2, 2019
05412f6
Use subscription
YanickSchraner Aug 2, 2019
f5d13f9
Handle words with no translations
YanickSchraner Aug 2, 2019
ef2e6f3
add icon to ComponentSelector
dafrie Aug 2, 2019
2ec4221
Cleanup
dafrie Aug 2, 2019
04cee29
Setup react-redux + redux-starter-kit with contentEditorSlice
dafrie Aug 2, 2019
de12305
Change ChapterById to subscriptions
dafrie Aug 2, 2019
c2af7fd
Improves "AppState"/rootReducer types of redux
dafrie Aug 2, 2019
21474b6
Change Comment to Subscriptions
dafrie Aug 2, 2019
34034ba
Improve naming of redux store type
dafrie Aug 2, 2019
7294bcf
Updated Comment queries to hasura + subscription
dafrie Aug 2, 2019
d8ea1a6
adds UserId (getter and setter) to AuthContext
dafrie Aug 2, 2019
092f9e4
Creation of New comments and answers
dafrie Aug 2, 2019
fdfb894
query comments based on chapter
dafrie Aug 2, 2019
4bf46c4
Fix warning messages in NewChapter
dafrie Aug 3, 2019
c5429ce
Fix Not rerendering route props properly on history change
dafrie Aug 3, 2019
b337c84
Switching Chapter creation to Hasura. Wrapping Chapter component.
dafrie Aug 3, 2019
78d421e
cleanup unecessary import warnings
dafrie Aug 3, 2019
db3a783
adds resolving and deletion mutations of comments
dafrie Aug 3, 2019
439b775
Include all comment ids (including children) upon deletion to avoid n…
dafrie Aug 3, 2019
390f869
Improve dnd setup (button as draggable)
dafrie Aug 5, 2019
a756a27
Update ComponentSelector/Types query to hasura
dafrie Aug 5, 2019
32973e9
Conditionally query component-selector based on selected component
dafrie Aug 5, 2019
20a6b17
ignore config files of vscode
dafrie Aug 5, 2019
329c722
Basic selected-component context aware toolbar with DnD context
dafrie Aug 5, 2019
3cf5440
Selecting, unselecting components
dafrie Aug 6, 2019
fddfbf9
Copy & Clone Workaround for react-beautiful-dnd
dafrie Aug 7, 2019
bd4330a
small styling improvements
dafrie Aug 7, 2019
60ea831
Adds position/order in components query
dafrie Aug 8, 2019
8ee0157
adding lost chapter fragments
dafrie Aug 8, 2019
7ff3d5d
Move OnDragEnd into func component
dafrie Aug 8, 2019
29e69d9
add react-apollo v3 (now @apollo/react-hooks) and remove old 2 libs
dafrie Aug 8, 2019
759d649
Updated imports
dafrie Aug 8, 2019
0d09fd2
merging apollo update branch
dafrie Aug 8, 2019
20bd25c
fix merge fails
dafrie Aug 8, 2019
ab277af
Adds creating (without content), reordering and deletion of components
dafrie Aug 9, 2019
9234954
insert empty string to data
dafrie Aug 12, 2019
d87438b
Stop events from bubbling up, unselect on delete and clickaway listener
dafrie Aug 12, 2019
105f177
cleanup
dafrie Aug 12, 2019
375181b
Add event types
dafrie Aug 12, 2019
5b4b188
Add "Text" component for translation behavior reusability
dafrie Aug 12, 2019
2752a8f
Remove ClickAwayListener, handle it within background of component list
dafrie Aug 12, 2019
bbdb4e9
Refactor state management to use apollo cache as source of truth.
dafrie Aug 18, 2019
e865a98
add client (local) schema with types
dafrie Aug 18, 2019
a345989
i18n for delete btn
dafrie Aug 18, 2019
429e111
type local queries
dafrie Aug 18, 2019
70970df
Adds update content of components
dafrie Aug 18, 2019
bae613b
Fix merge conflict
YanickSchraner Sep 28, 2019
9992caa
Fix issues after merging
YanickSchraner Sep 28, 2019
fa46444
Use new Hasura queries
YanickSchraner Sep 28, 2019
8e30cda
Fix word edit and add routes
YanickSchraner Oct 9, 2019
2f0d6f1
include language in chapter and selectedComponent queries
dafrie Oct 9, 2019
2937cf2
Allow title settings data submitting
dafrie Oct 9, 2019
b539ae9
Add conclusion of lengthy discussion: Media, texts and the settings j…
dafrie Oct 9, 2019
648220d
adds dialog component
dafrie Oct 16, 2019
a7d1046
initialRelation object for setting up relations onCreate
dafrie Oct 16, 2019
40ac493
implemententing initialRelation in ContentEditor
dafrie Oct 16, 2019
2842843
adds missing DialogSettings mapping, improved doc on handleOnSave
dafrie Oct 16, 2019
f7caf34
Make voggi section work again
YanickSchraner Oct 16, 2019
5454d80
cleanup warnings
dafrie Oct 16, 2019
1c5ee49
Add Dialog component (incl. subitems) structure
dafrie Oct 16, 2019
c67691b
Removes unecessary "InitialRelationDefinition"
dafrie Oct 16, 2019
73a4124
include "translatable" and updated types
dafrie Oct 17, 2019
0cd7bb2
cleanup comments
dafrie Oct 17, 2019
cb98a01
Adds component type name in settings widget. Reorganizes fragments
dafrie Oct 17, 2019
8814168
Adds "LanguageContext" to theme + text component
dafrie Oct 17, 2019
b5c4a5c
prepare "chapter" routing to include an "action" param
dafrie Oct 17, 2019
1bf897c
fixes duplicate fragment warning
dafrie Oct 17, 2019
dbc9aed
Adds new "ContextText" component for langauge aware styling
dafrie Oct 17, 2019
a9b0f10
Uses new ContextText component in TitleComponent
dafrie Oct 17, 2019
a6aa342
Adding "action" to routing of "Chapter" as preparation for support of…
dafrie Oct 17, 2019
aa260d7
updates to latest apollo version
dafrie Nov 5, 2019
0b17ac0
includes media in comp query + updates autogen types
dafrie Nov 5, 2019
fe6095f
updates types in sync with latest model changes
dafrie Nov 5, 2019
7f79513
adds Apollo Client middleware for __typename stripping in all mutations
dafrie Nov 11, 2019
b195453
updates react-router-dom + adds lodash for deepCopy
dafrie Nov 12, 2019
e2aeaa7
adds language to chapter + component queries, changes for missing fie…
dafrie Nov 12, 2019
7a6aae7
adds "Diff" helper class
dafrie Nov 12, 2019
9d3fe53
Adds "ContextText" component, a language context aware text renderer
dafrie Nov 12, 2019
88ba0a5
Adds a functional, messy "TitleComponent" in the ContentEditor
dafrie Nov 12, 2019
73b1941
Deselect Settings widget on saving
dafrie Nov 12, 2019
8cd23b9
Updates apollo npm packages
dafrie Nov 14, 2019
da53b6d
Cleans up unused import warnings
dafrie Nov 14, 2019
978ec5b
Removes warning
dafrie Nov 18, 2019
08132b8
Fixes regression where comp. update mutation was overwritten. Improve…
dafrie Nov 19, 2019
1ca6b32
Remove unecessary cache init
dafrie Nov 19, 2019
c6bced5
Refactors ComponentSelector and related query to simplify logic and c…
dafrie Nov 19, 2019
2a81e71
disables local directive in component selector query
dafrie Nov 19, 2019
230b716
upgrades packages to latest versions + necessary fixes
dafrie Nov 19, 2019
5b4fc81
Adding whyDidYouRender to components
dafrie Nov 19, 2019
2fe1f83
Updates Formik Form rendering syntax to new v2 version
dafrie Nov 19, 2019
03e80e0
Removes stalled react-swipeable-views
dafrie Nov 19, 2019
986f3cc
Cleanup
dafrie Nov 19, 2019
7d3956a
Work on vochi
YanickSchraner Nov 19, 2019
a9e8cb8
Fix merge conflict
YanickSchraner Nov 19, 2019
1355cf9
Updates to latest r-dnd version
dafrie Nov 19, 2019
2e62bc9
enable whyDidYouRender on top level components
dafrie Nov 19, 2019
25f1ef0
Passing now selectedComponent to Settings widget
dafrie Nov 19, 2019
554c2ce
Small cleanup
dafrie Nov 19, 2019
7c2c5c9
Improve BusyOrErrorCard by adding prop for returning nothing in case …
dafrie Nov 20, 2019
539ec95
Fix regression where child component types were not queried rightly i…
dafrie Nov 20, 2019
1246e6d
Adds "frontendWidget" to query to allow reusing of widgets
dafrie Nov 20, 2019
d02aaa5
Downgrades formik back to v1
dafrie Nov 20, 2019
a6b20e6
correctly render preview of component type's frontend widget
dafrie Nov 20, 2019
b6b1a5e
Colorize level's of each droppable
dafrie Nov 20, 2019
126ef3f
Fix nativeLanguages filter
dafrie Nov 20, 2019
ccb239b
Add loading prop for Settings Widget
dafrie Nov 20, 2019
f419bac
Adds Appbar to ComponentSelector and make copying selected Component …
dafrie Nov 21, 2019
df59ef7
Adding AppBar to SubChapterDetail as header
dafrie Nov 21, 2019
7450ac3
Destructure ContentEditor's main structure, adding "DefaultComponent"…
dafrie Nov 21, 2019
53d2ef6
Fixes issue with not being able to drop at first index
dafrie Nov 21, 2019
ada0966
Enables ApolloClient immutability perf improvements
dafrie Nov 23, 2019
c1da04c
Adds Editor state fields to apollo cache
dafrie Nov 23, 2019
bdfb481
Adds LanguageContextSelector
dafrie Nov 23, 2019
fcca927
Adds component creation on click in selector
dafrie Nov 23, 2019
61a325a
Fixes placeholder not showing in ContextText
dafrie Nov 23, 2019
d054dc7
Adds multiTranslatoinText component
dafrie Nov 23, 2019
573e80a
Display drag-handle in ComponentHeader only on hover
dafrie Nov 23, 2019
2384bba
Adds Body to Component
dafrie Nov 23, 2019
48c5f2d
Enabling Body in Component rendering
dafrie Nov 23, 2019
59b656b
Work on vochi stuff
YanickSchraner Nov 23, 2019
85ff056
Regenerate types based on db reset changes
dafrie Nov 23, 2019
538f72b
Necessary changes for language db updates
dafrie Nov 23, 2019
de6b066
Fix merge conflict
YanickSchraner Nov 23, 2019
9e69495
Fix merge conflict
YanickSchraner Nov 23, 2019
8d88b22
Work on queries
YanickSchraner Apr 4, 2020
64418a0
Fix merge conflict
YanickSchraner Apr 4, 2020
a2e7859
Restore losses after merge
YanickSchraner Apr 4, 2020
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
1 change: 0 additions & 1 deletion src/__generated__/globalTypes.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions src/components/VoggiChapterCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import CardContent from "@material-ui/core/CardContent";
import CardActionArea from "@material-ui/core/CardActionArea";

import { styles } from "styles";
import { chapters_wordGroups_chapters_edges_node } from "../queries/__generated__/chapters_wordGroups";
import { chapters_wordGroups_chapters } from "../queries/__generated__/chapters_wordGroups";

interface Props extends WithStyles<typeof styles> {
chapter: chapters_wordGroups_chapters_edges_node;
chapter: chapters_wordGroups_chapters;
}

const VoggiChapterCard = ({ classes, chapter }: Props) => {
Expand All @@ -35,7 +35,7 @@ const VoggiChapterCard = ({ classes, chapter }: Props) => {
</Typography>
<Typography variant="h5" component="h2">
{t("chapter:nWordGroups")}{" "}
{chapter.wordGroups ? chapter.wordGroups.edges.length : 0}
{chapter.wordgroups ? chapter.wordgroups.length : 0}
</Typography>
</CardContent>
</CardActionArea>
Expand Down
16 changes: 9 additions & 7 deletions src/components/WordCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,34 +9,36 @@ import CardActionArea from "@material-ui/core/CardActionArea";

import { styles } from "styles";
import { subscribeWordGroupById_wordGroup_words_word } from "queries/__generated__/subscribeWordGroupById";
import {useTranslation} from "react-i18next";

interface Props extends WithStyles<typeof styles> {
word: subscribeWordGroupById_wordGroup_words_word;
id: string;
wordGroupId: string;
}

const WordCard = ({ classes, word, id }: Props) => {
const WordCard = ({ classes, word, wordGroupId }: Props) => {
const { t } = useTranslation();
// Note: MUI links together with react-router-dom and Typescript are a bit tricky due to their dynamic nature
// See the discussion and provided solutions here... https://github.com/mui-org/material-ui/issues/7877
// <Button component={Link} {...{ to: "/about" } as any} />
return (
<Card>
<CardActionArea
component={RouterLink}
{...{ to: `/wordgroups/${id}/edit` } as any}
{...{ to: `${wordGroupId}/word/${word.id}` } as any}
>
<CardContent>
<Typography
className={classes.title}
color="textSecondary"
gutterBottom
>
{word.translations.map(t => (
<>
{word.translations.length ? word.translations.map(t => (
<React.Fragment key={t.id}>
{t.text}
<br />
</>
))}
</React.Fragment>
)): t("words:emptyWord") }
</Typography>
</CardContent>
</CardActionArea>
Expand Down
14 changes: 0 additions & 14 deletions src/pages/Dashboard/VoggiSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,6 @@ const VoggiSection: React.FunctionComponent<Props> = ({ classes }) => {
GET_WORDGROUPS
);

if (loading || error || (data && data.wordGroups.length))
return (
<BusyOrErrorCard
loading={loading}
error={error}
noResults={
!loading &&
data &&
data.wordGroups &&
data.wordGroups &&
!data.wordGroups.length
}
/>
);
return (
<SectionCardContainer>
{data &&
Expand Down
69 changes: 36 additions & 33 deletions src/pages/WordGroup/ChapterWordGroups.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,22 @@ import * as React from "react";
import { useTranslation } from "react-i18next";

import { withStyles, WithStyles } from "@material-ui/core/styles";
import { useQuery } from "@apollo/react-hooks";
import { RouteComponentProps } from "react-router-dom";
import { useSubscription } from "@apollo/react-hooks";import { RouteComponentProps } from "react-router-dom";
import Grid from "@material-ui/core/Grid";
import AddIcon from "@material-ui/icons/Add";

import { styles } from "styles";
import BusyOrErrorCard from "components/BusyOrErrorCard";
import SectionCardContainer from "../../components/SectionCardContainer";
import Section from "../../components/Section";
import { convertGlobalToDbId } from "../../helpers";
import {GET_CHAPTER_WORDGROUPS_BY_CHAPTER_ID} from "../../queries/chapters";
import {
subscribeChaptersWordGroupsByChapterId,
subscribeChaptersWordGroupsByChapterId_chapters_wordgroups
} from "../../queries/__generated__/subscribeChaptersWordGroupsByChapterId";
import WordGroupCard from "../../components/WordGroupCard";

import LinkCard from "../../components/LinkCard";
import { GET_CHAPTER_BY_ID } from "queries/chapters";

interface WordGroupRouterProps {
id: string;
Expand All @@ -27,44 +30,44 @@ interface Props
const ChapterWordGroups = ({ classes, match }: Props) => {
const { t } = useTranslation();

const { data, error, loading } = useQuery(GET_CHAPTER_BY_ID, {
const {data, error, loading} = useSubscription<subscribeChaptersWordGroupsByChapterId>(GET_CHAPTER_WORDGROUPS_BY_CHAPTER_ID, {
variables: {
id: convertGlobalToDbId(match.params.id)
id: match.params.id
},
skip: match.params.id === "new"
// skip: match.params.id === "new"
});

// Note: MUI links together with react-router-dom and Typescript are a bit tricky due to their dynamic nature
// See the discussion and provided solutions here... https://github.com/mui-org/material-ui/issues/7877
// <Button component={Link} {...{ to: "/about" } as any} />
let chapter_name =
data && data.chapter
? `${data.chapter.titleDE} / ${data.chapter.titleCH}`
: "";
return (
<Section title={t("wordGroups:wordGroupsChapter") + ` ${chapter_name}`}>
<SectionCardContainer>
<BusyOrErrorCard
loading={loading}
error={error}
noResults={
!loading &&
data &&
!!data.chapter &&
!!data.chapter.wordGroups &&
!data.chapter.wordGroups.edges.length
}
data && data.chapters && data.chapters.languages && data.chapters.languages.length ?
data.chapters.languages.map((language) => language.title) : "";
return <Section title={t("wordGroups:wordGroupsChapter") + ` ${chapter_name}`}>
<SectionCardContainer>
<BusyOrErrorCard
loading={loading}
error={error}
noResults={!loading && data && !!data.chapters && !!data.chapters.wordgroups && !data.chapters.wordgroups.length}
/>
{data &&
data.chapters &&
data.chapters.wordgroups &&
data.chapters.wordgroups.map((w: subscribeChaptersWordGroupsByChapterId_chapters_wordgroups | null) => (
w ?
<Grid item key={w.id}>
<WordGroupCard wordGroup={w}/>
</Grid> : null
))}
<Grid item>
<LinkCard
path={`/wordgroups/new`}
icon={<AddIcon/>}
helperText="wordGroups:createNewWordGroup"
/>
<Grid item>
<LinkCard
path={`/wordgroups/new`}
icon={<AddIcon />}
helperText="wordGroups:createNewWordGroup"
/>
</Grid>
</SectionCardContainer>
</Section>
);
</Grid>
</SectionCardContainer>
</Section>;
};

export default withStyles(styles, { withTheme: true })(ChapterWordGroups);
31 changes: 23 additions & 8 deletions src/pages/WordGroup/WordGroup.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,37 @@
import * as React from "react";

import { withStyles, WithStyles } from "@material-ui/core/styles";
import { useQuery } from "@apollo/react-hooks";
import { useSubscription } from "@apollo/react-hooks";
import { RouteComponentProps } from "react-router-dom";
import AddIcon from "@material-ui/icons/Add";

import { styles } from "styles";
import NewWordGroup from "./WordGroupEditor";
import { GET_WORDGROUP_BY_ID } from "queries/wordgroups";
import BusyOrErrorCard from "components/BusyOrErrorCard";
import { convertGlobalToDbId } from "../../helpers";
import { useTranslation } from "react-i18next";
import Section from "../../components/Section";
import SectionCardContainer from "../../components/SectionCardContainer";
import { Grid } from "@material-ui/core";
import WordCard from "../../components/WordCard";
import LinkCard from "../../components/LinkCard";
import { subscribeWordGroupById } from "queries/__generated__/subscribeWordGroupById";
import * as Yup from "yup";
import i18next from "../../i18n";

export const WordGroupSchema = Yup.object().shape({
titleDe: Yup.string()
.min(2, i18next.t("tooShort"))
.max(100, i18next.t("tooLong"))
.required(i18next.t("required")),
titleCh: Yup.string()
.min(2, i18next.t("tooShort"))
.max(100, i18next.t("tooLong"))
.required(i18next.t("required")),
chapter: Yup.number()
.min(1, i18next.t("chapterNumberTooLow"))
.max(100, i18next.t("chapterNumberTooHigh"))
});

// These can come from the router... See the route definitions
interface WordGroupRouterProps {
Expand All @@ -30,13 +45,13 @@ interface Props
const WordGroup = ({ classes, match }: Props) => {
const { t } = useTranslation();

const { loading, data, error } = useQuery<subscribeWordGroupById>(
const { loading, data, error } = useSubscription<subscribeWordGroupById>(
GET_WORDGROUP_BY_ID,
{
variables: {
id: convertGlobalToDbId(match.params.id)
id: match.params.id
},
skip: match.params.id === "new"
// skip: match.params.id === "new"
}
);

Expand All @@ -47,7 +62,7 @@ const WordGroup = ({ classes, match }: Props) => {
let title_name = ``;

return (
<Section title={t("wordGroups:wordGroup") + ` ${title_name}`}>
<Section title={t("words:wordGroup") + ` ${title_name}`}>
<SectionCardContainer>
<BusyOrErrorCard
loading={loading}
Expand All @@ -66,13 +81,13 @@ const WordGroup = ({ classes, match }: Props) => {
data.wordGroup.words.map(w =>
w ? (
<Grid item key={w.id}>
<WordCard word={w.word} id={match.params.id} />
<WordCard word={w.word} wordGroupId={match.params.id} />
</Grid>
) : null
)}
<Grid item>
<LinkCard
path={`/wordgroups/${match.params.id}/edit`}
path={`/wordgroups/${match.params.id}/word/new`}
icon={<AddIcon />}
helperText="wordGroups:addWordToWordGroup"
/>
Expand Down
20 changes: 9 additions & 11 deletions src/pages/WordGroup/WordGroups.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from "react";
import { useQuery } from "@apollo/react-hooks";
import { useSubscription } from "@apollo/react-hooks";

import { withStyles, WithStyles } from "@material-ui/core/styles";
import Grid from "@material-ui/core/Grid";
Expand All @@ -11,7 +11,7 @@ import Section from "../../components/Section";
import { GET_CHAPTER_WORDGROUPS } from "../../queries/chapters";
import {
chapters_wordGroups,
chapters_wordGroups_chapters_edges
chapters_wordGroups_chapters
} from "../../queries/__generated__/chapters_wordGroups";
import VoggiChapterCard from "../../components/VoggiChapterCard";

Expand All @@ -20,7 +20,7 @@ interface Props extends WithStyles<typeof styles> {
}

const WordGroups = ({ classes }: Props) => {
const { data, error, loading } = useQuery<chapters_wordGroups>(
const { data, error, loading } = useSubscription<chapters_wordGroups>(
GET_CHAPTER_WORDGROUPS
);

Expand All @@ -37,18 +37,16 @@ const WordGroups = ({ classes }: Props) => {
!loading &&
data &&
!!data.chapters &&
data.chapters.edges &&
!data.chapters.edges.length
!data.chapters.length
}
/>
{data &&
data.chapters &&
data.chapters.edges &&
data.chapters.edges.map(
(c: chapters_wordGroups_chapters_edges | null) =>
c && c.node && c.node.parentChapter ? (
<Grid item key={c.node.id}>
<VoggiChapterCard chapter={c.node} />
data.chapters.map(
(c: chapters_wordGroups_chapters | null) =>
c && c.parentChapter ? (
<Grid item key={c.id}>
<VoggiChapterCard chapter={c} />
</Grid>
) : null
)}
Expand Down
1 change: 0 additions & 1 deletion src/queries/__generated__/ChapterHeaderParts.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion src/queries/__generated__/CharacterParts.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion src/queries/__generated__/CommentParts.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion src/queries/__generated__/ComponentParts.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion src/queries/__generated__/ComponentTypeParts.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion src/queries/__generated__/ProfileParts.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion src/queries/__generated__/UserParts.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion src/queries/__generated__/WordParts.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading