IT |
ITmedia 総合記事一覧 |
[ITmedia Mobile] NetflixやYouTube Premiumなどを合算払いすると最大20%還元! ドコモが「爆上げ セレクション」を4月から提供 |
https://www.itmedia.co.jp/mobile/articles/2303/06/news142.html
|
ITmediaMobileNetflixやYouTubePremiumなどを合算払いすると最大還元ドコモが「爆上げセレクション」を月から提供NTTドコモが、指定の有料サブスクリプションサービスの料金を携帯電話料金との一括払いにすると「dポイント」を付与するサービスを開始する。 |
2023-03-06 16:50:00 |
IT |
ITmedia 総合記事一覧 |
[ITmedia PC USER] JAPANNEXT、Type-C接続に対応した28型4K液晶ディスプレイ |
https://www.itmedia.co.jp/pcuser/articles/2303/06/news136.html
|
itmediapcuserjapannext |
2023-03-06 16:33:00 |
IT |
ITmedia 総合記事一覧 |
[ITmedia News] 邪神ちゃん、トークソフトになる 「このソフトが売れれば私は大金持ちですの!」 AHSが販売へ |
https://www.itmedia.co.jp/news/articles/2303/06/news132.html
|
itmedia |
2023-03-06 16:30:00 |
IT |
ITmedia 総合記事一覧 |
[ITmedia ビジネスオンライン] マツダともみじ饅頭がコラボ 歴代マツダ車の焼き印入り饅頭や特製シールを同封 |
https://www.itmedia.co.jp/business/articles/2303/06/news128.html
|
itmedia |
2023-03-06 16:03:00 |
TECH |
Techable(テッカブル) |
Web3スタジオ1BLOCK、ルパン新作アニメのNFTスニーカー発売決定 |
https://techable.jp/archives/198186
|
airsmokezero |
2023-03-06 07:00:21 |
js |
JavaScriptタグが付けられた新着投稿 - Qiita |
【jQuery / JavaScript】今日の日付(0埋め) |
https://qiita.com/enzi/items/ccd0dcc79ada08f93c1e
|
etfullyearletmonthrowdate |
2023-03-06 16:48:37 |
Linux |
Ubuntuタグが付けられた新着投稿 - Qiita |
HTTP/3対応のcurlをUbuntu 20.04で構築する(Docker版) |
https://qiita.com/akase244/items/d801924720e28501e2fe
|
docker |
2023-03-06 16:20:15 |
golang |
Goタグが付けられた新着投稿 - Qiita |
Go言語で使う「go.opencensus.io/trace」とは? |
https://qiita.com/atsutama/items/77e84ae1d59203c59a05
|
goopencensusiotrace |
2023-03-06 16:54:56 |
golang |
Goタグが付けられた新着投稿 - Qiita |
[Go]埋め込み |
https://qiita.com/WisteriaWave/items/11cea617254165102c85
|
embed |
2023-03-06 16:09:46 |
Ruby |
Railsタグが付けられた新着投稿 - Qiita |
【超簡単】Railsでレシピ検索アプリ作ってみた(楽天API) |
https://qiita.com/Naoya_pro/items/566e0b38b8f662882310
|
rails |
2023-03-06 16:16:29 |
技術ブログ |
Developers.IO |
Google Cloud:CDK for TerraformのJavaでIaCを構築する(MacBook) |
https://dev.classmethod.jp/articles/google-cloud-iac-cdkforterraform1/
|
clouddevelopmentmanage |
2023-03-06 07:44:51 |
技術ブログ |
Developers.IO |
【4/5(水)リモート】クラスメソッドの会社説明会〜フリーランスエンジニア編〜を開催します |
https://dev.classmethod.jp/news/jobfair-freelance-230405/
|
事業会社 |
2023-03-06 07:27:17 |
海外TECH |
DEV Community |
React Admin Panel Tutorial with Chakra UI and Strapi |
https://dev.to/refine/react-admin-panel-tutorial-with-chakra-ui-and-strapi-32pj
|
React Admin Panel Tutorial with Chakra UI and StrapiAuthor Peter Osah IntroductionIn building data intensive applications like React admin dashboards and in house applications among others speed customizability and performance are of the essence as these applications are pivotal in the management of most businesses and software This has led developers to opt for solutions like refine that provide these qualities out of the box refine is a React based framework that helps to build data intensive applications in due time It does this by providing hooks providers and components that provide room for UI customizability and data management as well as easy integration with any custom backend APIs and popular backend services like Strapi Hasura etc In this React admin panel tutorial we will be creating an admin application with refine that will be built with ChakraUI an enterprise level React component library and Strapi a popular backend service as its backend provider Benefits of using refinerefine accelerates development by creating a higher abstraction of most functionalities such as routing data providers authentication internationalization layouts asynchronous state management and many others that developers would have to set up from scratch if building the application from the ground up With refine you have the choice to build your application with a custom design a headless approach or a UI component library refine includes integrations for some component libraries and design systems like Material UI Chakra UI Ant Design and Mantime It can also be integrated into any REST or GraphQL backend service and includes out of the box support for popular BAAS backend as a service such as NestJs CRUD Airtable Strapi Supabase Altogic and others A peculiarity of refine is that it provides a lot of out of the box functionality for rapid development while still allowing for extreme customization You can build a variety of applications with refine and it isn t limited to major use cases like React admin panels BB applications and dashboards In this React admin tutorial we will be illustrating how to build a CRUD app with refine Whether you re a beginner or an experienced developer this React admin tutorial will walk you through the entire process step by step and show you how to integrate Strapi as your backend CMS to create an amazing React admin panel What is Strapi Strapi is a free and open source headless Content Management System built on Node js It allows developers to easily create manage and consume content through a customizable API Strapi provides a user friendly admin panel for content editors to manage content without having to write code while also providing a flexible content modeling system that can be tailored to fit specific project needs Constituents of A refine ApplicationBefore delving in to build the CRUD React admin tutorial app we need to know the constitutents of an refine application The lt Refine gt ComponentThe lt Refine gt acts as the entrypoint of the application it is a component that recieves the configurations passed into it as react props src App tsximport Refine from pankod refine core import dataProvider from pankod refine simple rest import PostList from pages posts const API URL const App React FC gt return lt Refine dataProvider dataProvider API URL resources name posts list PostList gt export default App There are a variety of configurations that can be passed into a refine application they are DataProvider a data provider enables a refine application connect to an external API or service A dataProvider sends HTTP requests and receives responses via predefined methods Here is a sample on how to adding a dataProvider to the refine component src App tsximport Refine from pankod refine core import authProvider axiosInstance from authProvider import DataProvider from pankod refine strapi v function App return lt Refine dataProvider DataProvider API URL api axiosInstance gt export default App Resources A resources is a fundamental component of a refine application A resource acts as a bridge between the Data API layer and the Document Page Layer A resource enables the application s pages to interact with the API In order to create a resource we have to pass the resources property which will be an array of objects with each object specifying the pages route name and the basic operations the pages under that route name can perform which are the list displaying records from an API or service create add or creating a record to an API or service edit modifying an existing record from an API or service show display a specific record from an API or service operations to the lt Refine gt component src App tsximport Refine from pankod refine core import PostList PostCreate PostEdit PostShow from pages posts const API URL const App React FC gt return lt Refine resources name posts list PostList create PostCreate edit PostEdit show PostShow gt export default App Bootstrapping the refine ApplicationTo create our refine application for this article we will use the create refine app wizard create refine app comes with built in templates for the CRA Next js and Remix environments allowing you to setup a refine project quickly It also provides an array of options for automatically configuring your UI framework in router authentication and data provider settings In order to use this execute the following command npm create refine app latest lt name of your application gt You will be directed to the CLI wizard after running the command To complete the CLI wizard select the following options When these options are selected the CLI will bootstrap a refine application with the Strapi v provider Following installation we will execute the following command npm run devThe refine application should be up and running after you run the command To access it go to http localhost Utilizing the Strapi v Provider in refineOn installation since we selected the strapi v data provider refine adds a fake strapi API url to the data provider of the refine applicationIn this React admin tutorial we will be using refine s fake strapi v API url for demo purposes If you have a strapi v API url you wish to integrate into the application you can always replace the fake strapi API with that Setting AuthProviderThe create refine app command generates a new refine application with a default AuthProvider If you followed the steps above to create your application using create react app you should already have the src authProvider ts file It s worth noting that the authProvider s login method is especially important We ll be using email and password to sign in to our application so make sure that the login method contains the code provided below src authProvider tsexport const authProvider AuthProvider highlight start login async email password gt const data status await strapiAuthHelper login email password highlight end if status localStorage setItem TOKEN KEY data jwt set header axios instance axiosInstance defaults headers common Authorization Bearer data jwt return Promise resolve return Promise reject Implementing CRUD operations on React admin panelWe will implement CRUD operations such as listing creating and editing records in our React admin tutorial application In this article we describe our React admin tutorial app which is one that can track the list of posts created as well as have the functionality of viewing a post as well as updating and deleting a post respectively Listing recordsTo display data on the UI we must create a lt PostList gt page To begin we ll require an interface to interact with the data from the API endpoint If you don t already have one we ll create one under the src folder called interfaces Then create a file called index d ts with the following code src interfaces index d tsexport interface IPost id number title string content string category any publishedAt string createdAt string Next we create a new folder named pages under the src folder Under that folder create a posts folder and add a list tsx file with the following code pages posts list tsximport React from react import IResourceComponentsProps GetManyResponse useMany from pankod refine core import useTable ColumnDef flexRender from pankod refine react table import List TableContainer Table Thead Tr Th Tbody Td HStack Button IconButton usePagination Box EditButton ShowButton from pankod refine chakra ui import IconChevronRight IconChevronLeft from tabler icons import IPost from interfaces export const PostList React FC lt IResourceComponentsProps gt gt const columns React useMemo lt ColumnDef lt IPost gt gt gt id id accessorKey id header Id id title accessorKey title header Title id createdAt accessorKey createdAt header Created At cell function render getValue table return lt DateField value getValue as string format LLL gt id actions accessorKey id header Actions cell function render getValue return lt HStack gt lt ShowButton hideText recordItemId getValue as string gt lt EditButton hideText recordItemId getValue as string gt lt HStack gt const getHeaderGroups getRowModel setOptions refineCore setCurrent pageCount current tableQueryResult data tableData useTable columns setOptions prev gt prev meta prev meta return lt List gt lt TableContainer whiteSpace pre line gt lt Table variant simple gt lt Thead gt getHeaderGroups map headerGroup gt lt Tr key headerGroup id gt headerGroup headers map header gt lt Th key header id gt header isPlaceholder amp amp flexRender header column columnDef header header getContext lt Th gt lt Tr gt lt Thead gt lt Tbody gt getRowModel rows map row gt lt Tr key row id gt row getVisibleCells map cell gt lt Td key cell id gt flexRender cell column columnDef cell cell getContext lt Td gt lt Tr gt lt Tbody gt lt Table gt lt TableContainer gt lt List gt In the code above we use the useTable hook from the pankod refine react table package to fetch records from Strapi the useTable maps the records into rows based on the columns variable definition After this we can now add the component lt PostList gt in the list tsx file to our resource present in the App tsx file src App tsximport React from react import Refine from pankod refine core import notificationProvider ChakraProvider refineTheme ReadyPage ErrorComponent Layout AuthPage from pankod refine chakra ui import DataProvider from pankod refine strapi v import routerProvider from pankod refine react router v import authProvider axiosInstance from authProvider import API URL from constants import PostList from pages posts function App return lt ChakraProvider theme refineTheme gt lt Refine highlight start LoginPage AuthPage resources name posts list PostList highlight end gt lt ChakraProvider gt export default App After adding the rescource the application will now redirect to the URL specified by the name property It will prompt you to log in to the app Since we are using refine s fake strapi v API Try these credentials Username demo refine devPassword demodemoCheck that the URL is routed to posts and that posts are present Handling RelationshipsWhen retrieving recorda relations are not populated Hence We will use the metaData option to populate the Strapi v API with relational data category data in our case Refer to docs for handling relations with strapiWe will populate records with a category id field from the posts endpoint with their respective titles To automatically get category titles from the categoriesendpoint for each record and display them on our table we must use Strapi v s populate feature We ll use the populate parameter to specify which fields should be filled in we will assign an array to the populate parameter which will contain the map the values from the categories endpoint to the records with a category id on the posts endpoint The populate parameter will be a property of the metaData property which is subsequently a property of the refineCoreProps object pages posts list tsxconst getHeaderGroups getRowModel setOptions refineCore setCurrent pageCount current tableQueryResult data tableData useTable columns refineCoreProps metaData populate category To show category field in table we need to add new column to the PostList component pages posts list tsxconst columns React useMemo lt GridColumns lt IPost gt gt gt id category accessorKey category title header Category cell function render getValue table return getValue Pagination Of Listed RecordsNext we will add Pagination to our application in order to achieve this the usePagination hook provides certain functions that handle pagination They are We will go to update the lt PostList gt component with the code below pages posts list tsximport React from react import IResourceComponentsProps GetManyResponse useMany from pankod refine core import useTable ColumnDef flexRender from pankod refine react table import List TableContainer Table Thead Tr Th Tbody Td HStack Button IconButton usePagination Box EditButton ShowButton from pankod refine chakra ui import IconChevronRight IconChevronLeft from tabler icons import IPost from interfaces export const PostList React FC lt IResourceComponentsProps gt gt const columns React useMemo lt ColumnDef lt IPost gt gt gt const getHeaderGroups getRowModel setOptions refineCore setCurrent pageCount current tableQueryResult data tableData useTable columns setOptions prev gt prev meta prev meta return lt List gt lt Pagination current current pageCount pageCount setCurrent setCurrent gt lt List gt type PaginationProps current number pageCount number setCurrent page number gt void const Pagination React FC lt PaginationProps gt current pageCount setCurrent gt const pagination usePagination current pageCount return lt Box display flex justifyContent flex end gt lt HStack my spacing gt pagination prev amp amp lt IconButton aria label previous page onClick gt setCurrent current disabled pagination prev variant outline gt lt IconChevronLeft size gt lt IconButton gt pagination items map page gt if typeof page string return lt span key page gt lt span gt return lt Button key page onClick gt setCurrent page variant page current solid outline gt page lt Button gt pagination next amp amp lt IconButton aria label next page onClick gt setCurrent current variant outline gt lt IconChevronRight size gt lt IconButton gt lt HStack gt lt Box gt In the code above we create a lt Pagination gt components which accepts properties current This property holds the current page number obtained from the useTable hook pageCount This property holds the total amount of pages present from the useTable hook setCurrent This property sets the current page number to an value it handles the navigation to either the next page or the previous page Viewing a recordTo view a record we will use the useShow hook which is included in the pankod refine core package The hook useShow allows you to retrieve the desired record It uses the getOne method from the dataProvider passed to lt Refine gt as the query function We ll add a show tsx file in the posts folder under the pages folder next with the following code Show code pages posts show tsximport useOne useShow from pankod refine core import Show Heading NumberField TextField DateField from pankod refine chakra ui export const PostShow gt const queryResult useShow metaData populate category const data isLoading queryResult const record data data const data categoryData isLoading categoryIsLoading useOne resource categories id record category id queryOptions enabled record return lt Show isLoading isLoading gt lt Heading as h size sm mt gt Id lt Heading gt lt NumberField value record id gt lt Heading as h size sm mt gt Title lt Heading gt lt TextField value record title gt lt Heading as h size sm mt gt Category lt Heading gt categoryIsLoading lt gt Loading lt gt lt gt categoryData data title lt gt lt Heading as h size sm mt gt Content lt Heading gt lt TextField value record content gt lt Heading as h size sm mt gt Created At lt Heading gt lt DateField value record createdAt gt lt Heading as h size sm mt gt Published At lt Heading gt lt DateField value record publishedAt gt lt Heading as h size sm mt gt Locale lt Heading gt lt TextField value record locale gt lt Show gt After this we can now add the component lt PostShow gt in the show tsx file to our resource present in the App tsx file src App tsx import PostList highlight next line PostShow from pages posts function App return lt ChakraProvider theme refineTheme gt lt Refine name posts list PostList highlight next line show PostShow gt lt ChakraProvider gt export default App Creating a recordTo create a record we will use the pankod refine react hook form package It provides the useForm hook which includes form validation and handles our form submission request to Strapi Next in the posts folder under the pages folder we ll include a create tsx file with the following code Show code pages posts create tsximport React from react import Create FormControl FormLabel FormErrorMessage Input Textarea Select from pankod refine chakra ui import useSelect from pankod refine core import useForm from pankod refine react hook form export const PostCreate gt const refineCore formLoading queryResult saveButtonProps register resetField formState errors useForm const postsData queryResult data data const options categoryOptions useSelect resource categories defaultValue postsData category id React useEffect gt resetField category id categoryOptions return lt Create isLoading formLoading saveButtonProps saveButtonProps gt lt FormControl mb isInvalid errors as any title gt lt FormLabel gt Title lt FormLabel gt lt Input type text register title required This field is required gt lt FormErrorMessage gt errors as any title message as string lt FormErrorMessage gt lt FormControl gt lt FormControl mb isInvalid errors as any title gt lt FormLabel gt Content lt FormLabel gt lt Textarea register content required This field is required gt lt FormErrorMessage gt errors as any title message as string lt FormErrorMessage gt lt FormControl gt lt FormControl mb isInvalid errors category gt lt FormLabel gt Category lt FormLabel gt lt Select placeholder Select category register category id required This field is required gt categoryOptions map option gt lt option value option value key option value gt option label lt option gt lt Select gt lt FormErrorMessage gt errors as any category id message as string lt FormErrorMessage gt lt FormControl gt lt Create gt In the code above we used the useForm hook to create records This hook comes from the pankod refine react hook form which is a refine adapter of the React Hook Form library This library allows you to use the React Hook Form library with refine More information about the useForm hook can be obtained here we use methods provided by the useForm hook like register to validate the new post we will add into Strapi The hooks also provide an object like saveButtonProps which accepts the properties shown below disabled boolean onClick e React BaseSyntheticEvent lt object any any gt gt void These properties handles the submission of the form action button loading and disable states After this we can now add the component lt PostCreate gt in the create tsx file to our resource present in the App tsx file src App tsx import highlight next line PostCreate from pages posts function App return lt ChakraProvider theme refineTheme gt lt Refine resources name posts list PostList show PostShow highlight next line create PostCreate gt lt ChakraProvider gt export default App Modifying Editing records For editing a record we will add an edit tsx file In the posts folder under the pages folder and add the code below to the file pages posts edit tsximport React from react import Edit FormControl FormLabel FormErrorMessage Input Select from pankod refine chakra ui import useForm from pankod refine react hook form import useSelect from pankod refine core export const PostEdit gt const refineCore formLoading queryResult saveButtonProps register resetField formState errors useForm refineCoreProps metaData populate category const postsData queryResult data data const options categoryOptions useSelect resource categories defaultValue postsData category id React useEffect gt resetField category id categoryOptions return lt Edit isLoading formLoading saveButtonProps saveButtonProps gt lt FormControl mb isInvalid errors as any id gt lt FormLabel gt Id lt FormLabel gt lt Input disabled type number register id required This field is required gt lt FormErrorMessage gt errors as any id message as string lt FormErrorMessage gt lt FormControl gt lt FormControl mb isInvalid errors as any title gt lt FormLabel gt Title lt FormLabel gt lt Input type text register title required This field is required gt lt FormErrorMessage gt errors as any title message as string lt FormErrorMessage gt lt FormControl gt lt FormControl mb isInvalid errors as any content gt lt FormLabel gt Content lt FormLabel gt lt Input type text register content required This field is required gt lt FormErrorMessage gt errors as any content message as string lt FormErrorMessage gt lt FormControl gt lt FormControl mb isInvalid errors category gt lt FormLabel gt Category lt FormLabel gt lt Select placeholder Select category register category id required This field is required gt categoryOptions map option gt lt option value option value key option value gt option label lt option gt lt Select gt lt FormErrorMessage gt errors as any category id message as string lt FormErrorMessage gt lt FormControl gt lt FormControl mb isInvalid errors as any createdAt gt lt FormLabel gt Created At lt FormLabel gt lt Input disabled register createdAt required This field is required gt lt FormErrorMessage gt errors as any createdAt message as string lt FormErrorMessage gt lt FormControl gt lt FormControl mb isInvalid errors as any updatedAt gt lt FormLabel gt Updated At lt FormLabel gt lt Input disabled register updatedAt required This field is required gt lt FormErrorMessage gt errors as any updatedAt message as string lt FormErrorMessage gt lt FormControl gt lt FormControl mb isInvalid errors as any publishedAt gt lt FormLabel gt Published At lt FormLabel gt lt Input disabled register publishedAt required This field is required gt lt FormErrorMessage gt errors as any publishedAt message as string lt FormErrorMessage gt lt FormControl gt lt FormControl mb isInvalid errors as any locale gt lt FormLabel gt Locale lt FormLabel gt lt Input disabled type text register locale required This field is required gt lt FormErrorMessage gt errors as any locale message as string lt FormErrorMessage gt lt FormControl gt lt Edit gt In the code above just like in the lt PostCreate gt component we use methods provided by the useForm hook like register to validate the new post we will add into Strapi The hooks also provide an object like saveButtonProps which handles the submission of the form action button loading and disable statesAfter this we can now add the component lt PostEdit gt in the edit tsx file to our resource present in the App tsx file src App tsximport highlight next line PostEdit from pages posts function App return lt ChakraProvider theme refineTheme gt lt Refine resources name posts list PostList show PostShow create PostCreate highlight next line edit PostEdit gt lt ChakraProvider gt export default App Deleting post recordTo delete a record We ll add a Delete button so we ll need to update our lt PostList gt component to include the button to the actions row Add the highlighted lines below to the existing list component pages posts list tsx export const PostList React FC gt const show edit create useNavigation const mutate useDelete const columns React useMemo lt ColumnDef lt IPost gt gt gt highlight start id actions accessorKey id header Actions cell function render getValue return lt HStack gt lt DeleteButton hideText recordItemId getValue as string gt lt HStack gt highlight end Another way to include a delete button on the lt PostEdit gt page To display the delete button on the edit page and the view page the canDelete prop must be passed to the resource object src App tsx function App return lt ChakraProvider theme refineTheme gt lt Refine resources highlight next line canDelete true gt lt ChakraProvider gt export default App Implement sorting of listed recordsSince the pankod refine react table package is based on the Tanstack Table package we can add sorting and filtering features to our table Let s make a lt ColumnSorter gt component for our table header This component will be in charge of changing the table s sorting state we create a new folder named components under the src folder Under that folder add a ColumnSorter tsx file with the following code components ColumnSorter tsximport IconButton from chakra ui react import IconChevronDown IconSelector from tabler icons import type Column from pankod refine react table export const ColumnSorter React FC lt column Column lt any any gt gt column gt if column getCanSort return null const sorted column getIsSorted return lt IconButton aria label Sort size xs onClick column getToggleSortingHandler gt sorted lt IconChevronDown size gt lt IconSelector size gt lt IconButton gt In the code above the lt ColumnSorter gt is a simple component that displays a button The column getToggleSortingHandler method is called when the user clicks on the button This method will alter the table s sorting state Also we use the column getCanSort method to determine if the column is sortable If it is We will render the lt ColumnSorter gt component and vice versa Once the column is sorted the IconChevronDown icon will be rendered Otherwise the IconSelector icon will be rendered Next we import the lt ColumnSorter gt component to the list tsx file located at the src pages posts directory and add the component to the lt Th gt of the table as a child as shown below pages posts list tsx import ColumnSorter from components ColumnSorter lt Thead gt getHeaderGroups map headerGroup gt lt Tr key headerGroup id gt headerGroup headers map header gt lt Th key header id gt header isPlaceholder amp amp flexRender header column columnDef header header getContext lt ColumnSorter column header column gt lt Th gt lt Tr gt lt Thead gt You can set the enableSorting property of the column to false in the column definition to disable sorting for the actions column as shown below pages posts list tsx id actions accessorKey id header Actions enableSorting false Implement filters on listed recordsFirstly Let s make a lt ColumnFilter gt component for our table header This component will handle the filtering of listed records we create a new folder named components under the src folder Under that folder add a ColumnFilter tsx file with the following code components ColumnFilter tsximport React useState from react import Input Menu IconButton MenuButton MenuList VStack HStack from pankod refine chakra ui import IconFilter IconX IconCheck from tabler icons import type Column from pankod refine react table export const ColumnFilter React FC lt column Column lt any any gt gt column gt const state setState useState null as null value any if column getCanFilter return null const open gt setState value column getFilterValue const close gt setState null const change value any gt setState value const clear gt column setFilterValue undefined close const save gt if state return column setFilterValue state value close const renderFilterElement gt const FilterComponent column columnDef meta as any filterElement if FilterComponent amp amp state return lt Input borderRadius md size sm autoComplete off value state value onChange e gt change e target value gt return lt FilterComponent value state value onChange e any gt change e target value gt return lt Menu isOpen state onClose close gt lt MenuButton onClick open as IconButton aria label Options icon lt IconFilter size gt variant ghost size xs gt lt MenuList p gt state amp amp lt VStack align flex start gt renderFilterElement lt HStack spacing gt lt IconButton aria label Clear size sm colorScheme red onClick clear gt lt IconX size gt lt IconButton gt lt IconButton aria label Save size sm onClick save colorScheme green gt lt IconCheck size gt lt IconButton gt lt HStack gt lt VStack gt lt MenuList gt lt Menu gt In the code above lt ColumnFilter gt is a button on clicking the button a menu will be opened In the menu exists a filter element of the column that is being rendered The filter element is an lt Input gt component in which you can add a value which will be used to subsequently filter the records based on that value Next we Import the lt ColumnFilter gt component to the list tsx file located at the src pages posts directory and add the component to the lt Th gt of the table just like we did the lt ColumnSorter gt component pages posts list tsximport ColumnFilter from components ColumnFilter lt Thead gt getHeaderGroups map headerGroup gt lt Tr key headerGroup id gt headerGroup headers map header gt lt Th key header id gt header isPlaceholder amp amp flexRender header column columnDef header header getContext lt ColumnSorter column header column gt lt ColumnFilter column header column gt lt Th gt lt Tr gt lt Thead gt We can change the filter operator for columns to contains The filterOperator is set to eq by default As a result we changed the filterOperator for specific columns to contains as shown below pages posts list tsx id id accessorKey id header Id meta filterOperator contains id title accessorKey title header Title meta filterOperator contains id category accessorKey category title header Category meta filterOperator contains id createdAt accessorKey createdAt header Created At We can also disable filtering for the actions column by setting the column s enableColumnFilter property to false in the column definition as shown below pages posts list tsx id actions accessorKey id header Actions enableColumnFilter false Implementing mutation mode Mutation modes controls how side effects or actions like deletion creation updating etc are applied refine provides three mutation modes namely pessimistic In this mode UI updates are delayed until the server confirms the mutation undoable In this mode UI updates are immediately applied but the mutation can be reversed optimistic UI updates are immediately updated before confirmed by server We will implement undoable mutation mode The mutation is applied locally and redirection and UI updates are performed as soon as the mutation is successful It then Waits for a configurable amount of time before applying the mutation During the timeout the mutation from the notification can be cancelled using an undo button and the UI will revert the changes to its previous state To enable mutation mode we will set the mutationMode property in the Refine component options property src App tsx function App return lt ChakraProvider theme refineTheme gt lt Refine options mutationMode undoable gt lt ChakraProvider gt export default App ConclusionIn this article we covered how to create a React admin panel with refine We also learnt How to bootstrap a refine application Connecting a Strapiv data provider to a refine application implemented CRUD operations on a refine application If you re looking to build a robust and dynamic admin panel for your web application then this React admin tutorial is just what you need This article demonstrates the flexibility that comes with using refine to create web applications refine is a fantastic tool that accelerates development by abstracting many time consuming tasks giving the developer more time to focus on the application s core business logic It also comes with detailed documentation that will get you started Visit here to access the documentation |
2023-03-06 07:33:26 |
海外TECH |
DEV Community |
Implement These 7 JavaScript Web APIs for a Futuristic Website Experience |
https://dev.to/devbambhaniya/implement-these-7-javascript-web-apis-for-a-futuristic-website-experience-3ckk
|
Implement These JavaScript Web APIs for a Futuristic Website ExperienceJavaScript Web APIs offer many opportunities for hire dedicated developers to create visually stunning and engaging websites By leveraging the power of these APIs developers can create cutting edge web applications that push the boundaries of what is possible on the web In this article we will explore seven JavaScript Web APIs that can help you build cutting edge websites you might not have known about Web Animations APIThe Web Animations API allows developers to create complex animations with ease This API offers a set of high level JavaScript functions to create animations using keyframes and timing functions The Web Animations API can be used to create stunning visual effects such as parallax scrolling and animated backgrounds Intersection Observer APIThe Intersection Observer API allows developers to monitor the position of a DOM element in relation to the viewport This API can be used to create lazy loading of images and videos infinite scrolling and much more The Intersection Observer API helps optimize web page performance by loading content only when it is needed Geolocation APIThe Geolocation API allows developers to retrieve a user s location This API can be used to create location based services such as weather apps local business directories and location based marketing The Geolocation API makes it possible to personalize web content based on the user s location Speech Recognition APIThe Speech Recognition API allows developers to add voice commands to their web applications This API can be used to create voice search voice navigation and speech to text features The Speech Recognition API helps create more accessible and user friendly websites Web Bluetooth APIThe Web Bluetooth API allows developers to communicate with Bluetooth devices directly from the browser This API can be used to create web based IoT applications such as controlling smart devices and collecting data from sensors The Web Bluetooth API makes it possible to create seamless connections between web applications and Bluetooth devices Web MIDI APIThe Web MIDI API allows developers to create music and sound effects directly from the browser This API can be used to create interactive web based music applications such as virtual pianos and music games The Web MIDI API allows users to create music without the need for additional software or hardware Device Orientation APIThe Device Orientation API allows developers to access the orientation and motion data of a user s device This API can be used to create web based augmented reality and virtual reality applications The Device Orientation API makes it possible to create immersive web experiences without the need for additional software or hardware ConclusionIn conclusion by incorporating these seven JavaScript Web APIs into their web development projects developers can create futuristic websites that are visually impressive and highly functional Moreover these APIs can be integrated into API integration services allowing businesses to create innovative web applications that provide exceptional user experiences With the power of these APIs developers can unlock new levels of creativity and efficiency enabling them to stay ahead of the curve in the ever evolving digital landscape |
2023-03-06 07:11:12 |
海外TECH |
Engadget |
Tesla slashes Model S and X US prices by up to $10,000 |
https://www.engadget.com/tesla-slashes-model-s-and-x-us-prices-by-up-to-10000-074541439.html?src=rss
|
Tesla slashes Model S and X US prices by up to Tesla has cut the prices of its high end Model S and Model X electric cars by percent and percent respectively according to changes in its website seen by TechCrunch nbsp It s the second time this year the company has chopped prices so the Model X has dropped from at the beginning of the year to just currently The Model S meanwhile has fallen from to since January st ーa steep reduction nbsp Neither car qualifies for Federal Tax rebates set to expire later this month as those only apply to SUVs priced below and cars under Still they re likely to push many fence sitters over the edge That tracks with what CEO Elon Musk said on Tesla Investor s Day that quot the desire for people to own a Tesla is extremely high but the limiting factor is their ability to pay for a Tesla quot Most Model and Y vehicles do qualify for the rebates thanks to Tesla s January price cuts on those EVs As a reminder it s a “nonrefundable tax credit so you ll only benefit if you have a federal tax liability of at least After mid March however the rules will change and many EVs that currently qualify may become ineligible This article originally appeared on Engadget at |
2023-03-06 07:45:41 |
海外TECH |
CodeProject Latest Articles |
A Simple Sliding Puzzle |
https://www.codeproject.com/Articles/24983/A-Simple-Sliding-Puzzle
|
jigsaw |
2023-03-06 07:34:00 |
海外TECH |
CodeProject Latest Articles |
A Little Update to Picture Slide Puzzle |
https://www.codeproject.com/Articles/30544/A-Little-Update-to-My-Jigsaw
|
jigsaw |
2023-03-06 07:34:00 |
金融 |
ニッセイ基礎研究所 |
2021年/2000年都道府県の「赤ちゃん数維持力」-圧倒的維持力の東京都・女性移動が生み出すエリア人口の未来- |
https://www.nli-research.co.jp/topics_detail1/id=74061?site=nli
|
結果として、エリアが抱える代から代前半の女性人口数と、エリア女性の人当たり出生力出生率が生み出す「赤ちゃん数維持力」の総合力において、東京都が位の沖縄県をポイント引き離して圧勝という形となった。 |
2023-03-06 16:47:56 |
ニュース |
@日本経済新聞 電子版 |
京都タリウム殺人、容疑者「市販薬買って飲ませた」
https://t.co/bEFkjGF00o |
https://twitter.com/nikkei/statuses/1632644172435066886
|
殺人 |
2023-03-06 07:27:58 |
ニュース |
@日本経済新聞 電子版 |
三菱電機、国際特許出願件数で世界4位に 22年
https://t.co/UN2HAu0ljf |
https://twitter.com/nikkei/statuses/1632644169863921664
|
三菱電機 |
2023-03-06 07:27:57 |
ニュース |
@日本経済新聞 電子版 |
米アマゾン、しぼむ「アレクサ」の壮大な夢 (FT)
https://t.co/3UThjImFwQ |
https://twitter.com/nikkei/statuses/1632642642734649345
|
壮大 |
2023-03-06 07:21:53 |
ニュース |
BBC News - Home |
Channel migrants face removal and lifetime ban on returning to UK |
https://www.bbc.co.uk/news/uk-64848101?at_medium=RSS&at_campaign=KARANGA
|
legislation |
2023-03-06 07:58:32 |
ニュース |
BBC News - Home |
Cardiff: Police searching for five missing people find three dead |
https://www.bbc.co.uk/news/uk-64859195?at_medium=RSS&at_campaign=KARANGA
|
deada |
2023-03-06 07:13:44 |
マーケティング |
MarkeZine |
【視聴無料】ツール・システム選びの前に確認しておきたい!EVERRISEが語るデータ統合のポイント |
http://markezine.jp/article/detail/41583
|
everrise |
2023-03-06 16:15:00 |
IT |
週刊アスキー |
九州全7県の老舗や有名店の名産品・伝統工芸品などが大集合! 京王百貨店新宿店「大九州展~うまかもん・よかもん大集合~」 |
https://weekly.ascii.jp/elem/000/004/127/4127422/
|
京王百貨店 |
2023-03-06 16:45:00 |
IT |
週刊アスキー |
花見シーズン直前に楽しむ桜と苺のスイーツブッフェ「スイーツナイトブッフェ~春香る桜&イチゴ~」 |
https://weekly.ascii.jp/elem/000/004/127/4127424/
|
新横浜プリンスホテル |
2023-03-06 16:30:00 |
IT |
週刊アスキー |
新宿中央公園内「SHUKNOVA(シュクノバ)」前にて福島県地域の特産物・飲⻝の提供・情報発信を行なう「福島を繋ぐフェスタ」3月11日・12日開催 |
https://weekly.ascii.jp/elem/000/004/127/4127431/
|
shuknova |
2023-03-06 16:15:00 |
IT |
週刊アスキー |
ヤフオク!で鑑定付「スニーカーダンク」出品アイテムを同時掲載・購入可能に |
https://weekly.ascii.jp/elem/000/004/127/4127440/
|
真贋判定 |
2023-03-06 16:15:00 |
コメント
コメントを投稿