diff --git a/nextjs-app-v14/src/app/integrations/form/form.tsx b/nextjs-app-v14/src/app/integrations/form/form.tsx index 9bce966..244f79b 100644 --- a/nextjs-app-v14/src/app/integrations/form/form.tsx +++ b/nextjs-app-v14/src/app/integrations/form/form.tsx @@ -4,6 +4,7 @@ import React, { useState } from 'react'; import NavigationLayout from '@/app/layout/navigation'; import { PieFormLabel } from '@justeattakeaway/pie-webc/react/form-label.js'; import { PieRadio } from '@justeattakeaway/pie-webc/react/radio.js'; +import { PieRadioGroup } from '@justeattakeaway/pie-webc/react/radio-group.js'; import { PieSwitch } from '@justeattakeaway/pie-webc/react/switch.js'; import { PieButton } from '@justeattakeaway/pie-webc/react/button.js'; import { PieTextInput } from '@justeattakeaway/pie-webc/react/text-input.js'; @@ -27,6 +28,7 @@ export default function Form() { const [favouriteNumber, setFavouriteNumber] = useState(''); const [favouriteNumberValidationMessage, setFavouriteNumberValidationMessage] = useState(''); const [radioValue, setRadioValue] = useState(''); + const [favouriteTakeaway, setFavouriteTakeaway] = useState(''); const [formDataDisplay, setFormDataDisplay] = useState(null); @@ -104,6 +106,11 @@ export default function Form() { setContactByEmail(current => !current); }; + const handleFavouriteTakeaway = (event: InputEvent) => { + const newFavourite = (event.target as HTMLInputElement).value; + setFavouriteTakeaway(newFavourite); + } + const handleSubmit = (event: React.FormEvent) => { event.preventDefault(); const data = { @@ -118,7 +125,7 @@ export default function Form() { url, tel, password, - radioValue, + favouriteTakeaway, description, }; @@ -276,10 +283,11 @@ export default function Form() { -
- Radio 1 - Radio 2 -
+ + Choose a radio button: + Chinese + Shawarma +
Reset diff --git a/nuxt-app/pages/integrations/form.vue b/nuxt-app/pages/integrations/form.vue index f4b0dda..828b3fb 100644 --- a/nuxt-app/pages/integrations/form.vue +++ b/nuxt-app/pages/integrations/form.vue @@ -128,21 +128,20 @@ Receive discounts, loyalty offers and other updates via email -
+ + + Your favourite takeaway + - Radio 1 + value="chinese"> + Chinese - Radio 2 + data-test-id="shawarma" + value="shawarma"> + Shawarma -
+ Choose the way we can contact you: @@ -186,6 +185,7 @@ import '@justeattakeaway/pie-webc/components/form-label.js'; import '@justeattakeaway/pie-webc/components/text-input.js'; import '@justeattakeaway/pie-webc/components/textarea.js'; import '@justeattakeaway/pie-webc/components/radio.js'; +import '@justeattakeaway/pie-webc/components/radio-group.js'; import '@justeattakeaway/pie-webc/components/switch.js'; import '@justeattakeaway/pie-webc/components/checkbox.js'; import '@justeattakeaway/pie-webc/components/checkbox-group.js'; @@ -211,7 +211,7 @@ const favouriteNumber = ref(''); const favouriteNumberValidationMessage = ref(''); const newsletter = ref(false); const description = ref(''); -const radio = ref(''); +const favouriteTakeaway = ref(''); const contactByEmail = ref(false); const contactByPhone = ref(false); @@ -239,7 +239,7 @@ function handleSubmit() { email: email.value, tel: tel.value, url: url.value, - radioValue: radio.value, + favouriteTakeaway: favouriteTakeaway.value, password: password.value, approveSettings: approveSettings.value, enableNotifications: notifications.value, diff --git a/test/playwright/page-objects/form.page.ts b/test/playwright/page-objects/form.page.ts index ab20ebd..027f5f4 100644 --- a/test/playwright/page-objects/form.page.ts +++ b/test/playwright/page-objects/form.page.ts @@ -8,7 +8,7 @@ export type TestFormData = { url: string; tel: string; password: string; - radioValue: string; + favouriteTakeaway: string; approveSettings: boolean; enableNotifications: boolean; newsletterSignup: boolean; @@ -34,7 +34,7 @@ export class FormPage { readonly newsletterSignupCheckbox: Locator; readonly contactByEmailCheckbox: Locator; readonly contactByPhoneCheckbox: Locator; - readonly radioButton2: Locator; + readonly favouriteTakeaway: Locator; constructor(page: Page) { this.page = page; @@ -50,7 +50,7 @@ export class FormPage { this.newsletterSignupCheckbox = page.getByTestId('newsletterSignup').getByTestId('checkbox-component'); this.contactByEmailCheckbox = page.getByTestId('contactByEmail').getByTestId('checkbox-component'); this.contactByPhoneCheckbox = page.getByTestId('contactByPhone').getByTestId('checkbox-component'); - this.radioButton2 = page.getByTestId('radio-2').getByTestId('pie-radio'); + this.favouriteTakeaway = page.getByTestId('shawarma').getByTestId('pie-radio'); this.resetBtn = page.getByTestId('reset-btn'); this.submitBtn = page.getByTestId('submit-btn'); @@ -74,7 +74,7 @@ export class FormPage { await this.approveSettingsSwitch.click(); await this.enableNotificationsSwitch.click(); await this.newsletterSignupCheckbox.click(); - await this.radioButton2.click(); + await this.favouriteTakeaway.click(); await this.contactByEmailCheckbox.click(); await this.contactByPhoneCheckbox.click(); } diff --git a/test/system/form.spec.ts b/test/system/form.spec.ts index 149ccb9..77a9102 100644 --- a/test/system/form.spec.ts +++ b/test/system/form.spec.ts @@ -11,7 +11,7 @@ test.describe(`Form Page - ${process.env.APP_NAME}`, () => { url: 'https://example.com', tel: '1234567890', password: 'foo', - radioValue: 'radio-2', + favouriteTakeaway: 'shawarma', approveSettings: true, enableNotifications: true, newsletterSignup: true, diff --git a/vanilla-app/integrations/form.html b/vanilla-app/integrations/form.html index 354986a..839b124 100644 --- a/vanilla-app/integrations/form.html +++ b/vanilla-app/integrations/form.html @@ -65,10 +65,11 @@

Vanilla - PIE Form Test Page

Contact By Phone
-
- Radio option 1 - Radio option 2 -
+ + Favourite takeaway: + Chinese + Shawarma +
Reset diff --git a/vanilla-app/js/form.js b/vanilla-app/js/form.js index 396fe24..80a7358 100644 --- a/vanilla-app/js/form.js +++ b/vanilla-app/js/form.js @@ -2,6 +2,7 @@ import '@justeattakeaway/pie-webc/components/button.js'; import '@justeattakeaway/pie-webc/components/text-input.js'; import '@justeattakeaway/pie-webc/components/textarea.js'; import '@justeattakeaway/pie-webc/components/radio.js'; +import '@justeattakeaway/pie-webc/components/radio-group.js'; import '@justeattakeaway/pie-webc/components/switch.js'; import '@justeattakeaway/pie-webc/components/checkbox.js'; import '@justeattakeaway/pie-webc/components/checkbox-group.js';