From 830f28e9438996287e00a42ba54c82dc47fb9e7e Mon Sep 17 00:00:00 2001 From: Rushabh Javeri Date: Sun, 7 Aug 2022 06:53:04 +0530 Subject: [PATCH] Converted to JS using rw ts-to-js --- api/{tsconfig.json => jsconfig.json} | 0 .../{requireAuth.ts => requireAuth.js} | 0 ...equireAuth.test.ts => requireAuth.test.js} | 0 .../skipAuth/{skipAuth.ts => skipAuth.js} | 0 .../{skipAuth.test.ts => skipAuth.test.js} | 0 api/src/functions/{auth.ts => auth.js} | 1 - api/src/functions/{graphql.ts => graphql.js} | 0 .../{contacts.sdl.ts => contacts.sdl.js} | 0 .../graphql/{posts.sdl.ts => posts.sdl.js} | 0 api/src/lib/{auth.ts => auth.js} | 7 ++- api/src/lib/{db.ts => db.js} | 0 api/src/lib/{logger.ts => logger.js} | 0 api/src/services/contacts/contacts.js | 20 ++++++++ ...cts.scenarios.ts => contacts.scenarios.js} | 6 +-- .../{contacts.test.ts => contacts.test.js} | 5 +- api/src/services/contacts/contacts.ts | 24 --------- api/src/services/posts/posts.js | 30 +++++++++++ api/src/services/posts/posts.scenarios.js | 6 +++ api/src/services/posts/posts.scenarios.ts | 10 ---- .../posts/{posts.test.ts => posts.test.js} | 9 ++-- api/src/services/posts/posts.ts | 32 ------------ scripts/{tsconfig.json => jsconfig.json} | 0 scripts/{seed.ts => seed.js} | 3 ++ web/{tsconfig.json => jsconfig.json} | 0 web/src/{App.tsx => App.js} | 0 web/src/{Routes.tsx => Routes.js} | 36 +++++++++++-- .../Article/{Article.tsx => Article.js} | 9 +--- ...Article.stories.tsx => Article.stories.js} | 0 .../{Article.test.tsx => Article.test.js} | 0 web/src/components/ArticleCell/ArticleCell.js | 22 ++++++++ ...rticleCell.mock.ts => ArticleCell.mock.js} | 2 +- ...ell.stories.tsx => ArticleCell.stories.js} | 0 ...ticleCell.test.tsx => ArticleCell.test.js} | 0 .../components/ArticleCell/ArticleCell.tsx | 30 ----------- .../{ArticlesCell.tsx => ArticlesCell.js} | 10 +--- ...iclesCell.mock.ts => ArticlesCell.mock.js} | 3 +- ...ll.stories.tsx => ArticlesCell.stories.js} | 0 ...clesCell.test.tsx => ArticlesCell.test.js} | 0 .../{EditPostCell.tsx => EditPostCell.js} | 9 ++-- .../Post/NewPost/{NewPost.tsx => NewPost.js} | 1 + .../Post/Post/{Post.tsx => Post.js} | 24 ++++++--- .../PostCell/{PostCell.tsx => PostCell.js} | 8 +-- .../PostForm/{PostForm.tsx => PostForm.js} | 51 +++++++------------ .../Post/Posts/{Posts.tsx => Posts.js} | 15 +++++- .../PostsCell/{PostsCell.tsx => PostsCell.js} | 13 ++--- .../{BlogLayout.tsx => BlogLayout.js} | 11 ++-- ...yout.stories.tsx => BlogLayout.stories.js} | 0 ...BlogLayout.test.tsx => BlogLayout.test.js} | 0 .../{PostsLayout.tsx => PostsLayout.js} | 19 +++---- .../AboutPage/{AboutPage.tsx => AboutPage.js} | 0 ...tPage.stories.tsx => AboutPage.stories.js} | 0 .../{AboutPage.test.tsx => AboutPage.test.js} | 0 .../{ArticlePage.tsx => ArticlePage.js} | 6 +-- ...age.stories.tsx => ArticlePage.stories.js} | 0 ...ticlePage.test.tsx => ArticlePage.test.js} | 0 .../{ContactPage.tsx => ContactPage.js} | 24 ++++----- ...age.stories.tsx => ContactPage.stories.js} | 0 ...ntactPage.test.tsx => ContactPage.test.js} | 0 .../{FatalErrorPage.tsx => FatalErrorPage.js} | 1 + ...PasswordPage.tsx => ForgotPasswordPage.js} | 8 ++- .../HomePage/{HomePage.tsx => HomePage.js} | 1 + ...mePage.stories.tsx => HomePage.stories.js} | 0 .../{HomePage.test.tsx => HomePage.test.js} | 0 .../LoginPage/{LoginPage.tsx => LoginPage.js} | 11 +++- .../{NotFoundPage.tsx => NotFoundPage.js} | 1 + .../{EditPostPage.tsx => EditPostPage.js} | 6 +-- .../{NewPostPage.tsx => NewPostPage.js} | 0 .../PostPage/{PostPage.tsx => PostPage.js} | 6 +-- .../PostsPage/{PostsPage.tsx => PostsPage.js} | 0 ...tPasswordPage.tsx => ResetPasswordPage.js} | 7 ++- .../{SignupPage.tsx => SignupPage.js} | 12 ++++- 71 files changed, 248 insertions(+), 251 deletions(-) rename api/{tsconfig.json => jsconfig.json} (100%) rename api/src/directives/requireAuth/{requireAuth.ts => requireAuth.js} (100%) rename api/src/directives/requireAuth/{requireAuth.test.ts => requireAuth.test.js} (100%) rename api/src/directives/skipAuth/{skipAuth.ts => skipAuth.js} (100%) rename api/src/directives/skipAuth/{skipAuth.test.ts => skipAuth.test.js} (100%) rename api/src/functions/{auth.ts => auth.js} (99%) rename api/src/functions/{graphql.ts => graphql.js} (100%) rename api/src/graphql/{contacts.sdl.ts => contacts.sdl.js} (100%) rename api/src/graphql/{posts.sdl.ts => posts.sdl.js} (100%) rename api/src/lib/{auth.ts => auth.js} (94%) rename api/src/lib/{db.ts => db.js} (100%) rename api/src/lib/{logger.ts => logger.js} (100%) create mode 100644 api/src/services/contacts/contacts.js rename api/src/services/contacts/{contacts.scenarios.ts => contacts.scenarios.js} (50%) rename api/src/services/contacts/{contacts.test.ts => contacts.test.js} (82%) delete mode 100644 api/src/services/contacts/contacts.ts create mode 100644 api/src/services/posts/posts.js create mode 100644 api/src/services/posts/posts.scenarios.js delete mode 100644 api/src/services/posts/posts.scenarios.ts rename api/src/services/posts/{posts.test.ts => posts.test.js} (78%) delete mode 100644 api/src/services/posts/posts.ts rename scripts/{tsconfig.json => jsconfig.json} (100%) rename scripts/{seed.ts => seed.js} (99%) rename web/{tsconfig.json => jsconfig.json} (100%) rename web/src/{App.tsx => App.js} (100%) rename web/src/{Routes.tsx => Routes.js} (72%) rename web/src/components/Article/{Article.tsx => Article.js} (75%) rename web/src/components/Article/{Article.stories.tsx => Article.stories.js} (100%) rename web/src/components/Article/{Article.test.tsx => Article.test.js} (100%) create mode 100644 web/src/components/ArticleCell/ArticleCell.js rename web/src/components/ArticleCell/{ArticleCell.mock.ts => ArticleCell.mock.js} (90%) rename web/src/components/ArticleCell/{ArticleCell.stories.tsx => ArticleCell.stories.js} (100%) rename web/src/components/ArticleCell/{ArticleCell.test.tsx => ArticleCell.test.js} (100%) delete mode 100644 web/src/components/ArticleCell/ArticleCell.tsx rename web/src/components/ArticlesCell/{ArticlesCell.tsx => ArticlesCell.js} (59%) rename web/src/components/ArticlesCell/{ArticlesCell.mock.ts => ArticlesCell.mock.js} (94%) rename web/src/components/ArticlesCell/{ArticlesCell.stories.tsx => ArticlesCell.stories.js} (100%) rename web/src/components/ArticlesCell/{ArticlesCell.test.tsx => ArticlesCell.test.js} (100%) rename web/src/components/Post/EditPostCell/{EditPostCell.tsx => EditPostCell.js} (84%) rename web/src/components/Post/NewPost/{NewPost.tsx => NewPost.js} (99%) rename web/src/components/Post/Post/{Post.tsx => Post.js} (88%) rename web/src/components/Post/PostCell/{PostCell.tsx => PostCell.js} (60%) rename web/src/components/Post/PostForm/{PostForm.tsx => PostForm.js} (63%) rename web/src/components/Post/Posts/{Posts.tsx => Posts.js} (96%) rename web/src/components/Post/PostsCell/{PostsCell.tsx => PostsCell.js} (61%) rename web/src/layouts/BlogLayout/{BlogLayout.tsx => BlogLayout.js} (94%) rename web/src/layouts/BlogLayout/{BlogLayout.stories.tsx => BlogLayout.stories.js} (100%) rename web/src/layouts/BlogLayout/{BlogLayout.test.tsx => BlogLayout.test.js} (100%) rename web/src/layouts/PostsLayout/{PostsLayout.tsx => PostsLayout.js} (63%) rename web/src/pages/AboutPage/{AboutPage.tsx => AboutPage.js} (100%) rename web/src/pages/AboutPage/{AboutPage.stories.tsx => AboutPage.stories.js} (100%) rename web/src/pages/AboutPage/{AboutPage.test.tsx => AboutPage.test.js} (100%) rename web/src/pages/ArticlePage/{ArticlePage.tsx => ArticlePage.js} (76%) rename web/src/pages/ArticlePage/{ArticlePage.stories.tsx => ArticlePage.stories.js} (100%) rename web/src/pages/ArticlePage/{ArticlePage.test.tsx => ArticlePage.test.js} (100%) rename web/src/pages/ContactPage/{ContactPage.tsx => ContactPage.js} (89%) rename web/src/pages/ContactPage/{ContactPage.stories.tsx => ContactPage.stories.js} (100%) rename web/src/pages/ContactPage/{ContactPage.test.tsx => ContactPage.test.js} (100%) rename web/src/pages/FatalErrorPage/{FatalErrorPage.tsx => FatalErrorPage.js} (99%) rename web/src/pages/ForgotPasswordPage/{ForgotPasswordPage.tsx => ForgotPasswordPage.js} (95%) rename web/src/pages/HomePage/{HomePage.tsx => HomePage.js} (99%) rename web/src/pages/HomePage/{HomePage.stories.tsx => HomePage.stories.js} (100%) rename web/src/pages/HomePage/{HomePage.test.tsx => HomePage.test.js} (100%) rename web/src/pages/LoginPage/{LoginPage.tsx => LoginPage.js} (95%) rename web/src/pages/NotFoundPage/{NotFoundPage.tsx => NotFoundPage.js} (99%) rename web/src/pages/Post/EditPostPage/{EditPostPage.tsx => EditPostPage.js} (58%) rename web/src/pages/Post/NewPostPage/{NewPostPage.tsx => NewPostPage.js} (100%) rename web/src/pages/Post/PostPage/{PostPage.tsx => PostPage.js} (56%) rename web/src/pages/Post/PostsPage/{PostsPage.tsx => PostsPage.js} (100%) rename web/src/pages/ResetPasswordPage/{ResetPasswordPage.tsx => ResetPasswordPage.js} (97%) rename web/src/pages/SignupPage/{SignupPage.tsx => SignupPage.js} (97%) diff --git a/api/tsconfig.json b/api/jsconfig.json similarity index 100% rename from api/tsconfig.json rename to api/jsconfig.json diff --git a/api/src/directives/requireAuth/requireAuth.ts b/api/src/directives/requireAuth/requireAuth.js similarity index 100% rename from api/src/directives/requireAuth/requireAuth.ts rename to api/src/directives/requireAuth/requireAuth.js diff --git a/api/src/directives/requireAuth/requireAuth.test.ts b/api/src/directives/requireAuth/requireAuth.test.js similarity index 100% rename from api/src/directives/requireAuth/requireAuth.test.ts rename to api/src/directives/requireAuth/requireAuth.test.js diff --git a/api/src/directives/skipAuth/skipAuth.ts b/api/src/directives/skipAuth/skipAuth.js similarity index 100% rename from api/src/directives/skipAuth/skipAuth.ts rename to api/src/directives/skipAuth/skipAuth.js diff --git a/api/src/directives/skipAuth/skipAuth.test.ts b/api/src/directives/skipAuth/skipAuth.test.js similarity index 100% rename from api/src/directives/skipAuth/skipAuth.test.ts rename to api/src/directives/skipAuth/skipAuth.test.js diff --git a/api/src/functions/auth.ts b/api/src/functions/auth.js similarity index 99% rename from api/src/functions/auth.ts rename to api/src/functions/auth.js index ee9e7bafa..6f4c3fc69 100644 --- a/api/src/functions/auth.ts +++ b/api/src/functions/auth.js @@ -2,7 +2,6 @@ import { db } from 'src/lib/db' import { DbAuthHandler } from '@redwoodjs/api' export const handler = async (event, context) => { - const forgotPasswordOptions = { // handler() is invoked after verifying that a user was found with the given // username. This is where you can send the user an email with a link to diff --git a/api/src/functions/graphql.ts b/api/src/functions/graphql.js similarity index 100% rename from api/src/functions/graphql.ts rename to api/src/functions/graphql.js diff --git a/api/src/graphql/contacts.sdl.ts b/api/src/graphql/contacts.sdl.js similarity index 100% rename from api/src/graphql/contacts.sdl.ts rename to api/src/graphql/contacts.sdl.js diff --git a/api/src/graphql/posts.sdl.ts b/api/src/graphql/posts.sdl.js similarity index 100% rename from api/src/graphql/posts.sdl.ts rename to api/src/graphql/posts.sdl.js diff --git a/api/src/lib/auth.ts b/api/src/lib/auth.js similarity index 94% rename from api/src/lib/auth.ts rename to api/src/lib/auth.js index 07234fb46..9efe80814 100644 --- a/api/src/lib/auth.ts +++ b/api/src/lib/auth.js @@ -31,7 +31,7 @@ export const getCurrentUser = async (session) => { * * @returns {boolean} - If the currentUser is authenticated */ -export const isAuthenticated = (): boolean => { +export const isAuthenticated = () => { return !!context.currentUser } @@ -39,7 +39,6 @@ export const isAuthenticated = (): boolean => { * When checking role membership, roles can be a single value, a list, or none. * You can use Prisma enums too (if you're using them for roles), just import your enum type from `@prisma/client` */ -type AllowedRoles = string | string[] | undefined /** * Checks if the currentUser is authenticated (and assigned one of the given roles) @@ -49,7 +48,7 @@ type AllowedRoles = string | string[] | undefined * @returns {boolean} - Returns true if the currentUser is logged in and assigned one of the given roles, * or when no roles are provided to check against. Otherwise returns false. */ -export const hasRole = (roles: AllowedRoles): boolean => { +export const hasRole = (roles) => { if (!isAuthenticated()) { return false } @@ -98,7 +97,7 @@ export const hasRole = (roles: AllowedRoles): boolean => { * * @see https://github.com/redwoodjs/redwood/tree/main/packages/auth for examples */ -export const requireAuth = ({ roles }: { roles: AllowedRoles }) => { +export const requireAuth = ({ roles }) => { if (!isAuthenticated()) { throw new AuthenticationError("You don't have permission to do that.") } diff --git a/api/src/lib/db.ts b/api/src/lib/db.js similarity index 100% rename from api/src/lib/db.ts rename to api/src/lib/db.js diff --git a/api/src/lib/logger.ts b/api/src/lib/logger.js similarity index 100% rename from api/src/lib/logger.ts rename to api/src/lib/logger.js diff --git a/api/src/services/contacts/contacts.js b/api/src/services/contacts/contacts.js new file mode 100644 index 000000000..066d47742 --- /dev/null +++ b/api/src/services/contacts/contacts.js @@ -0,0 +1,20 @@ +import { validate } from '@redwoodjs/api' + +import { db } from 'src/lib/db' + +export const contacts = () => { + return db.contact.findMany() +} + +export const contact = ({ id }) => { + return db.contact.findUnique({ + where: { id }, + }) +} + +export const createContact = ({ input }) => { + validate(input.email, 'email', { email: true }) + return db.contact.create({ + data: input, + }) +} diff --git a/api/src/services/contacts/contacts.scenarios.ts b/api/src/services/contacts/contacts.scenarios.js similarity index 50% rename from api/src/services/contacts/contacts.scenarios.ts rename to api/src/services/contacts/contacts.scenarios.js index 9ff86a68a..6a8dd4554 100644 --- a/api/src/services/contacts/contacts.scenarios.ts +++ b/api/src/services/contacts/contacts.scenarios.js @@ -1,6 +1,4 @@ -import type { Prisma } from '@prisma/client' - -export const standard = defineScenario({ +export const standard = defineScenario({ contact: { john: { data: { @@ -11,5 +9,3 @@ export const standard = defineScenario({ }, }, }) - -export type StandardScenario = typeof standard diff --git a/api/src/services/contacts/contacts.test.ts b/api/src/services/contacts/contacts.test.js similarity index 82% rename from api/src/services/contacts/contacts.test.ts rename to api/src/services/contacts/contacts.test.js index dfbd0bb78..6515c9983 100644 --- a/api/src/services/contacts/contacts.test.ts +++ b/api/src/services/contacts/contacts.test.js @@ -1,5 +1,4 @@ import { contacts, contact, createContact } from './contacts' -import type { StandardScenario } from './contacts.scenarios' // Generated boilerplate tests do not account for all circumstances // and can fail without adjustments, e.g. Float and DateTime types. @@ -8,13 +7,13 @@ import type { StandardScenario } from './contacts.scenarios' // https://redwoodjs.com/docs/testing#jest-expect-type-considerations describe('contacts', () => { - scenario('returns all contacts', async (scenario: StandardScenario) => { + scenario('returns all contacts', async (scenario) => { const result = await contacts() expect(result.length).toEqual(Object.keys(scenario.contact).length) }) - scenario('returns a single contact', async (scenario: StandardScenario) => { + scenario('returns a single contact', async (scenario) => { const result = await contact({ id: scenario.contact.john.id }) expect(result).toEqual(scenario.contact.john) diff --git a/api/src/services/contacts/contacts.ts b/api/src/services/contacts/contacts.ts deleted file mode 100644 index 323d4c038..000000000 --- a/api/src/services/contacts/contacts.ts +++ /dev/null @@ -1,24 +0,0 @@ -import type { QueryResolvers, MutationResolvers } from 'types/graphql' - -import { validate } from '@redwoodjs/api' - -import { db } from 'src/lib/db' - -export const contacts: QueryResolvers['contacts'] = () => { - return db.contact.findMany() -} - -export const contact: QueryResolvers['contact'] = ({ id }) => { - return db.contact.findUnique({ - where: { id }, - }) -} - -export const createContact: MutationResolvers['createContact'] = ({ - input, -}) => { - validate(input.email, 'email', { email: true }) - return db.contact.create({ - data: input, - }) -} diff --git a/api/src/services/posts/posts.js b/api/src/services/posts/posts.js new file mode 100644 index 000000000..3d680c99d --- /dev/null +++ b/api/src/services/posts/posts.js @@ -0,0 +1,30 @@ +import { db } from 'src/lib/db' + +export const posts = () => { + return db.post.findMany() +} + +export const post = ({ id }) => { + return db.post.findUnique({ + where: { id }, + }) +} + +export const createPost = ({ input }) => { + return db.post.create({ + data: input, + }) +} + +export const updatePost = ({ id, input }) => { + return db.post.update({ + data: input, + where: { id }, + }) +} + +export const deletePost = ({ id }) => { + return db.post.delete({ + where: { id }, + }) +} diff --git a/api/src/services/posts/posts.scenarios.js b/api/src/services/posts/posts.scenarios.js new file mode 100644 index 000000000..81261539b --- /dev/null +++ b/api/src/services/posts/posts.scenarios.js @@ -0,0 +1,6 @@ +export const standard = defineScenario({ + post: { + one: { data: { title: 'String', body: 'String' } }, + two: { data: { title: 'String', body: 'String' } }, + }, +}) diff --git a/api/src/services/posts/posts.scenarios.ts b/api/src/services/posts/posts.scenarios.ts deleted file mode 100644 index 05b59dfde..000000000 --- a/api/src/services/posts/posts.scenarios.ts +++ /dev/null @@ -1,10 +0,0 @@ -import type { Prisma } from '@prisma/client' - -export const standard = defineScenario({ - post: { - one: { data: { title: 'String', body: 'String' } }, - two: { data: { title: 'String', body: 'String' } }, - }, -}) - -export type StandardScenario = typeof standard diff --git a/api/src/services/posts/posts.test.ts b/api/src/services/posts/posts.test.js similarity index 78% rename from api/src/services/posts/posts.test.ts rename to api/src/services/posts/posts.test.js index 124cf38b2..12eb27e77 100644 --- a/api/src/services/posts/posts.test.ts +++ b/api/src/services/posts/posts.test.js @@ -1,5 +1,4 @@ import { posts, post, createPost, updatePost, deletePost } from './posts' -import type { StandardScenario } from './posts.scenarios' // Generated boilerplate tests do not account for all circumstances // and can fail without adjustments, e.g. Float and DateTime types. @@ -8,13 +7,13 @@ import type { StandardScenario } from './posts.scenarios' // https://redwoodjs.com/docs/testing#jest-expect-type-considerations describe('posts', () => { - scenario('returns all posts', async (scenario: StandardScenario) => { + scenario('returns all posts', async (scenario) => { const result = await posts() expect(result.length).toEqual(Object.keys(scenario.post).length) }) - scenario('returns a single post', async (scenario: StandardScenario) => { + scenario('returns a single post', async (scenario) => { const result = await post({ id: scenario.post.one.id }) expect(result).toEqual(scenario.post.one) @@ -29,7 +28,7 @@ describe('posts', () => { expect(result.body).toEqual('String') }) - scenario('updates a post', async (scenario: StandardScenario) => { + scenario('updates a post', async (scenario) => { const original = await post({ id: scenario.post.one.id }) const result = await updatePost({ id: original.id, @@ -39,7 +38,7 @@ describe('posts', () => { expect(result.title).toEqual('String2') }) - scenario('deletes a post', async (scenario: StandardScenario) => { + scenario('deletes a post', async (scenario) => { const original = await deletePost({ id: scenario.post.one.id }) const result = await post({ id: original.id }) diff --git a/api/src/services/posts/posts.ts b/api/src/services/posts/posts.ts deleted file mode 100644 index 877d9fa74..000000000 --- a/api/src/services/posts/posts.ts +++ /dev/null @@ -1,32 +0,0 @@ -import type { QueryResolvers, MutationResolvers } from 'types/graphql' - -import { db } from 'src/lib/db' - -export const posts: QueryResolvers['posts'] = () => { - return db.post.findMany() -} - -export const post: QueryResolvers['post'] = ({ id }) => { - return db.post.findUnique({ - where: { id }, - }) -} - -export const createPost: MutationResolvers['createPost'] = ({ input }) => { - return db.post.create({ - data: input, - }) -} - -export const updatePost: MutationResolvers['updatePost'] = ({ id, input }) => { - return db.post.update({ - data: input, - where: { id }, - }) -} - -export const deletePost: MutationResolvers['deletePost'] = ({ id }) => { - return db.post.delete({ - where: { id }, - }) -} diff --git a/scripts/tsconfig.json b/scripts/jsconfig.json similarity index 100% rename from scripts/tsconfig.json rename to scripts/jsconfig.json diff --git a/scripts/seed.ts b/scripts/seed.js similarity index 99% rename from scripts/seed.ts rename to scripts/seed.js index 0adeb0487..198f1e4e0 100644 --- a/scripts/seed.ts +++ b/scripts/seed.js @@ -7,11 +7,13 @@ export default async () => { title: 'Welcome to the blog!', body: "I'm baby single- origin coffee kickstarter lo - fi paleo skateboard.Tumblr hashtag austin whatever DIY plaid knausgaard fanny pack messenger bag blog next level woke.Ethical bitters fixie freegan,helvetica pitchfork 90's tbh chillwave mustache godard subway tile ramps art party. Hammock sustainable twee yr bushwick disrupt unicorn, before they sold out direct trade chicharrones etsy polaroid hoodie. Gentrify offal hoodie fingerstache.", }, + { id: 2, title: 'A little more about me', body: "Raclette shoreditch before they sold out lyft. Ethical bicycle rights meh prism twee. Tote bag ennui vice, slow-carb taiyaki crucifix whatever you probably haven't heard of them jianbing raw denim DIY hot chicken. Chillwave blog succulents freegan synth af ramps poutine wayfarers yr seitan roof party squid. Jianbing flexitarian gentrify hexagon portland single-origin coffee raclette gluten-free. Coloring book cloud bread street art kitsch lumbersexual af distillery ethical ugh thundercats roof party poke chillwave. 90's palo santo green juice subway tile, prism viral butcher selvage etsy pitchfork sriracha tumeric bushwick.", }, + { id: 3, title: 'What is the meaning of life?', @@ -39,6 +41,7 @@ export default async () => { 'ad9563042fe9f154419361eeeb775d8a12f3975a3722953fd8e326dd108d5645', salt: '1c99de412b219e9abf4665293211adce', }, + update: {}, }) diff --git a/web/tsconfig.json b/web/jsconfig.json similarity index 100% rename from web/tsconfig.json rename to web/jsconfig.json diff --git a/web/src/App.tsx b/web/src/App.js similarity index 100% rename from web/src/App.tsx rename to web/src/App.js diff --git a/web/src/Routes.tsx b/web/src/Routes.js similarity index 72% rename from web/src/Routes.tsx rename to web/src/Routes.js index 493c38460..5d9268c3d 100644 --- a/web/src/Routes.tsx +++ b/web/src/Routes.js @@ -16,23 +16,51 @@ const Routes = () => { return ( + - - + + + + + - - + + + + + + + + + + ) diff --git a/web/src/components/Article/Article.tsx b/web/src/components/Article/Article.js similarity index 75% rename from web/src/components/Article/Article.tsx rename to web/src/components/Article/Article.js index e0fa96477..ec0b17a64 100644 --- a/web/src/components/Article/Article.tsx +++ b/web/src/components/Article/Article.js @@ -1,12 +1,6 @@ -import type { Post } from 'types/graphql' - import { Link, routes } from '@redwoodjs/router' -interface Props { - article: Post -} - -const Article = ({ article }: Props) => { +const Article = ({ article }) => { return (
@@ -14,6 +8,7 @@ const Article = ({ article }: Props) => { {article.title}
+
{article.body}
) diff --git a/web/src/components/Article/Article.stories.tsx b/web/src/components/Article/Article.stories.js similarity index 100% rename from web/src/components/Article/Article.stories.tsx rename to web/src/components/Article/Article.stories.js diff --git a/web/src/components/Article/Article.test.tsx b/web/src/components/Article/Article.test.js similarity index 100% rename from web/src/components/Article/Article.test.tsx rename to web/src/components/Article/Article.test.js diff --git a/web/src/components/ArticleCell/ArticleCell.js b/web/src/components/ArticleCell/ArticleCell.js new file mode 100644 index 000000000..437d0e1cb --- /dev/null +++ b/web/src/components/ArticleCell/ArticleCell.js @@ -0,0 +1,22 @@ +import Article from 'src/components/Article' + +export const QUERY = gql` + query FindArticleQuery($id: Int!) { + article: post(id: $id) { + id + title + body + createdAt + } + } +` + +export const Loading = () =>
Loading...
+ +export const Empty = () =>
Empty
+ +export const Failure = ({ error }) =>
Error: {error.message}
+ +export const Success = ({ article }) => { + return
+} diff --git a/web/src/components/ArticleCell/ArticleCell.mock.ts b/web/src/components/ArticleCell/ArticleCell.mock.js similarity index 90% rename from web/src/components/ArticleCell/ArticleCell.mock.ts rename to web/src/components/ArticleCell/ArticleCell.mock.js index 0d7a805f6..b74c87905 100644 --- a/web/src/components/ArticleCell/ArticleCell.mock.ts +++ b/web/src/components/ArticleCell/ArticleCell.mock.js @@ -1,5 +1,5 @@ // Define your own mock data here: -export const standard = (/* vars, { ctx, req } */) => ({ +export const standard = () => ({ article: { id: 1, title: 'First Post', diff --git a/web/src/components/ArticleCell/ArticleCell.stories.tsx b/web/src/components/ArticleCell/ArticleCell.stories.js similarity index 100% rename from web/src/components/ArticleCell/ArticleCell.stories.tsx rename to web/src/components/ArticleCell/ArticleCell.stories.js diff --git a/web/src/components/ArticleCell/ArticleCell.test.tsx b/web/src/components/ArticleCell/ArticleCell.test.js similarity index 100% rename from web/src/components/ArticleCell/ArticleCell.test.tsx rename to web/src/components/ArticleCell/ArticleCell.test.js diff --git a/web/src/components/ArticleCell/ArticleCell.tsx b/web/src/components/ArticleCell/ArticleCell.tsx deleted file mode 100644 index 22d5c485d..000000000 --- a/web/src/components/ArticleCell/ArticleCell.tsx +++ /dev/null @@ -1,30 +0,0 @@ -import type { FindArticleQuery, FindArticleQueryVariables } from 'types/graphql' - -import type { CellSuccessProps, CellFailureProps } from '@redwoodjs/web' - -import Article from 'src/components/Article' - -export const QUERY = gql` - query FindArticleQuery($id: Int!) { - article: post(id: $id) { - id - title - body - createdAt - } - } -` - -export const Loading = () =>
Loading...
- -export const Empty = () =>
Empty
- -export const Failure = ({ - error, -}: CellFailureProps) => ( -
Error: {error.message}
-) - -export const Success = ({ article }: CellSuccessProps) => { - return
-} diff --git a/web/src/components/ArticlesCell/ArticlesCell.tsx b/web/src/components/ArticlesCell/ArticlesCell.js similarity index 59% rename from web/src/components/ArticlesCell/ArticlesCell.tsx rename to web/src/components/ArticlesCell/ArticlesCell.js index 9bdd723c7..6b0b3ddb9 100644 --- a/web/src/components/ArticlesCell/ArticlesCell.tsx +++ b/web/src/components/ArticlesCell/ArticlesCell.js @@ -1,7 +1,3 @@ -import type { PostsQuery } from 'types/graphql' - -import type { CellSuccessProps, CellFailureProps } from '@redwoodjs/web' - import Article from 'src/components/Article' export const QUERY = gql` @@ -19,11 +15,9 @@ export const Loading = () =>
Loading...
export const Empty = () =>
Empty
-export const Failure = ({ error }: CellFailureProps) => ( -
Error: {error.message}
-) +export const Failure = ({ error }) =>
Error: {error.message}
-export const Success = ({ articles }: CellSuccessProps) => { +export const Success = ({ articles }) => { return (
{articles.map((article) => ( diff --git a/web/src/components/ArticlesCell/ArticlesCell.mock.ts b/web/src/components/ArticlesCell/ArticlesCell.mock.js similarity index 94% rename from web/src/components/ArticlesCell/ArticlesCell.mock.ts rename to web/src/components/ArticlesCell/ArticlesCell.mock.js index 6b249fc4f..fdd293ad6 100644 --- a/web/src/components/ArticlesCell/ArticlesCell.mock.ts +++ b/web/src/components/ArticlesCell/ArticlesCell.mock.js @@ -1,5 +1,5 @@ // Define your own mock data here: -export const standard = (/* vars, { ctx, req } */) => ({ +export const standard = () => ({ articles: [ { id: 1, @@ -7,6 +7,7 @@ export const standard = (/* vars, { ctx, req } */) => ({ body: `Neutra tacos hot chicken prism raw denim, put a bird on it enamel pin post-ironic vape cred DIY. Street art next level umami squid. Hammock hexagon glossier 8-bit banjo. Neutra la croix mixtape echo park four loko semiotics kitsch forage chambray. Semiotics salvia selfies jianbing hella shaman. Letterpress helvetica vaporware cronut, shaman butcher YOLO poke fixie hoodie gentrify woke heirloom.`, createdAt: '2020-01-01T12:34:56Z', }, + { id: 2, title: 'Second Post', diff --git a/web/src/components/ArticlesCell/ArticlesCell.stories.tsx b/web/src/components/ArticlesCell/ArticlesCell.stories.js similarity index 100% rename from web/src/components/ArticlesCell/ArticlesCell.stories.tsx rename to web/src/components/ArticlesCell/ArticlesCell.stories.js diff --git a/web/src/components/ArticlesCell/ArticlesCell.test.tsx b/web/src/components/ArticlesCell/ArticlesCell.test.js similarity index 100% rename from web/src/components/ArticlesCell/ArticlesCell.test.tsx rename to web/src/components/ArticlesCell/ArticlesCell.test.js diff --git a/web/src/components/Post/EditPostCell/EditPostCell.tsx b/web/src/components/Post/EditPostCell/EditPostCell.js similarity index 84% rename from web/src/components/Post/EditPostCell/EditPostCell.tsx rename to web/src/components/Post/EditPostCell/EditPostCell.js index 67b6b3e9c..687a0284e 100644 --- a/web/src/components/Post/EditPostCell/EditPostCell.tsx +++ b/web/src/components/Post/EditPostCell/EditPostCell.js @@ -1,7 +1,5 @@ -import type { EditPostById } from 'types/graphql' - import { navigate, routes } from '@redwoodjs/router' -import type { CellSuccessProps, CellFailureProps } from '@redwoodjs/web' + import { useMutation } from '@redwoodjs/web' import { toast } from '@redwoodjs/web/toast' @@ -30,11 +28,11 @@ const UPDATE_POST_MUTATION = gql` export const Loading = () =>
Loading...
-export const Failure = ({ error }: CellFailureProps) => ( +export const Failure = ({ error }) => (
{error.message}
) -export const Success = ({ post }: CellSuccessProps) => { +export const Success = ({ post }) => { const [updatePost, { loading, error }] = useMutation(UPDATE_POST_MUTATION, { onCompleted: () => { toast.success('Post updated') @@ -54,6 +52,7 @@ export const Success = ({ post }: CellSuccessProps) => {

Edit Post {post.id}

+
diff --git a/web/src/components/Post/NewPost/NewPost.tsx b/web/src/components/Post/NewPost/NewPost.js similarity index 99% rename from web/src/components/Post/NewPost/NewPost.tsx rename to web/src/components/Post/NewPost/NewPost.js index 63affd233..fd6bb36bd 100644 --- a/web/src/components/Post/NewPost/NewPost.tsx +++ b/web/src/components/Post/NewPost/NewPost.js @@ -32,6 +32,7 @@ const NewPost = () => {

New Post

+
diff --git a/web/src/components/Post/Post/Post.tsx b/web/src/components/Post/Post/Post.js similarity index 88% rename from web/src/components/Post/Post/Post.tsx rename to web/src/components/Post/Post/Post.js index 2569dd625..095f41406 100644 --- a/web/src/components/Post/Post/Post.tsx +++ b/web/src/components/Post/Post/Post.js @@ -12,13 +12,13 @@ const DELETE_POST_MUTATION = gql` } ` -const formatEnum = (values: string | string[] | null | undefined) => { +const formatEnum = (values) => { if (values) { if (Array.isArray(values)) { const humanizedValues = values.map((value) => humanize(value)) return humanizedValues.join(', ') } else { - return humanize(values as string) + return humanize(values) } } } @@ -66,26 +66,37 @@ const Post = ({ post }) => { <>
-

Post {post.id} Detail

+

+ Post {post.id} Detail +

+ + - + + + - + + + - + + +
Id{post.id}
Title{post.title}
Body{post.body}
Created at{timeTag(post.createdAt)}
+