This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import type { Product, Brand, Category, Price } from '@prisma/client'; | |
interface TProduct extends Product { | |
category: Category; | |
brand: Brand; | |
price: Price[]; | |
} | |
export const categories: Category[] = [ | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 1. MUTABLE VS IMMUTABLE | |
*/ | |
// CASE 1 | |
let a = 1; | |
let b = a; | |
console.log(b); // No.1 | |
b = 3; | |
console.log(a); // No.2 | |
console.log(b) // No.3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useRef } from "react"; | |
function Component() { | |
const abortControllerRef = useRef<AbortController>(new AbortController()); | |
const onAbortFetch = () => { | |
if (abortControllerRef.current) { | |
abortControllerRef.current.abort(); | |
console.log("Download aborted"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// maksimum 2 angka setelah koma | |
const regex = [ | |
{ | |
"desc":"min. 0 dan max. Big. Int", | |
"value":"/^\s*([0-9])\d*(?:,\d{0,2})?\s*$/g", | |
}, | |
{ | |
"desc":"min. 0,01 dan max. 100", | |
"value":"/^(?:100(?:,00?)?|[1-9](?:,\d{1,2})?|[1-9]\d(?:,\d{1,2})?|0(?:,[1-9]?|,[0-9][1-9]))$/g", | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE IF NOT EXISTS `country` ( | |
`id` int(11) NOT NULL AUTO_INCREMENT, | |
`iso` char(2) NOT NULL, | |
`name` varchar(80) NOT NULL, | |
`nicename` varchar(80) NOT NULL, | |
`iso3` char(3) DEFAULT NULL, | |
`numcode` smallint(6) DEFAULT NULL, | |
`phonecode` int(5) NOT NULL, | |
PRIMARY KEY (`id`) | |
) ENGINE=MyISAM DEFAULT CHARSET=latin1; |