1- import DashboardMenu from ' ../components/DashboardMenu' ;
2- import { getProducts , createProduct , deleteProduct } from ' ../api' ;
3- import { showLoading , hideLoading , rerender , showMessage } from ' ../utils' ;
1+ import DashboardMenu from " ../components/DashboardMenu" ;
2+ import { getProducts , createProduct , deleteProduct } from " ../api" ;
3+ import { showLoading , hideLoading , rerender , showMessage } from " ../utils" ;
44
55const ProductListScreen = {
66 after_render : ( ) => {
77 document
8- . getElementById ( ' create-product-button' )
9- . addEventListener ( ' click' , async ( ) => {
8+ . getElementById ( " create-product-button" )
9+ . addEventListener ( " click" , async ( ) => {
1010 const data = await createProduct ( ) ;
1111 document . location . hash = `/product/${ data . product . _id } /edit` ;
1212 } ) ;
13- const editButtons = document . getElementsByClassName ( ' edit-button' ) ;
13+ const editButtons = document . getElementsByClassName ( " edit-button" ) ;
1414 Array . from ( editButtons ) . forEach ( ( editButton ) => {
15- editButton . addEventListener ( ' click' , ( ) => {
15+ editButton . addEventListener ( " click" , ( ) => {
1616 document . location . hash = `/product/${ editButton . id } /edit` ;
1717 } ) ;
1818 } ) ;
19- const deleteButtons = document . getElementsByClassName ( ' delete-button' ) ;
19+ const deleteButtons = document . getElementsByClassName ( " delete-button" ) ;
2020 Array . from ( deleteButtons ) . forEach ( ( deleteButton ) => {
21- deleteButton . addEventListener ( ' click' , async ( ) => {
22- if ( confirm ( ' Are you sure to delete this product?' ) ) {
21+ deleteButton . addEventListener ( " click" , async ( ) => {
22+ if ( confirm ( " Are you sure to delete this product?" ) ) {
2323 showLoading ( ) ;
2424 const data = await deleteProduct ( deleteButton . id ) ;
2525 if ( data . error ) {
@@ -33,10 +33,10 @@ const ProductListScreen = {
3333 } ) ;
3434 } ,
3535 render : async ( ) => {
36- const products = await getProducts ( ) ;
36+ const products = await getProducts ( { } ) ;
3737 return `
3838 <div class="dashboard">
39- ${ DashboardMenu . render ( { selected : ' products' } ) }
39+ ${ DashboardMenu . render ( { selected : " products" } ) }
4040 <div class="dashboard-content">
4141 <h1>Products</h1>
4242 <button id="create-product-button" class="primary">
@@ -71,7 +71,7 @@ const ProductListScreen = {
7171 </tr>
7272 `
7373 )
74- . join ( '\n' ) }
74+ . join ( "\n" ) }
7575 </tbody>
7676 </table>
7777 </div>
0 commit comments