| 31 | } |
| 32 | |
| 33 | export function ProjectMapper({ |
| 34 | fields, |
| 35 | append, |
| 36 | remove, |
| 37 | projects, |
| 38 | register, |
| 39 | watch, |
| 40 | setValue, |
| 41 | }: ProjectMapperProps) { |
| 42 | return ( |
| 43 | <div className="space-y-2"> |
| 44 | <div className="flex items-center justify-between"> |
| 45 | <Label className="mb-0">Project Mapper (Optional)</Label> |
| 46 | <Button |
| 47 | type="button" |
| 48 | variant="outline" |
| 49 | size="sm" |
| 50 | onClick={() => append({ from: '', to: '' })} |
| 51 | > |
| 52 | <PlusIcon className="mr-1 h-4 w-4" /> |
| 53 | Add Mapping |
| 54 | </Button> |
| 55 | </div> |
| 56 | {fields.length === 0 && ( |
| 57 | <p className="text-sm text-muted-foreground leading-normal"> |
| 58 | Map source project IDs to your OpenPanel projects. If you skip mapping |
| 59 | all data will be imported to your current project. |
| 60 | </p> |
| 61 | )} |
| 62 | |
| 63 | {fields.length > 0 && ( |
| 64 | <div className="space-y-2"> |
| 65 | {fields.map((field, index) => ( |
| 66 | <div key={field.id} className="gap-2 rounded-md border p-3 row"> |
| 67 | <div className="grid grid-cols-2 gap-2"> |
| 68 | <div className="flex-1"> |
| 69 | <Label className="text-xs text-muted-foreground"> |
| 70 | From (Source Project ID) |
| 71 | </Label> |
| 72 | <Input |
| 73 | placeholder="e.g., abc123" |
| 74 | {...register(`projectMapper.${index}.from`)} |
| 75 | className="mt-1" |
| 76 | /> |
| 77 | </div> |
| 78 | <div className="flex-1"> |
| 79 | <Label className="text-xs text-muted-foreground"> |
| 80 | To (OpenPanel Project) |
| 81 | </Label> |
| 82 | <Select |
| 83 | value={watch(`projectMapper.${index}.to`)} |
| 84 | onValueChange={(value) => |
| 85 | setValue(`projectMapper.${index}.to`, value) |
| 86 | } |
| 87 | > |
| 88 | <SelectTrigger className="mt-1 w-full" size="sm"> |
| 89 | <SelectValue placeholder="Select project" /> |
| 90 | </SelectTrigger> |