Skip to content

Commit

Permalink
feat: integrate ordered exercises
Browse files Browse the repository at this point in the history
  • Loading branch information
rumizz committed Dec 28, 2024
1 parent 043e8df commit e6955fb
Show file tree
Hide file tree
Showing 10 changed files with 283 additions and 72 deletions.
6 changes: 3 additions & 3 deletions src/components/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import {
ListItemButton,
ListItemText,
Stack,
ToggleButton,
ToggleButtonGroup,
Typography,
alpha,
useColorScheme,
ToggleButtonGroup,
ToggleButton,
} from "@mui/material";
import { signOut as firebaseSignout } from "firebase/auth";
import { useSetAtom } from "jotai";
Expand Down Expand Up @@ -58,7 +58,7 @@ export const Sidebar = () => {
>
<Box sx={{ width: drawerWidth }} role="presentation" pt={2} height="100%">
<Stack height="100%" sx={{ p: 2 }}>
<Typography width="100%" textAlign="center">
<Typography width="100%" textAlign="center" mb={2}>
Feladatbeküldő
</Typography>
<Stack gap={1}>
Expand Down
2 changes: 1 addition & 1 deletion src/components/compose/ExerciseCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ const ExerciseCard: FC<{
exerciseView === ExerciseView.CARD
? view === "all"
? 72
: 200
: 198
: "fit-content";

return (
Expand Down
12 changes: 6 additions & 6 deletions src/components/compose/Item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ export const Item: FC<{
const setItems = useSetAtom(composeAtom);

const height =
exerciseView === ExerciseView.CARD
? view === "all"
? 76
: 200
: "fit-content";
view === "all"
? 76
: exerciseView === ExerciseView.CARD
? 200
: "fit-content";
if (loading) {
return <Skeleton width={"100%"} height={height} />;
}
Expand Down Expand Up @@ -102,7 +102,7 @@ export const Item: FC<{
<ExerciseCard id={id} exercise={data.exercise} />
</motion.div>
) : (
<Placeholder order={order} />
<Placeholder order={order} height={height} />
)}
</Box>
);
Expand Down
7 changes: 5 additions & 2 deletions src/components/compose/Placeholder.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import { Card, Stack, Typography } from "@mui/material";
import { FC } from "react";

export const Placeholder: FC<{ order: number }> = ({ order }) => {
export const Placeholder: FC<{ order: number; height: number | string }> = ({
order,
height,
}) => {
return (
<Card
component={"div"}
sx={{
width: "100%",
height: 76,
height,
borderRadius: 1,
background: "transparent",
transition: "0.2s",
Expand Down
170 changes: 167 additions & 3 deletions src/generated/graphql.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1931,6 +1931,30 @@
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "talonItems",
"description": null,
"args": [],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "LIST",
"name": null,
"ofType": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "OBJECT",
"name": "ExerciseSheetTalonItem",
"ofType": null
}
}
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "updatedAt",
"description": null,
Expand Down Expand Up @@ -2038,7 +2062,7 @@
"name": null,
"ofType": {
"kind": "OBJECT",
"name": "Exercise",
"name": "OrderedExercise",
"ofType": null
}
}
Expand Down Expand Up @@ -2121,8 +2145,8 @@
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "ID",
"kind": "INPUT_OBJECT",
"name": "OrderedExerciseInput",
"ofType": null
}
}
Expand Down Expand Up @@ -2153,6 +2177,58 @@
"enumValues": null,
"possibleTypes": null
},
{
"kind": "OBJECT",
"name": "ExerciseSheetTalonItem",
"description": null,
"isOneOf": null,
"fields": [
{
"name": "exercises",
"description": null,
"args": [],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "LIST",
"name": null,
"ofType": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "OBJECT",
"name": "OrderedExercise",
"ofType": null
}
}
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "id",
"description": null,
"args": [],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "ID",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
}
],
"inputFields": null,
"interfaces": [],
"enumValues": null,
"possibleTypes": null
},
{
"kind": "ENUM",
"name": "ExerciseStatus",
Expand Down Expand Up @@ -3532,6 +3608,94 @@
],
"possibleTypes": null
},
{
"kind": "OBJECT",
"name": "OrderedExercise",
"description": null,
"isOneOf": null,
"fields": [
{
"name": "exercise",
"description": null,
"args": [],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "OBJECT",
"name": "Exercise",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "order",
"description": null,
"args": [],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "Int",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
}
],
"inputFields": null,
"interfaces": [],
"enumValues": null,
"possibleTypes": null
},
{
"kind": "INPUT_OBJECT",
"name": "OrderedExerciseInput",
"description": null,
"isOneOf": false,
"fields": null,
"inputFields": [
{
"name": "exerciseID",
"description": null,
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "ID",
"ofType": null
}
},
"defaultValue": null,
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "order",
"description": null,
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "Int",
"ofType": null
}
},
"defaultValue": null,
"isDeprecated": false,
"deprecationReason": null
}
],
"interfaces": null,
"enumValues": null,
"possibleTypes": null
},
{
"kind": "OBJECT",
"name": "Query",
Expand Down
43 changes: 32 additions & 11 deletions src/generated/graphql.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ export type ExerciseSheet = {
id: Scalars['ID']['output'];
name: Scalars['String']['output'];
sheetItems: Array<ExerciseSheetItem>;
talonItems: Array<ExerciseSheetTalonItem>;
updatedAt: Scalars['String']['output'];
};

Expand All @@ -200,17 +201,23 @@ export type ExerciseSheetInput = {
export type ExerciseSheetItem = {
__typename: 'ExerciseSheetItem';
ageGroup: ExerciseAgeGroup;
exercises: Array<Exercise>;
exercises: Array<OrderedExercise>;
id: Scalars['ID']['output'];
level: Scalars['Int']['output'];
};

export type ExerciseSheetItemInput = {
ageGroup: ExerciseAgeGroup;
exercises: Array<Scalars['ID']['input']>;
exercises: Array<OrderedExerciseInput>;
level: Scalars['Int']['input'];
};

export type ExerciseSheetTalonItem = {
__typename: 'ExerciseSheetTalonItem';
exercises: Array<OrderedExercise>;
id: Scalars['ID']['output'];
};

export type ExerciseStatus =
| 'APPROVED'
| 'CREATED'
Expand Down Expand Up @@ -393,6 +400,17 @@ export type OrderDirection =
| 'ASC'
| 'DESC';

export type OrderedExercise = {
__typename: 'OrderedExercise';
exercise: Exercise;
order: Scalars['Int']['output'];
};

export type OrderedExerciseInput = {
exerciseID: Scalars['ID']['input'];
order: Scalars['Int']['input'];
};

export type Query = {
__typename: 'Query';
alternativeDifficultyExerciseGroups: Array<AlternativeDifficultyExerciseGroup>;
Expand Down Expand Up @@ -598,7 +616,7 @@ export type ExerciseSheetQueryVariables = Exact<{
}>;


export type ExerciseSheetQuery = { __typename: 'Query', exerciseSheet?: { __typename: 'ExerciseSheet', id: string, name: string, createdAt: string, updatedAt: string, sheetItems: Array<{ __typename: 'ExerciseSheetItem', id: string, ageGroup: ExerciseAgeGroup, level: number, exercises: Array<{ __typename: 'Exercise', id: string, description: string, exerciseImage?: { __typename: 'Image', url: string } | null, difficulty: Array<{ __typename: 'ExerciseDifficulty', ageGroup: ExerciseAgeGroup, difficulty: number }> }> }>, createdBy: { __typename: 'User', name: string } } | null };
export type ExerciseSheetQuery = { __typename: 'Query', exerciseSheet?: { __typename: 'ExerciseSheet', id: string, name: string, createdAt: string, updatedAt: string, sheetItems: Array<{ __typename: 'ExerciseSheetItem', id: string, ageGroup: ExerciseAgeGroup, level: number, exercises: Array<{ __typename: 'OrderedExercise', order: number, exercise: { __typename: 'Exercise', id: string, description: string, exerciseImage?: { __typename: 'Image', url: string } | null, difficulty: Array<{ __typename: 'ExerciseDifficulty', ageGroup: ExerciseAgeGroup, difficulty: number }> } }> }>, createdBy: { __typename: 'User', name: string } } | null };

export type ExerciseSheetsQueryVariables = Exact<{ [key: string]: never; }>;

Expand Down Expand Up @@ -1215,15 +1233,18 @@ export const ExerciseSheetDocument = gql`
ageGroup
level
exercises {
id
exerciseImage {
url
}
difficulty {
ageGroup
difficulty
order
exercise {
id
exerciseImage {
url
}
difficulty {
ageGroup
difficulty
}
description
}
description
}
}
createdAt
Expand Down
Loading

0 comments on commit e6955fb

Please sign in to comment.