xxxxxxxxxx
function getDaysDifference(isoDateTime: string): number {
// Convert the ISO formatted date-time to a Date object
const targetDate = new Date(isoDateTime);
// Get the current date-time
const currentDate = new Date();
// Calculate the difference in milliseconds
const differenceInMs = targetDate.getTime() - currentDate.getTime();
// Convert milliseconds to days
const daysDifference = differenceInMs / (1000 * 60 * 60 * 24);
// Round the result and return as an integer
return Math.round(daysDifference);
}
// Example usage:
const isoDateTime = "2023-07-26T03:58:04.877";
const daysDifference: number = getDaysDifference(isoDateTime);
console.log("Days Difference:", daysDifference);
xxxxxxxxxx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
module.exports = ({ env }) => ({
// ...
upload: {
config: {
provider: 'cloudinary',
providerOptions: {
cloud_name: env('CLOUDINARY_NAME'),
api_key: env('CLOUDINARY_KEY'),
api_secret: env('CLOUDINARY_SECRET'),
},
actionOptions: {
upload: {},
uploadStream: {},
delete: {},
},
},
},
// ...
});
xxxxxxxxxx
1. Add tsconfig.json file to project
2. Integrate with a build tool
3. Change all .js files to .ts files
4. Check for any errors
xxxxxxxxxx
const Validacao =() => {
const {getFieldProps, handleSubmit, isValid} = useFormik({
initialValues: {
name:'',
contact:{
email:'',
phone:''
}
},
validate: values => {
const err ={}
const message= ' campo obrigatorio'
if(!values.name) err.name = message
if(!values.contact.email) err.email = message
return err
},
onSubmit: (values, bag) => {
console.log(values)
}
})
const [name, metadataName] = getFieldProps('name','text')
const [email, metadataEmail] = getFieldProps('contact.email', 'text')
const [phone, metadataPhone] = getFieldProps('contact.phone', 'text')
xxxxxxxxxx
import React from 'react';
import { BrowserRouter, Route, Switch } from 'react-router-dom';
import FirstStep from '../components/FirstStep';
import Header from '../components/Header';
const AppRouter = () => (
<BrowserRouter>
<div className="container">
<Header />
<Switch>
<Route component={FirstStep} path="/" exact={true} />
</Switch>
</div>
</BrowserRouter>
);
export default AppRouter;
xxxxxxxxxx
$('.progress').each(function (_, progress) {
var steps = $('> div.right > div', progress);
steps.each(function (i, el) { return $(el).mouseenter(function (e) { return onHover(el); }); });
var onHover = function (el) {
steps.removeClass(['current', 'prev']);
el.classList.add('current');
$(el).prevAll().slice(1).addClass('prev');
};
});
xxxxxxxxxx
first.put("first.name", "Alan");
first.put("last.name", "Jones");
first.put("owner", true);
first.put("years.old", 30);
**JSONArray cars = new JSONArray();**
cars.add(0, "VW");
cars.add(1, "GM");
cars.add(2, "Lexus");
cars.add(3, true);
cars.add(4, 42);
cars.add(5, 2.71);
first.put("cars", cars);
finalJson.add(first);
xxxxxxxxxx
import React from "react";
import { useTable } from "react-table";
export default function BasicTable({ columns, data }) {
// Use the useTable Hook to send the columns and data to build the table
const {
getTableProps, // Sends the needed props to your table.
getTableBodyProps, // Sends needed props to your table body
headerGroups, // Returns normalized header groups
rows, // rows for the table based on the data passed
prepareRow // Prepare the row in order to be displayed.
} = useTable({
columns,
data
});
}