This file contains hidden or 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
| type MaxFileSize = number // in KB | |
| export default (file: File, maxFileSize?: MaxFileSize) => { | |
| let base64 = '' | |
| if (!file) return base64 | |
| const sizeInKb = file.size / 1024 | |
This file contains hidden or 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
| const API_URL = '' | |
| const fetchApi = async (endpoint: string, options?: object) => { | |
| const response = await fetch(`${API_URL}/${endpoint}`, options) | |
| const data = await response.json() | |
| return { | |
| data, | |
| success: response.ok, | |
| } |
This file contains hidden or 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
| function validateNIF(value: string) { | |
| // has 9 digits? | |
| if (/^[0-9]{9}$/.test(value) === false) return false | |
| // starts with 5 (Pessoa coletiva) | |
| if(!['1', '2', '3', '5', '6', '8'].includes(value.substring(0,1)) && | |
| !['45', '70', '71', '72', '77', '79', '90', '91', '98', '99'].includes(value.substring(0,2))) | |
| return false |
This file contains hidden or 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
| { | |
| "$schema": "https://schemas.wp.org/trunk/block.json", | |
| "apiVersion": 3, | |
| "name": "THEME_NAME/BLOCK_NAME", | |
| "version": "0.1.0", | |
| "title": "BLOCK_TITLE", | |
| "description": "", | |
| "category": "THEME_NAME", | |
| "textdomain": "THEME_NAME", | |
| "keywords": [], |