投稿時間:2021-07-27 10:39:52 RSSフィード2021-07-27 10:00 分まとめ(41件)

カテゴリー等 サイト名等 記事タイトル・トレンドワード等 リンクURL 頻出ワード・要約等/検索ボリューム 登録日
TECH Engadget Japanese 【動画】『APEX Legends』新シーズン予告。変わり果てたWorld's Edgeと新武器ランページLMGなど https://japanese.engadget.com/apex-legends-emergence-season-gameplay-trailer-004025843.html apexlegends 2021-07-27 00:40:25
IT ITmedia 総合記事一覧 [ITmedia News] Intel、nmではない新命名法でのロードマップを発表 次は「Intel 7」に https://www.itmedia.co.jp/news/articles/2107/27/news077.html alderlake 2021-07-27 09:46:00
IT ITmedia 総合記事一覧 [ITmedia News] 「歓迎されないオリンピック」は本当か? 実は売れているBS4Kレコーダーと世論の関係 https://www.itmedia.co.jp/news/articles/2107/27/news076.html itmedia 2021-07-27 09:44:00
IT ITmedia 総合記事一覧 [ITmedia ビジネスオンライン] 実施人口は16年で2倍! 「筋トレ」を日本の成長戦略の柱に置くべき理由 https://www.itmedia.co.jp/business/articles/2107/27/news055.html itmedia 2021-07-27 09:36:00
IT ITmedia 総合記事一覧 [ITmedia ビジネスオンライン] 首都圏版「住みここちランキング2021」 3年連続1位の街は? https://www.itmedia.co.jp/business/articles/2107/27/news057.html itmedia 2021-07-27 09:30:00
IT ITmedia 総合記事一覧 [ITmedia News] 経営者・平井一夫氏はソニーをどう復活させたのか 15年追ってきた記者が『ソニー再生』を読む https://www.itmedia.co.jp/news/articles/2107/27/news075.html itmedia 2021-07-27 09:25:00
IT ITmedia 総合記事一覧 [ITmedia PC USER] 2025年までに「1.8nm相当」に――Intelが半導体生産のロードマップを説明 https://www.itmedia.co.jp/pcuser/articles/2107/27/news069.html intel 2021-07-27 09:15:00
IT ITmedia 総合記事一覧 [ITmedia News] 次期Mac ProはApple Siliconではない? Mac Pro (2022) はIntel Xeon W 3300搭載か https://www.itmedia.co.jp/news/articles/2107/27/news074.html applesilicon 2021-07-27 09:11:00
IT ITmedia 総合記事一覧 [ITmedia ビジネスオンライン] 銀行とセキュリティ 6人に1人がパスワード使い回し https://www.itmedia.co.jp/business/articles/2107/27/news072.html itmedia 2021-07-27 09:08:00
AWS AWS Architecture Blog Improving Retail Forecast Accuracy with Machine Learning https://aws.amazon.com/blogs/architecture/improving-retail-forecast-accuracy-with-machine-learning/ Improving Retail Forecast Accuracy with Machine LearningThe global retail market continues to grow larger and the influx of consumer data increases daily The rise in volume variety and velocity of data poses challenges with demand forecasting and inventory planning Outdated systems generate inaccurate demand forecasts This results in multiple challenges for retailers They are faced with over stocking and lost sales and … 2021-07-27 00:41:26
AWS AWS DevOps Blog Choosing a Well-Architected CI/CD approach: Open Source on AWS https://aws.amazon.com/blogs/devops/choosing-a-well-architected-ci-cd-approach-open-source-on-aws/ Choosing a Well Architected CI CD approach Open Source on AWSIntroduction When building a CI CD platform it is important to make an informed decision regarding every underlying tool This post explores evaluating the criteria for selecting each tool focusing on a balance between meeting functional and non functional requirements and maximizing value Your first decision source code management Source code is potentially your most valuable asset … 2021-07-27 00:41:36
AWS AWS DevOps Blog Use the Snyk CLI to scan Python packages using AWS CodeCommit, AWS CodePipeline, and AWS CodeBuild https://aws.amazon.com/blogs/devops/snyk-cli-scan-python-codecommit-codepipeline-codebuild/ codebuildlearn 2021-07-27 00:34:52
AWS AWS Security Blog New 2021 H1 IRAP report is now available on AWS Artifact for Australian customers https://aws.amazon.com/blogs/security/new-2021-h1-irap-report-is-now-available-on-aws-artifact-for-australian-customers/ New H IRAP report is now available on AWS Artifact for Australian customersWe are excited to announce that an additional AWS services are now assessed to be in scope for Information Security Registered Assessors Program IRAP after a successful incremental audit completed in June by independent ASD Australian Signals Directorate certified IRAP assessor This brings the total to services assessed at IRAP PROTECTED level … 2021-07-27 00:58:17
AWS AWS Japan Blog AWS SDK for Java 2.x がリリースされました https://aws.amazon.com/jp/blogs/news/aws-sdk-for-java-2-x-released/ x非同期クライアントはHTTP層までノンブロッキングになっており、少数の固定スレッドで同時実行性が高くなります。 2021-07-27 00:46:13
AWS AWS Security Blog New 2021 H1 IRAP report is now available on AWS Artifact for Australian customers https://aws.amazon.com/blogs/security/new-2021-h1-irap-report-is-now-available-on-aws-artifact-for-australian-customers/ New H IRAP report is now available on AWS Artifact for Australian customersWe are excited to announce that an additional AWS services are now assessed to be in scope for Information Security Registered Assessors Program IRAP after a successful incremental audit completed in June by independent ASD Australian Signals Directorate certified IRAP assessor This brings the total to services assessed at IRAP PROTECTED level … 2021-07-27 00:58:17
デザイン コリス プロのUIデザイナーに学ぶ!UIとUXの印象がよくなるデザインの知識とテクニックのまとめ vol.7 https://coliss.com/articles/build-websites/operation/design/ui-ux-micro-tips-volume-seven.html 続きを読む 2021-07-27 00:36:06
js JavaScriptタグが付けられた新着投稿 - Qiita javascriptの分割代入 https://qiita.com/Sakaiyu-0321/items/884193bcae6e94a78552 javascriptの分割代入分割代入を使用するとconstMyProfilenameゆうageconsttest名前はMyProfilenameです。 2021-07-27 09:38:00
Program [全てのタグ]の新着質問一覧|teratail(テラテイル) JavaScript input range https://teratail.com/questions/351394?rss=all 2021-07-27 09:55:48
Program [全てのタグ]の新着質問一覧|teratail(テラテイル) 【python】googletransの原文を日本語に設定できない https://teratail.com/questions/351393?rss=all 【python】googletransの原文を日本語に設定できないやりたいことpythonnbspgoogletransライブラリnbspで日本語を英語に翻訳したいです。 2021-07-27 09:49:33
Program [全てのタグ]の新着質問一覧|teratail(テラテイル) Javascriptの標準入力で一つの配列の中にある二つの単語の位置を反転させて表示させたい。 https://teratail.com/questions/351392?rss=all Javascriptの標準入力で一つの配列の中にある二つの単語の位置を反転させて表示させたい。 2021-07-27 09:42:54
Program [全てのタグ]の新着質問一覧|teratail(テラテイル) elementor proについてのご質問 https://teratail.com/questions/351391?rss=all elementorproについてのご質問wordpressについてのご質問をさせていただきます。 2021-07-27 09:39:44
Program [全てのタグ]の新着質問一覧|teratail(テラテイル) tf2.3でGANを作成すると、Dのlossが正しく計算されない。 https://teratail.com/questions/351390?rss=all tensorfowでGANを作成しています。 2021-07-27 09:33:38
AWS AWSタグが付けられた新着投稿 - Qiita 【6日目】AWS認定ソリューションアーキテクト合格までの道 https://qiita.com/nakachan-ing/items/aae291961c16ea0b4b60 2021-07-27 09:10:55
技術ブログ Developers.IO AWS WAFの管理ルールと独自ルールを組み合わせたルールの作成方法を教えてください https://dev.classmethod.jp/articles/tsnote-waf-how-to-make-managed-and-own-rule/ awswaf 2021-07-27 00:53:03
海外TECH DEV Community Semantic Versioning and Changelog https://dev.to/walternascimentobarroso/semantic-versioning-and-changelog-32ad Semantic Versioning and Changelog Clique aqui para ler em português All projects should have a semantic versioning so it would facilitate the use of specific versions as dependencies and old versions for specific platforms or even avoid that bug that appeared in the X Y Z version of the project Semantic VersioningSimple set of rules and requirements that determine how version numbers are assigned and in turn incremented MAJOR when you make incompatible API changes MINOR when you add backward compatible functionality PATCH when you fix backward compatible bugs You can read more about the specification at ChangelogWhen you are going to update a project and want to know what has changed you go after all the previous releases and the changelog is a file that makes this easier for you and your users How to make a good changelog Fundamental principlesChangelogs are for humans not machines There must be an entry for each version Changes of the same type must be grouped together Versions and sections must be linked with links The latest version comes first The release date of each version is displayed Mention whether you follow semantic versioning Types of changesCreate your tags to help view the changelog if you need help here are some patterns You can read more about it at Thanks for reading If you have any questions complaints or tips you can leave them here in the comments I will be happy to answer See you 2021-07-27 00:31:09
海外TECH DEV Community How To Build A Contact Manager Application With Next JS, Auth0 and Fauna https://dev.to/bkoiki950/how-to-build-a-contact-manager-application-with-next-js-and-fauna-663 How To Build A Contact Manager Application With Next JS Auth and FaunaAuthored in connection with the Write with Fauna program IntroductionThis article will demonstrate how to build a contact manager with Next js and Fauna by walking you through the process of building a Google contact application clone What is NextJS Next js is a React js front end framework with server side capabilities which makes it easy to build full stack applications withSome of its features and benefits include Static Site Generation SSG Server Side Rendering SSR Pre renderingBetter SEO Fast compilation times Automatic build size optimization Prerequisites Knowledge of React and JSX Basic knowledge of Express jsBasic knowledge of Next jsnpm and npx installedInstallation of the create next app CLI tool What you will learn in this article Next js app setupRouting on the client sideRouting on the server sideAuthentication with Next jsand AuthCreating Fauna databases collections and indexesBuilding a fully functional app Setting Up A Next js ApplicationTo set up a next js app all we need to do is to run the following command in the terminal npx create next app relativePathToDir npx create next app This will create everything we need in the specified directory You can look at the package json file to check out the dependencies and scripts there As we can see the package json file has three scripts and three dependencies The dev command is used to start the app in development mode while the build command is used to compile it Meanwhile the start command runs the app in production mode Note however we need to compile our application before running it in production mode The app also has three dependencies react react dom and next itself Now let s run our app To do this we need to type npm run dev in the application s root directory We should see the following As we can see from the diagram above there is are links to navigate from one site to another We can also try to go to a random endpoint in the app You should see the following which is the default page Next js created for us Routing in NextJSUnlike React js Next js offers routing support out of the box In React js we need to install React Router dom to have routing abilities However with Next js we do not need to do so Rather we just need to follow a particular syntax Let s look at how we can handle both client side and server side routing in next js Client Side RoutingIn your pages folder you can create a file and that file name will be the route s endpoint For example say I want to have a login endpoint all I need to do is create a pages login js file The page will then show a return value of the exported component Server Side RoutingA folder called api should contain a file called hello js with a simple express like server in your pages folder To test the API go to the api hello endpoint You should see the following name John Doe That is the JSON object which is sent as a response Just as we route in the client we create a file with the name we want to give the endpoint Complex RoutesSay we want to create a route like api users userId where userId is dynamic create a route like api users contacts follow or api users userId follow friendId How can we achieve this Let s start with a route that is not dynamic say api users contacts follow or users contacts follow We need to chain it down using directories and sub directories in our pages folder To create the users contacts follow route we need to create a pages users contacts follow js file in our application We can create a dynamic route on the other hand by naming the file with the path parameter enclosed in a square bracket Say for example we want to create a route api users userId we need to just create a file pages api users userId js To read more about routing in next js click here Authentication In Auth and NextJSHandling authentication ourselves in some cases might not be a good idea because of security breaches In this application we ll be using Auth for authentication Let s install the authjs library for nextjs in the terminal we will have to type the following npm i auth nextjs authIf you do not have an auth account create one here Head over to your dashboard and go to your applications page then create a new application As we re using NextJS we need to select regular web applications After creating the application we should redirect to its settings page Scroll down and edit the application URL as shown below then save your changes You can check auth next js documentation here Connecting Auth and NextJSWe need to get the following from our auth dashboard AUTH SECRET random characterAUTH BASE URL lt http localhost gt base URL of the applicationAUTH ISSUER BASE URL Your domainAUTH CLIENT ID Your client idAUTH CLIENT SECRET Your Client SecretTo create environment variables in our next js app during development we need to create a env local file in the root directory of our application We need to create this file and pass in these values Next js will parse the environment variables for us automatically which we can use in the node environment of our app If we want to access these variables in the browser we need to prefix the name with NEXT PUBLIC Now create a file called pages api auth auth js which will expose us to four different endpoints due to the fact that we re destructuring the file api auth login api auth callback api auth me and api auth logout that we can use in our application In the file you created type the following import handleAuth from auth nextjs auth export default handleAuth Also update your pages app js file with the following import UserProvider from auth nextjs auth import styles globals css function MyApp Component pageProps return lt UserProvider gt lt Component pageProps gt lt UserProvider gt export default MyAppWith these two things set up we can have a login and logout button on our home page just to test the functionality of our app Change the content of the pages index js file to the code snippet below import Head from next head import Image from next image import styles from styles Home module css export default function Home return lt div className styles container gt lt Head gt lt title gt Create Next App lt title gt lt meta name description content Generated by create next app gt lt link rel icon href favicon ico gt lt Head gt lt main className styles main gt lt h className styles title gt Welcome to lt a href gt Next js lt a gt lt h gt lt p className styles description gt lt a className styles code href api auth login gt Get started lt a gt by Creating an account or logging in lt p gt lt p className styles description gt lt a className styles code href api auth logout gt Logout lt a gt lt p gt lt p className styles description gt lt a className styles code href api auth me gt Profile lt a gt lt p gt lt p className styles description gt lt a className styles code href api auth callback gt callback lt a gt lt p gt lt main gt lt footer className styles footer gt lt a href utm source create next app amp utm medium default template amp utm campaign create next app target blank rel noopener noreferrer gt Powered by lt span className styles logo gt lt Image src vercel svg alt Vercel Logo width height gt lt span gt lt a gt lt footer gt lt div gt The app should now look like this try to navigate to a different part of the app using the links Start by creating an account or logging in you should see the following page After signing in in click on the profile link You should get a JSON response showing your profile data Navigate to the callback and logout route to see what happens Note that we won t be using the api auth me in the client side of our app as auth provided us with a hook called useUser which returns the same thing when the user is logged in and it returns null when the user is logged out Route Protection In Next JS and AuthIt s not enough to have an endpoint to log users in and out of the application we need to be able to protect unauthenticated users from viewing some pages in the application and also restrict access to some APIs Auth provides us with two functions that help ensure only authenticated users have access to a particular resource withApiAuthRequired and withPageAuthRequiredThese functions take in a callback function while we use withApiAuthRequired in the API part of the app and we use withPageAuthRequired in the components Let s now look at how we can restrict unauthenticated users to get a resource from the endpoint api user and the dashboard page We ll need to create the following files pages api user js and pages dashboard js We need to put the following in the pages api user js file import withApiAuthRequired getSession from auth nextjs auth export default withApiAuthRequired async req res gt const user getSession req res user the getSession function is used to get the session object that s created in the app Which is where auth data is kepy res json user In our pages dashboard js file let s type the following import withPageAuthRequired useUser from auth nextjs auth const Dashboard gt const user useUser return lt div gt lt main gt user amp amp lt div gt lt div gt user email user email verified amp amp lt span gt Your account is not verified lt span gt lt div gt lt div gt lt main gt lt div gt export const getServerSideProps withPageAuthRequired export default DashboardIf you go to the dashboard endpoint without logging in it redirects to the login page Similarly if you go to the api user endpoint it will return with an error message We ve successfully protected routes both on the client and server side Connecting Our Application To Fauna Creating A Fauna DatabaseTo create a Fauna database head to the dashboard Next click on the New Database button enter the database name and click enter Creating Fauna CollectionsA collection is a group of documents rows with the same or a similar purpose A collection acts similarly to a table in a traditional SQL database In the app we re creating we ll have one collection contacts The user collection is where we ll be storing our contact data To create these click on the database you created and New Collection Enter only the collection name contacts then click save Creating Fauna IndexesUse indexes to quickly find data without searching each document in a database collection every time you need to access one Indexes using one or more fields of a database collection To create a Fauna index click on the indexes section on the left of your dashboard In this application we will be creating the one index which is the user contacts index this is used to retrieve all passwords created by a particular user Generating Your Fauna SecretThe Fauna secret key connects an application or script to the database and it is unique per database To generate it go to your dashboard s security section and click on New Key Enter your key name and a new key will be generated for you Paste the key in your env local file in this format REACT APP FAUNA KEY API key Building Our ApplicationFirst we need to figure out the structure of our application Our application will have the following endpoints home route dashboard The dashboard route Only authenticated users can access this page api contacts This is an API It will support the GET HTTP method for getting all the contacts created by the user and the POST HTTP method for creating a new contactapi contacts contactId This is also an API which will support GET PUT and theDELETE HTTP method for getting a single contact updating it and deleting a contact respectively Now we know the routes that we need to create and automatically we know the files we need to create to achieve this we also need to have some components that will be used in the app Thus we will create a components folder in the root directory of our app and put each component there Navbar This is the navbar of the app We Will create a file called components Navbar js for this Contact This contains details of a single contact detail We won t have a separate file for this Contacts This will use the Contact component and display all the contacts created by the authenticated user We will create a file called components Contacts and put both the Contacts and Contact components there BaseModal is the component we will build all our modals upon We will place it in a file called components BaseModal js CreateContact modal is the component that creates a modal for creating a new contact We will place it in a file called CreateContact modal js EditContact modal This is the component that creates a modal for editing a contact We will add it to a file called EditContact modal jsWe also need to have a file that handles the logic of database modeling so we won t have to be writing queries directly in the api folder This file models js will be in the root directory of our app We also need to install the remaining dependencies Type the following in the root directory of your application npm i faunadb axios fortawesome react fontawesome fortawesome free solid svg icons fortawesome fontawesome svg core fortawesome fontawesome free react bootstrap ModelsIn your models js type the followingimport faunadb query as q from faunadb const client new faunadb Client secret process env REACT APP FAUNA KEY export const createContact async firstName lastName email phone user jobTitle company address avatar gt const date new Date const months January February March April May June July August September October November December let newContact await client query q Create q Collection contacts data firstName lastName email phone company jobTitle address avatar created at months date getMonth date getDate date getFullYear user id user sub if newContact name BadRequest return newContact data id newContact ref value id return newContact data export const getContactsByUserID async id gt try let userContacts await client query q Paginate q Match q Index user contacts id if userContacts name NotFound return if userContacts name BadRequest return Something went wrong let contacts for let contactId of userContacts data let contact await getContact contactId value id contacts push contact return contacts catch error if error message instance not found return return export const getContact async id gt let contact await client query q Get q Ref q Collection contacts id if contact name NotFound return if contact name BadRequest return Something went wrong contact data id contact ref value id return contact data export const updateContact async payload id gt let contact await client query q Update q Ref q Collection contacts id data payload if contact name NotFound return if contact name BadRequest return Something went wrong contact data id contact ref value id return contact data export const deleteContact async id gt let contact await client query q Delete q Ref q Collection contacts id if contact name NotFound return if contact name BadRequest return Something went wrong contact data id contact ref value id return contact data The logic of this file is pretty straightforward We have functions to create a new contact get all contacts created by a user obtain a single contact update a single contact and delete a single contact You might be wondering why we do not handle the user dB well we do not need to in this case because we do not have a complex dB We just need to be able to figure out the owner of a particular contact and auth gives us access to the ID and email of the logged in user amongst other things Components Navbar ComponentIn your components Navbar js file type the following import Navbar Nav from react bootstrap import useUser from auth nextjs auth import Image from next image const NavbarComponent gt const user isLoading error useUser return lt Navbar fixed top collapseOnSelect expand lg bg dark variant dark gt lt Navbar Brand className mx mx md href gt Contact Manager lt Navbar Brand gt lt Navbar Toggle aria controls responsive navbar nav gt lt Navbar Collapse className d lg flex justify content end id responsive navbar nav gt user amp error lt gt lt Nav Link className text light href api auth login gt Sign In lt Nav Link gt lt Image alt avatar loader myLoader src name John Doe width height className rounded circle gt lt gt lt gt lt Nav Link className text light href dashboard gt Dashboard lt Nav Link gt lt Nav Link className text light href api auth logout gt Sign Out lt Nav Link gt lt Nav Link href profile gt lt Image alt avatar loader myLoader src user picture name firstName lastName width height className rounded circle gt lt Nav Link gt lt gt lt Navbar Collapse gt lt Navbar gt const myLoader src gt return src export default NavbarComponentWe used the useUser hook here to determine if the user is logged in or not since we want to return things from this component dynamically We also have a myLoader function at the bottom of the file and this is because we are using the Image tag with a link BaseModal ComponentIn your components BaseModal js file type the following import Modal from react bootstrap Modal import Container from react bootstrap Container import Button from react bootstrap Button import Form from react bootstrap Form import Row from react bootstrap Row import Col from react bootstrap Col const BaseModal props gt const onHide gt if props create props updateFirstName props updateLastName props updateEmail props updatePhone props updateAddress props onHide return lt Modal props size xlg aria labelledby contained modal title vcenter centered onHide onHide gt lt Modal Header closeButton gt lt Modal Title id contained modal title vcenter gt props header amp amp props header props title amp amp props title lt Modal Title gt lt Modal Header gt lt Modal Body className show grid gt lt Container gt lt Form gt lt Row gt lt Form Group as Col className form group gt lt Form Control placeholder First name className form control value props firstName onChange e gt props updateFirstName e target value gt lt Form Group gt lt Form Group as Col className form group gt lt Form Control placeholder Last name className form control value props lastName onChange e gt props updateLastName e target value gt lt Form Group gt lt Row gt lt Row gt lt Form Group as Col gt lt Form Control type email placeholder Email value props email onChange e gt props updateEmail e target value gt lt Form Group gt lt Row gt lt Row gt lt Form Group as Col gt lt Form Control type phone placeholder Phone number value props phone onChange e gt props updatePhone e target value gt lt Form Group gt lt Row gt lt Row gt lt Form Group as Col gt lt Form Control placeholder Address value props address onChange e gt props updateAddress e target value gt lt Form Group gt lt Row gt lt Form gt lt Container gt lt Modal Body gt lt Modal Footer gt lt Button variant danger onClick onHide gt Close lt Button gt lt Button variant success onClick props create props handleCreate props handleEdit disabled props firstName props lastName props phone true false gt props btnText lt Button gt lt Modal Footer gt lt Modal gt export default BaseModal Contacts and Contact componentIn your components Contacts js file type the following import Image from next image import Button from react bootstrap Button import Table from react bootstrap Table import useState from react import EditContactModal from EditContact modal const Contact id firstName lastName email phone address avatar handleDelete handleEdit gt const editModal setEditModal useState false const editContact gt setEditModal true const deleteContact gt handleDelete id alert Contact deleted successfully return lt tr gt lt td gt lt Image alt avt loader myLoader src avatar width height className rounded circle gt lt td gt lt td gt firstName lastName lt td gt lt td gt lt a href mailto email gt email lt a gt lt td gt lt td gt lt a href tel phone gt phone lt a gt lt td gt lt td gt address lt td gt lt td gt lt Button onClick editContact gt Edit lt Button gt lt td gt lt td gt lt Button onClick deleteContact gt Delete lt Button gt lt td gt lt EditContactModal show editModal firstname firstName lastname lastName email email phone phone address address title Edit Contact for firstName onHide gt let n window confirm Your changes won t be saved if n setEditModal false onEdit contact gt contact id id handleEdit contact alert Contact for firstName updated successfully setEditModal false gt lt tr gt const Contacts contacts handleEdit handleDelete gt return lt gt contacts amp amp Fetching contacts lt Table striped bordered hover responsive gt lt thead gt lt tr gt lt th gt avatar lt th gt lt th gt Name lt th gt lt th gt Email lt th gt lt th gt Phone lt th gt lt th gt Address lt th gt lt th gt Edit lt th gt lt th gt Delete lt th gt lt tr gt lt thead gt lt tbody gt contacts map ele gt lt Contact ele key ele id handleEdit handleEdit handleDelete handleDelete gt lt tbody gt lt Table gt lt gt const myLoader src gt return src export default Contacts Create Contact ModalIn your CreateContact modal js file type the following import BaseModal from BaseModal import useState from react const CreateContactModal props gt const firstName setFirstName useState const lastName setLastName useState const email setEmail useState const phone setPhone useState const address setAddress useState const handleCreate gt const payload firstName lastName email phone address props onCreate payload return lt BaseModal show props show onHide props onHide firstName firstName lastName lastName email email phone phone address address updateFirstName newInput gt setFirstName newInput updateLastName newInput gt setLastName newInput updateEmail newInput gt setEmail newInput updatePhone newInput gt setPhone newInput updateAddress newInput gt setAddress newInput header Create New Contact btnText Create handleCreate handleCreate create true gt export default CreateContactModalThis component uses the BaseModal js file and passes props to the component Edit Contact ModalIn your components EditContact modal js file type the following import BaseModal from BaseModal import useState from react const EditContactModal props gt const firstName setFirstName useState props firstname const lastName setLastName useState props lastname const email setEmail useState props email const phone setPhone useState props phone const address setAddress useState props address const onEdit gt const payload firstName lastName email phone address props onEdit payload return lt BaseModal show props show onHide props onHide title props title firstName firstName lastName lastName email email phone phone address address updateFirstName newInput gt setFirstName newInput updateLastName newInput gt setLastName newInput updateEmail newInput gt setEmail newInput updatePhone newInput gt setPhone newInput updateAddress newInput gt setAddress newInput btnText Edit handleEdit onEdit create false gt export default EditContactModalYou might notice that the pages index js file has a Meta tag All pages should have their meta tag for SEO optimization Let s create a components MetaData js file MetaData ComponentIn your components MetaData js file type the following import Head from next head const MetaData title gt return lt Head gt lt title gt Contact Manager App title amp amp title lt title gt lt meta name description content A simple Contact Manager gt lt link rel icon href favicon ico gt lt Head gt export default MetaData APIBefore we start creating our screens it s ideal for our backend to be complete since we will consume the APIs in the frontend of our app We need the following files for our API excluding the auth endpoint api contacts we need to create a pages api contacts js filea GET get all contacts b POST create a new contact api contacts id we need to create a pages api contacts id js filea GET get a single contactb PUT update a single contactc DELETE delete a single contacts Create and Get all contactsIn your pages api contacts js file type the following Next js API route support import withApiAuthRequired getSession from auth nextjs auth import createContact deleteContact getContactsByUserID from models export default withApiAuthRequired async req res gt const user getSession req res user if req method POST let firstName lastName email company jobTitle phone address avatar req body let newContact await createContact firstName lastName email phone user jobTitle company address avatar res status json message Successfully created contact data newContact status ok else if req method GET let contacts await getContactsByUserID user sub if contacts return res status json message Something went wrong data null status false res status json message Successfully retrieved contacts data contacts status ok else res status json message Method not allowed data null status false In this file we used the getSession function to get the current user from the request and response object We then used this to set the contact creator and get contacts created by the user UPDATE DELETE and GET a single ContactIn your pages api contacts id js type the following Next js API route support import withApiAuthRequired getSession from auth nextjs auth import deleteContact getContact updateContact from models export default withApiAuthRequired async req res gt const user getSession req res user if req method PUT let contact await updateContact req body req query id res status json message Successfully updated contact data contact status ok else if req method GET let contact await getContact req query id res status json message Successfully retrieved contact data contact status ok else if req method DELETE let contact await getContact req query id if contact user id user sub return res status json message Forbidden status false data null contact await deleteContact req query id res status json message Successfully deleted contact data contact status ok else res status json message Method not allowed data null status false With this we have our API all set up You can test it by going to different endpoints using an API testing tool like Postman PagesNow we finished creating our components and APIs we need to create the pages and use the above Index PageChange the content of your pages index js file to the following import Image from next image import useUser from auth nextjs auth import MetaData from components MetaData import styles from styles Home module css export default function Home const error isLoading useUser if isLoading return lt div gt Loading lt div gt if error return lt div gt error message lt div gt return lt div gt lt MetaData title gt lt main className styles container gt lt Image className styles img alt home src home jpeg width height gt lt main gt lt div gt This page just returns an image as the content of the app You might be wondering where will our navbar be So as not to call the navbar more than once we ll place it in our pages app js file Basically this file is what is served and it changes based on what is happening on the current page Dashboard PageIn your pages dasboard js file type the following import useEffect useState from react import withPageAuthRequired useUser from auth nextjs auth import Button from react bootstrap Button import axios from axios import CreateContactModal from components CreateContact modal import Contacts from components Contacts import MetaData from components MetaData import styles from styles Home module css const Dashboard gt const user useUser const contacts setContacts useState const createModalShow setCreateModalShow useState false const handleHide gt let n window confirm Your changes won t be saved if n setCreateModalShow false useEffect async gt let res await axios get api contacts data res await res data setContacts res reverse const createContact async payload gt payload avatar name payload firstName payload lastName let newContact await axios post api contacts payload data setContacts newContact data contacts const editContact async payload gt let id payload id delete payload id let replacedContact await axios put api contacts id payload data setContacts contacts map contact gt contact id id replacedContact data contact const deleteContact async id gt await axios delete api contacts id data setContacts contacts filter contact gt contact id id return lt div gt lt MetaData title Dashboard gt lt main gt user amp amp lt div className styles dashboardContainer gt lt div gt lt img alt avatar src user picture className rounded circle m width height gt lt span gt Welcome user nickname toLowerCase charAt toUpperCase user nickname toLowerCase slice lt span gt user email verified amp amp lt div gt Your account is not verified lt div gt lt div gt lt div gt lt Button variant primary onClick gt setCreateModalShow true gt Create New Contact lt Button gt lt CreateContactModal show createModalShow onHide handleHide onCreate payload gt createContact payload setCreateModalShow false gt lt div gt lt div gt lt main gt lt Contacts contacts contacts handleEdit id gt editContact id handleDelete id gt deleteContact id gt lt div gt export const getServerSideProps withPageAuthRequired export default DashboardWhat is happening here is pretty straightforward We are getting contacts the user created when the page loads and we render it We also show some details about the logged in user and we have a create contact button Before we can run our application we need to make one change we need to add the navbar to the pages app js file Root ComponentUpdate the content of your pages app js file with the following import React useEffect useState from react import UserProvider from auth nextjs auth import axios from axios import MetaData from components MetaData import NavbarComponent from components Navbar import bootstrap dist css bootstrap min css import styles globals css export default function App Component pageProps return lt UserProvider gt lt NavbarComponent gt lt Component pageProps gt lt UserProvider gt Running Our ApplicationWe have successfully built our application Next we need to run it in development mode If you run your application you should see the following After signing in you should get redirected to the home page after signing in with the navbar being different Go to the dashboard endpoint and create some contacts Also edit some of them and watch how the dashboard component is changing You can also check the network request You ll notice that our Fauna secret key isn t present as we handle this from the server We ve successfully tested our application Next StepsWe have now built our application but we re never really done developing it as there s always room for improvement These are some of the things we can add to this application to make it look better We can improve the appearance of the UI We can add a PWA feature to our applicationWe can also create a profile page for the logged in user where they can update their profile ConclusionThis article has offered a deep dive into Next js and why we should use it in our projects It also explains how to build a fully functional application with authentication features using NextJS and auth for authentication and Fauna as our database provider Do you have something to add to this project kindly let me know You can reach out to me via Twitter If you like this project kindly give it a star on GitHub You can also check out the deployed app here 2021-07-27 00:01:52
Apple AppleInsider - Frontpage News Elon Musk takes jabs at Apple during Tesla earnings call https://appleinsider.com/articles/21/07/27/elon-musk-takes-jabs-at-apple-during-tesla-earnings-call?utm_medium=rss Elon Musk takes jabs at Apple during Tesla earnings callTesla CEO Elon Musk took two potshots at Apple during a quarterly earnings conference call on Monday noting the batteries in his company s cars use less cobalt than devices made by the tech giant Musk referenced Apple when questioned about Tesla s supply chain specifically the use of cobalt ーa mineral whose mining is often linked to human rights abuses ーin lithium ion batteries reports CNBC Apple uses I think almost cobalt in their batteries and cell phones and laptops but Tesla uses no cobalt in the iron phosphate packs and almost none in the nickel based chemistries Musk said On on a weighted average basis we might use cobalt compared to say Apple s cobalt Anyway so it s just really not a factor Read more 2021-07-27 00:46:45
Apple AppleInsider - Frontpage News Apple ceases iOS 14.6 code signing, blocks downgrades from iOS 14.7 and above https://appleinsider.com/articles/21/07/26/apple-ceases-ios-146-code-signing-blocks-downgrades-from-ios-147-and-above?utm_medium=rss Apple ceases iOS code signing blocks downgrades from iOS and aboveApple on Monday stopped signing code for iOS following the release of iOS last week and iOS today meaning users are now unable to downgrade to the previous operating system version Apple issued iOS a week ago with support for the new MagSafe Battery Pack and improvements to Apple Card Family General performance enhancements and security fixes were also included Earlier today iOS was released to remedy an issue that prevented Apple Watch from unlocking iPhones with Touch ID The update also closed a potentially serious security hole that was exploited in the wild Read more 2021-07-27 00:16:55
Apple AppleInsider - Frontpage News Facebook's Oculus investigating Apple Health app integration https://appleinsider.com/articles/21/07/26/facebooks-oculus-investigating-apple-health-app-integration?utm_medium=rss Facebook x s Oculus investigating Apple Health app integrationCode discovered in Facebook s Oculus app reveals the company is investigating an Apple Health app integration that would allow users to save workout data generated by Oculus Move Discovered by developer Steve Moser the code suggests Facebook is experimenting with a feature that would synchronize Oculus Move data to the Health app Bloomberg reports Users might also be able to view information saved in the Health app on a connected Oculus VR headset the report says Introduced last year Oculus Move is a Quest and Quest feature that tracks movement and calories burned across any VR game or app The resulting data is siloed in a special dashboard located in a user s Library Some Oculus apps can display real time statistics in an overlay similar to the Apple Watch and Apple TV setup in Apple Fitness Read more 2021-07-27 00:14:54
Apple AppleInsider - Frontpage News Intel to manufacture chips for Qualcomm, Amazon as it plays catch-up with TSMC https://appleinsider.com/articles/21/07/26/intel-to-manufacture-chips-for-qualcomm-amazon-as-it-plays-catch-up-with-tsmc?utm_medium=rss Intel to manufacture chips for Qualcomm Amazon as it plays catch up with TSMCIntel on Monday provided details on its plan to catch up to specialist foundries like Apple partner TSMC announcing new deals to make chips for Qualcomm and Amazon on its way to a roadmapped industry lead by Intel CEO Pat Gelsinger Source IntelOnce the world s leading chipmaker Intel has seen up and coming specialist production companies help competitors like AMD surpass its products in both performance and technology To regain its throne Intel created a new manufacturing arm called Intel Foundry Services which will produce the firm s favored x architecture as well as ARM designs used by companies like Apple Read more 2021-07-27 00:13:00
Apple AppleInsider - Frontpage News 'Ted Lasso' season premiere breaks Apple TV+ viewing record https://appleinsider.com/articles/21/07/26/ted-lasso-season-premiere-breaks-apple-tv-viewing-record?utm_medium=rss x Ted Lasso x season premiere breaks Apple TV viewing recordThe season two premiere of breakout hit Ted Lasso managed to bring in the most viewers of any Apple TV series or movie debut to date the company said Monday While Apple is not offering specific figures the tech giant said more Apple TV subscribers watched the season premiere in its opening weekend than any prior launch reports Variety The viewing window ran from Friday July to Sunday July Apple boasts the show increased its viewership by x over season one though again the company is not revealing exact viewer numbers Ted Lasso is also driving adoption with Apple TV growing its user base by a week over week during the premiere weekend the report said The series premiere also lifted numbers for Apple TV comedies including the new musical series Schmigadoon Physical and Mythic Quest Apple said Read more 2021-07-27 00:09:53
海外科学 NYT > Science A 2nd New Nuclear Missile Base for China, and Many Questions About Strategy https://www.nytimes.com/2021/07/26/us/politics/china-nuclear-weapons.html A nd New Nuclear Missile Base for China and Many Questions About StrategyIs China scrapping its “minimum deterrent strategy and joining an arms race Or is it looking to create a negotiating card in case it is drawn into arms control negotiations 2021-07-27 00:03:26
海外TECH WIRED Intel's Ambitious Plan to Regain Chipmaking Leadership https://www.wired.com/story/intels-ambitious-plan-regain-chipmaking-leadership government 2021-07-27 00:17:53
金融 日本銀行:RSS 金融市場の分析を行う職員の募集について http://www.boj.or.jp/announcements/release_2021/rel210727b.htm 金融市場 2021-07-27 10:00:00
ニュース BBC News - Home How Amy Winehouse's legacy is helping women in addiction recovery https://www.bbc.co.uk/news/newsbeat-57975385 addiction 2021-07-27 00:01:04
ニュース BBC News - Home John Stonehouse: Bizarre tale of the MP who faked his own death https://www.bbc.co.uk/news/uk-politics-57942759 james 2021-07-27 00:04:43
ニュース BBC News - Home Tokyo Olympics: Britain's Georgia Taylor-Brown wins silver in women's triathlon https://www.bbc.co.uk/sport/olympics/57979326 Tokyo Olympics Britain x s Georgia Taylor Brown wins silver in women x s triathlonGreat Britain s Georgia Taylor Brown fights back from a bike puncture to earn an Olympic silver medal in the women s triathlon 2021-07-27 00:08:10
北海道 北海道新聞 五十嵐が4強、大原は敗退 サーフィン・27日 https://www.hokkaido-np.co.jp/article/571381/ 五十嵐カノア 2021-07-27 09:03:31
北海道 北海道新聞 MLBヘルナンデスが週間MVP テーラーも、ともに打率4割 https://www.hokkaido-np.co.jp/article/571393/ 大リーグ 2021-07-27 09:05:00
北海道 北海道新聞 新型エンジンで発射実験、鹿児島 JAXAが観測ロケット https://www.hokkaido-np.co.jp/article/571392/ 宇宙航空研究開発機構 2021-07-27 09:05:00
マーケティング AdverTimes ローソン、中国系デリバリー「DiDiフード」導入へ https://www.advertimes.com/20210727/article359022/ 取り扱い 2021-07-27 00:15:39

コメント

このブログの人気の投稿

投稿時間:2021-06-17 05:05:34 RSSフィード2021-06-17 05:00 分まとめ(1274件)

投稿時間:2021-06-20 02:06:12 RSSフィード2021-06-20 02:00 分まとめ(3871件)

投稿時間:2020-12-01 09:41:49 RSSフィード2020-12-01 09:00 分まとめ(69件)