Skip to content

Instantly share code, notes, and snippets.

View vladdedita's full-sized avatar

Vlad Dedita vladdedita

  • Suceava
View GitHub Profile
<form id="stripeForm" onSubmit={handleSubmit}>
<div
style={{ margin: "2rem", display: "flex", justifyContent: "center" }}
>
<Grid.Column>
<Grid.Row>
<PaymentCard
className={styles.paymentCard}
style={{ width: "100%!important" }}
brand={cardType}
@vladdedita
vladdedita / CheckoutForm.js
Created March 3, 2021 18:54
Full Scope of Checkout Form
const CheckoutFormComponent = (props) => {
const stripe = useStripe();
const elements = useElements();
const { fullName, email } = props;
const [cardType, setCardType] = useState("");
useEffect(() => {}, []);
const handleSubmit = async (event) => {
// Block native form submission.
@Component
public abstract class SingletonService {
public void usePrototype() {
PrototypeService prototypeService = createPrototypeService();
prototypeService.doSomething();
}
@Lookup
protected abstract PrototypeService createPrototypeService();
@Component
public abstract class SingletonService {
public void usePrototype() {
PrototypeService prototypeService = createPrototypeService();
prototypeService.doSomething();
}
@Lookup
public PrototypeService createPrototypeService() {
public interface NotificationService {
void sendNotification(String message, String recipient);
String getServiceName();
}
@Component
public class EmailNotificationService implements NotificationService {
public void sendNotification(String message, String recipient) { /* Email sending logic */ }
public String getServiceName() { return "Email"; }
}
@Service
public class NotificationManager {
@Autowired
private List<NotificationService> notificationServices;
public void sendNotifications(String message, String recipient) {
for (NotificationService service : notificationServices) {
service.sendNotification(message, recipient);
}
}
public interface MessageProcessor<T> {
void process(T message);
}
@Component
public class TextMessageProcessor implements MessageProcessor<TextMessage> {
@Override
public void process(TextMessage message) {
// Processing logic for text messages
}
@Service
public class MessageProcessingService {
private final MessageProcessor<TextMessage> textMessageProcessor;
private final MessageProcessor<ImageMessage> imageMessageProcessor;
@Autowired
public MessageProcessingService(MessageProcessor<TextMessage> textMessageProcessor,
MessageProcessor<ImageMessage> imageMessageProcessor) {
this.textMessageProcessor = textMessageProcessor;
@Service
public class MyService {
public void methodA() {
// This method calls methodB internally
this.methodB();
}
@Cacheable("myCache")
public String methodB() {
@RestController
@RequestMapping("/coffees")
public class CoffeeController {
@GetMapping("/{criteria}/details/{details}/reviews")
public String getCoffeeDetailsAndReviews(@MatrixVariable(pathVar = "criteria") Map<String, String> criteriaMatrixVars,
@MatrixVariable(pathVar = "details") Map<String, String> detailsMatrixVars) {
String roast = criteriaMatrixVars.get("roast");
String origin = criteriaMatrixVars.get("origin");
String flavor = criteriaMatrixVars.get("flavor");