<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: NardjesBen</title>
    <description>The latest articles on DEV Community by NardjesBen (@nardjes).</description>
    <link>https://dev.to/nardjes</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F630071%2F04105b66-27f3-4333-b797-76cc74116801.png</url>
      <title>DEV Community: NardjesBen</title>
      <link>https://dev.to/nardjes</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/nardjes"/>
    <language>en</language>
    <item>
      <title>Add onclick event to material table react js
</title>
      <dc:creator>NardjesBen</dc:creator>
      <pubDate>Mon, 30 Aug 2021 17:36:35 +0000</pubDate>
      <link>https://dev.to/nardjes/add-onclick-event-to-material-table-react-js-1bd7</link>
      <guid>https://dev.to/nardjes/add-onclick-event-to-material-table-react-js-1bd7</guid>
      <description>&lt;p&gt;I need to retrieve data from the server then I display this data in a table and if a user clicks on a button in the table he can download the file&lt;/p&gt;

&lt;p&gt;Here is my data :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;files = [ {name : "file1", created_at: "29/01/2021"},
          {name : "file2", created_at: "20/03/2021"}]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;table headers :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const tableColumns = [
  { title: "name", field: "name" },

  {
    title: "Date",
    field: "created_at",
    type: "date",
    dateSetting: { locale: "en-GB" },
    filterComponent: (props) =&amp;gt; &amp;lt;CustomDatePicker {...props} /&amp;gt;
  }
];
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;My array :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{file &amp;amp;&amp;amp; (
&amp;lt;Fragment&amp;gt;
&amp;lt;MaterialTable
columns={tableColumns}
data={file}
title="Material Table - Custom Filter Component"
options={{search: false, filtering: true }}

actions={[
  {
    icon: 'save',
    tooltip: 'Save User',
    onClick: () =&amp;gt; window.open('http://localhost:5000/files/' + file.name, '_blank').focus()
  }
]}
/&amp;gt;
&amp;lt;/Fragment&amp;gt;)}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I get the error: ENOENT: no such file or directory, stat '/Users/admin//files/undefined'"}&lt;/p&gt;

&lt;p&gt;how can i use in react js the link of each file, i tried to use the map function on my data but it doesn't work&lt;/p&gt;

</description>
      <category>react</category>
    </item>
    <item>
      <title>Ignore headers of csv files with papaparse </title>
      <dc:creator>NardjesBen</dc:creator>
      <pubDate>Sun, 27 Jun 2021 18:33:33 +0000</pubDate>
      <link>https://dev.to/nardjes/ignore-headers-of-csv-files-with-papaparse-ni7</link>
      <guid>https://dev.to/nardjes/ignore-headers-of-csv-files-with-papaparse-ni7</guid>
      <description>&lt;p&gt;I have a csv file that I need to parse and store in a database. I use sequelize for this &lt;/p&gt;

&lt;p&gt;Here is how I defined the model of my table in sequelize :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    const Person= sequelize.define(
      'person',
      {
        id: {
          type: DataTypes.UUID,
          primaryKey: true,
          defaultValue: uuidv4(),
          allowNull: false
        },
        name: {
          type: DataTypes.STRING,
        },
        age: {
          type: DataTypes.INTEGER,
        }
        }, {
            createdAt: false,
            updatedAt: false,        
            tableName: 'person'
         }
    )
    return Person
  }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;then I have a csv file "test.csv":&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;he ,dd
liza, 23
sarah, 22
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;basically I can't change the headers in my csv file and I have to keep the same structure defined in the db, I use papaparse to parse this file :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;        const papa = require('papaparse');
        const fs = require('fs')

        const file = fs.createReadStream(__basedir + "/test.csv");


        papa.parse(file, {
          header: true,
          step: async function(results, parser) {
            console.log("Row data:", results.data);
            try{
              await Person.create(results.data)

            }catch(e){
              console.log(e)
            }

          }
      });
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;in output I get the following error :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SequelizeUniqueConstraintError: Validation error
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;the name, surname and age fields are null in the database&lt;/p&gt;

&lt;p&gt;I am looking for a solution to ignore the headers of the csv file, how can I do that?&lt;/p&gt;

</description>
      <category>node</category>
      <category>papaparse</category>
      <category>csv</category>
      <category>sequelize</category>
    </item>
    <item>
      <title>Combine React js with Node Js ?</title>
      <dc:creator>NardjesBen</dc:creator>
      <pubDate>Wed, 12 May 2021 13:01:06 +0000</pubDate>
      <link>https://dev.to/nardjes/combine-react-js-with-node-js-1el9</link>
      <guid>https://dev.to/nardjes/combine-react-js-with-node-js-1el9</guid>
      <description>&lt;p&gt;I am a beginner and I would like to make an application with :&lt;/p&gt;

&lt;p&gt;Front-end : React js &lt;br&gt;
Back-end : Node js&lt;/p&gt;

&lt;p&gt;my interface will contain 2 buttons : Download and Send, I would like to download csv files from a sftp server and when we click on download files will be displayed in the interface and the send button allows to send files from my local machine to the sftp server.&lt;/p&gt;

&lt;p&gt;How can I combine the react and node part, I was able to connect and upload files in nodejs but I don't know how to combine that with React?&lt;/p&gt;

</description>
      <category>node</category>
      <category>npm</category>
      <category>react</category>
      <category>javascript</category>
    </item>
  </channel>
</rss>
